Skip to content

Commit

Permalink
cross-images: attempt to fix musl static builds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pkgw committed Sep 5, 2020
1 parent 0253bfa commit 4a349d7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cross-images/linkwrapper.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ args=()

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

Expand Down

0 comments on commit 4a349d7

Please sign in to comment.