Chris Bieneman | 18929dd | 2016-05-09 21:45:52 +0000 | [diff] [blame] | 1 | include(BuiltinTests) |
Chris Bieneman | 8a22938 | 2016-08-12 01:29:26 +0000 | [diff] [blame] | 2 | include(CheckCSourceCompiles) |
Chris Bieneman | 18929dd | 2016-05-09 21:45:52 +0000 | [diff] [blame] | 3 | |
| 4 | # Make all the tests only check the compiler |
| 5 | set(TEST_COMPILE_ONLY On) |
Chris Bieneman | 18929dd | 2016-05-09 21:45:52 +0000 | [diff] [blame] | 6 | |
| 7 | builtin_check_c_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG) |
| 8 | builtin_check_c_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG) |
| 9 | builtin_check_c_compiler_flag(-fno-builtin COMPILER_RT_HAS_FNO_BUILTIN_FLAG) |
| 10 | builtin_check_c_compiler_flag(-std=c99 COMPILER_RT_HAS_STD_C99_FLAG) |
| 11 | builtin_check_c_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG) |
| 12 | builtin_check_c_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG) |
| 13 | builtin_check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FREESTANDING_FLAG) |
| 14 | builtin_check_c_compiler_flag(-mfloat-abi=soft COMPILER_RT_HAS_FLOAT_ABI_SOFT_FLAG) |
| 15 | builtin_check_c_compiler_flag(-mfloat-abi=hard COMPILER_RT_HAS_FLOAT_ABI_HARD_FLAG) |
| 16 | builtin_check_c_compiler_flag(-static COMPILER_RT_HAS_STATIC_FLAG) |
| 17 | |
Chris Bieneman | a00b213 | 2016-08-15 20:12:43 +0000 | [diff] [blame^] | 18 | builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD |
Chris Bieneman | 8a22938 | 2016-08-12 01:29:26 +0000 | [diff] [blame] | 19 | " |
| 20 | int foo(int x, int y) { |
| 21 | _Atomic int result = x * y; |
| 22 | return result; |
| 23 | } |
| 24 | ") |
| 25 | |
| 26 | |
Chris Bieneman | 18929dd | 2016-05-09 21:45:52 +0000 | [diff] [blame] | 27 | set(ARM64 aarch64) |
| 28 | set(ARM32 arm armhf) |
| 29 | set(X86 i386 i686) |
| 30 | set(X86_64 x86_64) |
| 31 | set(MIPS32 mips mipsel) |
| 32 | set(MIPS64 mips64 mips64el) |
| 33 | set(PPC64 powerpc64 powerpc64le) |
| 34 | set(WASM32 wasm32) |
| 35 | set(WASM64 wasm64) |
| 36 | |
| 37 | if(APPLE) |
| 38 | set(ARM64 arm64) |
| 39 | set(ARM32 armv7 armv7k armv7s) |
| 40 | set(X86_64 x86_64 x86_64h) |
| 41 | endif() |
| 42 | |
| 43 | set(ALL_BUILTIN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} |
| 44 | ${MIPS32} ${MIPS64} ${WASM32} ${WASM64}) |
| 45 | |
| 46 | include(CompilerRTUtils) |
| 47 | include(CompilerRTDarwinUtils) |
| 48 | |
| 49 | if(APPLE) |
| 50 | |
| 51 | find_darwin_sdk_dir(DARWIN_osx_SYSROOT macosx) |
| 52 | find_darwin_sdk_dir(DARWIN_iossim_SYSROOT iphonesimulator) |
| 53 | find_darwin_sdk_dir(DARWIN_ios_SYSROOT iphoneos) |
| 54 | find_darwin_sdk_dir(DARWIN_watchossim_SYSROOT watchsimulator) |
| 55 | find_darwin_sdk_dir(DARWIN_watchos_SYSROOT watchos) |
| 56 | find_darwin_sdk_dir(DARWIN_tvossim_SYSROOT appletvsimulator) |
| 57 | find_darwin_sdk_dir(DARWIN_tvos_SYSROOT appletvos) |
| 58 | |
| 59 | set(DARWIN_EMBEDDED_PLATFORMS) |
| 60 | set(DARWIN_osx_BUILTIN_MIN_VER 10.5) |
| 61 | set(DARWIN_osx_BUILTIN_MIN_VER_FLAG |
| 62 | -mmacosx-version-min=${DARWIN_osx_BUILTIN_MIN_VER}) |
| 63 | |
| 64 | if(COMPILER_RT_ENABLE_IOS) |
| 65 | list(APPEND DARWIN_EMBEDDED_PLATFORMS ios) |
| 66 | set(DARWIN_ios_MIN_VER_FLAG -miphoneos-version-min) |
| 67 | set(DARWIN_ios_BUILTIN_MIN_VER 6.0) |
| 68 | set(DARWIN_ios_BUILTIN_MIN_VER_FLAG |
| 69 | ${DARWIN_ios_MIN_VER_FLAG}=${DARWIN_ios_BUILTIN_MIN_VER}) |
| 70 | endif() |
| 71 | if(COMPILER_RT_ENABLE_WATCHOS) |
| 72 | list(APPEND DARWIN_EMBEDDED_PLATFORMS watchos) |
| 73 | set(DARWIN_watchos_MIN_VER_FLAG -mwatchos-version-min) |
| 74 | set(DARWIN_watchos_BUILTIN_MIN_VER 2.0) |
| 75 | set(DARWIN_watchos_BUILTIN_MIN_VER_FLAG |
| 76 | ${DARWIN_watchos_MIN_VER_FLAG}=${DARWIN_watchos_BUILTIN_MIN_VER}) |
| 77 | endif() |
| 78 | if(COMPILER_RT_ENABLE_TVOS) |
| 79 | list(APPEND DARWIN_EMBEDDED_PLATFORMS tvos) |
| 80 | set(DARWIN_tvos_MIN_VER_FLAG -mtvos-version-min) |
| 81 | set(DARWIN_tvos_BUILTIN_MIN_VER 9.0) |
| 82 | set(DARWIN_tvos_BUILTIN_MIN_VER_FLAG |
| 83 | ${DARWIN_tvos_MIN_VER_FLAG}=${DARWIN_tvos_BUILTIN_MIN_VER}) |
| 84 | endif() |
| 85 | |
| 86 | set(BUILTIN_SUPPORTED_OS osx) |
| 87 | |
| 88 | # We're setting the flag manually for each target OS |
| 89 | set(CMAKE_OSX_DEPLOYMENT_TARGET "") |
| 90 | |
| 91 | if(NOT DARWIN_osx_ARCHS) |
| 92 | set(DARWIN_osx_ARCHS i386 x86_64 x86_64h) |
| 93 | endif() |
| 94 | |
| 95 | set(DARWIN_sim_ARCHS i386 x86_64) |
| 96 | set(DARWIN_device_ARCHS armv7 armv7s armv7k arm64) |
| 97 | |
| 98 | message(STATUS "OSX supported arches: ${DARWIN_osx_ARCHS}") |
| 99 | foreach(arch ${DARWIN_osx_ARCHS}) |
| 100 | list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) |
| 101 | set(CAN_TARGET_${arch} 1) |
| 102 | endforeach() |
| 103 | |
| 104 | # Need to build a 10.4 compatible libclang_rt |
| 105 | set(DARWIN_10.4_SYSROOT ${DARWIN_osx_SYSROOT}) |
| 106 | set(DARWIN_10.4_BUILTIN_MIN_VER 10.4) |
| 107 | set(DARWIN_10.4_BUILTIN_MIN_VER_FLAG |
| 108 | -mmacosx-version-min=${DARWIN_10.4_BUILTIN_MIN_VER}) |
| 109 | set(DARWIN_10.4_SKIP_CC_KEXT On) |
| 110 | darwin_test_archs(10.4 DARWIN_10.4_ARCHS i386 x86_64) |
| 111 | message(STATUS "OSX 10.4 supported builtin arches: ${DARWIN_10.4_ARCHS}") |
| 112 | if(DARWIN_10.4_ARCHS) |
| 113 | # don't include the Haswell slice in the 10.4 compatibility library |
| 114 | list(REMOVE_ITEM DARWIN_10.4_ARCHS x86_64h) |
| 115 | list(APPEND BUILTIN_SUPPORTED_OS 10.4) |
| 116 | endif() |
| 117 | |
| 118 | foreach(platform ${DARWIN_EMBEDDED_PLATFORMS}) |
| 119 | if(DARWIN_${platform}sim_SYSROOT) |
| 120 | set(DARWIN_${platform}sim_BUILTIN_MIN_VER |
| 121 | ${DARWIN_${platform}_BUILTIN_MIN_VER}) |
| 122 | set(DARWIN_${platform}sim_BUILTIN_MIN_VER_FLAG |
| 123 | ${DARWIN_${platform}_BUILTIN_MIN_VER_FLAG}) |
| 124 | |
| 125 | set(DARWIN_${platform}sim_SKIP_CC_KEXT On) |
| 126 | |
| 127 | set(test_arches ${DARWIN_sim_ARCHS}) |
| 128 | if(DARWIN_${platform}sim_ARCHS) |
| 129 | set(test_arches DARWIN_${platform}sim_ARCHS) |
| 130 | endif() |
| 131 | |
| 132 | darwin_test_archs(${platform}sim |
| 133 | DARWIN_${platform}sim_ARCHS |
| 134 | ${test_arches}) |
| 135 | message(STATUS "${platform} Simulator supported builtin arches: ${DARWIN_${platform}sim_ARCHS}") |
| 136 | if(DARWIN_${platform}sim_ARCHS) |
| 137 | list(APPEND BUILTIN_SUPPORTED_OS ${platform}sim) |
| 138 | endif() |
| 139 | foreach(arch ${DARWIN_${platform}sim_ARCHS}) |
| 140 | list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) |
| 141 | set(CAN_TARGET_${arch} 1) |
| 142 | endforeach() |
| 143 | endif() |
| 144 | |
| 145 | if(DARWIN_${platform}_SYSROOT) |
| 146 | set(test_arches ${DARWIN_device_ARCHS}) |
| 147 | if(DARWIN_${platform}_ARCHS) |
| 148 | set(test_arches DARWIN_${platform}_ARCHS) |
| 149 | endif() |
| 150 | |
| 151 | darwin_test_archs(${platform} |
| 152 | DARWIN_${platform}_ARCHS |
| 153 | ${test_arches}) |
| 154 | message(STATUS "${platform} supported builtin arches: ${DARWIN_${platform}_ARCHS}") |
| 155 | if(DARWIN_${platform}_ARCHS) |
| 156 | list(APPEND BUILTIN_SUPPORTED_OS ${platform}) |
| 157 | endif() |
| 158 | foreach(arch ${DARWIN_${platform}_ARCHS}) |
| 159 | list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) |
| 160 | set(CAN_TARGET_${arch} 1) |
| 161 | endforeach() |
| 162 | endif() |
| 163 | endforeach() |
| 164 | |
| 165 | list_intersect(BUILTIN_SUPPORTED_ARCH ALL_BUILTIN_SUPPORTED_ARCH COMPILER_RT_SUPPORTED_ARCH) |
| 166 | |
| 167 | else() |
| 168 | # If we're not building the builtins standalone, just rely on the tests in |
| 169 | # config-ix.cmake to tell us what to build. Otherwise we need to do some leg |
| 170 | # work here... |
| 171 | if(COMPILER_RT_BUILTINS_STANDALONE_BUILD) |
| 172 | test_targets() |
| 173 | endif() |
| 174 | # Architectures supported by compiler-rt libraries. |
| 175 | filter_available_targets(BUILTIN_SUPPORTED_ARCH |
| 176 | ${ALL_BUILTIN_SUPPORTED_ARCH}) |
| 177 | endif() |
| 178 | |
| 179 | message(STATUS "Builtin supported architectures: ${BUILTIN_SUPPORTED_ARCH}") |