-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lang/go: support older OS versions using legacysupport PG.
Fixes: https://trac.macports.org/ticket/58138 This adds a simple patch and changes the go build procedure to inject the legacy-support library into all compiled binaries, getting support for 10.9 and probably older OS versions. Users will have to do the same when compiling go programs, the new note details this process. A separate patch is needed to workaround a base bug which won't let ports define environment variables with a quote character in them. Since base is fixed, this is conditional and not used for newer base versions.
- Loading branch information
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- src/cmd/dist/build.go.old 2019-03-14 20:43:37.000000000 +0100 | ||
+++ src/cmd/dist/build.go 2019-03-19 11:46:25.000000000 +0100 | ||
@@ -190,6 +190,7 @@ func xinit() { | ||
} | ||
|
||
gogcflags = os.Getenv("BOOT_GO_GCFLAGS") | ||
+ goldflags = os.Getenv("BOOT_GO_LDFLAGS") | ||
|
||
cc, cxx := "gcc", "g++" | ||
if defaultclang { | ||
@@ -646,7 +647,11 @@ func runInstall(dir string, ch chan stru | ||
if elem == "go" { | ||
elem = "go_bootstrap" | ||
} | ||
- link = []string{pathf("%s/link", tooldir), "-o", pathf("%s/%s%s", tooldir, elem, exe)} | ||
+ link = []string{pathf("%s/link", tooldir)} | ||
+ if goldflags != "" { | ||
+ link = append(link, goldflags) | ||
+ } | ||
+ link = append (link, "-o", pathf("%s/%s%s", tooldir, elem, exe)) | ||
targ = len(link) - 1 | ||
} | ||
ttarg := mtime(link[targ]) | ||
@@ -1237,7 +1242,7 @@ func cmdbootstrap() { | ||
} | ||
|
||
gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now | ||
- goldflags = os.Getenv("GO_LDFLAGS") | ||
+ goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now | ||
goBootstrap := pathf("%s/go_bootstrap", tooldir) | ||
cmdGo := pathf("%s/go", gobin) | ||
if debug { |
71 changes: 71 additions & 0 deletions
71
lang/go/files/workaround-base-env-issue-GO_EXT_LDFLAGS.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- src/cmd/dist/build.go.old 2019-03-19 14:24:21.000000000 +0100 | ||
+++ src/cmd/dist/build.go 2019-03-19 14:30:14.000000000 +0100 | ||
@@ -38,6 +38,7 @@ var ( | ||
goextlinkenabled string | ||
gogcflags string // For running built compiler | ||
goldflags string | ||
+ goextldflags string // Flags passed to external linker, if enabled | ||
workdir string | ||
tooldir string | ||
oldgoos string | ||
@@ -191,6 +192,7 @@ func xinit() { | ||
|
||
gogcflags = os.Getenv("BOOT_GO_GCFLAGS") | ||
goldflags = os.Getenv("BOOT_GO_LDFLAGS") | ||
+ goextldflags = os.Getenv("BOOT_GO_EXT_LDFLAGS") | ||
|
||
cc, cxx := "gcc", "g++" | ||
if defaultclang { | ||
@@ -651,6 +653,9 @@ func runInstall(dir string, ch chan stru | ||
if goldflags != "" { | ||
link = append(link, goldflags) | ||
} | ||
+ if goextldflags != "" { | ||
+ link = append(link, "-extldflags=" + goextldflags) | ||
+ } | ||
link = append (link, "-o", pathf("%s/%s%s", tooldir, elem, exe)) | ||
targ = len(link) - 1 | ||
} | ||
@@ -1243,6 +1248,7 @@ func cmdbootstrap() { | ||
|
||
gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now | ||
goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now | ||
+ goextldflags = os.Getenv("GO_EXT_LDFLAGS") // we were using $BOOT_GO_EXT_LDFLAGS until now | ||
goBootstrap := pathf("%s/go_bootstrap", tooldir) | ||
cmdGo := pathf("%s/go", gobin) | ||
if debug { | ||
@@ -1378,7 +1384,12 @@ func cmdbootstrap() { | ||
} | ||
|
||
func goInstall(goBinary string, args ...string) { | ||
- installCmd := []string{goBinary, "install", "-gcflags=all=" + gogcflags, "-ldflags=all=" + goldflags} | ||
+ installCmd := []string{goBinary, "install", "-gcflags=all=" + gogcflags} | ||
+ if goextldflags != "" { | ||
+ installCmd = append(installCmd, "-ldflags=all=" + goldflags + " \"-extldflags=" + goextldflags + "\"") | ||
+ } else { | ||
+ installCmd = append(installCmd, "-ldflags=all=" + goldflags) | ||
+ } | ||
if vflag > 0 { | ||
installCmd = append(installCmd, "-v") | ||
} | ||
@@ -1392,12 +1403,15 @@ func goInstall(goBinary string, args ... | ||
} | ||
|
||
func checkNotStale(goBinary string, targets ...string) { | ||
+ checkCmd := []string{goBinary, "list", "-gcflags=all=" + gogcflags} | ||
+ if goextldflags != "" { | ||
+ checkCmd = append(checkCmd, "-ldflags=all=" + goldflags + " \"-extldflags=" + goextldflags + "\"") | ||
+ } else { | ||
+ checkCmd = append(checkCmd, "-ldflags=all=" + goldflags) | ||
+ } | ||
+ checkCmd = append(checkCmd, "-f={{if .Stale}}\tSTALE {{.ImportPath}}: {{.StaleReason}}{{end}}") | ||
out := run(goroot, CheckExit, | ||
- append([]string{ | ||
- goBinary, | ||
- "list", "-gcflags=all=" + gogcflags, "-ldflags=all=" + goldflags, | ||
- "-f={{if .Stale}}\tSTALE {{.ImportPath}}: {{.StaleReason}}{{end}}", | ||
- }, targets...)...) | ||
+ append(checkCmd, targets...)...) | ||
if strings.Contains(out, "\tSTALE ") { | ||
os.Setenv("GODEBUG", "gocachehash=1") | ||
for _, target := range []string{"runtime/internal/sys", "cmd/dist", "cmd/link"} { |