Skip to content

Commit 7c5be0f

Browse files
committed
[build-script] Cross-compile sourcekit-lsp for arm64
Currently, when building an open source toolchain, SourceKit-LSP is only built for x86_64. Copy the cross-compilation config from swiftpm.py to also produce a fat sourcekit-lsp executable for both x86_64 and arm64. rdar://78039145
1 parent 997ace4 commit 7c5be0f

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

utils/swift_build_support/swift_build_support/products/indexstoredb.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,23 @@ def run_build_script_helper(action, host_target, product, args,
105105
elif args.enable_tsan:
106106
helper_cmd.extend(['--sanitize', 'thread'])
107107

108-
if not product.is_darwin_host(
109-
host_target) and product.is_cross_compile_target(host_target):
110-
helper_cmd.extend(['--cross-compile-host', host_target])
111-
build_toolchain_path = install_destdir + args.install_prefix
112-
resource_dir = '%s/lib/swift' % build_toolchain_path
113-
helper_cmd += [
114-
'--cross-compile-config',
115-
targets.StdlibDeploymentTarget.get_target_for_name(host_target).platform
116-
.swiftpm_config(args, output_dir=build_toolchain_path,
117-
swift_toolchain=toolchain_path,
118-
resource_path=resource_dir)
119-
]
108+
# Pass Cross compile host info
109+
if args.has_cross_compile_hosts():
110+
if product.is_darwin_host(host_target):
111+
helper_cmd += ['--cross-compile-hosts']
112+
for cross_compile_host in args.cross_compile_hosts:
113+
helper_cmd += [cross_compile_host]
114+
elif product.is_cross_compile_target(host_target):
115+
helper_cmd += ['--cross-compile-hosts', host_target]
116+
build_toolchain_path = product.host_install_destdir(
117+
host_target) + args.install_prefix
118+
resource_dir = '%s/lib/swift' % build_toolchain_path
119+
helper_cmd += [
120+
'--cross-compile-config',
121+
targets.StdlibDeploymentTarget.get_target_for_name(host_target).platform
122+
.swiftpm_config(args, output_dir=build_toolchain_path,
123+
swift_toolchain=toolchain_path,
124+
resource_path=resource_dir)]
120125

121126
if action == 'install' and product.product_name() == "sourcekitlsp":
122127
helper_cmd.extend([

utils/swift_build_support/swift_build_support/products/product.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ def is_cross_compile_target(self, host_target):
244244
return self.args.cross_compile_hosts and \
245245
host_target in self.args.cross_compile_hosts
246246

247+
def has_cross_compile_hosts(self):
248+
return self.args.cross_compile_hosts
249+
247250
def generate_darwin_toolchain_file(self, platform, arch):
248251
shell.makedirs(self.build_dir)
249252
toolchain_file = os.path.join(self.build_dir, 'BuildScriptToolchain.cmake')

utils/swift_build_support/swift_build_support/products/swiftdriver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def run_build_script_helper(action, host_target, product, args):
128128
'--lit-test-dir', lit_test_dir
129129
]
130130
# Pass Cross compile host info
131-
if swiftpm.SwiftPM.has_cross_compile_hosts(args):
131+
if product.has_cross_compile_hosts():
132132
if product.is_darwin_host(host_target):
133133
helper_cmd += ['--cross-compile-hosts']
134134
for cross_compile_host in args.cross_compile_hosts:

utils/swift_build_support/swift_build_support/products/swiftpm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def run_bootstrap_script(self, action, host_target, additional_params=[]):
9393
]
9494

9595
# Pass Cross compile host info
96-
if self.has_cross_compile_hosts(self.args):
96+
if self.has_cross_compile_hosts():
9797
if self.is_darwin_host(host_target):
9898
helper_cmd += ['--cross-compile-hosts']
9999
for cross_compile_host in self.args.cross_compile_hosts:
@@ -133,10 +133,6 @@ def clean(self, host_target):
133133
def should_install(self, host_target):
134134
return self.args.install_swiftpm
135135

136-
@classmethod
137-
def has_cross_compile_hosts(self, args):
138-
return args.cross_compile_hosts
139-
140136
def install(self, host_target):
141137
install_destdir = self.host_install_destdir(host_target)
142138
install_prefix = install_destdir + self.args.install_prefix

0 commit comments

Comments
 (0)