Skip to content

Commit aed4f74

Browse files
committed
[ASTGen] Set the target triple for swiftASTGen.
Builds of Swift sources via CMake are not getting a target triple set, so they pick up the host triple. This leads to spurious warnings about linking in code built for a newer OS version (e.g., the one you're on) into libraries with an older deployment target. It also breaks building a cross-compiler. Always set the target triple.
1 parent 7fd7e4f commit aed4f74

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/ASTGen/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ if (SWIFT_SWIFT_PARSER)
88
Sources/ASTGen/Stmts.swift
99
)
1010

11+
# Set the appropriate target triple.
12+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
13+
set(DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
14+
endif()
15+
16+
if(SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID)
17+
set(DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL})
18+
endif()
19+
20+
get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}"
21+
MACCATALYST_BUILD_FLAVOR ""
22+
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}")
23+
24+
target_compile_options(swiftASTGen PRIVATE $<$<COMPILE_LANGUAGE:Swift>:-target;${target}>)
25+
1126
# Link against the SwiftSyntax parser and libraries it depends on. The actual
1227
# formulation of this is a hack to work around a CMake bug in Ninja file
1328
# generation that results in multiple Ninja targets producing the same file in

0 commit comments

Comments
 (0)