Lines Matching +full:libc +full:- +full:build

5 set(LLVM_SUBPROJECT_TITLE "libc++")
18 set(CMAKE_FOLDER "libc++")
26 # Require out of source build.
29 "${PROJECT_NAME} requires an out of source build. Please create a separate
30 build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
33 message(STATUS "Configuring for clang-cl")
47 # Basic options ---------------------------------------------------------------
48 option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
49 option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
58 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
94 be useful when porting to platforms that don't support UTF-8 encoding (e.g.
97 "Build libc++ with support for checking whether a stream is a terminal." ON)
104 option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
106 "Build libc++ with support for a monotonic clock.
109 # To use time zone support in libc++ the platform needs to have the IANA
110 # database installed. Libc++ will fail to build if this is enabled on a
129 libc++ for any specific vendor, and we disable those annotations. Vendors wishing
130 to provide compile-time errors when using features unavailable on some version of
135 set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in")
137 set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-mingw.cfg.in")
138 elseif(WIN32) # clang-cl
140 set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-clangcl.cfg.in")
142 set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static-clangcl.cfg.in")
146 set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared.cfg.in")
148 set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static.cfg.in")
157 message(STATUS "Using libc++ testing configuration: ${LIBCXX_TEST_CONFIG}")
161 # TODO: Figure out how to build GoogleBenchmark on those platforms, and how to build when exceptions or RTTI is disabled
173 option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ${_include_benchmarks})
175 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
178 option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
179 option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
181 "Install the libc++ C++20 module source files (experimental)." ON
184 "Install the static libc++ library." ON
187 "Install the shared libc++ library." ON
190 option(LIBCXX_ABI_UNSTABLE "Use the unstable ABI of libc++. This is equivalent to specifying LIBCXX_ABI_VERSION=n, where n is the not-yet-stable version." OFF)
197 "ABI version of libc++. Can be either 1 or 2, where 2 is currently the unstable ABI.
200 "Version of libc++. This will be reflected in the name of the shared library produced.
201 For example, -DLIBCXX_LIBRARY_VERSION=x.y will result in the library being named
202 libc++.x.y.dylib, along with the usual symlinks pointing to that. On Apple platforms,
204 set(LIBCXX_ABI_NAMESPACE "__${LIBCXX_ABI_VERSION}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.")
208 option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
209 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
226 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
228 # C Library options -----------------------------------------------------------
230 set(LIBCXX_SUPPORTED_C_LIBRARIES system llvm-libc)
236 # ABI Library options ---------------------------------------------------------
243 set(LIBCXX_SUPPORTED_ABI_LIBRARIES none libcxxabi system-libcxxabi libcxxrt libstdc++ libsupc++ vcruntime)
250 "Use a static copy of the ABI library when linking libc++.
261 # Generate and install a linker script inplace of libc++.so. The linker script
262 # will link libc++ to the correct ABI library. This option is on by default
264 # statically link libc++abi inside libc++.so, we don't build libc++.so at all
280 "Build libc++ with definitions for operator new/delete. These are normally
281 defined in libc++abi, but this option can be used to define them in libc++
282 instead. If you define them in libc++, make sure they are NOT defined in
283 libc++abi. Doing otherwise is an ODR violation." OFF)
284 # Build libc++abi with libunwind. We need this option to determine whether to
286 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." ON)
288 # Target options --------------------------------------------------------------
289 option(LIBCXX_BUILD_32_BITS "Build 32 bit multilib libc++. This option is not supported anymore when building the runtimes. Please specify a full triple instead." ${LLVM_BUILD_32_BITS})
294 # Feature options -------------------------------------------------------------
295 option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
296 option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
297 option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF)
299 "Build libc++ with an externalized threading API.
308 # Misc options ----------------------------------------------------------------
309 # FIXME: Turn -pedantic back ON. It is currently off because it warns
370 message(FATAL_ERROR "Libc++ cannot be built with exceptions enabled but RTTI"
372 " https://github.com/llvm/llvm-project/issues/66117"
397 message(WARNING "A static CRT linked into a shared libc++ doesn't work correctly.")
404 # TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR
405 # instead of hard-coding include/c++/v1.
408 "Path where target-agnostic libc++ headers should be installed.")
410 "Path where built libc++ runtime libraries should be installed.")
411 set(LIBCXX_INSTALL_MODULES_DIR "share/libc++/v1" CACHE STRING
412 "Path where target-agnostic libc++ module source files should be installed.")
414 set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared libc++ runtime library.")
415 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.")
427 "Path where built libc++ libraries should be installed.")
429 "Path where target-specific libc++ headers should be installed.")
443 "Path where built libc++ libraries should be installed.")
445 "Path where target-specific libc++ headers should be installed.")
452 # Declare libc++ configuration variables.
457 # LIBCXX_LIBRARIES: libraries libc++ is linked to.
462 "Additional compile flags to use when building libc++. This should be a CMake ;-delimited list of individual
463 compiler options to use. For options that must be passed as-is to the compiler without deduplication (e.g.
464 `-Xclang -foo` option groups), consider using `SHELL:` (https://cmake.org/cmake/help/latest/command/add_compile_options.html#option-de-duplication).")
466 "Additional libraries libc++ is linked to which can be provided in cache")
468 # Include macros for adding and removing libc++ flags.
473 # 'config-ix' use them during feature checks. It also adds them to both
477 add_flags_if_supported("-mdefault-visibility-export-mapping=explicit")
482 include(config-ix)
492 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
493 # so they don't get transformed into -Wno and -errors respectively.
494 remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
506 # functions based on the deployment target -- they are always available
509 target_add_compile_flags_if_supported(${target} PRIVATE -fno-aligned-allocation)
511 target_add_compile_flags_if_supported(${target} PRIVATE -faligned-allocation)
515 # MSVC only has -X, which disables all default includes; including the crt.
518 target_add_compile_flags_if_supported(${target} PUBLIC -nostdinc++)
523 target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility-inlines-hidden)
525 # Our visibility annotations are not quite right for non-Clang compilers,
530 target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden)
533 # Build with -fsized-deallocation, which is default in recent versions of Clang.
535 target_add_compile_flags_if_supported(${target} PRIVATE -fsized-deallocation)
537 # Let the library headers know they are currently being used to build the
539 target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY)
541 # Make sure the library can be build without transitive includes. This makes
542 # it easier to upgrade the library to a newer language standard without build
544 target_compile_definitions(${target} PRIVATE -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
548 target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB)
551 target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_RT_LIB)
562 target_add_compile_flags_if_supported(${target} PUBLIC -EHsc)
564 target_add_compile_flags_if_supported(${target} PUBLIC -EHs- -EHa-)
565 target_add_compile_flags_if_supported(${target} PUBLIC -fno-exceptions)
573 target_add_compile_flags_if_supported(${target} PUBLIC -GR-)
575 target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti)
581 # FIXME The libc++ sources are fundamentally non-modular. They need special
587 target_add_compile_flags_if_supported(${target} PUBLIC -Wno-unused-command-line-argument)
588 target_compile_options(${target} PUBLIC -fno-modules)
602 append_flags_if_supported(SANITIZER_FLAGS "-fno-omit-frame-pointer")
603 append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only")
607 append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only")
610 append_flags(SANITIZER_FLAGS "-fsanitize=address")
612 append_flags(SANITIZER_FLAGS "-fsanitize=hwaddress")
614 append_flags(SANITIZER_FLAGS -fsanitize=memory)
616 append_flags(SANITIZER_FLAGS "-fsanitize-memory-track-origins")
619 append_flags(SANITIZER_FLAGS "-fsanitize=undefined" "-fno-sanitize=vptr,function" "-fno-sanitize-recover=all")
622 append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined" "-fno-sanitize=vptr,function" "-fno-sanitize-recover=all")
624 append_flags(SANITIZER_FLAGS -fsanitize=thread)
626 append_flags(SANITIZER_FLAGS -fsanitize=dataflow)
637 add_library(cxx-sanitizer-flags INTERFACE)
638 target_compile_options(cxx-sanitizer-flags INTERFACE ${SANITIZER_FLAGS})
643 # dylibs are built with AddressSanitizer. However, when building libc++,
645 # If the _LIBCPP_INSTRUMENTED_WITH_ASAN flag is not defined, then parts of the ASan instrumentation code in libc++
647 # For context, read: https://github.com/llvm/llvm-project/pull/72677#pullrequestreview-1765402800
649 if (NOT "${building_with_asan}" STREQUAL "-1")
658 target_link_libraries(${target} PRIVATE "-nostdlib++")
665 target_add_link_flags_if_supported(${target} PRIVATE "--unwindlib=none")
707 # Required for standards-complaint wide character formatting functions
718 # Windows-related flags =======================================================
722 # Ignore the -MSC_VER mismatch, as we may build
726 # as we will define the iterator types; libc++
815 # By default libc++ on Windows expects to use a shared library, which requires
819 message(STATUS "Generating custom __config for non-DLL Windows build")
826 add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS)
829 # Setup all common build flags =================================================
838 target_link_libraries(${target} PRIVATE cxx-sanitizer-flags)
844 add_custom_target(cxx-test-depends
845 COMMENT "Build dependencies required to run the libc++ test suite.")