From 4a349d7dbf5f4200cd3c1902e54256b00022bc69 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Sat, 5 Sep 2020 12:26:40 -0400 Subject: [PATCH] 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: /~https://github.com/rust-lang/rust/pull/70740 --- cross-images/linkwrapper.sh.in | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cross-images/linkwrapper.sh.in b/cross-images/linkwrapper.sh.in index 65cb51f..49cbbaa 100644 --- a/cross-images/linkwrapper.sh.in +++ b/cross-images/linkwrapper.sh.in @@ -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