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