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