From 43e9afa88fcb2e609a720a86e0daf230117cd8a8 Mon Sep 17 00:00:00 2001 From: Dilyn Corner Date: Mon, 15 Mar 2021 15:26:15 -0400 Subject: [PATCH] src/make.bash: Always check for the linker/loader Alpine Linux is not the only musl-based Linux distribution. Checking for /etc/alpine-release excludes many other distributions (Oasis, KISS, Sabotage, sta.li). Not having the correct GO_LDSO set during go builds will result in the wrong linker/loader on nonalpine musl systems for pie builds. Instead, the dynamic loader should be checked for every system and set. This results in the correct dynamic linker being found on glibc systems (/lib/ld-linux-x86-64.so.2 on Arch) and musl systems (/lib/ld-musl-x84_64.so.1 on KISS). --- src/make.bash | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/make.bash b/src/make.bash index b58f27bb1b..a1a8569a64 100755 --- a/src/make.bash +++ b/src/make.bash @@ -130,13 +130,11 @@ if [ "$(uname -s)" = "GNU/kFreeBSD" ]; then export CGO_ENABLED=0 fi -# On Alpine Linux, use the musl dynamic linker/loader -if [ -f "/etc/alpine-release" ]; then - if type readelf >/dev/null 2>&1; then - echo "int main() { return 0; }" | ${CC:-gcc} -o ./test-alpine-ldso -x c - - export GO_LDSO=$(readelf -l ./test-alpine-ldso | grep 'interpreter:' | sed -e 's/^.*interpreter: \(.*\)[]]/\1/') - rm -f ./test-alpine-ldso - fi +# Test which linker/loader our system is using +if type readelf >/dev/null 2>&1; then + echo "int main() { return 0; }" | ${CC:-cc} -o ./test-musl-ldso -x c - + export GO_LDSO=$(readelf -l ./test-musl-ldso | grep 'interpreter:' | sed -e 's/^.*interpreter: \(.*\)[]]/\1/') + rm -f ./test-musl-ldso fi # Clean old generated file that will cause problems in the build.