forge
Explore
Log in

Don't you dare go Hollow

Point the musl link at the bundled rust-lld, not BFD

Browse files at this commit

9e90080644b7ed6d201dcb769fe4904952c5e21aAhmet Kaan GümüşParent: c6d6abc
  • perf
    • point the musl link at the bundled rust-lld, not BFD
Show full message
⚡ perf(ci): point the musl link at the bundled rust-lld, not BFD

The previous commit removed the musl-gcc linker pin expecting rustc's
default to be rust-lld; probing shows the musl target's default is still
cc, which drives GNU BFD. So the config now passes the two link args the
gnu target's default uses: -B<sysroot>/.../bin/gcc-ld -fuse-ld=lld,
routing the link through rustc's bundled ld.lld wrapper. A warm relink
of this binary measures 142s under BFD against 23s under lld. Verified
locally that the generated config links musl statically via lld.
.github/workflows/main.ymlmodified+16 -9
@@ -63,16 +63,23 @@ jobs:
63 run: |63 run: |
64 set -euo pipefail64 set -euo pipefail
65 # `topcoat asset bundle` runs its own `cargo build` and strips every65 # `topcoat asset bundle` runs its own `cargo build` and strips every
66- # CARGO_* variable from it, so the target cannot be passed by66+ # CARGO_* variable from it, so neither the target nor its link flags
67- # environment; it goes into the cargo config that inner build reads.67+ # can be passed by environment; they go into the cargo config that
68- # This file is written in CI only; it is not committed.68+ # inner build reads. This file is written in CI only; it is not
69+ # committed.
69 mkdir -p .cargo70 mkdir -p .cargo
70- printf '[build]\ntarget = "%s"\n' "$TARGET" >> .cargo/config.toml71+ {
71- # The linker stays rustc's default (the bundled rust-lld): a warm72+ printf '[build]\ntarget = "%s"\n\n' "$TARGET"
72- # relink of this binary measured 142s under musl-gcc's BFD against73+ printf '[target.x86_64-unknown-linux-musl]\n'
73- # 23s under rust-lld, and that link was the largest single chunk of74+ # Link with the toolchain's bundled rust-lld, not the BFD that cc
74- # the deploy build. musl-gcc remains the C compiler below — ring's75+ # would pick: a warm relink of this binary measured 142s under
75- # assembly needs it, and lld links the objects it produces.76+ # BFD against 23s under lld, and that link is the largest single
77+ # chunk of the deploy build. `link-self-contained=+linker` would
78+ # say this directly, but its values are unstable — so the cc
79+ # driver is pointed at rustc's own gcc-ld/ld.lld wrapper, the
80+ # same mechanism the gnu target's default linker uses.
81+ printf 'rustflags = ["-C", "link-arg=-B%s/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld", "-C", "link-arg=-fuse-ld=lld"]\n' "$(rustc --print sysroot)"
82+ } >> .cargo/config.toml
76 # C dependencies (ring, under lettre's TLS) compile against musl too.83 # C dependencies (ring, under lettre's TLS) compile against musl too.
77 echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV"84 echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV"
78 85