Lines Matching +full:bare +full:- +full:cross +full:- +full:build
1 # CMake build for CompilerRT.
3 # An important constraint of the build is that it only produces libraries
12 # Check if compiler-rt is built as a standalone project.
19 # Add path for custom compiler-rt modules.
31 include(base-config-ix)
34 option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
36 option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON)
40 option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
42 option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
44 option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
46 option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON)
48 option(COMPILER_RT_BUILD_MEMPROF "Build memory profiling runtime" ON)
50 option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" OFF)
58 if (NOT (COMPILER_RT_ASAN_SHADOW_SCALE GREATER -1 AND
65 -mllvm -asan-mapping-scale=${COMPILER_RT_ASAN_SHADOW_SCALE})
69 -D${COMPILER_RT_ASAN_SHADOW_SCALE_DEFINITION})
76 "Build for a bare-metal target.")
83 set_target_properties(intrinsics_gen PROPERTIES FOLDER "Compiler-RT Misc")
107 set(LIT_ARGS_DEFAULT "-sv")
109 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
124 string(REGEX MATCH "-target(=| +)[^ ]+android[a-z]*([0-9]+)" ANDROID_API_LEVEL "${CMAKE_C_FLAGS}")
134 # We support running instrumented tests when we're not cross compiling
135 # and target a UNIX-like system or Windows.
136 # We can run tests on Android even when we are cross-compiling.
144 option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF)
151 "Support interception of libdispatch (GCD). Requires '-fblocks'" OFF)
155 set(COMPILER_RT_LIBDISPATCH_CFLAGS -fblocks)
159 -I${COMPILER_RT_LIBDISPATCH_INSTALL_PATH}/include
160 -L${COMPILER_RT_LIBDISPATCH_INSTALL_PATH}/lib
161 -Wl,-rpath=${COMPILER_RT_LIBDISPATCH_INSTALL_PATH}/lib)
163 list(APPEND COMPILER_RT_TEST_LIBDISPATCH_CFLAGS -lBlocksRuntime -ldispatch)
187 # Specifying -stdlib= in CMAKE_CXX_FLAGS overrides the defaults.
188 if (CMAKE_CXX_FLAGS MATCHES "-stdlib=([a-zA-Z+]*)")
247 "Use compiler-rt builtins instead of libgcc" ${DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY})
249 include(config-ix)
257 # remove other /W[0-4] flags will result in a warning about overriding a
260 string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
261 string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
265 append_string_if(COMPILER_RT_HAS_WALL_FLAG -Wall CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
268 append_string_if(COMPILER_RT_HAS_WERROR_FLAG -Werror CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
272 append_string_if(COMPILER_RT_HAS_STD_CXX14_FLAG -std=c++14 CMAKE_CXX_FLAGS)
276 add_definitions(-D__func__=__FUNCTION__)
281 list(APPEND SANITIZER_COMMON_CFLAGS -fno-emulated-tls)
282 string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " -fno-emulated-tls")
285 append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC SANITIZER_COMMON_CFLAGS)
287 append_list_if(COMPILER_RT_HAS_FNO_BUILTIN_FLAG -fno-builtin SANITIZER_COMMON_CFLAGS)
288 append_list_if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions SANITIZER_COMMON_CFLAGS)
290 …append_list_if(COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG -fomit-frame-pointer SANITIZER_COMMON_CFLA…
292 append_list_if(COMPILER_RT_HAS_FUNWIND_TABLES_FLAG -funwind-tables SANITIZER_COMMON_CFLAGS)
293 append_list_if(COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG -fno-stack-protector SANITIZER_COMMON_CFLAG…
294 append_list_if(COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG -fno-sanitize=safe-stack SANITIZER_COMM…
295 append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS)
297 …append_list_if(COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZ…
299 append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS)
301 # By default do not instrument or use profdata for compiler-rt.
304 list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-use")
307 list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-generate")
309 list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-generate")
314 # that requires -fno-function-sections to work properly. If lacking, the ASan
315 # Linux test function-sections-are-bad.cpp fails with the following error:
319 append("-qnofuncsect" TARGET_powerpc64le_CFLAGS)
321 …append_list_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections TARGET_powerpc64l…
331 …append_list_if(COMPILER_RT_HAS_FNO_PARTIAL_INLINING_FLAG -fno-partial-inlining SANITIZER_COMMON_CF…
349 append_list_if(COMPILER_RT_HAS_Oy_FLAG /Oy- SANITIZER_COMMON_CFLAGS)
350 append_list_if(COMPILER_RT_HAS_GS_FLAG /GS- SANITIZER_COMMON_CFLAGS)
355 list(APPEND SANITIZER_COMMON_CFLAGS /Zc:threadSafeInit-)
358 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS)
364 # Build with optimization, unless we're in debug mode.
366 list(APPEND SANITIZER_COMMON_CFLAGS -O0)
368 list(APPEND SANITIZER_COMMON_CFLAGS -O3)
373 # Stack frames on PowerPC, Mips, SystemZ and in debug build can be much larger than
375 # FIXME: Fix all sanitizers and add -Wframe-larger-than to
390 # Build sanitizer runtimes with debug info.
404 list(APPEND SANITIZER_COMMON_CFLAGS -gline-tables-only)
406 list(APPEND SANITIZER_COMMON_CFLAGS -g)
410 # Sanitizers cannot be built with -fmodules. The interceptors intentionally
412 list(APPEND SANITIZER_COMMON_CFLAGS -fno-modules)
416 append_list_if(COMPILER_RT_HAS_WGNU_FLAG -Wno-gnu SANITIZER_COMMON_CFLAGS)
417 append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros SANITIZER_COMMON_CFLAGS)
418 append_list_if(COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG -Wno-c99-extensions SANITIZER_COMMON_CFLAGS)
425 append_list_if(MINGW -fms-extensions SANITIZER_COMMON_CFLAGS)
428 append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS)
429 append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS)
432 string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
444 list(APPEND SANITIZER_COMMON_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro)
449 # intended for use in non-sanitizer runtimes such as libFuzzer, profile or XRay,
451 # and SANITIZER_COMMON_LINK_FLAGS from those and append sanitizer-specific flags.
456 append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ SANITIZER_COMMON_CFLAGS)
457 append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SANITIZER_COMMON_LINK_FLAGS)
459 # Remove -stdlib= which is unused when passing -nostdinc++...
460 string(REGEX MATCHALL "-stdlib=[a-zA-Z+]*" stdlib_flag "${CMAKE_CXX_FLAGS}")
461 string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
463 # ...we need it to build some runtimes and tests so readd it where appropriate.
505 # When cross-compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help in compilation
512 set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc)
514 -DGTEST_NO_LLVM_SUPPORT=1
515 -DGTEST_HAS_RTTI=0
516 -I${COMPILER_RT_GTEST_PATH}/include
517 -I${COMPILER_RT_GTEST_PATH}
522 set(COMPILER_RT_GMOCK_SOURCE ${COMPILER_RT_GMOCK_PATH}/src/gmock-all.cc)
524 -DGTEST_NO_LLVM_SUPPORT=1
525 -DGTEST_HAS_RTTI=0
526 -I${COMPILER_RT_GMOCK_PATH}/include
527 -I${COMPILER_RT_GMOCK_PATH}
530 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS)
531 append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT…
532 append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override COMPILER_RT_UNITTEST_CF…
536 list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations)
540 append_string_if(COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG -Wno-unused-parameter CMAKE_C_FLAGS CMAKE_C…
545 # files, rather than skipping these files in the build system.
549 # the whole compiler-rt project.
554 set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -X32_64 qc <TARGET> <LINK_FLAGS> <OBJECTS>")
555 set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -X32_64 qc <TARGET> <LINK_FLAGS> <OBJECTS>")
556 set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> -X32_64 q <TARGET> <LINK_FLAGS> <OBJECTS>")
557 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> -X32_64 q <TARGET> <LINK_FLAGS> <OBJECTS>")
558 set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -X32_64 <TARGET>")
559 set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -X32_64 <TARGET>")
565 "Enable compiler-rt to use libc++ from the source tree" ON)
606 append_list_if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG -fuse-ld=lld SANITIZER_COMMON_LINK_FLAGS)
607 append_list_if(COMPILER_RT_HAS_LLD -fuse-ld=lld COMPILER_RT_UNITTEST_LINK_FLAGS)
620 # Don't build llvm-lit for runtimes-build, it will clean up map_config.
622 # If we have a valid source tree, generate llvm-lit into the bin directory.
624 # by specifying -DLLVM_EXTERNAL_LIT, but we generate it regardless.
625 if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
628 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)