Skip to content

Commit 4a349d7

Browse files
committed
cross-images: attempt to fix musl static builds
It looks like Rust 1.46 introduced a default static PIE link mode for x86_64-unknown-linux-musl that is not compatible with our epic hacks to get a static binary going. Work around them. Cf: rust-lang/rust#70740
1 parent 0253bfa commit 4a349d7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cross-images/linkwrapper.sh.in

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,21 @@ args=()
1515

1616
for arg in "$@"; do
1717
if [[ $arg = *"Bdynamic"* ]]; then
18-
true # we do not want this arg
18+
true # we do not want this arg
19+
elif [[ $arg = *"static-pie"* ]]; then
20+
# As of rust 1.46, the Rust musl target defaults to building in static PIE mode:
21+
# https://github.com/rust-lang/rust/pull/70740
22+
# This seems to conflict with our hacks to get static linking with C++ code.
23+
# So for now we disable this feature. (The next `if` case is also relevant.)
24+
args+=("-no-pie")
25+
elif [[ $arg = *"rcrt1.o"* ]]; then
26+
args+=($(echo "$arg" |sed -e s/rcrt1/crt1/))
1927
elif [[ $arg = *"crti.o"* ]]; then
20-
args+=("$arg" "$gcclibdir/crtbeginT.o" "-Bstatic")
28+
args+=("$arg" "$gcclibdir/crtbeginT.o" "-Bstatic")
2129
elif [[ $arg = *"crtn.o"* ]]; then
22-
args+=("-lgcc" "-lgcc_eh" "-lc" "$gcclibdir/crtend.o" "$arg")
30+
args+=("-lgcc" "-lgcc_eh" "-lc" "$gcclibdir/crtend.o" "$arg")
2331
else
24-
args+=("$arg")
32+
args+=("$arg")
2533
fi
2634
done
2735

0 commit comments

Comments
 (0)