Commit 4c74376
committed
ci/release: Specify target and static linking of C runtime explicitly
Without specifying the target, `upload-rust-binary-action` uses the host
target, which in case of Linux runners is `*-unknown-linux-gnu`. We are
are interested in producing `*-musl` binaries, not `*-gnu`, since the
latter does not support static linking of libc and C runtime and
therefore:
1) It won't work on distros using other libcs.
2) It won't work even on GNU distros with glibc older than the one used
for build (glibc is forwards compatible, but not backwards
compatible).
Static `*-musl` binaries will work fine on all distros, including the
ones with GNU userland. cargo-binstall falls back to downloading
`*-musl` binaries even on `*-gnu` hosts if a `*-gnu` binary is not
available[0].
Make use of the `xtask musl-sysroot-url` command to fetch the sysroot
containing libstd++ linked to musl, then pass the found library via
`CXXSTDLIB_PATH` environment variable.
On top of that, make sure that libc and C runtime are actually linked
statically by specifying `-C target-feature=+crt-static` rustflag. As of
today, that's still a default option on the most of `*-musl`
targets[1][2], but it's being phased out in favor of dynamic linking
being the default option.[3][4][5]
[0] https://github.com/cargo-bins/cargo-binstall/blob/efd0e93316a9af26e9847b5090b5ab2419befad4/crates/detect-targets/src/detect/linux.rs#L78-L81
[1] https://github.com/rust-lang/rust/blob/672388edbee9e93c35e5fdf7dac818a6612a5103/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs#L19-L20
[2] https://github.com/rust-lang/rust/blob/672388edbee9e93c35e5fdf7dac818a6612a5103/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs#L17-L18
[3] rust-lang/compiler-team#422
[4] rust-lang/rust#133386
[5] rust-lang/rust#1445131 parent 0f9ed18 commit 4c74376
1 file changed
+14
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
| |||
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
58 | 70 | | |
59 | 71 | | |
60 | 72 | | |
| 73 | + | |
| 74 | + | |
61 | 75 | | |
62 | 76 | | |
63 | 77 | | |
| |||
0 commit comments