Skip to content

[build] Add a flag that allows disabling appending the host target's name to the install-destdir for a cross-compiled toolchain #40633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ KNOWN_SETTINGS=(
cross-compile-with-host-tools "" "set to use the clang we build for the host to then build the cross-compile hosts"
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"
cross-compile-deps-path "" "path for CMake to look for cross-compiled library dependencies, such as libXML2"
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"
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
coverage-db "" "If set, coverage database to use when prioritizing testing"
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
Expand Down Expand Up @@ -1133,8 +1134,10 @@ function get_host_install_destdir() {
if [[ $(should_include_host_in_lipo ${host}) ]]; then
# If this is one of the hosts we should lipo, install in to a temporary subdirectory.
local host_install_destdir="${BUILD_DIR}/intermediate-install/${host}"
elif [[ "${host}" == "merged-hosts" ]]; then
# This assumes that all hosts are merged to the lipo.
elif [[ "${host}" == "merged-hosts" ]] ||
[[ "$(true_false ${CROSS_COMPILE_APPEND_HOST_TARGET_TO_DESTDIR})" == "FALSE" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned out way better than I imagined -- thanks for reminding me about the true_false facility.

# This assumes that all hosts are merged to the lipo, or the build
# was told not to append anything.
local host_install_destdir="${INSTALL_DESTDIR}"
else
local host_install_destdir="${INSTALL_DESTDIR}/${host}"
Expand Down
6 changes: 6 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ def create_argument_parser():
'library dependencies of the corelibs and other Swift repos, '
'such as the libcurl dependency of FoundationNetworking')

option('--cross-compile-append-host-target-to-destdir', toggle_true,
default=True,
help="Append each cross-compilation host target's name as a subdirectory "
"for each cross-compiled toolchain's destdir, useful when building "
"multiple toolchains and can be disabled if only cross-compiling one.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you phrased this description -- in particular how concise it is.


option('--stdlib-deployment-targets', store,
type=argparse.ShellSplitType(),
default=None,
Expand Down
2 changes: 2 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
'cmark_build_variant': 'Debug',
'compiler_vendor': defaults.COMPILER_VENDOR,
'coverage_db': None,
'cross_compile_append_host_target_to_destdir': True,
'cross_compile_deps_path': None,
'cross_compile_hosts': [],
'darwin_deployment_version_ios':
Expand Down Expand Up @@ -538,6 +539,7 @@ class BuildScriptImplOption(_BaseOption):
EnableOption('--build-swift-stdlib-static-print'),
EnableOption('--build-swift-private-stdlib'),
EnableOption('--build-swift-stdlib-unicode-data'),
EnableOption('--cross-compile-append-host-target-to-destdir'),
EnableOption('--distcc'),
EnableOption('--sccache'),
EnableOption('--enable-asan'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def convert_to_impl_arguments(self):
"--lldb-assertions", str(
args.lldb_assertions).lower(),
"--cmake-generator", args.cmake_generator,
"--cross-compile-append-host-target-to-destdir", str(
args.cross_compile_append_host_target_to_destdir).lower(),
"--build-jobs", str(args.build_jobs),
"--common-cmake-options=%s" % ' '.join(
pipes.quote(opt) for opt in cmake.common_options()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ def host_install_destdir(self, host_target):
# install in to a temporary subdirectory.
return '%s/intermediate-install/%s' % \
(os.path.dirname(self.build_dir), host_target)
elif host_target == "merged-hosts":
# This assumes that all hosts are merged to the lipo.
elif host_target == "merged-hosts" or \
not self.args.cross_compile_append_host_target_to_destdir:
# This assumes that all hosts are merged to the lipo, or the build
# was told not to append anything.
return self.args.install_destdir
else:
return '%s/%s' % (self.args.install_destdir, host_target)
Expand Down