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