diff options
Diffstat (limited to 'meta/recipes-devtools/go/go-1.11/0007-cmd-go-make-GOROOT-precious-by-default.patch')
-rw-r--r-- | meta/recipes-devtools/go/go-1.11/0007-cmd-go-make-GOROOT-precious-by-default.patch | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/meta/recipes-devtools/go/go-1.11/0007-cmd-go-make-GOROOT-precious-by-default.patch b/meta/recipes-devtools/go/go-1.11/0007-cmd-go-make-GOROOT-precious-by-default.patch deleted file mode 100644 index 29ef947abd..0000000000 --- a/meta/recipes-devtools/go/go-1.11/0007-cmd-go-make-GOROOT-precious-by-default.patch +++ /dev/null | |||
@@ -1,106 +0,0 @@ | |||
1 | From 7cc60b3887be2d5674b9f5d422d022976cf205e5 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] 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 | --- | ||
22 | src/cmd/go/internal/work/action.go | 3 +++ | ||
23 | src/cmd/go/internal/work/build.go | 5 +++++ | ||
24 | src/cmd/go/internal/work/exec.go | 25 +++++++++++++++++++++++++ | ||
25 | 3 files changed, 33 insertions(+) | ||
26 | |||
27 | Index: go/src/cmd/go/internal/work/action.go | ||
28 | =================================================================== | ||
29 | --- go.orig/src/cmd/go/internal/work/action.go | ||
30 | +++ go/src/cmd/go/internal/work/action.go | ||
31 | @@ -600,6 +600,9 @@ func (b *Builder) addTransitiveLinkDeps( | ||
32 | if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] { | ||
33 | continue | ||
34 | } | ||
35 | + if goRootPrecious && (p1.Standard || p1.Goroot) { | ||
36 | + continue | ||
37 | + } | ||
38 | haveShlib[filepath.Base(p1.Shlib)] = true | ||
39 | // TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild, | ||
40 | // we'll end up building an overall library or executable that depends at runtime | ||
41 | Index: go/src/cmd/go/internal/work/build.go | ||
42 | =================================================================== | ||
43 | --- go.orig/src/cmd/go/internal/work/build.go | ||
44 | +++ go/src/cmd/go/internal/work/build.go | ||
45 | @@ -147,6 +147,7 @@ See also: go install, go get, go clean. | ||
46 | } | ||
47 | |||
48 | const concurrentGCBackendCompilationEnabledByDefault = true | ||
49 | +var goRootPrecious bool = true | ||
50 | |||
51 | func init() { | ||
52 | // break init cycle | ||
53 | @@ -160,6 +161,10 @@ func init() { | ||
54 | |||
55 | AddBuildFlags(CmdBuild) | ||
56 | AddBuildFlags(CmdInstall) | ||
57 | + | ||
58 | + if x := os.Getenv("GOROOT_OVERRIDE"); x != "" { | ||
59 | + goRootPrecious = false | ||
60 | + } | ||
61 | } | ||
62 | |||
63 | // Note that flags consulted by other parts of the code | ||
64 | Index: go/src/cmd/go/internal/work/exec.go | ||
65 | =================================================================== | ||
66 | --- go.orig/src/cmd/go/internal/work/exec.go | ||
67 | +++ go/src/cmd/go/internal/work/exec.go | ||
68 | @@ -436,6 +436,23 @@ func (b *Builder) build(a *Action) (err | ||
69 | return fmt.Errorf("missing or invalid binary-only package; expected file %q", a.Package.Target) | ||
70 | } | ||
71 | |||
72 | + if goRootPrecious && (a.Package.Standard || a.Package.Goroot) { | ||
73 | + _, err := os.Stat(a.Package.Target) | ||
74 | + if err == nil { | ||
75 | + a.built = a.Package.Target | ||
76 | + a.Target = a.Package.Target | ||
77 | + a.buildID = b.fileHash(a.Package.Target) | ||
78 | + a.Package.Stale = false | ||
79 | + a.Package.StaleReason = "GOROOT-resident package" | ||
80 | + return nil | ||
81 | + } | ||
82 | + a.Package.Stale = true | ||
83 | + a.Package.StaleReason = "missing or invalid GOROOT-resident package" | ||
84 | + if b.IsCmdList { | ||
85 | + return nil | ||
86 | + } | ||
87 | + } | ||
88 | + | ||
89 | if err := b.Mkdir(a.Objdir); err != nil { | ||
90 | return err | ||
91 | } | ||
92 | @@ -1438,6 +1455,14 @@ func BuildInstallFunc(b *Builder, a *Act | ||
93 | return nil | ||
94 | } | ||
95 | |||
96 | + if goRootPrecious && a.Package != nil { | ||
97 | + p := a.Package | ||
98 | + if p.Standard || p.Goroot { | ||
99 | + err := fmt.Errorf("attempting to install package %s into read-only GOROOT", p.ImportPath) | ||
100 | + return err | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
104 | if err := b.Mkdir(a.Objdir); err != nil { | ||
105 | return err | ||
106 | } | ||