diff options
Diffstat (limited to 'meta/recipes-devtools/go/go-1.10/0007-cmd-go-make-GOROOT-precious-by-default.patch')
-rw-r--r-- | meta/recipes-devtools/go/go-1.10/0007-cmd-go-make-GOROOT-precious-by-default.patch | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.10/0007-cmd-go-make-GOROOT-precious-by-default.patch b/meta/recipes-devtools/go/go-1.10/0007-cmd-go-make-GOROOT-precious-by-default.patch new file mode 100644 index 0000000000..72427627bc --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0007-cmd-go-make-GOROOT-precious-by-default.patch | |||
@@ -0,0 +1,108 @@ | |||
1 | From f98aa287941417226a6e4f78759f8a5e19732cde Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Fri, 2 Mar 2018 06:00:20 -0800 | ||
4 | Subject: [PATCH 7/9] cmd/go: make GOROOT precious by default | ||
5 | |||
6 | The go build tool normally rebuilds whatever it detects is | ||
7 | stale. This can be a problem when GOROOT is intended to | ||
8 | be read-only and the go runtime has been built as a shared | ||
9 | library, since we don't want every application to be rebuilding | ||
10 | the shared runtime - particularly in cross-build/packaging | ||
11 | setups, since that would lead to 'abi mismatch' runtime errors. | ||
12 | |||
13 | This patch prevents the install and linkshared actions from | ||
14 | installing to GOROOT unless overridden with the GOROOT_OVERRIDE | ||
15 | environment variable. | ||
16 | |||
17 | Upstream-Status: Inappropriate [OE specific] | ||
18 | |||
19 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
20 | --- | ||
21 | src/cmd/go/internal/work/action.go | 3 +++ | ||
22 | src/cmd/go/internal/work/build.go | 5 +++++ | ||
23 | src/cmd/go/internal/work/exec.go | 25 +++++++++++++++++++++++++ | ||
24 | 3 files changed, 33 insertions(+) | ||
25 | |||
26 | diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go | ||
27 | index 9f1f8f8a50..a382880474 100644 | ||
28 | --- a/src/cmd/go/internal/work/action.go | ||
29 | +++ b/src/cmd/go/internal/work/action.go | ||
30 | @@ -563,6 +563,9 @@ func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) { | ||
31 | if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] { | ||
32 | continue | ||
33 | } | ||
34 | + if goRootPrecious && (p1.Standard || p1.Goroot) { | ||
35 | + continue | ||
36 | + } | ||
37 | haveShlib[filepath.Base(p1.Shlib)] = true | ||
38 | // TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild, | ||
39 | // we'll end up building an overall library or executable that depends at runtime | ||
40 | diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go | ||
41 | index 57b7b00879..e2ba95420e 100644 | ||
42 | --- a/src/cmd/go/internal/work/build.go | ||
43 | +++ b/src/cmd/go/internal/work/build.go | ||
44 | @@ -143,6 +143,7 @@ See also: go install, go get, go clean. | ||
45 | } | ||
46 | |||
47 | const concurrentGCBackendCompilationEnabledByDefault = true | ||
48 | +var goRootPrecious bool = true | ||
49 | |||
50 | func init() { | ||
51 | // break init cycle | ||
52 | @@ -156,6 +157,10 @@ func init() { | ||
53 | |||
54 | AddBuildFlags(CmdBuild) | ||
55 | AddBuildFlags(CmdInstall) | ||
56 | + | ||
57 | + if x := os.Getenv("GOROOT_OVERRIDE"); x != "" { | ||
58 | + goRootPrecious = false | ||
59 | + } | ||
60 | } | ||
61 | |||
62 | // Note that flags consulted by other parts of the code | ||
63 | diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go | ||
64 | index b0f6b45647..c8f266a8ad 100644 | ||
65 | --- a/src/cmd/go/internal/work/exec.go | ||
66 | +++ b/src/cmd/go/internal/work/exec.go | ||
67 | @@ -371,6 +371,23 @@ func (b *Builder) build(a *Action) (err error) { | ||
68 | return fmt.Errorf("missing or invalid binary-only package") | ||
69 | } | ||
70 | |||
71 | + if goRootPrecious && (a.Package.Standard || a.Package.Goroot) { | ||
72 | + _, err := os.Stat(a.Package.Target) | ||
73 | + if err == nil { | ||
74 | + a.built = a.Package.Target | ||
75 | + a.Target = a.Package.Target | ||
76 | + a.buildID = b.fileHash(a.Package.Target) | ||
77 | + a.Package.Stale = false | ||
78 | + a.Package.StaleReason = "GOROOT-resident package" | ||
79 | + return nil | ||
80 | + } | ||
81 | + if b.ComputeStaleOnly { | ||
82 | + a.Package.Stale = true | ||
83 | + a.Package.StaleReason = "missing or invalid GOROOT-resident package" | ||
84 | + return nil | ||
85 | + } | ||
86 | + } | ||
87 | + | ||
88 | if err := b.Mkdir(a.Objdir); err != nil { | ||
89 | return err | ||
90 | } | ||
91 | @@ -1097,6 +1114,14 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) { | ||
92 | return nil | ||
93 | } | ||
94 | |||
95 | + if goRootPrecious && a.Package != nil { | ||
96 | + p := a.Package | ||
97 | + if p.Standard || p.Goroot { | ||
98 | + err := fmt.Errorf("attempting to install package %s into read-only GOROOT", p.ImportPath) | ||
99 | + return err | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | if err := b.Mkdir(a.Objdir); err != nil { | ||
104 | return err | ||
105 | } | ||
106 | -- | ||
107 | 2.14.1 | ||
108 | |||