defaultcflags string
defaultldflags string
defaultpkgconfig string
+ defaultldso string
rebuildall bool
defaultclang bool
}
defaultpkgconfig = b
+ defaultldso = os.Getenv("GO_LDSO")
+
// For tools being invoked but also for os.ExpandEnv.
os.Setenv("GO386", go386)
os.Setenv("GOARCH", goarch)
fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
+ fmt.Fprintf(&buf, "const defaultGO_LDSO = `%s`\n", defaultldso)
fmt.Fprintf(&buf, "const version = `%s`\n", findgoversion())
fmt.Fprintf(&buf, "const stackGuardMultiplierDefault = %d\n", stackGuardMultiplierDefault())
fmt.Fprintf(&buf, "const goexperiment = `%s`\n", os.Getenv("GOEXPERIMENT"))
}
// Test internal linking of PIE binaries where it is supported.
- if goos == "linux" && goarch == "amd64" && !isAlpineLinux() {
- // Issue 18243: We don't have a way to set the default
- // dynamic linker used in internal linking mode. So
- // this test is skipped on Alpine.
+ if goos == "linux" && goarch == "amd64" {
t.tests = append(t.tests, distTest{
name: "pie_internal",
heading: "internal linking of -buildmode=pie",
if goarch == "arm64" || goarch == "mips64" || goarch == "mips64le" || goarch == "mips" || goarch == "mipsle" {
return false
}
- if isAlpineLinux() {
- // Issue 18243.
- return false
- }
return true
}
GOARM = goarm()
GOMIPS = gomips()
GOMIPS64 = gomips64()
+ GO_LDSO = defaultGO_LDSO
Version = version
)
sh.type_ = SHT_PROGBITS
sh.flags = SHF_ALLOC
sh.addralign = 1
+
+ if interpreter == "" && objabi.GO_LDSO != "" {
+ interpreter = objabi.GO_LDSO
+ }
+
if interpreter == "" {
switch ctxt.HeadType {
case objabi.Hlinux:
# 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".
#
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