Skip to content

Commit 93c91dd

Browse files
committed
Set CMAKE_Swift_COMPILER_TARGET flag centrally and bump build on CI
1 parent 98c6379 commit 93c91dd

File tree

5 files changed

+17
-95
lines changed

5 files changed

+17
-95
lines changed

.github/workflows/sdks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
SWIFT_TAG="swift-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
3232
fi
3333
echo "tag=$SWIFT_TAG" >> $GITHUB_OUTPUT
34-
echo "key=$SWIFT_TAG-ndk-${NDK_VERSION}-bt-bundle" >> $GITHUB_OUTPUT
34+
echo "key=$SWIFT_TAG-ndk-${NDK_VERSION}-get-bundle" >> $GITHUB_OUTPUT
3535
- name: Get cached SDK bundle
3636
id: cache-bundle
3737
uses: actions/cache/restore@v4
@@ -136,7 +136,7 @@ jobs:
136136
else
137137
git apply swift-android-ci-devel.patch
138138
fi
139-
git apply -C2 swift-android-ci-except-release.patch swift-android-testing-except-release.patch
139+
git apply -C2 swift-android-ci-except-release.patch
140140
BUILD_FLAG="--cross-compile-build-swift-tools=0"
141141
SDK_NAME=$(ls | grep swift-${{ matrix.version }}-android-aarch64)
142142
perl -pi -e 's%33%24%' $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/execinfo.h

swift-android-testing-except-release.patch

Lines changed: 0 additions & 30 deletions
This file was deleted.

swift-android-testing-release.patch

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,3 @@ index 90f4aa78..0429425b 100644
4444
// Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting:
4545
// - Amazon Linux 2 (EoL mid-2025)
4646
return ENOSYS;
47-
diff --git a/swift-testing/cmake/modules/SwiftModuleInstallation.cmake b/swift-testing/cmake/modules/SwiftModuleInstallation.cmake
48-
index 1553725..d9f9e5b 100644
49-
--- a/swift-testing/cmake/modules/SwiftModuleInstallation.cmake
50-
+++ b/swift-testing/cmake/modules/SwiftModuleInstallation.cmake
51-
@@ -75,6 +75,10 @@ function(_swift_testing_install_target module)
52-
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
53-
if(CMAKE_Swift_COMPILER_TARGET)
54-
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
55-
+ else()
56-
+ set(arg_list ${CMAKE_Swift_FLAGS})
57-
+ separate_arguments(arg_list)
58-
+ list(APPEND module_triple_command ${arg_list})
59-
endif()
60-
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
61-
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")

swift-android-trunk-libdispatch.patch

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
diff --git a/swift-corelibs-libdispatch/cmake/modules/SwiftSupport.cmake b/swift-corelibs-libdispatch/cmake/modules/SwiftSupport.cmake
2-
index 3da519e..e2dd8ed 100644
3-
--- a/swift-corelibs-libdispatch/cmake/modules/SwiftSupport.cmake
4-
+++ b/swift-corelibs-libdispatch/cmake/modules/SwiftSupport.cmake
5-
@@ -4,6 +4,10 @@ if(NOT dispatch_MODULE_TRIPLE)
6-
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
7-
if(CMAKE_Swift_COMPILER_TARGET)
8-
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
9-
+ else()
10-
+ set(arg_list ${CMAKE_Swift_FLAGS})
11-
+ separate_arguments(arg_list)
12-
+ list(APPEND module_triple_command ${arg_list})
13-
endif()
14-
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
15-
161
diff --git a/swift-corelibs-libdispatch/src/swift/CMakeLists.txt b/swift-corelibs-libdispatch/src/swift/CMakeLists.txt
172
index 38bef37..d0ddf98 100644
183
--- a/swift-corelibs-libdispatch/src/swift/CMakeLists.txt

