Skip to content

Commit 4290b78

Browse files
committed
Extend --cross-compile-build-swift-tools=False to disable building and installing LLVM
and the Testing macros for cross-compiled hosts, then enable building and using the Testing macros for the native host.
1 parent 917b800 commit 4290b78

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

swift-ci/sdks/android/patches/swift-android.patch

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,81 @@ index fba09416ddb..67b81daba12 100644
148148

149149
android_toolchain_path = self.ndk_toolchain_path(args)
150150

151+
diff --git a/swift/utils/build_swift/build_swift/driver_arguments.py b/swift/utils/build_swift/build_swift/driver_arguments.py
152+
index 2b7d6d07799..e0d04d22825 100644
153+
--- a/swift/utils/build_swift/build_swift/driver_arguments.py
154+
+++ b/swift/utils/build_swift/build_swift/driver_arguments.py
155+
@@ -677,6 +677,12 @@ def create_argument_parser():
156+
"for each cross-compiled toolchain's destdir, useful when building "
157+
"multiple toolchains and can be disabled if only cross-compiling one.")
158+
159+
+ option('--cross-compile-build-swift-tools', toggle_true,
160+
+ default=True,
161+
+ help="Cross-compile the Swift compiler, other host tools from the "
162+
+ "compiler repository, and various macros for each listed "
163+
+ "--cross-compile-hosts platform.")
164+
+
165+
option('--stdlib-deployment-targets', store,
166+
type=argparse.ShellSplitType(),
167+
default=None,
168+
diff --git a/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py b/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py
169+
index a0289515fd0..355d72fe21f 100644
170+
--- a/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py
171+
+++ b/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py
172+
@@ -119,6 +119,8 @@ class BuildScriptInvocation(object):
173+
"--cmake-generator", args.cmake_generator,
174+
"--cross-compile-append-host-target-to-destdir", str(
175+
args.cross_compile_append_host_target_to_destdir).lower(),
176+
+ "--cross-compile-build-swift-tools", str(
177+
+ args.cross_compile_build_swift_tools).lower(),
178+
"--build-jobs", str(args.build_jobs),
179+
"--lit-jobs", str(args.lit_jobs),
180+
"--common-cmake-options=%s" % ' '.join(
181+
diff --git a/swift/utils/swift_build_support/swift_build_support/products/llvm.py b/swift/utils/swift_build_support/swift_build_support/products/llvm.py
182+
index ffae1d66702..bc6e00e7ea3 100644
183+
--- a/swift/utils/swift_build_support/swift_build_support/products/llvm.py
184+
+++ b/swift/utils/swift_build_support/swift_build_support/products/llvm.py
185+
@@ -249,7 +249,7 @@ class LLVM(cmake_product.CMakeProduct):
186+
# space/time efficient than -g on that platform.
187+
llvm_cmake_options.define('LLVM_USE_SPLIT_DWARF:BOOL', 'YES')
188+
189+
- if not self.args._build_llvm:
190+
+ if not self.args._build_llvm or (not self.args.cross_compile_build_swift_tools and self.is_cross_compile_target(host_target)):
191+
# Indicating we don't want to build LLVM at all should
192+
# override everything.
193+
build_targets = []
194+
@@ -484,7 +484,7 @@ class LLVM(cmake_product.CMakeProduct):
195+
Whether or not this product should be installed with the given
196+
arguments.
197+
"""
198+
- return self.args.install_llvm
199+
+ return self.args.install_llvm and (self.args.cross_compile_build_swift_tools or not self.is_cross_compile_target(host_target))
200+
201+
def install(self, host_target):
202+
"""
203+
diff --git a/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py b/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py
204+
index ddb3b553de7..7195d921da2 100644
205+
--- a/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py
206+
+++ b/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py
207+
@@ -42,13 +42,19 @@ class SwiftTestingMacros(product.Product):
208+
return True
209+
210+
def should_build(self, host_target):
211+
- return True
212+
+ build_macros = not self.is_cross_compile_target(host_target) or self.args.cross_compile_build_swift_tools
213+
+ if not build_macros:
214+
+ print("Skipping building Testing Macros for %s, because the host tools are not being built", host_target)
215+
+ return build_macros
216+
217+
def should_test(self, host_target):
218+
return False
219+
220+
def should_install(self, host_target):
221+
- return self.args.install_swift_testing_macros
222+
+ install_macros = self.args.install_swift_testing_macros and (not self.is_cross_compile_target(host_target) or self.args.cross_compile_build_swift_tools)
223+
+ if self.args.install_swift_testing_macros and not install_macros:
224+
+ print("Skipping installing Testing Macros for %s, because the host tools are not being built", host_target)
225+
+ return install_macros
226+
227+
def _cmake_product(self, host_target):
228+
build_root = os.path.dirname(self.build_dir)

swift-ci/sdks/android/scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ for arch in $archs; do
460460
--install-foundation \
461461
--xctest --install-xctest \
462462
--swift-testing --install-swift-testing \
463-
--cross-compile-build-swift-tools=0 \
464-
--llvm-ninja-targets-for-cross-compile-hosts=help \
463+
--swift-testing-macros --install-swift-testing-macros \
464+
--cross-compile-build-swift-tools=False \
465465
--libdispatch-cmake-options=-DCMAKE_SHARED_LINKER_FLAGS= \
466466
--foundation-cmake-options=-DCMAKE_SHARED_LINKER_FLAGS= \
467467
--cross-compile-append-host-target-to-destdir=False

0 commit comments

Comments
 (0)