aboutsummaryrefslogtreecommitdiff
path: root/src/make.bash
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2019-02-25 11:32:00 +0100
committerTobias Klauser <tobias.klauser@gmail.com>2019-03-01 06:06:13 +0000
commite27402aee03b9232b7042ca6cba8b42b15727ef7 (patch)
tree6cc0597d3ff8d52ee3735e8ea078e935578eeeaf /src/make.bash
parent60abc07113e66873d468f54bb5be09fbdd20ca07 (diff)
downloadgo-e27402aee03b9232b7042ca6cba8b42b15727ef7.tar.gz
go-e27402aee03b9232b7042ca6cba8b42b15727ef7.zip
cmd/dist, cmd/link: allow passing default dynamic linker/loader
Add an environment variable to make.bash to allow setting the default dynamic linker/loader. This fixes alpine builds to use /lib/ld-musl-x86_64.so.1: $ readelf -l ../bin/go | grep 'interpreter:' | sed -e 's/^.*interpreter: \(.*\)[]]/\1/' /lib/ld-musl-x86_64.so.1 Also re-enable the internal linker tests that were previously disabled for alpine (CL 41759, CL 41678). Fixes #18243 Updates #19938 This resurrects CL 50070 authored by Jessie Frazelle. Change-Id: I132b5282045a3d60c8568e3b002a7f075eac2d93 Reviewed-on: https://go-review.googlesource.com/c/163977 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/make.bash')
-rwxr-xr-xsrc/make.bash12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/make.bash b/src/make.bash
index 13497eb039..b0e33cf6a4 100755
--- a/src/make.bash
+++ b/src/make.bash
@@ -34,6 +34,9 @@
# controls the default behavior of the linker's -linkmode option. The
# default value depends on the system.
#
+# GO_LDSO: Sets the default dynamic linker/loader (ld.so) to be used
+# by the internal linker.
+#
# CC: Command line to run to compile C code for GOHOSTARCH.
# Default is "gcc". Also supported: "clang".
#
@@ -126,6 +129,15 @@ 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
+fi
+
# Clean old generated file that will cause problems in the build.
rm -f ./runtime/runtime_defs.go