swift-android.patch

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
22
index 16e05052609..7ab8cebfab8 100755
33
--- a/swift/utils/build-script-impl
44
+++ b/swift/utils/build-script-impl
5+
@@ -828,6 +828,9 @@ function set_build_options_for_host() {
6+
# and it must be the same for both LLVM and Swift
7+
8+
if [[ "${SWIFT_HOST_TRIPLE}" ]] ; then
9+
+ SWIFT_TARGET_CMAKE_OPTIONS+=(
10+
+ -DCMAKE_Swift_COMPILER_TARGET:STRING="${SWIFT_HOST_TRIPLE}"
11+
+ )
12+
llvm_cmake_options+=(
13+
-DLLVM_HOST_TRIPLE:STRING="${SWIFT_HOST_TRIPLE}"
14+
)
515
@@ -2622,6 +2622,7 @@ for host in "${ALL_HOSTS[@]}"; do
616
echo "Cleaning the libdispatch build directory"
717
call rm -rf "${LIBDISPATCH_BUILD_DIR}"
@@ -24,15 +34,16 @@ index 324d1a77eea..e88601a8701 100644
2434

2535
from . import cmake_product
2636
from . import product
27-
@@ -115,6 +117,22 @@ class SwiftTestingCMakeShim(cmake_product.CMakeProduct):
37+
@@ -115,6 +117,24 @@ class SwiftTestingCMakeShim(cmake_product.CMakeProduct):
2838
# FIXME: If we build macros for the builder, specify the path.
2939
self.cmake_options.define('SwiftTesting_MACRO', 'NO')
3040

3141
+ if host_target.startswith('android') and self.is_cross_compile_target(host_target):
3242
+ host_config = HostSpecificConfiguration(host_target, self.args)
3343
+ self.cmake_options.extend(host_config.cmake_options)
34-
+ flags = '-target %s-unknown-linux-android%s ' % (self.args.android_arch,
35-
+ self.args.android_api_level)
44+
+ triple = '%s-unknown-linux-android%s' % (self.args.android_arch,
45+
+ self.args.android_api_level)
46+
+ flags = '-target %s ' % (triple)
3647
+
3748
+ flags += '-resource-dir %s/lib/swift ' % (
3849
+ self.host_install_destdir(host_target) + self.args.install_prefix)
@@ -41,6 +52,7 @@ index 324d1a77eea..e88601a8701 100644
4152
+ flags += '-sdk %s/sysroot ' % (ndk_path)
4253
+ flags += '-tools-directory %s/bin' % (ndk_path)
4354
+ self.cmake_options.define('CMAKE_Swift_FLAGS', flags)
55+
+ self.cmake_options.define('CMAKE_Swift_COMPILER_TARGET', triple)
4456
+ self.cmake_options.define('CMAKE_CXX_COMPILER_WORKS', 'True')
4557
+ self.cmake_options.define('CMAKE_FIND_ROOT_PATH', self.args.cross_compile_deps_path)
4658
+
@@ -100,21 +112,6 @@ index 758dd1df..02970992 100644
100112
guard var spawnAttrs else {
101113
throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno),
102114
userInfo: [NSURLErrorKey:self.executableURL!])
103-
diff --git a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
104-
index cbdfc2a..bb4121d 100644
105-
--- a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
106-
+++ b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
107-
@@ -37,6 +37,10 @@ function(_swift_foundation_install_target module)
108-
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
109-
if(CMAKE_Swift_COMPILER_TARGET)
110-
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
111-
+ else()
112-
+ set(arg_list ${CMAKE_Swift_FLAGS})
113-
+ separate_arguments(arg_list)
114-
+ list(APPEND module_triple_command ${arg_list})
115-
endif()
116-
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
117-
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
118115
diff --git a/swift-testing/CMakeLists.txt b/swift-testing/CMakeLists.txt
119116
index 1be9a4b..bd7b1bd 100644
120117
--- a/swift-testing/CMakeLists.txt
@@ -143,18 +140,3 @@ index e40cb1b..ff2f920 100644
143140
endif()
144141
target_link_libraries(Testing PUBLIC
145142
Foundation)
146-
diff --git a/swift-testing/cmake/modules/TargetTriple.cmake b/swift-testing/cmake/modules/TargetTriple.cmake
147-
index e087cc4..02f3a95 100644
148-
--- a/swift-testing/cmake/modules/TargetTriple.cmake
149-
+++ b/swift-testing/cmake/modules/TargetTriple.cmake
150-
@@ -10,6 +10,10 @@
151-
set(SWT_TARGET_INFO_COMMAND "${CMAKE_Swift_COMPILER}" -print-target-info)
152-
if(CMAKE_Swift_COMPILER_TARGET)
153-
list(APPEND SWT_TARGET_INFO_COMMAND -target ${CMAKE_Swift_COMPILER_TARGET})
154-
+else()
155-
+ set(arg_list ${CMAKE_Swift_FLAGS})
156-
+ separate_arguments(arg_list)
157-
+ list(APPEND SWT_TARGET_INFO_COMMAND ${arg_list})
158-
endif()
159-
execute_process(COMMAND ${SWT_TARGET_INFO_COMMAND} OUTPUT_VARIABLE SWT_TARGET_INFO_JSON)
160-
string(JSON SWT_TARGET_TRIPLE GET "${SWT_TARGET_INFO_JSON}" "target" "unversionedTriple")

0 commit comments

Comments
 (0)