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

Conversation

finagolfin
Copy link
Member

@finagolfin finagolfin commented Dec 20, 2021

This is useful if you're cross-compiling the toolchain for a single host and don't want your specified install path modified.

I have been patching out the hostname for years when cross-compiling the toolchain for Android, so I just came up with this build-script flag instead, finagolfin/termux-packages@17cb147, and that worked. Another advantage is when cross-compiling standalone SDKs, these unnecessary hostname directories won't be applied.

I'm not particular about hacking in a build flag like this, so if someone has a better idea, I'm all ears. @karwa, you added this in #2497 more than five years ago and @gribozavr approved it, any input welcome.

@karwa
Copy link
Contributor

karwa commented Dec 21, 2021

I have no idea, sorry. It's been too long, and the build script has totally changed in that time.

Although I think "hostname" in this case might be a little ambiguous. When I looked at it just now, I thought it would be appending a name like "Karls-Laptop" (i.e. a network hostname)... which would be alarming and not making a lot of sense.

I feel like there are already so many flags, it's hard to know what any of them do or why you'd use them. Ideally at least their names would be extremely clear.

@finagolfin
Copy link
Member Author

the build script has totally changed in that time.

I was surprised to find that this installation code is untouched since you wrote it in 2016. Of course, not many people cross-compile the Swift toolchain, so that's why.

I feel like there are already so many flags, it's hard to know what any of them do or why you'd use them.

Most come with a short description in the help, as I've written here, so that usually hasn't been a problem for me.

@finagolfin
Copy link
Member Author

@kubamracek, would you review?

@kubamracek
Copy link
Contributor

Looks fine to me, maybe I'd suggest some shorter name for the flag, but actually I think @compnerd, @edymtt and @gottesmm are probably better folks to review this change.

Copy link
Contributor

@edymtt edymtt left a comment

Choose a reason for hiding this comment

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

The general approach looks good to me -- we are still relying on build-script-impl for part of our build logic, and in this case I don't think we can avoid updating it.

My only suggestion would be to rename the flag -- more details in the comments (start from utils/build_swift/build_swift/driver_arguments.py)

…name to the install-destdir for a cross-compiled toolchain

This is useful if you're cross-compiling the toolchain for a single host and don't
want your specified install path modified.
@finagolfin finagolfin force-pushed the cross-compile-install-path branch from d113d7b to 3e77176 Compare January 17, 2022 17:30
@finagolfin finagolfin changed the title [build] Add a flag to disable appending the hostname to the install-destdir for a cross-compiled toolchain [build] Add a flag that allows disabling appending the host target's name to the install-destdir for a cross-compiled toolchain Jan 17, 2022
@finagolfin
Copy link
Member Author

@edymtt, made all the changes you asked for, ready for review.

Copy link
Contributor

@edymtt edymtt left a comment

Choose a reason for hiding this comment

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

That looks good to me, thanks a lot for incorporating my feedback!

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.

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.

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

@swift-ci please smoke test

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

@swift-ci please test Apple Silicon

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
@swift-ci please test with toolchain and preset

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

@swift-ci please python lint

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

@swift-ci Please Build Toolchain

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3e77176

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

@swift-ci please smoke test macOS

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

stdlib_S_standalone_minimal_macho_x86_64,build,test is failing with the same error as the incremental job, e.g. https://ci.swift.org/job/oss-swift-test-stdlib-with-toolchain-minimal/1219/console

12:15:56 ******************** TEST 'Swift(freestanding-x86_64) :: Interop/Cxx/stdlib/use-std-vector.swift' FAILED ********************
<snip>
12:15:56 --
12:15:56 Exit Code: 1
12:15:56 
12:15:56 Command Output (stderr):
12:15:56 --
12:15:56 Undefined symbols for architecture x86_64:
12:15:56   "__ZNSt3__17forwardIDnEEOT_RNS_16remove_referenceIS1_E4typeE", referenced from:
12:15:56       __ZNSt3__117__compressed_pairIPiNS_9allocatorIiEEEC2IDnNS_18__default_init_tagEEEOT_OT0_ in lto.o
12:15:56       __ZNSt3__122__compressed_pair_elemIPiLi0ELb0EEC2IDnvEEOT_ in lto.o
<snip>

@edymtt
Copy link
Contributor

edymtt commented Jan 19, 2022

@swift-ci please smoke test Linux

@finagolfin
Copy link
Member Author

All tests should pass, since cross-compiling the toolchain for non-Darwin platforms isn't tested on the CI.

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - 3e77176

Install command
tar zxf swift-PR-40633-781-ubuntu16.04.tar.gz
More info

@finagolfin
Copy link
Member Author

Failing macOS tests are unrelated to this pull.

@edymtt edymtt merged commit 45aeca8 into swiftlang:main Jan 20, 2022
@finagolfin finagolfin deleted the cross-compile-install-path branch January 20, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants