diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -310,7 +310,7 @@ # fcf-protection is a gcc/clang option for CET support on Linux platforms. # We need to handle MSVC CET option on Windows platforms. if (NOT MSVC) - if (COMPILER_RT_ENABLE_CET AND NOT COMPILER_RT_HAS_FCF_PROTECTION_FLAG) + if (COMPILER_RT_ENABLE_CET AND NOT C_SUPPORTS_FCF_PROTECTION_FLAG) message(FATAL_ERROR "Compiler used to build compiler-rt doesn't support CET!") endif() endif() @@ -319,17 +319,17 @@ # Override any existing /W flags with /W4. This is what LLVM does. Failing to # remove other /W[0-4] flags will result in a warning about overriding a # previous flag. - if (COMPILER_RT_HAS_W4_FLAG) + if (CXX_SUPPORTS_W4_FLAG) string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - append_string_if(COMPILER_RT_HAS_W4_FLAG /W4 CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append_string_if(CXX_SUPPORTS_W4_FLAG /W4 CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() else() - append_string_if(COMPILER_RT_HAS_WALL_FLAG -Wall CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append_string_if(CXX_SUPPORTS_WALL_FLAG -Wall CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() if(COMPILER_RT_ENABLE_WERROR) - append_string_if(COMPILER_RT_HAS_WERROR_FLAG -Werror CMAKE_C_FLAGS CMAKE_CXX_FLAGS) - append_string_if(COMPILER_RT_HAS_WX_FLAG /WX CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append_string_if(CXX_SUPPORTS_WERROR_FLAG -Werror CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append_string_if(CXX_SUPPORTS_WX_FLAG /WX CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() # Emulate C99 and C++11's __func__ for MSVC prior to 2013 CTP. @@ -343,32 +343,32 @@ string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " -fno-emulated-tls") endif() if(NOT WIN32) - append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC SANITIZER_COMMON_CFLAGS) + append_list_if(C_SUPPORTS_FPIC_FLAG -fPIC SANITIZER_COMMON_CFLAGS) endif() -append_list_if(COMPILER_RT_HAS_FNO_BUILTIN_FLAG -fno-builtin SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions SANITIZER_COMMON_CFLAGS) +append_list_if(C_SUPPORTS_FNO_BUILTIN_FLAG -fno-builtin SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG -fno-exceptions SANITIZER_COMMON_CFLAGS) if(NOT COMPILER_RT_DEBUG AND NOT APPLE) - append_list_if(COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG -fomit-frame-pointer SANITIZER_COMMON_CFLAGS) + append_list_if(CXX_SUPPORTS_FOMIT_FRAME_POINTER_FLAG -fomit-frame-pointer SANITIZER_COMMON_CFLAGS) endif() -append_list_if(COMPILER_RT_HAS_FUNWIND_TABLES_FLAG -funwind-tables SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG -fno-stack-protector SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG -fno-sanitize=safe-stack SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS) -if(NOT COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG) - append_list_if(COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_FUNWIND_TABLES_FLAG -funwind-tables SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_FNO_STACK_PROTECTOR_FLAG -fno-stack-protector SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_FNO_SANITIZE_SAFE_STACK_FLAG -fno-sanitize=safe-stack SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS) +if(NOT CXX_SUPPORTS_FVISIBILITY_HIDDEN_FLAG) + append_list_if(CXX_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZER_COMMON_CFLAGS) endif() -append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS) +append_list_if(C_SUPPORTS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS) # By default do not instrument or use profdata for compiler-rt. if(NOT COMPILER_RT_ENABLE_PGO) - if(LLVM_PROFDATA_FILE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG) + if(LLVM_PROFDATA_FILE AND C_SUPPORTS_FNO_PROFILE_INSTR_USE_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-use") endif() - if(LLVM_BUILD_INSTRUMENTED MATCHES IR AND COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG) + if(LLVM_BUILD_INSTRUMENTED MATCHES IR AND C_SUPPORTS_FNO_PROFILE_GENERATE_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-generate") - elseif((LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) + elseif((LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND C_SUPPORTS_FNO_PROFILE_INSTR_GENERATE_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-generate") - if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND CXX_SUPPORTS_FNO_COVERAGE_MAPPING_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS "-fno-coverage-mapping") endif() endif() @@ -382,7 +382,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "XL") append("-qnofuncsect" TARGET_powerpc64le_CFLAGS) else() - append_list_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections TARGET_powerpc64le_CFLAGS) + append_list_if(CXX_SUPPORTS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections TARGET_powerpc64le_CFLAGS) endif() endif() @@ -392,14 +392,14 @@ # interceptors, changes backtraces seen in asan error cases, which causes # testsuite failures. if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x") - append_list_if(COMPILER_RT_HAS_FNO_PARTIAL_INLINING_FLAG -fno-partial-inlining SANITIZER_COMMON_CFLAGS) + append_list_if(CXX_SUPPORTS_FNO_PARTIAL_INLINING_FLAG -fno-partial-inlining SANITIZER_COMMON_CFLAGS) endif() if(MSVC) # Replace the /M[DT][d] flags with /MT, and strip any definitions of _DEBUG, # which cause definition mismatches at link time. # FIXME: In fact, sanitizers should support both /MT and /MD, see PR20214. - if(COMPILER_RT_HAS_MT_FLAG) + if(CXX_SUPPORTS_MT_FLAG) foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO @@ -410,8 +410,8 @@ string(REGEX REPLACE "/D_DEBUG" "" ${flag_var} "${${flag_var}}") endforeach() endif() - append_list_if(COMPILER_RT_HAS_Oy_FLAG /Oy- SANITIZER_COMMON_CFLAGS) - append_list_if(COMPILER_RT_HAS_GS_FLAG /GS- SANITIZER_COMMON_CFLAGS) + append_list_if(CXX_SUPPORTS_OY_FLAG /Oy- SANITIZER_COMMON_CFLAGS) + append_list_if(CXX_SUPPORTS_GS_FLAG /GS- SANITIZER_COMMON_CFLAGS) # Disable thread safe initialization for static locals. ASan shouldn't need # it. Thread safe initialization assumes that the CRT has already been @@ -421,9 +421,9 @@ append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WTHREAD_SAFETY_FLAG -Wthread-safety THREAD_SAFETY_FLAGS) -append_list_if(COMPILER_RT_HAS_WTHREAD_SAFETY_REFERENCE_FLAG -Wthread-safety-reference THREAD_SAFETY_FLAGS) -append_list_if(COMPILER_RT_HAS_WTHREAD_SAFETY_BETA_FLAG -Wthread-safety-beta THREAD_SAFETY_FLAGS) +append_list_if(CXX_SUPPORTS_WTHREAD_SAFETY_FLAG -Wthread-safety THREAD_SAFETY_FLAGS) +append_list_if(CXX_SUPPORTS_WTHREAD_SAFETY_REFERENCE_FLAG -Wthread-safety-reference THREAD_SAFETY_FLAGS) +append_list_if(CXX_SUPPORTS_WTHREAD_SAFETY_BETA_FLAG -Wthread-safety-beta THREAD_SAFETY_FLAGS) list(APPEND SANITIZER_COMMON_CFLAGS ${THREAD_SAFETY_FLAGS}) string(REPLACE ";" " " thread_safety_flags_space_sep "${THREAD_SAFETY_FLAGS}") string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${thread_safety_flags_space_sep}") @@ -445,7 +445,7 @@ # anticipated. # FIXME: Fix all sanitizers and add -Wframe-larger-than to # SANITIZER_COMMON_FLAGS -if(COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG AND NOT COMPILER_RT_DEBUG +if(CXX_SUPPORTS_WFRAME_LARGER_THAN_FLAG AND NOT COMPILER_RT_DEBUG AND NOT ${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "powerpc|mips|s390x") set(SANITIZER_LIMIT_FRAME_SIZE TRUE) else() @@ -474,13 +474,13 @@ elseif(APPLE) # On Apple platforms use full debug info (i.e. not `-gline-tables-only`) # for all build types so that the runtime can be debugged. - if(NOT COMPILER_RT_HAS_G_FLAG) + if(NOT CXX_SUPPORTS_G_FLAG) message(FATAL_ERROR "-g is not supported by host compiler") endif() list(APPEND SANITIZER_COMMON_CFLAGS -g) -elseif(COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG AND NOT COMPILER_RT_DEBUG) +elseif(CXX_SUPPORTS_GLINE_TABLES_ONLY_FLAG AND NOT COMPILER_RT_DEBUG) list(APPEND SANITIZER_COMMON_CFLAGS -gline-tables-only) -elseif(COMPILER_RT_HAS_G_FLAG) +elseif(CXX_SUPPORTS_G_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS -g) endif() @@ -491,15 +491,15 @@ endif() # Turn off several warnings. -append_list_if(COMPILER_RT_HAS_WGNU_FLAG -Wno-gnu SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG -Wno-c99-extensions SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WGNU_FLAG -Wno-gnu SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WC99_EXTENSIONS_FLAG -Wno-c99-extensions SANITIZER_COMMON_CFLAGS) # format-pedantic warns about passing T* for %p, which is not useful. -append_list_if(COMPILER_RT_HAS_WD4146_FLAG /wd4146 SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WD4291_FLAG /wd4291 SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WD4391_FLAG /wd4391 SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WD4722_FLAG /wd4722 SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WD4146_FLAG /wd4146 SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WD4291_FLAG /wd4291 SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WD4391_FLAG /wd4391 SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WD4722_FLAG /wd4722 SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS) append_list_if(MINGW -fms-extensions SANITIZER_COMMON_CFLAGS) @@ -516,7 +516,7 @@ # # Note that this type of issue was discovered with lsan, but can apply to other # sanitizers. -append_list_if(COMPILER_RT_HAS_TRIVIAL_AUTO_INIT -ftrivial-auto-var-init=pattern SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_FTRIVIAL_AUTO_INIT_FLAG -ftrivial-auto-var-init=pattern SANITIZER_COMMON_CFLAGS) # Set common link flags. # TODO: We should consider using the same model as libc++, that is use either @@ -563,8 +563,8 @@ set(COMPILER_RT_COMMON_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) # We don't use the C++ standard library, so avoid including it by mistake. -append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ SANITIZER_COMMON_CFLAGS) -append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SANITIZER_COMMON_LINK_FLAGS) +append_list_if(CXX_SUPPORTS_NOSTDINCXX_FLAG -nostdinc++ SANITIZER_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_NOSTDLIBXX_FLAG -nostdlib++ SANITIZER_COMMON_LINK_FLAGS) # Remove -stdlib= which is unused when passing -nostdinc++... string(REGEX MATCHALL "-stdlib=[a-zA-Z+]*" stdlib_flag "${CMAKE_CXX_FLAGS}") @@ -599,8 +599,8 @@ if (COMPILER_RT_CXX_LIBRARY STREQUAL "libcxx") # We are using the in-tree libc++ so avoid including the default one. - append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_COMMON_CFLAGS) - append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_COMMON_LINK_FLAGS) + append_list_if(CXX_SUPPORTS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_COMMON_CFLAGS) + append_list_if(CXX_SUPPORTS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_COMMON_LINK_FLAGS) # Use the in-tree libc++ through explicit include and library paths. set(COMPILER_RT_CXX_CFLAGS "$<$:$,/imsvc,-isystem>$,$$,/imsvc,-isystem>>>") if (COMPILER_RT_STATIC_CXX_LIBRARY) @@ -610,8 +610,8 @@ endif() elseif (COMPILER_RT_CXX_LIBRARY STREQUAL "none") # We aren't using any C++ standard library so avoid including the default one. - append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_COMMON_CFLAGS) - append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_COMMON_LINK_FLAGS) + append_list_if(CXX_SUPPORTS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_COMMON_CFLAGS) + append_list_if(CXX_SUPPORTS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_COMMON_LINK_FLAGS) else() # Nothing to be done for `default`. endif() @@ -651,8 +651,8 @@ list(APPEND SANITIZER_TEST_CXX_LIBRARIES "$,cxx_shared,cxx_static>>") endif() # We are using the in tree libc++ so avoid including the default one. - append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_UNITTEST_CFLAGS) - append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_UNITTEST_LINK_FLAGS) + append_list_if(CXX_SUPPORTS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_UNITTEST_CFLAGS) + append_list_if(CXX_SUPPORTS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_UNITTEST_LINK_FLAGS) else() append_list_if(COMPILER_RT_HAS_LIBCXX -lc++ SANITIZER_TEST_CXX_LIBRARIES) endif() @@ -686,12 +686,12 @@ -I${COMPILER_RT_GMOCK_PATH} ) -if(COMPILER_RT_HAS_G_FLAG) +if(CXX_SUPPORTS_G_FLAG) list(APPEND COMPILER_RT_UNITTEST_CFLAGS -g) endif() append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS) -append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS) -append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override COMPILER_RT_UNITTEST_CFLAGS) +append_list_if(CXX_SUPPORTS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS) +append_list_if(CXX_SUPPORTS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override COMPILER_RT_UNITTEST_CFLAGS) if(MSVC) # gtest use a lot of stuff marked as deprecated on Windows. @@ -699,7 +699,7 @@ endif() # Warnings to turn off for all libraries, not just sanitizers. -append_string_if(COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG -Wno-unused-parameter CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +append_string_if(CXX_SUPPORTS_WUNUSED_PARAMETER_FLAG -Wno-unused-parameter CMAKE_C_FLAGS CMAKE_CXX_FLAGS) if (CMAKE_LINKER MATCHES "link.exe$") # Silence MSVC linker warnings caused by empty object files. The @@ -756,7 +756,7 @@ if(ANDROID) set(COMPILER_RT_HAS_LLD TRUE) set(COMPILER_RT_TEST_USE_LLD TRUE) - append_list_if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG -fuse-ld=lld SANITIZER_COMMON_LINK_FLAGS) + append_list_if(CXX_SUPPORTS_FUSE_LD_LLD_FLAG -fuse-ld=lld SANITIZER_COMMON_LINK_FLAGS) append_list_if(COMPILER_RT_HAS_LLD -fuse-ld=lld COMPILER_RT_UNITTEST_LINK_FLAGS) endif() pythonize_bool(COMPILER_RT_HAS_LLD) diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -193,7 +193,7 @@ set(libnames) # Until we support this some other way, build compiler-rt runtime without LTO # to allow non-LTO projects to link with it. - if(COMPILER_RT_HAS_FNO_LTO_FLAG) + if(C_SUPPORTS_FNO_LTO_FLAG) set(NO_LTO_FLAGS "-fno-lto") else() set(NO_LTO_FLAGS "") @@ -202,14 +202,14 @@ # By default do not instrument or use profdata for compiler-rt. set(NO_PGO_FLAGS "") if(NOT COMPILER_RT_ENABLE_PGO) - if(LLVM_PROFDATA_FILE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG) + if(LLVM_PROFDATA_FILE AND C_SUPPORTS_FNO_PROFILE_INSTR_USE_FLAG) list(APPEND NO_PGO_FLAGS "-fno-profile-instr-use") endif() - if(LLVM_BUILD_INSTRUMENTED MATCHES IR AND COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG) + if(LLVM_BUILD_INSTRUMENTED MATCHES IR AND C_SUPPORTS_FNO_PROFILE_GENERATE_FLAG) list(APPEND NO_PGO_FLAGS "-fno-profile-generate") - elseif((LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) + elseif((LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND C_SUPPORTS_FNO_PROFILE_INSTR_GENERATE_FLAG) list(APPEND NO_PGO_FLAGS "-fno-profile-instr-generate") - if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND CXX_SUPPORTS_FNO_COVERAGE_MAPPING_FLAG) list(APPEND NO_PGO_FLAGS "-fno-coverage-mapping") endif() endif() diff --git a/compiler-rt/cmake/Modules/CheckSectionExists.cmake b/compiler-rt/cmake/Modules/CheckSectionExists.cmake --- a/compiler-rt/cmake/Modules/CheckSectionExists.cmake +++ b/compiler-rt/cmake/Modules/CheckSectionExists.cmake @@ -17,16 +17,16 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET) list(APPEND try_compile_flags "-target ${CMAKE_C_COMPILER_TARGET}") endif() - append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto try_compile_flags) + append_list_if(C_SUPPORTS_FNO_LTO_FLAG -fno-lto try_compile_flags) if(NOT COMPILER_RT_ENABLE_PGO) - if(LLVM_PROFDATA_FILE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG) + if(LLVM_PROFDATA_FILE AND C_SUPPORTS_FNO_PROFILE_INSTR_USE_FLAG) list(APPEND try_compile_flags "-fno-profile-instr-use") endif() - if(LLVM_BUILD_INSTRUMENTED MATCHES IR AND COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG) + if(LLVM_BUILD_INSTRUMENTED MATCHES IR AND C_SUPPORTS_FNO_PROFILE_GENERATE_FLAG) list(APPEND try_compile_flags "-fno-profile-generate") - elseif((LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) + elseif((LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND C_SUPPORTS_FNO_PROFILE_INSTR_GENERATE_FLAG) list(APPEND try_compile_flags "-fno-profile-instr-generate") - if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND CXX_SUPPORTS_FNO_COVERAGE_MAPPING_FLAG) list(APPEND try_compile_flags "-fno-coverage-mapping") endif() endif() diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake --- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake +++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake @@ -42,11 +42,11 @@ macro(append_rtti_flag polarity list) if(${polarity}) - append_list_if(COMPILER_RT_HAS_FRTTI_FLAG -frtti ${list}) - append_list_if(COMPILER_RT_HAS_GR_FLAG /GR ${list}) + append_list_if(CXX_SUPPORTS_FRTTI_FLAG -frtti ${list}) + append_list_if(CXX_SUPPORTS_GR_FLAG /GR ${list}) else() - append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list}) - append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list}) + append_list_if(CXX_SUPPORTS_FNO_RTTI_FLAG -fno-rtti ${list}) + append_list_if(CXX_SUPPORTS_GR_FLAG /GR- ${list}) endif() endmacro() @@ -125,7 +125,7 @@ FLAGS ${TARGET_${arch}_CFLAGS}) else() set(FLAG_NO_EXCEPTIONS "") - if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG) + if(CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG) set(FLAG_NO_EXCEPTIONS " -fno-exceptions ") endif() set(SAVED_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) @@ -567,21 +567,21 @@ function(add_security_warnings out_flags macosx_sdk_version) set(flags "${${out_flags}}") - append_list_if(COMPILER_RT_HAS_ARRAY_BOUNDS_FLAG -Werror=array-bounds flags) - append_list_if(COMPILER_RT_HAS_UNINITIALIZED_FLAG -Werror=uninitialized flags) - append_list_if(COMPILER_RT_HAS_SHADOW_FLAG -Werror=shadow flags) - append_list_if(COMPILER_RT_HAS_EMPTY_BODY_FLAG -Werror=empty-body flags) - append_list_if(COMPILER_RT_HAS_SIZEOF_POINTER_MEMACCESS_FLAG -Werror=sizeof-pointer-memaccess flags) - append_list_if(COMPILER_RT_HAS_SIZEOF_ARRAY_ARGUMENT_FLAG -Werror=sizeof-array-argument flags) - append_list_if(COMPILER_RT_HAS_SUSPICIOUS_MEMACCESS_FLAG -Werror=suspicious-memaccess flags) - append_list_if(COMPILER_RT_HAS_BUILTIN_MEMCPY_CHK_SIZE_FLAG -Werror=builtin-memcpy-chk-size flags) - append_list_if(COMPILER_RT_HAS_ARRAY_BOUNDS_POINTER_ARITHMETIC_FLAG -Werror=array-bounds-pointer-arithmetic flags) - append_list_if(COMPILER_RT_HAS_RETURN_STACK_ADDRESS_FLAG -Werror=return-stack-address flags) - append_list_if(COMPILER_RT_HAS_SIZEOF_ARRAY_DECAY_FLAG -Werror=sizeof-array-decay flags) - append_list_if(COMPILER_RT_HAS_FORMAT_INSUFFICIENT_ARGS_FLAG -Werror=format-insufficient-args flags) - append_list_if(COMPILER_RT_HAS_BUILTIN_FORMAL_SECURITY_FLAG -Werror=format-security flags) - append_list_if(COMPILER_RT_HAS_SIZEOF_ARRAY_DIV_FLAG -Werror=sizeof-array-div) - append_list_if(COMPILER_RT_HAS_SIZEOF_POINTER_DIV_FLAG -Werror=sizeof-pointer-div) + append_list_if(CXX_SUPPORTS_ARRAY_BOUNDS_FLAG -Werror=array-bounds flags) + append_list_if(CXX_SUPPORTS_UNINITIALIZED_FLAG -Werror=uninitialized flags) + append_list_if(CXX_SUPPORTS_SHADOW_FLAG -Werror=shadow flags) + append_list_if(CXX_SUPPORTS_EMPTY_BODY_FLAG -Werror=empty-body flags) + append_list_if(CXX_SUPPORTS_SIZEOF_POINTER_MEMACCESS_FLAG -Werror=sizeof-pointer-memaccess flags) + append_list_if(CXX_SUPPORTS_SIZEOF_ARRAY_ARGUMENT_FLAG -Werror=sizeof-array-argument flags) + append_list_if(CXX_SUPPORTS_SUSPICIOUS_MEMACCESS_FLAG -Werror=suspicious-memaccess flags) + append_list_if(CXX_SUPPORTS_BUILTIN_MEMCPY_CHK_SIZE_FLAG -Werror=builtin-memcpy-chk-size flags) + append_list_if(CXX_SUPPORTS_ARRAY_BOUNDS_POINTER_ARITHMETIC_FLAG -Werror=array-bounds-pointer-arithmetic flags) + append_list_if(CXX_SUPPORTS_RETURN_STACK_ADDRESS_FLAG -Werror=return-stack-address flags) + append_list_if(CXX_SUPPORTS_SIZEOF_ARRAY_DECAY_FLAG -Werror=sizeof-array-decay flags) + append_list_if(CXX_SUPPORTS_FORMAT_INSUFFICIENT_ARGS_FLAG -Werror=format-insufficient-args flags) + append_list_if(CXX_SUPPORTS_BUILTIN_FORMAL_SECURITY_FLAG -Werror=format-security flags) + append_list_if(CXX_SUPPORTS_SIZEOF_ARRAY_DIV_FLAG -Werror=sizeof-array-div) + append_list_if(CXX_SUPPORTS_SIZEOF_POINTER_DIV_FLAG -Werror=sizeof-pointer-div) # Add -Wformat-nonliteral only if we can avoid adding the definition of # eprintf. On Apple platforms, eprintf is needed only on macosx and only if diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake --- a/compiler-rt/cmake/base-config-ix.cmake +++ b/compiler-rt/cmake/base-config-ix.cmake @@ -139,12 +139,12 @@ set(OSX_SYSROOT_FLAG "") endif() - try_compile_only(COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG + try_compile_only(CXX_SUPPORTS_DARWIN_TARGET_VARIANT_FLAG FLAGS "-target" "x86_64-apple-macos10.15" "-darwin-target-variant" "x86_64-apple-ios13.1-macabi" "-Werror") - option(COMPILER_RT_ENABLE_MACCATALYST "Enable building for Mac Catalyst" ${COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG}) + option(COMPILER_RT_ENABLE_MACCATALYST "Enable building for Mac Catalyst" ${CXX_SUPPORTS_DARWIN_TARGET_VARIANT_FLAG}) option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On) option(COMPILER_RT_ENABLE_WATCHOS "Enable building for watchOS - Experimental" Off) option(COMPILER_RT_ENABLE_TVOS "Enable building for tvOS - Experimental" Off) diff --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake --- a/compiler-rt/cmake/builtin-config-ix.cmake +++ b/compiler-rt/cmake/builtin-config-ix.cmake @@ -5,14 +5,14 @@ set(TEST_COMPILE_ONLY On) # Check host compiler support for certain flags -builtin_check_c_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG) -builtin_check_c_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG) -builtin_check_c_compiler_flag(-fno-builtin COMPILER_RT_HAS_FNO_BUILTIN_FLAG) -builtin_check_c_compiler_flag(-std=c11 COMPILER_RT_HAS_STD_C11_FLAG) -builtin_check_c_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG) -builtin_check_c_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG) -builtin_check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG) -builtin_check_c_compiler_flag(-fxray-instrument COMPILER_RT_HAS_XRAY_COMPILER_FLAG) +builtin_check_c_compiler_flag(-fPIC C_SUPPORTS_FPIC_FLAG) +builtin_check_c_compiler_flag(-fPIE C_SUPPORTS_FPIE_FLAG) +builtin_check_c_compiler_flag(-fno-builtin C_SUPPORTS_FNO_BUILTIN_FLAG) +builtin_check_c_compiler_flag(-std=c11 C_SUPPORTS_STD_C11_FLAG) +builtin_check_c_compiler_flag(-fvisibility=hidden C_SUPPORTS_VISIBILITY_HIDDEN_FLAG) +builtin_check_c_compiler_flag(-fomit-frame-pointer C_SUPPORTS_OMIT_FRAME_POINTER_FLAG) +builtin_check_c_compiler_flag(-ffreestanding C_SUPPORTS_FFREESTANDING_FLAG) +builtin_check_c_compiler_flag(-fxray-instrument C_SUPPORTS_XRAY_COMPILER_FLAG) builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD " diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -65,104 +65,102 @@ endif () # CodeGen options. -check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG) -check_c_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG) -check_c_compiler_flag(-std=c11 COMPILER_RT_HAS_STD_C11_FLAG) -check_c_compiler_flag(-fcf-protection=full COMPILER_RT_HAS_FCF_PROTECTION_FLAG) -check_cxx_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG) -check_cxx_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG) -check_cxx_compiler_flag(-fno-builtin COMPILER_RT_HAS_FNO_BUILTIN_FLAG) -check_cxx_compiler_flag(-fno-exceptions COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG) -check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG) -check_cxx_compiler_flag(-funwind-tables COMPILER_RT_HAS_FUNWIND_TABLES_FLAG) -check_cxx_compiler_flag(-fno-stack-protector COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG) -check_cxx_compiler_flag(-fno-sanitize=safe-stack COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG) -check_cxx_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG) -check_cxx_compiler_flag(-frtti COMPILER_RT_HAS_FRTTI_FLAG) -check_cxx_compiler_flag(-fno-rtti COMPILER_RT_HAS_FNO_RTTI_FLAG) -check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG) -check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC) -check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG) -check_cxx_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG) -check_cxx_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) -check_cxx_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG) -check_cxx_compiler_flag(-fno-coverage-mapping COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) -check_cxx_compiler_flag("-Werror -mcrc32" COMPILER_RT_HAS_MCRC32_FLAG) -check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG) -check_cxx_compiler_flag("-Werror -msse4.2" COMPILER_RT_HAS_MSSE4_2_FLAG) -check_cxx_compiler_flag(--sysroot=. COMPILER_RT_HAS_SYSROOT_FLAG) -check_cxx_compiler_flag("-Werror -mcrc" COMPILER_RT_HAS_MCRC_FLAG) -check_cxx_compiler_flag(-fno-partial-inlining COMPILER_RT_HAS_FNO_PARTIAL_INLINING_FLAG) -check_cxx_compiler_flag(-Werror -ftrivial-auto-var-init=pattern COMPILER_RT_HAS_TRIVIAL_AUTO_INIT) +check_c_compiler_flag(-ffreestanding C_SUPPORTS_FFREESTANDING_FLAG) +check_c_compiler_flag(-fomit-frame-pointer C_SUPPORTS_OMIT_FRAME_POINTER_FLAG) +check_c_compiler_flag(-std=c11 C_SUPPORTS_STD_C11_FLAG) +check_c_compiler_flag(-fcf-protection=full C_SUPPORTS_FCF_PROTECTION_FLAG) +check_c_compiler_flag(-fPIC C_SUPPORTS_FPIC_FLAG) +check_c_compiler_flag(-fPIE C_SUPPORTS_FPIE_FLAG) +check_c_compiler_flag(-fno-builtin C_SUPPORTS_FNO_BUILTIN_FLAG) +check_c_compiler_flag(-fno-lto C_SUPPORTS_FNO_LTO_FLAG) +check_c_compiler_flag(-fno-profile-generate C_SUPPORTS_FNO_PROFILE_GENERATE_FLAG) +check_c_compiler_flag(-fno-profile-instr-generate C_SUPPORTS_FNO_PROFILE_INSTR_GENERATE_FLAG) +check_c_compiler_flag(-fno-profile-instr-use C_SUPPORTS_FNO_PROFILE_INSTR_USE_FLAG) +check_cxx_compiler_flag(-fno-exceptions CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG) +check_cxx_compiler_flag(-fomit-frame-pointer CXX_SUPPORTS_FOMIT_FRAME_POINTER_FLAG) +check_cxx_compiler_flag(-funwind-tables CXX_SUPPORTS_FUNWIND_TABLES_FLAG) +check_cxx_compiler_flag(-fno-stack-protector CXX_SUPPORTS_FNO_STACK_PROTECTOR_FLAG) +check_cxx_compiler_flag(-fno-sanitize=safe-stack CXX_SUPPORTS_FNO_SANITIZE_SAFE_STACK_FLAG) +check_cxx_compiler_flag(-fvisibility=hidden CXX_SUPPORTS_FVISIBILITY_HIDDEN_FLAG) +check_cxx_compiler_flag(-frtti CXX_SUPPORTS_FRTTI_FLAG) +check_cxx_compiler_flag(-fno-rtti CXX_SUPPORTS_FNO_RTTI_FLAG) +check_cxx_compiler_flag("-Werror -fno-function-sections" CXX_SUPPORTS_FNO_FUNCTION_SECTIONS_FLAG) +check_cxx_compiler_flag(-ftls-model=initial-exec CXX_SUPPORTS_FTLS_MODEL_INITIAL_EXEC_FLAG) +check_cxx_compiler_flag(-fno-coverage-mapping CXX_SUPPORTS_FNO_COVERAGE_MAPPING_FLAG) +check_cxx_compiler_flag("-Werror -mcrc32" CXX_SUPPORTS_MCRC32_FLAG) +check_cxx_compiler_flag("-Werror -msse3" CXX_SUPPORTS_MSSE3_FLAG) +check_cxx_compiler_flag("-Werror -msse4.2" CXX_SUPPORTS_MSSE4_2_FLAG) +check_cxx_compiler_flag(--sysroot=. CXX_SUPPORTS_SYSROOT_FLAG) +check_cxx_compiler_flag("-Werror -mcrc" CXX_SUPPORTS_MCRC_FLAG) +check_cxx_compiler_flag(-fno-partial-inlining CXX_SUPPORTS_FNO_PARTIAL_INLINING_FLAG) +check_cxx_compiler_flag(-Werror -ftrivial-auto-var-init=pattern CXX_SUPPORTS_FTRIVIAL_AUTO_INIT_FLAG) if(NOT WIN32 AND NOT CYGWIN) # MinGW warns if -fvisibility-inlines-hidden is used. - check_cxx_compiler_flag("-fvisibility-inlines-hidden" COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG) + check_cxx_compiler_flag("-fvisibility-inlines-hidden" CXX_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG) endif() -check_cxx_compiler_flag(/GR COMPILER_RT_HAS_GR_FLAG) -check_cxx_compiler_flag(/GS COMPILER_RT_HAS_GS_FLAG) -check_cxx_compiler_flag(/MT COMPILER_RT_HAS_MT_FLAG) -check_cxx_compiler_flag(/Oy COMPILER_RT_HAS_Oy_FLAG) +check_cxx_compiler_flag(/GR CXX_SUPPORTS_GR_FLAG) +check_cxx_compiler_flag(/GS CXX_SUPPORTS_GS_FLAG) +check_cxx_compiler_flag(/MT CXX_SUPPORTS_MT_FLAG) +check_cxx_compiler_flag(/Oy CXX_SUPPORTS_OY_FLAG) # Debug info flags. -check_cxx_compiler_flag(-gline-tables-only COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG) -check_cxx_compiler_flag(-g COMPILER_RT_HAS_G_FLAG) -check_cxx_compiler_flag(/Zi COMPILER_RT_HAS_Zi_FLAG) +check_cxx_compiler_flag(-gline-tables-only CXX_SUPPORTS_GLINE_TABLES_ONLY_FLAG) +check_cxx_compiler_flag(-g CXX_SUPPORTS_G_FLAG) # Warnings. -check_cxx_compiler_flag(-Wall COMPILER_RT_HAS_WALL_FLAG) -check_cxx_compiler_flag(-Werror COMPILER_RT_HAS_WERROR_FLAG) -check_cxx_compiler_flag("-Werror -Wframe-larger-than=512" COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG) -check_cxx_compiler_flag("-Werror -Wglobal-constructors" COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG) -check_cxx_compiler_flag("-Werror -Wc99-extensions" COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG) -check_cxx_compiler_flag("-Werror -Wgnu" COMPILER_RT_HAS_WGNU_FLAG) -check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG) -check_cxx_compiler_flag("-Werror -Wvariadic-macros" COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG) -check_cxx_compiler_flag("-Werror -Wunused-parameter" COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG) -check_cxx_compiler_flag("-Werror -Wcovered-switch-default" COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG) -check_cxx_compiler_flag("-Werror -Wsuggest-override" COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG) -check_cxx_compiler_flag("-Werror -Wthread-safety" COMPILER_RT_HAS_WTHREAD_SAFETY_FLAG) -check_cxx_compiler_flag("-Werror -Wthread-safety-reference" COMPILER_RT_HAS_WTHREAD_SAFETY_REFERENCE_FLAG) -check_cxx_compiler_flag("-Werror -Wthread-safety-beta" COMPILER_RT_HAS_WTHREAD_SAFETY_BETA_FLAG) -check_cxx_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC) -check_cxx_compiler_flag(-Wno-format COMPILER_RT_HAS_WNO_FORMAT) -check_cxx_compiler_flag(-Wno-format-pedantic COMPILER_RT_HAS_WNO_FORMAT_PEDANTIC) - -check_cxx_compiler_flag("/experimental:external /external:W0" COMPILER_RT_HAS_EXTERNAL_FLAG) - -check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG) -check_cxx_compiler_flag(/WX COMPILER_RT_HAS_WX_FLAG) -check_cxx_compiler_flag(/wd4146 COMPILER_RT_HAS_WD4146_FLAG) -check_cxx_compiler_flag(/wd4206 COMPILER_RT_HAS_WD4206_FLAG) -check_cxx_compiler_flag(/wd4291 COMPILER_RT_HAS_WD4291_FLAG) -check_cxx_compiler_flag(/wd4221 COMPILER_RT_HAS_WD4221_FLAG) -check_cxx_compiler_flag(/wd4391 COMPILER_RT_HAS_WD4391_FLAG) -check_cxx_compiler_flag(/wd4722 COMPILER_RT_HAS_WD4722_FLAG) -check_cxx_compiler_flag(/wd4800 COMPILER_RT_HAS_WD4800_FLAG) - -check_cxx_compiler_flag(-Werror -Warray-bounds COMPILER_RT_HAS_ARRAY_BOUNDS_FLAG) -check_cxx_compiler_flag(-Werror -Wuninitialized COMPILER_RT_HAS_UNINITIALIZED_FLAG) -check_cxx_compiler_flag(-Werror -Wshadow COMPILER_RT_HAS_SHADOW_FLAG) -check_cxx_compiler_flag(-Werror -Wempty-body COMPILER_RT_HAS_EMPTY_BODY_FLAG) -check_cxx_compiler_flag(-Werror -Wsizeof-pointer-memaccess COMPILER_RT_HAS_SIZEOF_POINTER_MEMACCESS_FLAG) -check_cxx_compiler_flag(-Werror -Wsizeof-array-argument COMPILER_RT_HAS_SIZEOF_ARRAY_ARGUMENT_FLAG) -check_cxx_compiler_flag(-Werror -Wsuspicious-memaccess COMPILER_RT_HAS_SUSPICIOUS_MEMACCESS_FLAG) -check_cxx_compiler_flag(-Werror -Wbuiltin-memcpy-chk-size COMPILER_RT_HAS_BUILTIN_MEMCPY_CHK_SIZE_FLAG) -check_cxx_compiler_flag(-Werror -Warray-bounds-pointer-arithmetic COMPILER_RT_HAS_ARRAY_BOUNDS_POINTER_ARITHMETIC_FLAG) -check_cxx_compiler_flag(-Werror -Wreturn-stack-address COMPILER_RT_HAS_RETURN_STACK_ADDRESS_FLAG) -check_cxx_compiler_flag(-Werror -Wsizeof-array-decay COMPILER_RT_HAS_SIZEOF_ARRAY_DECAY_FLAG) -check_cxx_compiler_flag(-Werror -Wformat-insufficient-args COMPILER_RT_HAS_FORMAT_INSUFFICIENT_ARGS_FLAG) -check_cxx_compiler_flag(-Werror -Wformat-security COMPILER_RT_HAS_BUILTIN_FORMAL_SECURITY_FLAG) -check_cxx_compiler_flag(-Werror -Wsizeof-array-div COMPILER_RT_HAS_SIZEOF_ARRAY_DIV_FLAG) -check_cxx_compiler_flag(-Werror -Wsizeof-pointer-div COMPILER_RT_HAS_SIZEOF_POINTER_DIV_FLAG) +check_c_compiler_flag(-Wno-pedantic C_SUPPORTS_WNO_PEDANTIC_FLAG) +check_c_compiler_flag(-Wno-format C_SUPPORTS_WNO_FORMAT_FLAG) +check_cxx_compiler_flag(-Wall CXX_SUPPORTS_WALL_FLAG) +check_cxx_compiler_flag(-Werror CXX_SUPPORTS_WERROR_FLAG) +check_cxx_compiler_flag("-Werror -Wframe-larger-than=512" CXX_SUPPORTS_WFRAME_LARGER_THAN_FLAG) +check_cxx_compiler_flag("-Werror -Wglobal-constructors" CXX_SUPPORTS_WGLOBAL_CONSTRUCTORS_FLAG) +check_cxx_compiler_flag("-Werror -Wc99-extensions" CXX_SUPPORTS_WC99_EXTENSIONS_FLAG) +check_cxx_compiler_flag("-Werror -Wgnu" CXX_SUPPORTS_WGNU_FLAG) +check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" CXX_SUPPORTS_WNON_VIRTUAL_DTOR_FLAG) +check_cxx_compiler_flag("-Werror -Wvariadic-macros" CXX_SUPPORTS_WVARIADIC_MACROS_FLAG) +check_cxx_compiler_flag("-Werror -Wunused-parameter" CXX_SUPPORTS_WUNUSED_PARAMETER_FLAG) +check_cxx_compiler_flag("-Werror -Wcovered-switch-default" CXX_SUPPORTS_WCOVERED_SWITCH_DEFAULT_FLAG) +check_cxx_compiler_flag("-Werror -Wsuggest-override" CXX_SUPPORTS_WSUGGEST_OVERRIDE_FLAG) +check_cxx_compiler_flag("-Werror -Wthread-safety" CXX_SUPPORTS_WTHREAD_SAFETY_FLAG) +check_cxx_compiler_flag("-Werror -Wthread-safety-reference" CXX_SUPPORTS_WTHREAD_SAFETY_REFERENCE_FLAG) +check_cxx_compiler_flag("-Werror -Wthread-safety-beta" CXX_SUPPORTS_WTHREAD_SAFETY_BETA_FLAG) + +check_cxx_compiler_flag("/experimental:external /external:W0" CXX_SUPPORTS_EXTERNAL_FLAG) + +check_cxx_compiler_flag(/W4 CXX_SUPPORTS_W4_FLAG) +check_cxx_compiler_flag(/WX CXX_SUPPORTS_WX_FLAG) +check_cxx_compiler_flag(/wd4146 CXX_SUPPORTS_WD4146_FLAG) +check_cxx_compiler_flag(/wd4206 CXX_SUPPORTS_WD4206_FLAG) +check_cxx_compiler_flag(/wd4291 CXX_SUPPORTS_WD4291_FLAG) +check_cxx_compiler_flag(/wd4221 CXX_SUPPORTS_WD4221_FLAG) +check_cxx_compiler_flag(/wd4391 CXX_SUPPORTS_WD4391_FLAG) +check_cxx_compiler_flag(/wd4722 CXX_SUPPORTS_WD4722_FLAG) +check_cxx_compiler_flag(/wd4800 CXX_SUPPORTS_WD4800_FLAG) + +check_cxx_compiler_flag(-Werror -Warray-bounds CXX_SUPPORTS_ARRAY_BOUNDS_FLAG) +check_cxx_compiler_flag(-Werror -Wuninitialized CXX_SUPPORTS_UNINITIALIZED_FLAG) +check_cxx_compiler_flag(-Werror -Wshadow CXX_SUPPORTS_SHADOW_FLAG) +check_cxx_compiler_flag(-Werror -Wempty-body CXX_SUPPORTS_EMPTY_BODY_FLAG) +check_cxx_compiler_flag(-Werror -Wsizeof-pointer-memaccess CXX_SUPPORTS_SIZEOF_POINTER_MEMACCESS_FLAG) +check_cxx_compiler_flag(-Werror -Wsizeof-array-argument CXX_SUPPORTS_SIZEOF_ARRAY_ARGUMENT_FLAG) +check_cxx_compiler_flag(-Werror -Wsuspicious-memaccess CXX_SUPPORTS_SUSPICIOUS_MEMACCESS_FLAG) +check_cxx_compiler_flag(-Werror -Wbuiltin-memcpy-chk-size CXX_SUPPORTS_BUILTIN_MEMCPY_CHK_SIZE_FLAG) +check_cxx_compiler_flag(-Werror -Warray-bounds-pointer-arithmetic CXX_SUPPORTS_ARRAY_BOUNDS_POINTER_ARITHMETIC_FLAG) +check_cxx_compiler_flag(-Werror -Wreturn-stack-address CXX_SUPPORTS_RETURN_STACK_ADDRESS_FLAG) +check_cxx_compiler_flag(-Werror -Wsizeof-array-decay CXX_SUPPORTS_SIZEOF_ARRAY_DECAY_FLAG) +check_cxx_compiler_flag(-Werror -Wformat-insufficient-args CXX_SUPPORTS_FORMAT_INSUFFICIENT_ARGS_FLAG) +check_cxx_compiler_flag(-Werror -Wformat-security CXX_SUPPORTS_BUILTIN_FORMAL_SECURITY_FLAG) +check_cxx_compiler_flag(-Werror -Wsizeof-array-div CXX_SUPPORTS_SIZEOF_ARRAY_DIV_FLAG) +check_cxx_compiler_flag(-Werror -Wsizeof-pointer-div CXX_SUPPORTS_SIZEOF_POINTER_DIV_FLAG) # Symbols. check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL) # Includes. -check_cxx_compiler_flag(-nostdinc++ COMPILER_RT_HAS_NOSTDINCXX_FLAG) -check_cxx_compiler_flag(-nostdlib++ COMPILER_RT_HAS_NOSTDLIBXX_FLAG) +check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG) +check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG) check_include_files("sys/auxv.h" COMPILER_RT_HAS_AUXV) # Libraries. @@ -196,7 +194,7 @@ # Linker flags. llvm_check_compiler_linker_flag(C "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT) -llvm_check_compiler_linker_flag(C "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) +llvm_check_compiler_linker_flag(C "-fuse-ld=lld" CXX_SUPPORTS_FUSE_LD_LLD_FLAG) if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat") diff --git a/compiler-rt/cmake/crt-config-ix.cmake b/compiler-rt/cmake/crt-config-ix.cmake --- a/compiler-rt/cmake/crt-config-ix.cmake +++ b/compiler-rt/cmake/crt-config-ix.cmake @@ -4,13 +4,13 @@ # Make all the tests only check the compiler set(TEST_COMPILE_ONLY On) -builtin_check_c_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG) -builtin_check_c_compiler_flag(-std=c11 COMPILER_RT_HAS_STD_C11_FLAG) -builtin_check_c_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC) -builtin_check_c_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG) -builtin_check_c_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG) -builtin_check_c_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) -builtin_check_c_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG) +builtin_check_c_compiler_flag(-fPIC C_SUPPORTS_FPIC_FLAG) +builtin_check_c_compiler_flag(-std=c11 C_SUPPORTS_STD_C11_FLAG) +builtin_check_c_compiler_flag(-Wno-pedantic C_SUPPORTS_WNO_PEDANTIC_FLAG) +builtin_check_c_compiler_flag(-fno-lto C_SUPPORTS_FNO_LTO_FLAG) +builtin_check_c_compiler_flag(-fno-profile-generate C_SUPPORTS_FNO_PROFILE_GENERATE_FLAG) +builtin_check_c_compiler_flag(-fno-profile-instr-generate C_SUPPORTS_FNO_PROFILE_INSTR_GENERATE_FLAG) +builtin_check_c_compiler_flag(-fno-profile-instr-use C_SUPPORTS_FNO_PROFILE_INSTR_USE_FLAG) if(ANDROID) set(OS_NAME "Android") diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -92,11 +92,11 @@ # Silence warnings in system headers with MSVC. if(NOT CLANG_CL) - append_list_if(COMPILER_RT_HAS_EXTERNAL_FLAG "/experimental:external /external:W0 /external:anglebrackets" ASAN_CFLAGS) + append_list_if(CXX_SUPPORTS_EXTERNAL_FLAG "/experimental:external /external:W0 /external:anglebrackets" ASAN_CFLAGS) endif() # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format ASAN_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format ASAN_CFLAGS) set(ASAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) @@ -113,7 +113,7 @@ append_list_if(WIN32 INTERCEPTION_DYNAMIC_CRT ASAN_DYNAMIC_DEFINITIONS) set(ASAN_DYNAMIC_CFLAGS ${ASAN_CFLAGS}) -append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC +append_list_if(CXX_SUPPORTS_FTLS_MODEL_INITIAL_EXEC_FLAG -ftls-model=initial-exec ASAN_DYNAMIC_CFLAGS) append_list_if(MSVC /DEBUG ASAN_DYNAMIC_LINK_FLAGS) diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -32,7 +32,7 @@ -O2 -Wno-format -Werror=sign-compare) -append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros ASAN_UNITTEST_COMMON_CFLAGS) +append_list_if(CXX_SUPPORTS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros ASAN_UNITTEST_COMMON_CFLAGS) # This will ensure the target linker is used # during cross compilation diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -743,33 +743,33 @@ set(BUILTIN_CFLAGS "") add_security_warnings(BUILTIN_CFLAGS 0) - if (COMPILER_RT_HAS_FCF_PROTECTION_FLAG) + if (C_SUPPORTS_FCF_PROTECTION_FLAG) append_list_if(COMPILER_RT_ENABLE_CET -fcf-protection=full BUILTIN_CFLAGS) endif() append_list_if(COMPILER_RT_HAS_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 BUILTIN_CFLAGS) - append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS) + append_list_if(C_SUPPORTS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS) # These flags would normally be added to CMAKE_C_FLAGS by the llvm # cmake step. Add them manually if this is a standalone build. if(COMPILER_RT_STANDALONE_BUILD) if(COMPILER_RT_BUILTINS_ENABLE_PIC) - append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC BUILTIN_CFLAGS) + append_list_if(C_SUPPORTS_FPIC_FLAG -fPIC BUILTIN_CFLAGS) endif() - append_list_if(COMPILER_RT_HAS_FNO_BUILTIN_FLAG -fno-builtin BUILTIN_CFLAGS) + append_list_if(C_SUPPORTS_FNO_BUILTIN_FLAG -fno-builtin BUILTIN_CFLAGS) if(COMPILER_RT_BUILTINS_HIDE_SYMBOLS) - append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG -fvisibility=hidden BUILTIN_CFLAGS) + append_list_if(C_SUPPORTS_VISIBILITY_HIDDEN_FLAG -fvisibility=hidden BUILTIN_CFLAGS) endif() if(NOT COMPILER_RT_DEBUG) - append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fomit-frame-pointer BUILTIN_CFLAGS) + append_list_if(C_SUPPORTS_OMIT_FRAME_POINTER_FLAG -fomit-frame-pointer BUILTIN_CFLAGS) endif() endif() set(BUILTIN_DEFS "") if(COMPILER_RT_BUILTINS_HIDE_SYMBOLS) - append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG VISIBILITY_HIDDEN BUILTIN_DEFS) + append_list_if(C_SUPPORTS_VISIBILITY_HIDDEN_FLAG VISIBILITY_HIDDEN BUILTIN_DEFS) endif() if(COMPILER_RT_DISABLE_AARCH64_FMV) diff --git a/compiler-rt/lib/cfi/CMakeLists.txt b/compiler-rt/lib/cfi/CMakeLists.txt --- a/compiler-rt/lib/cfi/CMakeLists.txt +++ b/compiler-rt/lib/cfi/CMakeLists.txt @@ -12,7 +12,7 @@ ) # Too many existing bugs, needs cleanup. - append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format CFI_CFLAGS) + append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format CFI_CFLAGS) set(CFI_DIAG_CFLAGS -DCFI_ENABLE_DIAG=1 diff --git a/compiler-rt/lib/crt/CMakeLists.txt b/compiler-rt/lib/crt/CMakeLists.txt --- a/compiler-rt/lib/crt/CMakeLists.txt +++ b/compiler-rt/lib/crt/CMakeLists.txt @@ -44,12 +44,12 @@ check_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY SOURCE "volatile int x;\n__attribute__((constructor)) void f(void) {x = 0;}\nint main(void) { return 0; }\n") - append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 CRT_CFLAGS) + append_list_if(C_SUPPORTS_STD_C11_FLAG -std=c11 CRT_CFLAGS) append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS) append_list_if(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY -DEH_USE_FRAME_REGISTRY CRT_CFLAGS) - append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS) - append_list_if(COMPILER_RT_HAS_WNO_PEDANTIC -Wno-pedantic CRT_CFLAGS) - if (COMPILER_RT_HAS_FCF_PROTECTION_FLAG) + append_list_if(C_SUPPORTS_FPIC_FLAG -fPIC CRT_CFLAGS) + append_list_if(C_SUPPORTS_WNO_PEDANTIC_FLAG -Wno-pedantic CRT_CFLAGS) + if (C_SUPPORTS_FCF_PROTECTION_FLAG) append_list_if(COMPILER_RT_ENABLE_CET -fcf-protection=full CRT_CFLAGS) endif() diff --git a/compiler-rt/lib/dfsan/CMakeLists.txt b/compiler-rt/lib/dfsan/CMakeLists.txt --- a/compiler-rt/lib/dfsan/CMakeLists.txt +++ b/compiler-rt/lib/dfsan/CMakeLists.txt @@ -24,17 +24,17 @@ set(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS}) append_rtti_flag(OFF DFSAN_COMMON_CFLAGS) # Prevent clang from generating libc calls. -append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS) +append_list_if(C_SUPPORTS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS) # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format DFSAN_COMMON_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format DFSAN_COMMON_CFLAGS) # Static runtime library. add_compiler_rt_component(dfsan) foreach(arch ${DFSAN_SUPPORTED_ARCH}) set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS}) - append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE DFSAN_CFLAGS) + append_list_if(C_SUPPORTS_FPIE_FLAG -fPIE DFSAN_CFLAGS) add_compiler_rt_runtime(clang_rt.dfsan STATIC ARCHS ${arch} diff --git a/compiler-rt/lib/fuzzer/CMakeLists.txt b/compiler-rt/lib/fuzzer/CMakeLists.txt --- a/compiler-rt/lib/fuzzer/CMakeLists.txt +++ b/compiler-rt/lib/fuzzer/CMakeLists.txt @@ -63,14 +63,14 @@ COMPILER_RT_LIBCXX_PATH AND COMPILER_RT_LIBCXXABI_PATH) list(APPEND LIBFUZZER_CFLAGS -D_LIBCPP_ABI_VERSION=Fuzzer) - append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ LIBFUZZER_CFLAGS) + append_list_if(CXX_SUPPORTS_NOSTDINCXX_FLAG -nostdinc++ LIBFUZZER_CFLAGS) elseif(TARGET cxx-headers OR HAVE_LIBCXX) # libFuzzer uses C++ standard library headers. list(APPEND LIBFUZZER_CFLAGS ${COMPILER_RT_CXX_CFLAGS}) set(LIBFUZZER_DEPS cxx-headers) endif() -append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer LIBFUZZER_CFLAGS) +append_list_if(C_SUPPORTS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer LIBFUZZER_CFLAGS) if (CMAKE_CXX_FLAGS MATCHES "fsanitize-coverage") list(APPEND LIBFUZZER_CFLAGS -fsanitize-coverage=0) diff --git a/compiler-rt/lib/gwp_asan/CMakeLists.txt b/compiler-rt/lib/gwp_asan/CMakeLists.txt --- a/compiler-rt/lib/gwp_asan/CMakeLists.txt +++ b/compiler-rt/lib/gwp_asan/CMakeLists.txt @@ -35,7 +35,7 @@ # parts of the C++ standard library. set(GWP_ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS} -fno-rtti -fno-exceptions -nostdinc++ -pthread -fno-omit-frame-pointer) -append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS) +append_list_if(C_SUPPORTS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS) # append_list_if(COMPILER_RT_HAS_SANITIZER_COMMON ${SANITIZER_COMMON_CFLAGS} GWP_ASAN_CFLAGS) # Remove -stdlib= which is unused when passing -nostdinc++. diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt --- a/compiler-rt/lib/hwasan/CMakeLists.txt +++ b/compiler-rt/lib/hwasan/CMakeLists.txt @@ -59,12 +59,12 @@ set(HWASAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS}) append_rtti_flag(OFF HWASAN_RTL_CFLAGS) -append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC HWASAN_RTL_CFLAGS) +append_list_if(C_SUPPORTS_FPIC_FLAG -fPIC HWASAN_RTL_CFLAGS) # Prevent clang from generating libc calls. -append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding HWASAN_RTL_CFLAGS) +append_list_if(C_SUPPORTS_FFREESTANDING_FLAG -ffreestanding HWASAN_RTL_CFLAGS) # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format HWASAN_RTL_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format HWASAN_RTL_CFLAGS) set(HWASAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) @@ -77,7 +77,7 @@ endif() set(HWASAN_DYNAMIC_CFLAGS ${HWASAN_RTL_CFLAGS}) -append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC +append_list_if(CXX_SUPPORTS_FTLS_MODEL_INITIAL_EXEC_FLAG -ftls-model=initial-exec HWASAN_DYNAMIC_CFLAGS) append_list_if(MSVC /DEBUG HWASAN_DYNAMIC_LINK_FLAGS) diff --git a/compiler-rt/lib/interception/CMakeLists.txt b/compiler-rt/lib/interception/CMakeLists.txt --- a/compiler-rt/lib/interception/CMakeLists.txt +++ b/compiler-rt/lib/interception/CMakeLists.txt @@ -21,7 +21,7 @@ # Silence warnings in system headers with MSVC. if(NOT CLANG_CL) - append_list_if(COMPILER_RT_HAS_EXTERNAL_FLAG "/experimental:external /external:W0 /external:anglebrackets" INTERCEPTION_CFLAGS) + append_list_if(CXX_SUPPORTS_EXTERNAL_FLAG "/experimental:external /external:W0 /external:anglebrackets" INTERCEPTION_CFLAGS) endif() add_compiler_rt_object_libraries(RTInterception diff --git a/compiler-rt/lib/lsan/CMakeLists.txt b/compiler-rt/lib/lsan/CMakeLists.txt --- a/compiler-rt/lib/lsan/CMakeLists.txt +++ b/compiler-rt/lib/lsan/CMakeLists.txt @@ -4,7 +4,7 @@ append_rtti_flag(OFF LSAN_CFLAGS) # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format LSAN_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format LSAN_CFLAGS) set(LSAN_COMMON_SOURCES lsan_common.cpp diff --git a/compiler-rt/lib/memprof/CMakeLists.txt b/compiler-rt/lib/memprof/CMakeLists.txt --- a/compiler-rt/lib/memprof/CMakeLists.txt +++ b/compiler-rt/lib/memprof/CMakeLists.txt @@ -52,7 +52,7 @@ set(MEMPROF_COMMON_DEFINITIONS "") # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format MEMPROF_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format MEMPROF_CFLAGS) append_rtti_flag(OFF MEMPROF_CFLAGS) @@ -62,7 +62,7 @@ ${MEMPROF_COMMON_DEFINITIONS} MEMPROF_DYNAMIC=1) set(MEMPROF_DYNAMIC_CFLAGS ${MEMPROF_CFLAGS}) -append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC +append_list_if(CXX_SUPPORTS_FTLS_MODEL_INITIAL_EXEC_FLAG -ftls-model=initial-exec MEMPROF_DYNAMIC_CFLAGS) set(MEMPROF_DYNAMIC_LIBS diff --git a/compiler-rt/lib/memprof/tests/CMakeLists.txt b/compiler-rt/lib/memprof/tests/CMakeLists.txt --- a/compiler-rt/lib/memprof/tests/CMakeLists.txt +++ b/compiler-rt/lib/memprof/tests/CMakeLists.txt @@ -16,7 +16,7 @@ # Suppress warnings for gmock variadic macros for clang and gcc respectively. append_list_if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG -Wno-gnu-zero-variadic-macro-arguments MEMPROF_UNITTEST_CFLAGS) -append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros MEMPROF_UNITTEST_CFLAGS) +append_list_if(CXX_SUPPORTS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros MEMPROF_UNITTEST_CFLAGS) file(GLOB MEMPROF_HEADERS ../*.h) diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt --- a/compiler-rt/lib/msan/CMakeLists.txt +++ b/compiler-rt/lib/msan/CMakeLists.txt @@ -31,14 +31,14 @@ set(MSAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS}) if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC -ftls-model=initial-exec MSAN_RTL_CFLAGS) + append_list_if(CXX_SUPPORTS_FTLS_MODEL_INITIAL_EXEC_FLAG -ftls-model=initial-exec MSAN_RTL_CFLAGS) endif() append_rtti_flag(OFF MSAN_RTL_CFLAGS) if(NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE MSAN_RTL_CFLAGS) + append_list_if(C_SUPPORTS_FPIE_FLAG -fPIE MSAN_RTL_CFLAGS) endif() # Prevent clang from generating libc calls. -append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding MSAN_RTL_CFLAGS) +append_list_if(C_SUPPORTS_FFREESTANDING_FLAG -ffreestanding MSAN_RTL_CFLAGS) set(MSAN_RUNTIME_LIBRARIES) diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt --- a/compiler-rt/lib/profile/CMakeLists.txt +++ b/compiler-rt/lib/profile/CMakeLists.txt @@ -111,17 +111,17 @@ endif() # We don't use the C++ Standard Library here, so avoid including it by mistake. -append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ EXTRA_FLAGS) +append_list_if(CXX_SUPPORTS_NOSTDINCXX_FLAG -nostdinc++ EXTRA_FLAGS) # XRay uses C++ standard library headers. string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # This appears to be a C-only warning banning the use of locals in aggregate # initializers. All other compilers accept this, though. # nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable -append_list_if(COMPILER_RT_HAS_WD4221_FLAG /wd4221 EXTRA_FLAGS) +append_list_if(CXX_SUPPORTS_WD4221_FLAG /wd4221 EXTRA_FLAGS) # Disable 'nonstandard extension used: translation unit is empty'. -append_list_if(COMPILER_RT_HAS_WD4206_FLAG /wd4206 EXTRA_FLAGS) +append_list_if(CXX_SUPPORTS_WD4206_FLAG /wd4206 EXTRA_FLAGS) if(APPLE) add_compiler_rt_runtime(clang_rt.profile diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt --- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt @@ -210,13 +210,13 @@ set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format SANITIZER_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format SANITIZER_CFLAGS) append_rtti_flag(OFF SANITIZER_CFLAGS) append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570 SANITIZER_CFLAGS) -append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors +append_list_if(CXX_SUPPORTS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors SANITIZER_CFLAGS) if(APPLE) diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt --- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt @@ -15,14 +15,14 @@ # Remove -stdlib= which is unused when passing -nostdinc++. string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SCUDO_CFLAGS) +append_list_if(CXX_SUPPORTS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SCUDO_CFLAGS) -append_list_if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions SCUDO_CFLAGS) +append_list_if(CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG -fno-exceptions SCUDO_CFLAGS) -append_list_if(COMPILER_RT_HAS_WNO_PEDANTIC -Wno-pedantic SCUDO_CFLAGS) +append_list_if(C_SUPPORTS_WNO_PEDANTIC_FLAG -Wno-pedantic SCUDO_CFLAGS) # FIXME: find cleaner way to agree with GWPAsan flags -append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SCUDO_CFLAGS) +append_list_if(C_SUPPORTS_FNO_LTO_FLAG -fno-lto SCUDO_CFLAGS) if(COMPILER_RT_DEBUG) list(APPEND SCUDO_CFLAGS -O0 -DSCUDO_DEBUG=1) @@ -37,7 +37,7 @@ list(APPEND SCUDO_LINK_FLAGS -ffunction-sections -fdata-sections -Wl,--gc-sections) # We don't use the C++ standard library, so avoid including it by mistake. -append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SCUDO_LINK_FLAGS) +append_list_if(CXX_SUPPORTS_NOSTDLIBXX_FLAG -nostdlib++ SCUDO_LINK_FLAGS) append_list_if(CXX_SUPPORTS_UNWINDLIB_NONE_FLAG --unwindlib=none SCUDO_LINK_FLAGS) if(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH) @@ -108,15 +108,15 @@ # Enable the necessary instruction set for scudo_crc32.cpp, if available. # Newer compiler versions use -mcrc32 rather than -msse4.2. -if (COMPILER_RT_HAS_MCRC32_FLAG) +if (CXX_SUPPORTS_MCRC32_FLAG) set_source_files_properties(crc32_hw.cpp PROPERTIES COMPILE_FLAGS -mcrc32) -elseif (COMPILER_RT_HAS_MSSE4_2_FLAG) +elseif (CXX_SUPPORTS_MSSE4_2_FLAG) set_source_files_properties(crc32_hw.cpp PROPERTIES COMPILE_FLAGS -msse4.2) endif() # Enable the AArch64 CRC32 feature for crc32_hw.cpp, if available. # Note that it is enabled by default starting with armv8.1-a. -if (COMPILER_RT_HAS_MCRC_FLAG) +if (CXX_SUPPORTS_MCRC_FLAG) set_source_files_properties(crc32_hw.cpp PROPERTIES COMPILE_FLAGS -mcrc) endif() @@ -136,7 +136,7 @@ RTGwpAsan RTGwpAsanBacktraceLibc RTGwpAsanSegvHandler RTGwpAsanOptionsParser) - append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer + append_list_if(C_SUPPORTS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer SCUDO_CFLAGS) list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS) diff --git a/compiler-rt/lib/tsan/CMakeLists.txt b/compiler-rt/lib/tsan/CMakeLists.txt --- a/compiler-rt/lib/tsan/CMakeLists.txt +++ b/compiler-rt/lib/tsan/CMakeLists.txt @@ -5,7 +5,7 @@ # TSan runtime to be built with -fPIE to reduce the number of register spills. # On FreeBSD however it provokes linkage issue thus we disable it. if(NOT CMAKE_SYSTEM MATCHES "FreeBSD") - append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TSAN_CFLAGS) + append_list_if(C_SUPPORTS_FPIE_FLAG -fPIE TSAN_CFLAGS) endif() append_rtti_flag(OFF TSAN_CFLAGS) diff --git a/compiler-rt/lib/tsan/rtl/CMakeLists.txt b/compiler-rt/lib/tsan/rtl/CMakeLists.txt --- a/compiler-rt/lib/tsan/rtl/CMakeLists.txt +++ b/compiler-rt/lib/tsan/rtl/CMakeLists.txt @@ -1,10 +1,10 @@ include_directories(../..) set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS}) -append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 TSAN_RTL_CFLAGS) +append_list_if(CXX_SUPPORTS_MSSE4_2_FLAG -msse4.2 TSAN_RTL_CFLAGS) append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530 TSAN_RTL_CFLAGS) -append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors +append_list_if(CXX_SUPPORTS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors TSAN_RTL_CFLAGS) append_list_if(COMPILER_RT_INTERCEPT_LIBDISPATCH ${COMPILER_RT_LIBDISPATCH_CFLAGS} TSAN_RTL_CFLAGS) diff --git a/compiler-rt/lib/tsan/tests/CMakeLists.txt b/compiler-rt/lib/tsan/tests/CMakeLists.txt --- a/compiler-rt/lib/tsan/tests/CMakeLists.txt +++ b/compiler-rt/lib/tsan/tests/CMakeLists.txt @@ -21,7 +21,7 @@ -DTSAN_DEBUG_OUTPUT=2) endif() -append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 TSAN_UNITTEST_CFLAGS) +append_list_if(CXX_SUPPORTS_MSSE4_2_FLAG -msse4.2 TSAN_UNITTEST_CFLAGS) set(TSAN_TEST_ARCH ${TSAN_SUPPORTED_ARCH}) diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt --- a/compiler-rt/lib/ubsan/CMakeLists.txt +++ b/compiler-rt/lib/ubsan/CMakeLists.txt @@ -45,7 +45,7 @@ append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CFLAGS) # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format UBSAN_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format UBSAN_CFLAGS) set(UBSAN_STANDALONE_CFLAGS ${SANITIZER_COMMON_CFLAGS}) append_rtti_flag(OFF UBSAN_STANDALONE_CFLAGS) @@ -57,7 +57,7 @@ # Silence warnings in system headers with MSVC. if(NOT CLANG_CL) - append_list_if(COMPILER_RT_HAS_EXTERNAL_FLAG "/experimental:external /external:W0 /external:anglebrackets" UBSAN_CXXFLAGS) + append_list_if(CXX_SUPPORTS_EXTERNAL_FLAG "/experimental:external /external:W0 /external:anglebrackets" UBSAN_CXXFLAGS) endif() set(UBSAN_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) diff --git a/compiler-rt/lib/xray/CMakeLists.txt b/compiler-rt/lib/xray/CMakeLists.txt --- a/compiler-rt/lib/xray/CMakeLists.txt +++ b/compiler-rt/lib/xray/CMakeLists.txt @@ -144,7 +144,7 @@ set(XRAY_COMMON_DEFINITIONS XRAY_HAS_EXCEPTIONS=1) # Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format XRAY_CFLAGS) +append_list_if(C_SUPPORTS_WNO_FORMAT_FLAG -Wno-format XRAY_CFLAGS) # We don't need RTTI in XRay, so turn that off. append_rtti_flag(OFF XRAY_CFLAGS) @@ -155,7 +155,7 @@ ${COMPILER_RT_CXX_LINK_LIBS}) append_list_if( - COMPILER_RT_HAS_XRAY_COMPILER_FLAG XRAY_SUPPORTED=1 XRAY_COMMON_DEFINITIONS) + C_SUPPORTS_XRAY_COMPILER_FLAG XRAY_SUPPORTED=1 XRAY_COMMON_DEFINITIONS) append_list_if( COMPILER_RT_BUILD_XRAY_NO_PREINIT XRAY_NO_PREINIT XRAY_COMMON_DEFINITIONS) diff --git a/compiler-rt/test/builtins/CMakeLists.txt b/compiler-rt/test/builtins/CMakeLists.txt --- a/compiler-rt/test/builtins/CMakeLists.txt +++ b/compiler-rt/test/builtins/CMakeLists.txt @@ -61,7 +61,7 @@ if(NOT arch MATCHES "i?86|x86_64|AMD64") message(SEND_ERROR "${arch} does not support CET") endif() - if(COMPILER_RT_HAS_FCF_PROTECTION_FLAG) + if(C_SUPPORTS_FCF_PROTECTION_FLAG) list(APPEND BUILTINS_TEST_TARGET_CFLAGS -fcf-protection=full) string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}") endif() diff --git a/compiler-rt/test/tsan/CMakeLists.txt b/compiler-rt/test/tsan/CMakeLists.txt --- a/compiler-rt/test/tsan/CMakeLists.txt +++ b/compiler-rt/test/tsan/CMakeLists.txt @@ -41,7 +41,7 @@ string(REPLACE ";" " " LIBDISPATCH_CFLAGS_STRING " ${COMPILER_RT_TEST_LIBDISPATCH_CFLAGS}") string(APPEND TSAN_TEST_TARGET_CFLAGS ${LIBDISPATCH_CFLAGS_STRING}) - if (COMPILER_RT_HAS_MSSE4_2_FLAG) + if (CXX_SUPPORTS_MSSE4_2_FLAG) string(APPEND TSAN_TEST_TARGET_CFLAGS " -msse4.2 ") endif()