llvm-project

Форк
0
/
builtin-config-ix.cmake 
254 строки · 9.6 Кб
1
include(BuiltinTests)
2
include(CheckIncludeFiles)
3
include(CheckCSourceCompiles)
4

5
# Make all the tests only check the compiler
6
set(TEST_COMPILE_ONLY On)
7

8
# Check host compiler support for certain flags
9
builtin_check_c_compiler_flag(-fPIC                 COMPILER_RT_HAS_FPIC_FLAG)
10
builtin_check_c_compiler_flag(-fPIE                 COMPILER_RT_HAS_FPIE_FLAG)
11
builtin_check_c_compiler_flag(-fno-builtin          COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
12
builtin_check_c_compiler_flag(-std=c11              COMPILER_RT_HAS_STD_C11_FLAG)
13
builtin_check_c_compiler_flag(-fvisibility=hidden   COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG)
14
builtin_check_c_compiler_flag(-fomit-frame-pointer  COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
15
builtin_check_c_compiler_flag(-ffreestanding        COMPILER_RT_HAS_FFREESTANDING_FLAG)
16
builtin_check_c_compiler_flag(-fxray-instrument     COMPILER_RT_HAS_XRAY_COMPILER_FLAG)
17
builtin_check_c_compiler_flag(-fno-lto              COMPILER_RT_HAS_FNO_LTO_FLAG)
18
builtin_check_c_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG)
19
builtin_check_c_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
20
builtin_check_c_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
21
builtin_check_c_compiler_flag(-Wno-pedantic         COMPILER_RT_HAS_WNO_PEDANTIC)
22
builtin_check_c_compiler_flag(-Wbuiltin-declaration-mismatch COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG)
23
builtin_check_c_compiler_flag(/Zl COMPILER_RT_HAS_ZL_FLAG)
24

25
builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD
26
"
27
int foo(int x, int y) {
28
 _Atomic int result = x * y;
29
 return result;
30
}
31
")
32

33
builtin_check_c_compiler_source(COMPILER_RT_HAS_ASM_LSE
34
"
35
asm(\".arch armv8-a+lse\");
36
asm(\"cas w0, w1, [x2]\");
37
")
38

39
builtin_check_c_compiler_source(COMPILER_RT_HAS_AARCH64_SME
40
"
41
void foo(void)  __arm_streaming_compatible {
42
  asm(\".arch armv9-a+sme\");
43
  asm(\"smstart\");
44
}
45
")
46

47
check_include_files("sys/auxv.h"    COMPILER_RT_HAS_AUXV)
48

49
if(ANDROID)
50
  set(OS_NAME "Android")
51
else()
52
  set(OS_NAME "${CMAKE_SYSTEM_NAME}")
53
endif()
54

55
set(ARM64 aarch64)
56
set(ARM32 arm armhf armv4t armv5te armv6 armv6m armv7m armv7em armv7 armv7s armv7k armv8m.base armv8m.main armv8.1m.main)
57
set(AVR avr)
58
set(HEXAGON hexagon)
59
set(X86 i386)
60
set(X86_64 x86_64)
61
set(LOONGARCH64 loongarch64)
62
set(MIPS32 mips mipsel)
63
set(MIPS64 mips64 mips64el)
64
set(PPC32 powerpc powerpcspe)
65
set(PPC64 powerpc64 powerpc64le)
66
set(RISCV32 riscv32)
67
set(RISCV64 riscv64)
68
set(SPARC sparc)
69
set(SPARCV9 sparcv9)
70
set(WASM32 wasm32)
71
set(WASM64 wasm64)
72
set(VE ve)
73

74
if(APPLE)
75
  set(ARM64 arm64 arm64e)
76
  set(ARM32 armv7 armv7k armv7s)
77
  set(X86_64 x86_64 x86_64h)
78
endif()
79

80
set(ALL_BUILTIN_SUPPORTED_ARCH
81
  ${X86} ${X86_64} ${ARM32} ${ARM64} ${AVR}
82
  ${HEXAGON} ${MIPS32} ${MIPS64} ${PPC32} ${PPC64}
83
  ${RISCV32} ${RISCV64} ${SPARC} ${SPARCV9}
84
  ${WASM32} ${WASM64} ${VE} ${LOONGARCH64})
85

86
include(CompilerRTUtils)
87
include(CompilerRTDarwinUtils)
88

89
if(APPLE)
90

91
  find_darwin_sdk_dir(DARWIN_osx_SYSROOT macosx)
92
  find_darwin_sdk_dir(DARWIN_iossim_SYSROOT iphonesimulator)
93
  find_darwin_sdk_dir(DARWIN_ios_SYSROOT iphoneos)
94
  find_darwin_sdk_dir(DARWIN_watchossim_SYSROOT watchsimulator)
95
  find_darwin_sdk_dir(DARWIN_watchos_SYSROOT watchos)
96
  find_darwin_sdk_dir(DARWIN_tvossim_SYSROOT appletvsimulator)
97
  find_darwin_sdk_dir(DARWIN_tvos_SYSROOT appletvos)
98
  find_darwin_sdk_dir(DARWIN_xrossim_SYSROOT xrsimulator)
99
  find_darwin_sdk_dir(DARWIN_xros_SYSROOT xros)
100

101
  # Get supported architecture from SDKSettings.
102
  function(sdk_has_arch_support sdk_path os arch has_support)
103
    execute_process(COMMAND
104
        /usr/libexec/PlistBuddy -c "Print :SupportedTargets:${os}:Archs" ${sdk_path}/SDKSettings.plist
105
      OUTPUT_VARIABLE SDK_SUPPORTED_ARCHS
106
      RESULT_VARIABLE PLIST_ERROR
107
      ERROR_QUIET)
108
    if (PLIST_ERROR EQUAL 0 AND
109
        SDK_SUPPORTED_ARCHS MATCHES " ${arch}\n")
110
      message(STATUS "Found ${arch} support in ${sdk_path}/SDKSettings.plist")
111
      set("${has_support}" On PARENT_SCOPE)
112
    else()
113
      message(STATUS "No ${arch} support in ${sdk_path}/SDKSettings.plist")
114
      set("${has_support}" Off PARENT_SCOPE)
115
    endif()
116
  endfunction()
117

118
  set(DARWIN_EMBEDDED_PLATFORMS)
119
  set(DARWIN_osx_BUILTIN_MIN_VER 10.7)
120
  set(DARWIN_osx_BUILTIN_MIN_VER_FLAG
121
      -mmacosx-version-min=${DARWIN_osx_BUILTIN_MIN_VER})
122
  set(DARWIN_osx_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64})
123
  # Add support for arm64 macOS if available in SDK.
124
  foreach(arch ${ARM64})
125
    sdk_has_arch_support(${DARWIN_osx_SYSROOT} macosx ${arch} MACOS_ARM_SUPPORT)
126
    if (MACOS_ARM_SUPPORT)
127
     list(APPEND DARWIN_osx_BUILTIN_ALL_POSSIBLE_ARCHS ${arch})
128
    endif()
129
  endforeach(arch)
130

131
  if(COMPILER_RT_ENABLE_IOS)
132
    list(APPEND DARWIN_EMBEDDED_PLATFORMS ios)
133
    set(DARWIN_ios_MIN_VER_FLAG -miphoneos-version-min)
134
    set(DARWIN_ios_BUILTIN_MIN_VER 6.0)
135
    set(DARWIN_ios_BUILTIN_MIN_VER_FLAG
136
      ${DARWIN_ios_MIN_VER_FLAG}=${DARWIN_ios_BUILTIN_MIN_VER})
137
    set(DARWIN_ios_BUILTIN_ALL_POSSIBLE_ARCHS ${ARM64} ${ARM32})
138
    set(DARWIN_iossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64})
139
    find_darwin_sdk_version(iossim_sdk_version "iphonesimulator")
140
    if ("${iossim_sdk_version}" VERSION_GREATER 14.0 OR "${iossim_sdk_version}" VERSION_EQUAL 14.0)
141
      list(APPEND DARWIN_iossim_BUILTIN_ALL_POSSIBLE_ARCHS arm64)
142
    endif()
143
  endif()
144
  if(COMPILER_RT_ENABLE_WATCHOS)
145
    list(APPEND DARWIN_EMBEDDED_PLATFORMS watchos)
146
    set(DARWIN_watchos_MIN_VER_FLAG -mwatchos-version-min)
147
    set(DARWIN_watchos_BUILTIN_MIN_VER 2.0)
148
    set(DARWIN_watchos_BUILTIN_MIN_VER_FLAG
149
      ${DARWIN_watchos_MIN_VER_FLAG}=${DARWIN_watchos_BUILTIN_MIN_VER})
150
    set(DARWIN_watchos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 armv7k arm64_32)
151
    set(DARWIN_watchossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86})
152
    find_darwin_sdk_version(watchossim_sdk_version "watchsimulator")
153
    if ("${watchossim_sdk_version}" VERSION_GREATER 7.0 OR "${watchossim_sdk_version}" VERSION_EQUAL 7.0)
154
      list(APPEND DARWIN_watchossim_BUILTIN_ALL_POSSIBLE_ARCHS arm64)
155
    endif()
156
  endif()
157
  if(COMPILER_RT_ENABLE_TVOS)
158
    list(APPEND DARWIN_EMBEDDED_PLATFORMS tvos)
159
    set(DARWIN_tvos_MIN_VER_FLAG -mtvos-version-min)
160
    set(DARWIN_tvos_BUILTIN_MIN_VER 9.0)
161
    set(DARWIN_tvos_BUILTIN_MIN_VER_FLAG
162
      ${DARWIN_tvos_MIN_VER_FLAG}=${DARWIN_tvos_BUILTIN_MIN_VER})
163
    set(DARWIN_tvos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 arm64)
164
    set(DARWIN_tvossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64})
165
    find_darwin_sdk_version(tvossim_sdk_version "appletvsimulator")
166
    if ("${tvossim_sdk_version}" VERSION_GREATER 14.0 OR "${tvossim_sdk_version}" VERSION_EQUAL 14.0)
167
      list(APPEND DARWIN_tvossim_BUILTIN_ALL_POSSIBLE_ARCHS arm64)
168
    endif()
169
  endif()
170
  if(COMPILER_RT_ENABLE_XROS)
171
    list(APPEND DARWIN_EMBEDDED_PLATFORMS xros)
172
    set(DARWIN_xros_BUILTIN_ALL_POSSIBLE_ARCHS ${ARM64} ${ARM32})
173
    set(DARWIN_xrossim_BUILTIN_ALL_POSSIBLE_ARCHS arm64)
174
  endif()
175

176
  set(BUILTIN_SUPPORTED_OS osx)
177

178
  # We're setting the flag manually for each target OS
179
  set(CMAKE_OSX_DEPLOYMENT_TARGET "")
180

181
  # NOTE: We deliberately avoid using `DARWIN_<os>_ARCHS` here because that is
182
  # used by `config-ix.cmake` in the context of building the rest of
183
  # compiler-rt where the global `${TEST_COMPILE_ONLY}` (used by
184
  # `darwin_test_archs()`) has a different value.
185
  darwin_test_archs(osx
186
    DARWIN_osx_BUILTIN_ARCHS
187
    ${DARWIN_osx_BUILTIN_ALL_POSSIBLE_ARCHS}
188
  )
189
  message(STATUS "OSX supported builtin arches: ${DARWIN_osx_BUILTIN_ARCHS}")
190
  foreach(arch ${DARWIN_osx_BUILTIN_ARCHS})
191
    list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})
192
    set(CAN_TARGET_${arch} 1)
193
  endforeach()
194

195
  foreach(platform ${DARWIN_EMBEDDED_PLATFORMS})
196
    if(DARWIN_${platform}sim_SYSROOT)
197
      set(DARWIN_${platform}sim_BUILTIN_MIN_VER
198
        ${DARWIN_${platform}_BUILTIN_MIN_VER})
199
      set(DARWIN_${platform}sim_BUILTIN_MIN_VER_FLAG
200
        ${DARWIN_${platform}_BUILTIN_MIN_VER_FLAG})
201

202
      set(DARWIN_${platform}sim_SKIP_CC_KEXT On)
203

204
      darwin_test_archs(${platform}sim
205
        DARWIN_${platform}sim_BUILTIN_ARCHS
206
        ${DARWIN_${platform}sim_BUILTIN_ALL_POSSIBLE_ARCHS}
207
      )
208
      message(STATUS "${platform} Simulator supported builtin arches: ${DARWIN_${platform}sim_BUILTIN_ARCHS}")
209
      if(DARWIN_${platform}sim_BUILTIN_ARCHS)
210
        list(APPEND BUILTIN_SUPPORTED_OS ${platform}sim)
211
      endif()
212
      foreach(arch ${DARWIN_${platform}sim_BUILTIN_ARCHS})
213
        list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})
