1include(CMakePushCheckState) 2include(CheckCXXCompilerFlag) 3include(CheckLibraryExists) 4include(CheckSymbolExists) 5include(TestBigEndian) 6 7function(check_linker_flag flag out_var) 8 cmake_push_check_state() 9 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") 10 check_cxx_compiler_flag("" ${out_var}) 11 cmake_pop_check_state() 12endfunction() 13 14# CodeGen options. 15check_cxx_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG) 16check_cxx_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG) 17check_cxx_compiler_flag(-fno-builtin COMPILER_RT_HAS_FNO_BUILTIN_FLAG) 18check_cxx_compiler_flag(-fno-exceptions COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG) 19check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG) 20check_cxx_compiler_flag(-funwind-tables COMPILER_RT_HAS_FUNWIND_TABLES_FLAG) 21check_cxx_compiler_flag(-fno-stack-protector COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG) 22check_cxx_compiler_flag(-fno-sanitize=safe-stack COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG) 23check_cxx_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG) 24check_cxx_compiler_flag(-frtti COMPILER_RT_HAS_FRTTI_FLAG) 25check_cxx_compiler_flag(-fno-rtti COMPILER_RT_HAS_FNO_RTTI_FLAG) 26check_cxx_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG) 27check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG) 28check_cxx_compiler_flag(-std=c++11 COMPILER_RT_HAS_STD_CXX11_FLAG) 29check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC) 30check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG) 31check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG) 32check_cxx_compiler_flag(--sysroot=. COMPILER_RT_HAS_SYSROOT_FLAG) 33 34if(NOT WIN32 AND NOT CYGWIN) 35 # MinGW warns if -fvisibility-inlines-hidden is used. 36 check_cxx_compiler_flag("-fvisibility-inlines-hidden" COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG) 37endif() 38 39check_cxx_compiler_flag(/GR COMPILER_RT_HAS_GR_FLAG) 40check_cxx_compiler_flag(/GS COMPILER_RT_HAS_GS_FLAG) 41check_cxx_compiler_flag(/MT COMPILER_RT_HAS_MT_FLAG) 42check_cxx_compiler_flag(/Oy COMPILER_RT_HAS_Oy_FLAG) 43 44# Debug info flags. 45check_cxx_compiler_flag(-gline-tables-only COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG) 46check_cxx_compiler_flag(-g COMPILER_RT_HAS_G_FLAG) 47check_cxx_compiler_flag(/Zi COMPILER_RT_HAS_Zi_FLAG) 48 49# Warnings. 50check_cxx_compiler_flag(-Wall COMPILER_RT_HAS_WALL_FLAG) 51check_cxx_compiler_flag(-Werror COMPILER_RT_HAS_WERROR_FLAG) 52check_cxx_compiler_flag("-Werror -Wframe-larger-than=512" COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG) 53check_cxx_compiler_flag("-Werror -Wglobal-constructors" COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG) 54check_cxx_compiler_flag("-Werror -Wc99-extensions" COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG) 55check_cxx_compiler_flag("-Werror -Wgnu" COMPILER_RT_HAS_WGNU_FLAG) 56check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG) 57check_cxx_compiler_flag("-Werror -Wvariadic-macros" COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG) 58check_cxx_compiler_flag("-Werror -Wunused-parameter" COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG) 59 60check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG) 61check_cxx_compiler_flag(/WX COMPILER_RT_HAS_WX_FLAG) 62check_cxx_compiler_flag(/wd4146 COMPILER_RT_HAS_WD4146_FLAG) 63check_cxx_compiler_flag(/wd4291 COMPILER_RT_HAS_WD4291_FLAG) 64check_cxx_compiler_flag(/wd4221 COMPILER_RT_HAS_WD4221_FLAG) 65check_cxx_compiler_flag(/wd4391 COMPILER_RT_HAS_WD4391_FLAG) 66check_cxx_compiler_flag(/wd4722 COMPILER_RT_HAS_WD4722_FLAG) 67check_cxx_compiler_flag(/wd4800 COMPILER_RT_HAS_WD4800_FLAG) 68 69# Symbols. 70check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL) 71 72# Libraries. 73check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC) 74check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL) 75check_library_exists(rt shm_open "" COMPILER_RT_HAS_LIBRT) 76check_library_exists(m pow "" COMPILER_RT_HAS_LIBM) 77check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD) 78check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX) 79 80# Linker flags. 81if(ANDROID) 82 check_linker_flag("-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL) 83 check_library_exists(log __android_log_write "" COMPILER_RT_HAS_LIBLOG) 84endif() 85 86# Architectures. 87 88# List of all architectures we can target. 89set(COMPILER_RT_SUPPORTED_ARCH) 90 91# Try to compile a very simple source file to ensure we can target the given 92# platform. We use the results of these tests to build only the various target 93# runtime libraries supported by our current compilers cross-compiling 94# abilities. 95set(SIMPLE_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/simple.cc) 96file(WRITE ${SIMPLE_SOURCE} "#include <stdlib.h>\n#include <limits>\nint main() {}\n") 97 98# Add $arch as supported with no additional flags. 99macro(add_default_target_arch arch) 100 set(TARGET_${arch}_CFLAGS "") 101 set(CAN_TARGET_${arch} 1) 102 list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) 103endmacro() 104 105# Detect whether the current target platform is 32-bit or 64-bit, and setup 106# the correct commandline flags needed to attempt to target 32-bit and 64-bit. 107if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4 AND 108 NOT CMAKE_SIZEOF_VOID_P EQUAL 8) 109 message(FATAL_ERROR "Please use architecture with 4 or 8 byte pointers.") 110endif() 111 112test_targets() 113 114# Returns a list of architecture specific target cflags in @out_var list. 115function(get_target_flags_for_arch arch out_var) 116 list(FIND COMPILER_RT_SUPPORTED_ARCH ${arch} ARCH_INDEX) 117 if(ARCH_INDEX EQUAL -1) 118 message(FATAL_ERROR "Unsupported architecture: ${arch}") 119 else() 120 if (NOT APPLE) 121 set(${out_var} ${TARGET_${arch}_CFLAGS} PARENT_SCOPE) 122 else() 123 # This is only called in constructing cflags for tests executing on the 124 # host. This will need to all be cleaned up to support building tests 125 # for cross-targeted hardware (i.e. iOS). 126 set(${out_var} -arch ${arch} PARENT_SCOPE) 127 endif() 128 endif() 129endfunction() 130 131set(ARM64 aarch64) 132set(ARM32 arm armhf) 133set(X86 i386 i686) 134set(X86_64 x86_64) 135set(MIPS32 mips mipsel) 136set(MIPS64 mips64 mips64el) 137set(PPC64 powerpc64 powerpc64le) 138set(S390X s390x) 139set(WASM32 wasm32) 140set(WASM64 wasm64) 141 142if(APPLE) 143 set(ARM64 arm64) 144 set(ARM32 armv7 armv7s armv7k) 145 set(X86_64 x86_64 x86_64h) 146endif() 147 148set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} 149 ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X}) 150set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} 151 ${MIPS32} ${MIPS64} ${PPC64}) 152set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64}) 153set(ALL_LSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64}) 154set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64}) 155set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC64} 156 ${MIPS32} ${MIPS64}) 157set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64}) 158set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} 159 ${MIPS32} ${MIPS64} ${PPC64} ${S390X}) 160set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${MIPS32} ${MIPS64}) 161set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64}) 162set(ALL_ESAN_SUPPORTED_ARCH ${X86_64}) 163set(ALL_SCUDO_SUPPORTED_ARCH ${X86_64}) 164 165if(APPLE) 166 include(CompilerRTDarwinUtils) 167 168 find_darwin_sdk_dir(DARWIN_osx_SYSROOT macosx) 169 find_darwin_sdk_dir(DARWIN_iossim_SYSROOT iphonesimulator) 170 find_darwin_sdk_dir(DARWIN_ios_SYSROOT iphoneos) 171 find_darwin_sdk_dir(DARWIN_watchossim_SYSROOT watchsimulator) 172 find_darwin_sdk_dir(DARWIN_watchos_SYSROOT watchos) 173 find_darwin_sdk_dir(DARWIN_tvossim_SYSROOT appletvsimulator) 174 find_darwin_sdk_dir(DARWIN_tvos_SYSROOT appletvos) 175 176 if(COMPILER_RT_ENABLE_IOS) 177 list(APPEND DARWIN_EMBEDDED_PLATFORMS ios) 178 set(DARWIN_ios_MIN_VER_FLAG -miphoneos-version-min) 179 set(DARWIN_ios_SANITIZER_MIN_VER_FLAG 180 ${DARWIN_ios_MIN_VER_FLAG}=7.0) 181 endif() 182 if(COMPILER_RT_ENABLE_WATCHOS) 183 list(APPEND DARWIN_EMBEDDED_PLATFORMS watchos) 184 set(DARWIN_watchos_MIN_VER_FLAG -mwatchos-version-min) 185 set(DARWIN_watchos_SANITIZER_MIN_VER_FLAG 186 ${DARWIN_watchos_MIN_VER_FLAG}=2.0) 187 endif() 188 if(COMPILER_RT_ENABLE_TVOS) 189 list(APPEND DARWIN_EMBEDDED_PLATFORMS tvos) 190 set(DARWIN_tvos_MIN_VER_FLAG -mtvos-version-min) 191 set(DARWIN_tvos_SANITIZER_MIN_VER_FLAG 192 ${DARWIN_tvos_MIN_VER_FLAG}=9.0) 193 endif() 194 195 # Note: In order to target x86_64h on OS X the minimum deployment target must 196 # be 10.8 or higher. 197 set(SANITIZER_COMMON_SUPPORTED_OS osx) 198 set(PROFILE_SUPPORTED_OS osx) 199 set(TSAN_SUPPORTED_OS osx) 200 if(NOT SANITIZER_MIN_OSX_VERSION) 201 string(REGEX MATCH "-mmacosx-version-min=([.0-9]+)" 202 MACOSX_VERSION_MIN_FLAG "${CMAKE_CXX_FLAGS}") 203 if(MACOSX_VERSION_MIN_FLAG) 204 set(SANITIZER_MIN_OSX_VERSION "${CMAKE_MATCH_1}") 205 elseif(CMAKE_OSX_DEPLOYMENT_TARGET) 206 set(SANITIZER_MIN_OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET}) 207 else() 208 set(SANITIZER_MIN_OSX_VERSION 10.9) 209 endif() 210 if(SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.7") 211 message(FATAL_ERROR "Too old OS X version: ${SANITIZER_MIN_OSX_VERSION}") 212 endif() 213 endif() 214 215 # We're setting the flag manually for each target OS 216 set(CMAKE_OSX_DEPLOYMENT_TARGET "") 217 218 set(DARWIN_COMMON_CFLAGS -stdlib=libc++) 219 set(DARWIN_COMMON_LINKFLAGS 220 -stdlib=libc++ 221 -lc++ 222 -lc++abi) 223 224 check_linker_flag("-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION) 225 if(COMPILER_RT_HAS_APP_EXTENSION) 226 list(APPEND DARWIN_COMMON_LINKFLAGS "-fapplication-extension") 227 endif() 228 229 set(DARWIN_osx_CFLAGS 230 ${DARWIN_COMMON_CFLAGS} 231 -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}) 232 set(DARWIN_osx_LINKFLAGS 233 ${DARWIN_COMMON_LINKFLAGS} 234 -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}) 235 236 if(DARWIN_osx_SYSROOT) 237 list(APPEND DARWIN_osx_CFLAGS -isysroot ${DARWIN_osx_SYSROOT}) 238 list(APPEND DARWIN_osx_LINKFLAGS -isysroot ${DARWIN_osx_SYSROOT}) 239 endif() 240 241 # Figure out which arches to use for each OS 242 darwin_get_toolchain_supported_archs(toolchain_arches) 243 message(STATUS "Toolchain supported arches: ${toolchain_arches}") 244 245 if(NOT MACOSX_VERSION_MIN_FLAG) 246 darwin_test_archs(osx 247 DARWIN_osx_ARCHS 248 ${toolchain_arches}) 249 message(STATUS "OSX supported arches: ${DARWIN_osx_ARCHS}") 250 foreach(arch ${DARWIN_osx_ARCHS}) 251 list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) 252 set(CAN_TARGET_${arch} 1) 253 endforeach() 254 255 foreach(platform ${DARWIN_EMBEDDED_PLATFORMS}) 256 if(DARWIN_${platform}sim_SYSROOT) 257 set(DARWIN_${platform}sim_CFLAGS 258 ${DARWIN_COMMON_CFLAGS} 259 ${DARWIN_${platform}_SANITIZER_MIN_VER_FLAG} 260 -isysroot ${DARWIN_${platform}sim_SYSROOT}) 261 set(DARWIN_${platform}sim_LINKFLAGS 262 ${DARWIN_COMMON_LINKFLAGS} 263 ${DARWIN_${platform}_SANITIZER_MIN_VER_FLAG} 264 -isysroot ${DARWIN_${platform}sim_SYSROOT}) 265 266 set(DARWIN_${platform}sim_SKIP_CC_KEXT On) 267 darwin_test_archs(${platform}sim 268 DARWIN_${platform}sim_ARCHS 269 ${toolchain_arches}) 270 message(STATUS "${platform} Simulator supported arches: ${DARWIN_${platform}sim_ARCHS}") 271 if(DARWIN_${platform}_ARCHS) 272 list(APPEND SANITIZER_COMMON_SUPPORTED_OS ${platform}sim) 273 list(APPEND PROFILE_SUPPORTED_OS ${platform}sim) 274 if(DARWIN_${platform}_SYSROOT_INTERNAL) 275 list(APPEND TSAN_SUPPORTED_OS ${platform}sim) 276 endif() 277 endif() 278 foreach(arch ${DARWIN_${platform}sim_ARCHS}) 279 list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) 280 set(CAN_TARGET_${arch} 1) 281 endforeach() 282 endif() 283 284 if(DARWIN_${platform}_SYSROOT) 285 set(DARWIN_${platform}_CFLAGS 286 ${DARWIN_COMMON_CFLAGS} 287 ${DARWIN_${platform}_SANITIZER_MIN_VER_FLAG} 288 -isysroot ${DARWIN_${platform}_SYSROOT}) 289 set(DARWIN_${platform}_LINKFLAGS 290 ${DARWIN_COMMON_LINKFLAGS} 291 ${DARWIN_${platform}_SANITIZER_MIN_VER_FLAG} 292 -isysroot ${DARWIN_${platform}_SYSROOT}) 293 294 darwin_test_archs(${platform} 295 DARWIN_${platform}_ARCHS 296 ${toolchain_arches}) 297 message(STATUS "${platform} supported arches: ${DARWIN_${platform}_ARCHS}") 298 if(DARWIN_${platform}_ARCHS) 299 list(APPEND SANITIZER_COMMON_SUPPORTED_OS ${platform}) 300 list(APPEND PROFILE_SUPPORTED_OS ${platform}) 301 endif() 302 foreach(arch ${DARWIN_${platform}_ARCHS}) 303 list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) 304 set(CAN_TARGET_${arch} 1) 305 endforeach() 306 endif() 307 endforeach() 308 endif() 309 310 # for list_intersect 311 include(CompilerRTUtils) 312 313 314 list_intersect(SANITIZER_COMMON_SUPPORTED_ARCH 315 ALL_SANITIZER_COMMON_SUPPORTED_ARCH 316 COMPILER_RT_SUPPORTED_ARCH 317 ) 318 set(LSAN_COMMON_SUPPORTED_ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}) 319 set(UBSAN_COMMON_SUPPORTED_ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}) 320 list_intersect(ASAN_SUPPORTED_ARCH 321 ALL_ASAN_SUPPORTED_ARCH 322 SANITIZER_COMMON_SUPPORTED_ARCH) 323 list_intersect(DFSAN_SUPPORTED_ARCH 324 ALL_DFSAN_SUPPORTED_ARCH 325 SANITIZER_COMMON_SUPPORTED_ARCH) 326 list_intersect(LSAN_SUPPORTED_ARCH 327 ALL_LSAN_SUPPORTED_ARCH 328 SANITIZER_COMMON_SUPPORTED_ARCH) 329 list_intersect(MSAN_SUPPORTED_ARCH 330 ALL_MSAN_SUPPORTED_ARCH 331 SANITIZER_COMMON_SUPPORTED_ARCH) 332 list_intersect(PROFILE_SUPPORTED_ARCH 333 ALL_PROFILE_SUPPORTED_ARCH 334 SANITIZER_COMMON_SUPPORTED_ARCH) 335 list_intersect(TSAN_SUPPORTED_ARCH 336 ALL_TSAN_SUPPORTED_ARCH 337 SANITIZER_COMMON_SUPPORTED_ARCH) 338 list_intersect(UBSAN_SUPPORTED_ARCH 339 ALL_UBSAN_SUPPORTED_ARCH 340 SANITIZER_COMMON_SUPPORTED_ARCH) 341 list_intersect(SAFESTACK_SUPPORTED_ARCH 342 ALL_SAFESTACK_SUPPORTED_ARCH 343 SANITIZER_COMMON_SUPPORTED_ARCH) 344 list_intersect(CFI_SUPPORTED_ARCH 345 ALL_CFI_SUPPORTED_ARCH 346 SANITIZER_COMMON_SUPPORTED_ARCH) 347 list_intersect(ESAN_SUPPORTED_ARCH 348 ALL_ESAN_SUPPORTED_ARCH 349 SANITIZER_COMMON_SUPPORTED_ARCH) 350 list_intersect(SCUDO_SUPPORTED_ARCH 351 ALL_SCUDO_SUPPORTED_ARCH 352 SANITIZER_COMMON_SUPPORTED_ARCH) 353else() 354 # Architectures supported by compiler-rt libraries. 355 filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH 356 ${ALL_SANITIZER_COMMON_SUPPORTED_ARCH}) 357 # LSan and UBSan common files should be available on all architectures 358 # supported by other sanitizers (even if they build into dummy object files). 359 filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH 360 ${SANITIZER_COMMON_SUPPORTED_ARCH}) 361 filter_available_targets(UBSAN_COMMON_SUPPORTED_ARCH 362 ${SANITIZER_COMMON_SUPPORTED_ARCH}) 363 filter_available_targets(ASAN_SUPPORTED_ARCH ${ALL_ASAN_SUPPORTED_ARCH}) 364 filter_available_targets(DFSAN_SUPPORTED_ARCH ${ALL_DFSAN_SUPPORTED_ARCH}) 365 filter_available_targets(LSAN_SUPPORTED_ARCH ${ALL_LSAN_SUPPORTED_ARCH}) 366 filter_available_targets(MSAN_SUPPORTED_ARCH ${ALL_MSAN_SUPPORTED_ARCH}) 367 filter_available_targets(PROFILE_SUPPORTED_ARCH ${ALL_PROFILE_SUPPORTED_ARCH}) 368 filter_available_targets(TSAN_SUPPORTED_ARCH ${ALL_TSAN_SUPPORTED_ARCH}) 369 filter_available_targets(UBSAN_SUPPORTED_ARCH ${ALL_UBSAN_SUPPORTED_ARCH}) 370 filter_available_targets(SAFESTACK_SUPPORTED_ARCH 371 ${ALL_SAFESTACK_SUPPORTED_ARCH}) 372 filter_available_targets(CFI_SUPPORTED_ARCH ${ALL_CFI_SUPPORTED_ARCH}) 373 filter_available_targets(ESAN_SUPPORTED_ARCH ${ALL_ESAN_SUPPORTED_ARCH}) 374 filter_available_targets(SCUDO_SUPPORTED_ARCH 375 ${ALL_SCUDO_SUPPORTED_ARCH}) 376endif() 377 378if (MSVC) 379 # See if the DIA SDK is available and usable. 380 set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK") 381 if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR}) 382 set(CAN_SYMBOLIZE 1) 383 else() 384 set(CAN_SYMBOLIZE 0) 385 endif() 386else() 387 set(CAN_SYMBOLIZE 1) 388endif() 389 390message(STATUS "Compiler-RT supported architectures: ${COMPILER_RT_SUPPORTED_ARCH}") 391 392if(ANDROID) 393 set(OS_NAME "Android") 394else() 395 set(OS_NAME "${CMAKE_SYSTEM_NAME}") 396endif() 397 398if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND 399 (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR 400 (OS_NAME MATCHES "Windows" AND MSVC))) 401 set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE) 402else() 403 set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE) 404endif() 405 406if (COMPILER_RT_HAS_SANITIZER_COMMON) 407 set(COMPILER_RT_HAS_INTERCEPTION TRUE) 408else() 409 set(COMPILER_RT_HAS_INTERCEPTION FALSE) 410endif() 411 412if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH) 413 set(COMPILER_RT_HAS_ASAN TRUE) 414else() 415 set(COMPILER_RT_HAS_ASAN FALSE) 416endif() 417 418if (OS_NAME MATCHES "Linux|FreeBSD|Windows") 419 set(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME TRUE) 420else() 421 set(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME FALSE) 422endif() 423 424# TODO: Add builtins support. 425 426if (COMPILER_RT_HAS_SANITIZER_COMMON AND DFSAN_SUPPORTED_ARCH AND 427 OS_NAME MATCHES "Linux") 428 set(COMPILER_RT_HAS_DFSAN TRUE) 429else() 430 set(COMPILER_RT_HAS_DFSAN FALSE) 431endif() 432 433if (COMPILER_RT_HAS_SANITIZER_COMMON AND LSAN_SUPPORTED_ARCH AND 434 OS_NAME MATCHES "Linux|FreeBSD") 435 set(COMPILER_RT_HAS_LSAN TRUE) 436else() 437 set(COMPILER_RT_HAS_LSAN FALSE) 438endif() 439 440if (COMPILER_RT_HAS_SANITIZER_COMMON AND MSAN_SUPPORTED_ARCH AND 441 OS_NAME MATCHES "Linux") 442 set(COMPILER_RT_HAS_MSAN TRUE) 443else() 444 set(COMPILER_RT_HAS_MSAN FALSE) 445endif() 446 447if (PROFILE_SUPPORTED_ARCH AND 448 OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows") 449 set(COMPILER_RT_HAS_PROFILE TRUE) 450else() 451 set(COMPILER_RT_HAS_PROFILE FALSE) 452endif() 453 454if (COMPILER_RT_HAS_SANITIZER_COMMON AND TSAN_SUPPORTED_ARCH AND 455 OS_NAME MATCHES "Darwin|Linux|FreeBSD") 456 set(COMPILER_RT_HAS_TSAN TRUE) 457else() 458 set(COMPILER_RT_HAS_TSAN FALSE) 459endif() 460 461if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND 462 OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows") 463 set(COMPILER_RT_HAS_UBSAN TRUE) 464else() 465 set(COMPILER_RT_HAS_UBSAN FALSE) 466endif() 467 468if (COMPILER_RT_HAS_SANITIZER_COMMON AND SAFESTACK_SUPPORTED_ARCH AND 469 OS_NAME MATCHES "Darwin|Linux|FreeBSD") 470 set(COMPILER_RT_HAS_SAFESTACK TRUE) 471else() 472 set(COMPILER_RT_HAS_SAFESTACK FALSE) 473endif() 474 475if (COMPILER_RT_HAS_SANITIZER_COMMON AND CFI_SUPPORTED_ARCH AND 476 OS_NAME MATCHES "Linux") 477 set(COMPILER_RT_HAS_CFI TRUE) 478else() 479 set(COMPILER_RT_HAS_CFI FALSE) 480endif() 481 482if (COMPILER_RT_HAS_SANITIZER_COMMON AND ESAN_SUPPORTED_ARCH AND 483 OS_NAME MATCHES "Linux") 484 set(COMPILER_RT_HAS_ESAN TRUE) 485else() 486 set(COMPILER_RT_HAS_ESAN FALSE) 487endif() 488 489if (COMPILER_RT_HAS_SANITIZER_COMMON AND SCUDO_SUPPORTED_ARCH AND 490 OS_NAME MATCHES "Linux") 491 set(COMPILER_RT_HAS_SCUDO TRUE) 492else() 493 set(COMPILER_RT_HAS_SCUDO FALSE) 494endif() 495 496