Skip to content

Commit 1c126eb

Browse files
authored
Allow cross host compilation without stdlib build (#35858)
This is to support certain build configuration which will provide the stdlib/runtime for the cross target by a different means. Addresses rdar://74188174, rdar://74154062
1 parent 1f3879b commit 1c126eb

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

utils/swift_build_support/swift_build_support/host_specific_configuration.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ def __init__(self, host_target, args):
3939
# Otherwise, this is a host we are building as part of
4040
# cross-compiling, so we only need the target itself.
4141
stdlib_targets_to_configure = [host_target]
42-
stdlib_targets_to_build = set(stdlib_targets_to_configure)
42+
if (hasattr(args, 'stdlib_deployment_targets')):
43+
# there are some build configs that expect
44+
# not to be building the stdlib for the target
45+
# since it will be provided by different means
46+
stdlib_targets_to_build = set(
47+
stdlib_targets_to_configure).intersection(
48+
set(args.stdlib_deployment_targets))
49+
else:
50+
stdlib_targets_to_build = set(stdlib_targets_to_configure)
4351

4452
if (hasattr(args, 'stdlib_deployment_targets') and
4553
args.stdlib_deployment_targets == []):

utils/swift_build_support/tests/test_host_specific_configuration.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,34 @@ def test_should_configure_and_build_when_cross_compiling(self):
7373
self.assertIn('swift-test-stdlib-iphoneos-arm64',
7474
hsc.swift_stdlib_build_targets)
7575

76+
def test_should_configure_and_build_cross_compiling_with_stdlib_targets(self):
77+
args = self.default_args()
78+
args.build_ios_device = True
79+
args.host_target = 'macosx-x86_64'
80+
args.stdlib_deployment_targets = ['iphoneos-arm64']
81+
82+
hsc = HostSpecificConfiguration('iphoneos-arm64', args)
83+
84+
self.assertEqual(len(hsc.sdks_to_configure), 1)
85+
self.assertIn('IOS', hsc.sdks_to_configure)
86+
87+
self.assertEqual(len(hsc.swift_stdlib_build_targets), 1)
88+
self.assertIn('swift-test-stdlib-iphoneos-arm64',
89+
hsc.swift_stdlib_build_targets)
90+
91+
def test_should_only_configure_when_cross_compiling_different_stdlib_targets(self):
92+
args = self.default_args()
93+
args.build_ios_device = True
94+
args.host_target = 'macosx-x86_64'
95+
args.stdlib_deployment_targets = ['iphonesimulator-arm64']
96+
97+
hsc = HostSpecificConfiguration('iphoneos-arm64', args)
98+
99+
self.assertEqual(len(hsc.sdks_to_configure), 1)
100+
self.assertIn('IOS', hsc.sdks_to_configure)
101+
102+
self.assertEqual(len(hsc.swift_stdlib_build_targets), 0)
103+
76104
def generate_should_skip_building_platform(
77105
host_target, sdk_name, build_target, build_arg_name):
78106
def test(self):

0 commit comments

Comments
 (0)