214
        set(CAN_TARGET_${arch} 1)
215
      endforeach()
216
    endif()
217

218
    if(DARWIN_${platform}_SYSROOT)
219
      darwin_test_archs(${platform}
220
        DARWIN_${platform}_BUILTIN_ARCHS
221
        ${DARWIN_${platform}_BUILTIN_ALL_POSSIBLE_ARCHS}
222
      )
223
      message(STATUS "${platform} supported builtin arches: ${DARWIN_${platform}_BUILTIN_ARCHS}")
224
      if(DARWIN_${platform}_BUILTIN_ARCHS)
225
        list(APPEND BUILTIN_SUPPORTED_OS ${platform})
226
      endif()
227
      foreach(arch ${DARWIN_${platform}_BUILTIN_ARCHS})
228
        list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})
229
        set(CAN_TARGET_${arch} 1)
230
      endforeach()
231
    endif()
232
  endforeach()
233

234
  list_intersect(BUILTIN_SUPPORTED_ARCH ALL_BUILTIN_SUPPORTED_ARCH COMPILER_RT_SUPPORTED_ARCH)
235

236
else()
237
  # If we're not building the builtins standalone, just rely on the  tests in
238
  # config-ix.cmake to tell us what to build. Otherwise we need to do some leg
239
  # work here...
240
  if(COMPILER_RT_BUILTINS_STANDALONE_BUILD)
241
    test_targets()
242
  endif()
243
  # Architectures supported by compiler-rt libraries.
244
  filter_available_targets(BUILTIN_SUPPORTED_ARCH
245
    ${ALL_BUILTIN_SUPPORTED_ARCH})
246
endif()
247

248
if (OS_NAME MATCHES "Linux|SerenityOS" AND NOT LLVM_USE_SANITIZER)
249
  set(COMPILER_RT_HAS_CRT TRUE)
250
else()
251
  set(COMPILER_RT_HAS_CRT FALSE)
252
endif()
253

254
message(STATUS "Builtin supported architectures: ${BUILTIN_SUPPORTED_ARCH}")
255

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.