File tree Expand file tree Collapse file tree 6 files changed +23
-8
lines changed Expand file tree Collapse file tree 6 files changed +23
-8
lines changed Original file line number Diff line number Diff line change 48
48
defaultcflags string
49
49
defaultldflags string
50
50
defaultpkgconfig string
51
+ defaultldso string
51
52
52
53
rebuildall bool
53
54
defaultclang bool
@@ -207,6 +208,8 @@ func xinit() {
207
208
}
208
209
defaultpkgconfig = b
209
210
211
+ defaultldso = os .Getenv ("GO_LDSO" )
212
+
210
213
// For tools being invoked but also for os.ExpandEnv.
211
214
os .Setenv ("GO386" , go386 )
212
215
os .Setenv ("GOARCH" , goarch )
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ func mkzbootstrap(file string) {
76
76
fmt .Fprintf (& buf , "const defaultGOOS = runtime.GOOS\n " )
77
77
fmt .Fprintf (& buf , "const defaultGOARCH = runtime.GOARCH\n " )
78
78
fmt .Fprintf (& buf , "const defaultGO_EXTLINK_ENABLED = `%s`\n " , goextlinkenabled )
79
+ fmt .Fprintf (& buf , "const defaultGO_LDSO = `%s`\n " , defaultldso )
79
80
fmt .Fprintf (& buf , "const version = `%s`\n " , findgoversion ())
80
81
fmt .Fprintf (& buf , "const stackGuardMultiplier = %d\n " , stackGuardMultiplier ())
81
82
fmt .Fprintf (& buf , "const goexperiment = `%s`\n " , os .Getenv ("GOEXPERIMENT" ))
Original file line number Diff line number Diff line change @@ -568,10 +568,7 @@ func (t *tester) registerTests() {
568
568
}
569
569
570
570
// Test internal linking of PIE binaries where it is supported.
571
- if goos == "linux" && goarch == "amd64" && ! isAlpineLinux () {
572
- // Issue 18243: We don't have a way to set the default
573
- // dynamic linker used in internal linking mode. So
574
- // this test is skipped on Alpine.
571
+ if goos == "linux" && goarch == "amd64" {
575
572
t .tests = append (t .tests , distTest {
576
573
name : "pie_internal" ,
577
574
heading : "internal linking of -buildmode=pie" ,
@@ -925,10 +922,6 @@ func (t *tester) internalLink() bool {
925
922
if goarch == "arm64" || goarch == "mips64" || goarch == "mips64le" || goarch == "mips" || goarch == "mipsle" {
926
923
return false
927
924
}
928
- if isAlpineLinux () {
929
- // Issue 18243.
930
- return false
931
- }
932
925
return true
933
926
}
934
927
Original file line number Diff line number Diff line change 28
28
GOARM = goarm ()
29
29
GOMIPS = gomips ()
30
30
GOMIPS64 = gomips64 ()
31
+ GO_LDSO = envOr ("GO_LDSO" , defaultGO_LDSO )
31
32
Version = version
32
33
)
33
34
Original file line number Diff line number Diff line change @@ -1840,6 +1840,11 @@ func Asmbelf(ctxt *Link, symo int64) {
1840
1840
sh .type_ = SHT_PROGBITS
1841
1841
sh .flags = SHF_ALLOC
1842
1842
sh .addralign = 1
1843
+
1844
+ if interpreter == "" && objabi .GO_LDSO != "" {
1845
+ interpreter = objabi .GO_LDSO
1846
+ }
1847
+
1843
1848
if interpreter == "" {
1844
1849
switch ctxt .HeadType {
1845
1850
case objabi .Hlinux :
Original file line number Diff line number Diff line change 34
34
# controls the default behavior of the linker's -linkmode option. The
35
35
# default value depends on the system.
36
36
#
37
+ # GO_LDSO: Sets the default dynamic linker/loader (ld.so) to be used
38
+ # by the internal linker.
39
+ #
37
40
# CC: Command line to run to compile C code for GOHOSTARCH.
38
41
# Default is "gcc". Also supported: "clang".
39
42
#
@@ -126,6 +129,15 @@ if [ "$(uname -s)" = "GNU/kFreeBSD" ]; then
126
129
export CGO_ENABLED=0
127
130
fi
128
131
132
+ # On Alpine Linux, use the musl dynamic linker/loader
133
+ if [ -f " /etc/alpine-release" ]; then
134
+ if type readelf > /dev/null 2>&1 ; then
135
+ echo " int main() { return 0; }" | ${CC:- gcc} -o ./test-alpine-ldso -x c -
136
+ export GO_LDSO=$( readelf -l ./test-alpine-ldso | grep ' interpreter:' | sed -e ' s/^.*interpreter: \(.*\)[]]/\1/' )
137
+ rm -f ./test-alpine-ldso
138
+ fi
139
+ fi
140
+
129
141
# Clean old generated file that will cause problems in the build.
130
142
rm -f ./runtime/runtime_defs.go
131
143
You can’t perform that action at this time.
0 commit comments