Skip to content

Commit f0594a4

Browse files
authored
[embedded] Make embedded target triples conditional on LLVM support (#70218)
LLVM might not be build with support for all architectures to save time. The changes in this commit check the value of LLVM_TARGETS_TO_BUILD provided by LLVMConfig.cmake to add or skip the different embedded targets if LLVM happens to not build with support for that target. While x86_64 and ARM/AArch64 are very common in `LLVM_TARGETS_TO_BUILD`, targets like RISCV are more specialized and might not be always enabled. This is not a problem for builds using the `build-script` because of the changes introduced in #70057, but it is still a problem for other builds that do not use `build-script`. This solution should work for any build.
1 parent 04fad1b commit f0594a4

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

stdlib/public/CMakeLists.txt

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,42 @@ elseif(BOOTSTRAPPING_MODE STREQUAL "OFF")
149149
endif()
150150

151151
if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
152-
set(EMBEDDED_STDLIB_TARGET_TRIPLES
153-
# arch module_name target triple
154-
"armv6 armv6-apple-none-macho armv6-apple-none-macho"
155-
"armv6m armv6m-apple-none-macho armv6m-apple-none-macho"
156-
"armv7 armv7-apple-none-macho armv7-apple-none-macho"
157-
"armv7em armv7em-apple-none-macho armv7em-apple-none-macho"
158-
"arm64 arm64-apple-none-macho arm64-apple-none-macho"
159-
160-
# the following are all ELF targets
161-
"armv6 armv6-none-none-eabi armv6-none-none-eabi"
162-
"armv6m armv6m-none-none-eabi armv6-none-none-eabi"
163-
"armv7 armv7-none-none-eabi armv7-none-none-eabi"
164-
"armv7em armv7em-none-none-eabi armv7em-none-none-eabi"
165-
"aarch64 aarch64-none-none-elf aarch64-none-none-elf"
166-
"riscv32 riscv32-none-none-eabi riscv32-none-none-eabi"
167-
"riscv64 riscv64-none-none-eabi riscv64-none-none-eabi"
152+
set(EMBEDDED_STDLIB_TARGET_TRIPLES)
153+
if("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
154+
list(APPEND EMBEDDED_STDLIB_TARGET_TRIPLES
155+
# arch module_name target triple
156+
"armv6 armv6-apple-none-macho armv6-apple-none-macho"
157+
"armv6m armv6m-apple-none-macho armv6m-apple-none-macho"
158+
"armv7 armv7-apple-none-macho armv7-apple-none-macho"
159+
"armv7em armv7em-apple-none-macho armv7em-apple-none-macho"
168160
)
161+
endif()
162+
if("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
163+
list(APPEND EMBEDDED_STDLIB_TARGET_TRIPLES
164+
"arm64 arm64-apple-none-macho arm64-apple-none-macho"
165+
)
166+
endif()
167+
168+
# the following are all ELF targets
169+
if("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
170+
list(APPEND EMBEDDED_STDLIB_TARGET_TRIPLES
171+
"armv6 armv6-none-none-eabi armv6-none-none-eabi"
172+
"armv6m armv6m-none-none-eabi armv6-none-none-eabi"
173+
"armv7 armv7-none-none-eabi armv7-none-none-eabi"
174+
"armv7em armv7em-none-none-eabi armv7em-none-none-eabi"
175+
)
176+
endif()
177+
if("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
178+
list(APPEND EMBEDDED_STDLIB_TARGET_TRIPLES
179+
"aarch64 aarch64-none-none-elf aarch64-none-none-elf"
180+
)
181+
endif()
182+
if("RISCV" IN_LIST LLVM_TARGETS_TO_BUILD)
183+
list(APPEND EMBEDDED_STDLIB_TARGET_TRIPLES
184+
"riscv32 riscv32-none-none-eabi riscv32-none-none-eabi"
185+
"riscv64 riscv64-none-none-eabi riscv64-none-none-eabi"
186+
)
187+
endif()
169188

170189
if (SWIFT_HOST_VARIANT STREQUAL "linux")
171190
set(EMBEDDED_STDLIB_TARGET_TRIPLES ${EMBEDDED_STDLIB_TARGET_TRIPLES}

0 commit comments

Comments
 (0)