Skip to content

Commit 45aeca8

Browse files
authored
Merge pull request swiftlang#40633 from buttaface/cross-compile-install-path
[build] Add a flag that allows disabling appending the host target's name to the install-destdir for a cross-compiled toolchain
2 parents e0eec4d + 3e77176 commit 45aeca8

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

utils/build-script-impl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ KNOWN_SETTINGS=(
249249
cross-compile-with-host-tools "" "set to use the clang we build for the host to then build the cross-compile hosts"
250250
cross-compile-install-prefixes "" "semicolon-separated list of install prefixes to use for the cross-compiled hosts. The list expands, so if there are more cross-compile hosts than prefixes, unmatched hosts use the last prefix in the list"
251251
cross-compile-deps-path "" "path for CMake to look for cross-compiled library dependencies, such as libXML2"
252+
cross-compile-append-host-target-to-destdir "1" "turns on appending the host target name of each cross-compiled toolchain to its install-destdir, to keep them separate from the natively-built toolchain"
252253
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
253254
coverage-db "" "If set, coverage database to use when prioritizing testing"
254255
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
@@ -1133,8 +1134,10 @@ function get_host_install_destdir() {
11331134
if [[ $(should_include_host_in_lipo ${host}) ]]; then
11341135
# If this is one of the hosts we should lipo, install in to a temporary subdirectory.
11351136
local host_install_destdir="${BUILD_DIR}/intermediate-install/${host}"
1136-
elif [[ "${host}" == "merged-hosts" ]]; then
1137-
# This assumes that all hosts are merged to the lipo.
1137+
elif [[ "${host}" == "merged-hosts" ]] ||
1138+
[[ "$(true_false ${CROSS_COMPILE_APPEND_HOST_TARGET_TO_DESTDIR})" == "FALSE" ]]; then
1139+
# This assumes that all hosts are merged to the lipo, or the build
1140+
# was told not to append anything.
11381141
local host_install_destdir="${INSTALL_DESTDIR}"
11391142
else
11401143
local host_install_destdir="${INSTALL_DESTDIR}/${host}"

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,12 @@ def create_argument_parser():
568568
'library dependencies of the corelibs and other Swift repos, '
569569
'such as the libcurl dependency of FoundationNetworking')
570570

571+
option('--cross-compile-append-host-target-to-destdir', toggle_true,
572+
default=True,
573+
help="Append each cross-compilation host target's name as a subdirectory "
574+
"for each cross-compiled toolchain's destdir, useful when building "
575+
"multiple toolchains and can be disabled if only cross-compiling one.")
576+
571577
option('--stdlib-deployment-targets', store,
572578
type=argparse.ShellSplitType(),
573579
default=None,

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
'cmark_build_variant': 'Debug',
129129
'compiler_vendor': defaults.COMPILER_VENDOR,
130130
'coverage_db': None,
131+
'cross_compile_append_host_target_to_destdir': True,
131132
'cross_compile_deps_path': None,
132133
'cross_compile_hosts': [],
133134
'darwin_deployment_version_ios':
@@ -538,6 +539,7 @@ class BuildScriptImplOption(_BaseOption):
538539
EnableOption('--build-swift-stdlib-static-print'),
539540
EnableOption('--build-swift-private-stdlib'),
540541
EnableOption('--build-swift-stdlib-unicode-data'),
542+
EnableOption('--cross-compile-append-host-target-to-destdir'),
541543
EnableOption('--distcc'),
542544
EnableOption('--sccache'),
543545
EnableOption('--enable-asan'),

utils/swift_build_support/swift_build_support/build_script_invocation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def convert_to_impl_arguments(self):
124124
"--lldb-assertions", str(
125125
args.lldb_assertions).lower(),
126126
"--cmake-generator", args.cmake_generator,
127+
"--cross-compile-append-host-target-to-destdir", str(
128+
args.cross_compile_append_host_target_to_destdir).lower(),
127129
"--build-jobs", str(args.build_jobs),
128130
"--common-cmake-options=%s" % ' '.join(
129131
pipes.quote(opt) for opt in cmake.common_options()),

utils/swift_build_support/swift_build_support/products/product.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ def host_install_destdir(self, host_target):
230230
# install in to a temporary subdirectory.
231231
return '%s/intermediate-install/%s' % \
232232
(os.path.dirname(self.build_dir), host_target)
233-
elif host_target == "merged-hosts":
234-
# This assumes that all hosts are merged to the lipo.
233+
elif host_target == "merged-hosts" or \
234+
not self.args.cross_compile_append_host_target_to_destdir:
235+
# This assumes that all hosts are merged to the lipo, or the build
236+
# was told not to append anything.
235237
return self.args.install_destdir
236238
else:
237239
return '%s/%s' % (self.args.install_destdir, host_target)

0 commit comments

Comments
 (0)