You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm pretty sure that this change: fbbeffb#diff-36309c5a61d54931f5e256402f92668bL232 broke cross-compilation with SwiftPM. The -target x86_64-unknown-linux or similar is no longer added to the linking swiftc invocation.
For example, trying to cross-compile & link a basic project that you can create using swift package init --type=executable will emit the following swiftc invocations:
In the compile step, everything's still good as we see -target x86_64-unknown-linux. The next swiftc invocation however (to link) is missing -target x86_64-unknown-linux:
The good news for users of the build_ubuntu_cross_compilation_toolchain script is that the fix is very simple: Just add "-target", "x86_64-unknown-linux" to the "extra-swiftc-flags" list. So your resulting ubuntu-xenial-destination.json will look similar to this:
Johannes and I discussed this a little with others on an Apple-internal chat, and I put forward the idea that even though it's a bit more work, the best way to get this would be to get Linux cross-compilation from macOS working without extra configuration (like splicing toolchains together). Given that we have support for this with Android, it seems like we ought to be able to get there with Linux too. At that point, we can do integration testing on a macOS host without having to build the Linux parts on a separate machine (or in a Docker environment).
Additional Detail from JIRA
md5: d4d52b6966c0402cec3532c5816ec822
Issue Description:
I'm pretty sure that this change: fbbeffb#diff-36309c5a61d54931f5e256402f92668bL232 broke cross-compilation with SwiftPM. The
-target x86_64-unknown-linux
or similar is no longer added to the linking swiftc invocation.For example, trying to cross-compile & link a basic project that you can create using
swift package init --type=executable
will emit the following swiftc invocations:compile:
In the compile step, everything's still good as we see
-target x86_64-unknown-linux
. The next swiftc invocation however (to link) is missing-target x86_64-unknown-linux
:which then results in
ld
being invoked to try to link a macOS binary (when run on macOS).@aciidb0mb3r was this deliberate?
The good news for users of the
build_ubuntu_cross_compilation_toolchain
script is that the fix is very simple: Just add"-target", "x86_64-unknown-linux"
to the"extra-swiftc-flags"
list. So your resultingubuntu-xenial-destination.json
will look similar to this:You might need to adopt the paths.
The text was updated successfully, but these errors were encountered: