Skip to content

Commit e88f0fb

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 e88f0fb

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

utils/swift_build_support/swift_build_support/products/indexstoredb.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def get_dependencies(cls):
7474
swiftpm.SwiftPM,
7575
swiftsyntax.SwiftSyntax]
7676

77+
@classmethod
78+
def has_cross_compile_hosts(self, args):
79+
return args.cross_compile_hosts
80+
7781

7882
def run_build_script_helper(action, host_target, product, args,
7983
sanitize_all=False):
@@ -105,18 +109,24 @@ def run_build_script_helper(action, host_target, product, args,
105109
elif args.enable_tsan:
106110
helper_cmd.extend(['--sanitize', 'thread'])
107111

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-
]
112+
# Pass Cross compile host info
113+
if product.has_cross_compile_hosts(args):
114+
if product.is_darwin_host(host_target):
115+
helper_cmd += ['--cross-compile-hosts']
116+
for cross_compile_host in args.cross_compile_hosts:
117+
helper_cmd += [cross_compile_host]
118+
elif product.is_cross_compile_target(host_target):
119+
helper_cmd += ['--cross-compile-hosts', host_target,
120+
'--skip-cmake-bootstrap']
121+
build_toolchain_path = product.host_install_destdir(
122+
host_target) + args.install_prefix
123+
resource_dir = '%s/lib/swift' % build_toolchain_path
124+
helper_cmd += [
125+
'--cross-compile-config',
126+
targets.StdlibDeploymentTarget.get_target_for_name(host_target).platform
127+
.swiftpm_config(args, output_dir=build_toolchain_path,
128+
swift_toolchain=toolchain_path,
129+
resource_path=resource_dir)]
120130

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

0 commit comments

Comments
 (0)