mirror of
https://github.com/golang/go
synced 2024-11-26 05:07:59 -07:00
make.bash: this change modifies Go to correctly select a dyamic linker
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) and musl systems (/lib/ld-musl-x84_64.so.1).
Fixes #45034
Change-Id: I4c9389abc759aa34431dc6c781022636b81d6910
GitHub-Last-Rev: e17b9eb106
GitHub-Pull-Request: golang/go#45036
Reviewed-on: https://go-review.googlesource.com/c/go/+/301989
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
3b0d28808d
commit
9f2a71b6e7
@ -130,13 +130,12 @@ 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 - || continue
|
||||
LDSO=$(readelf -l ./test-musl-ldso | grep 'interpreter:' | sed -e 's/^.*interpreter: \(.*\)[]]/\1/') >/dev/null 2>&1
|
||||
[ -z "$LDSO" ] || export GO_LDSO="$LDSO"
|
||||
rm -f ./test-musl-ldso
|
||||
fi
|
||||
|
||||
# Clean old generated file that will cause problems in the build.
|
||||
|
Loading…
Reference in New Issue
Block a user