File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -418,7 +418,10 @@ while(library_variants)
418418
419419 # compiler-rt
420420
421- set (runtimes_flags "${common_flags} -ffunction-sections -fdata-sections -fno-ident --sysroot ${sysroot} " )
421+ # Defining _DEFAULT_SOURCE means that extensions like posix_memalign
422+ # can be used by the C++ runtimes. This is required to implement
423+ # C++17's aligned new & delete operators.
424+ set (runtimes_flags "${common_flags} -ffunction-sections -fdata-sections -fno-ident --sysroot ${sysroot} -D_DEFAULT_SOURCE" )
422425
423426 ExternalProject_Add(
424427 compiler_rt_${variant}
@@ -476,7 +479,6 @@ while(library_variants)
476479
477480 # Other LLVM runtimes
478481
479- set (runtimes_cxx_flags "${runtimes_flags} -D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION" )
480482 ExternalProject_Add(
481483 runtimes_${variant}
482484 SOURCE_DIR ${llvmproject_SOURCE_DIR} /runtimes
@@ -489,7 +491,7 @@ while(library_variants)
489491 -DCMAKE_BUILD_TYPE=MinSizeRel
490492 -DCMAKE_CXX_COMPILER=${llvm_bin} /clang++
491493 -DCMAKE_CXX_COMPILER_TARGET=${target}
492- -DCMAKE_CXX_FLAGS=${runtimes_cxx_flags }
494+ -DCMAKE_CXX_FLAGS=${runtimes_flags }
493495 -DCMAKE_C_COMPILER=${llvm_bin} /clang
494496 -DCMAKE_C_COMPILER_TARGET=${target}
495497 -DCMAKE_C_FLAGS=${runtimes_flags}
Original file line number Diff line number Diff line change @@ -372,11 +372,11 @@ def build_cxx_libraries(self, lib_spec: config.LibrarySpec) -> None:
372372 Build and install a single variant of lib++abi, libc++ & libunwind
373373 """
374374 cmake_defs = self ._get_common_cmake_defs_for_libs (lib_spec )
375- # Disable C++17 aligned allocation feature because its implementation
376- # in libc++ relies on posix_memalign() which is not available in our
377- # picolibc build
375+ # Defining _DEFAULT_SOURCE means that extensions like
376+ # posix_memalign can be used by the C++ runtimes. This is
377+ # required to implement C++17's aligned new & delete operators.
378378 cxx_flags = (cmake_defs .get ('CMAKE_CXX_FLAGS' , '' )
379- + ' -D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION ' )
379+ + ' -D_DEFAULT_SOURCE ' )
380380 install_dir = os .path .join (self .cfg .target_llvm_rt_dir ,
381381 lib_spec .name )
382382 cmake_defs .update ({
You can’t perform that action at this time.
0 commit comments