diff options
author | Matt Madison <matt@madison.systems> | 2018-03-04 13:09:25 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-03-06 06:43:10 -0800 |
commit | 7a4ca89b557648d9aae30b405f6be09b4a383abe (patch) | |
tree | fb131b91c54b054ad525566d2da014abaa7c8f9f /meta/recipes-devtools/go/go-1.10 | |
parent | 26227695b350056225e9d309defdcd66573b79bb (diff) | |
download | poky-7a4ca89b557648d9aae30b405f6be09b4a383abe.tar.gz |
go: update go 1.9 -> go 1.10
* Patches and recipes reworked for go 1.10's significant
changes to its bootstrap and build steps.
* Update go1.4 source tarball used for go-native
bootstrapping to the version recommended
in the current go documentation
* Remove test data from installed sources to eliminate
some packaging QA warnings
* Set GOCACHE to 'off' to disable 1.10's build caching
in the go recipes and bbclass
* Update go_do_compile to compile both static and
dynamic objects dynamic linking is in use, since
go1.10's build tool is pickier about this
(From OE-Core rev: 4fd749ca6450a4870be1c1e13802f084b6eb0db6)
Signed-off-by: Matt Madison <matt@madison.systems>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/go/go-1.10')
9 files changed, 977 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.10/0001-allow-CC-and-CXX-to-have-multiple-words.patch b/meta/recipes-devtools/go/go-1.10/0001-allow-CC-and-CXX-to-have-multiple-words.patch new file mode 100644 index 0000000000..3bb33b0146 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0001-allow-CC-and-CXX-to-have-multiple-words.patch | |||
@@ -0,0 +1,33 @@ | |||
1 | From 7a7de46129fa6859fb6311096eb9f54c53c7fe2f Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Mon, 19 Feb 2018 08:49:33 -0800 | ||
4 | Subject: [PATCH 1/9] allow CC and CXX to have multiple words | ||
5 | |||
6 | Upstream-Status: Inappropriate [OE specific] | ||
7 | |||
8 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
9 | --- | ||
10 | src/cmd/go/internal/envcmd/env.go | 4 ++-- | ||
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go | ||
14 | index 603f7b5060..f891123f9c 100644 | ||
15 | --- a/src/cmd/go/internal/envcmd/env.go | ||
16 | +++ b/src/cmd/go/internal/envcmd/env.go | ||
17 | @@ -82,11 +82,11 @@ func MkEnv() []cfg.EnvVar { | ||
18 | |||
19 | cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch) | ||
20 | if env := strings.Fields(os.Getenv("CC")); len(env) > 0 { | ||
21 | - cc = env[0] | ||
22 | + cc = strings.Join(env, " ") | ||
23 | } | ||
24 | cxx := cfg.DefaultCXX(cfg.Goos, cfg.Goarch) | ||
25 | if env := strings.Fields(os.Getenv("CXX")); len(env) > 0 { | ||
26 | - cxx = env[0] | ||
27 | + cxx = strings.Join(env, " ") | ||
28 | } | ||
29 | env = append(env, cfg.EnvVar{Name: "CC", Value: cc}) | ||
30 | env = append(env, cfg.EnvVar{Name: "CXX", Value: cxx}) | ||
31 | -- | ||
32 | 2.14.1 | ||
33 | |||
diff --git a/meta/recipes-devtools/go/go-1.10/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch b/meta/recipes-devtools/go/go-1.10/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch new file mode 100644 index 0000000000..74f37a99ef --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch | |||
@@ -0,0 +1,220 @@ | |||
1 | From 8b2feaee81d7a16adc59e61d06c1e7314d3a5408 Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Mon, 19 Feb 2018 08:50:59 -0800 | ||
4 | Subject: [PATCH 2/9] cmd/go: make content-based hash generation less pedantic | ||
5 | |||
6 | Go 1.10's build tool now uses content-based hashes to | ||
7 | determine when something should be built or re-built. | ||
8 | This same mechanism is used to maintain a built-artifact | ||
9 | cache for speeding up builds. | ||
10 | |||
11 | However, the hashes it generates include information that | ||
12 | doesn't work well with OE, nor with using a shared runtime | ||
13 | library. | ||
14 | |||
15 | First, it embeds path names to source files, unless | ||
16 | building within GOROOT. This prevents the building | ||
17 | of a package in GOPATH for later staging into GOROOT. | ||
18 | |||
19 | This patch adds support for the environment variable | ||
20 | GOPATH_OMIT_IN_ACTIONID. If present, path name | ||
21 | embedding is disabled. | ||
22 | |||
23 | Second, if cgo is enabled, the build ID for cgo-related | ||
24 | packages will include the current value of the environment | ||
25 | variables for invoking the compiler (CC, CXX, FC) and | ||
26 | any CGO_xxFLAGS variables. Only if the settings used | ||
27 | during a compilation exactly match, character for character, | ||
28 | the values used for compiling runtime/cgo or any other | ||
29 | cgo-enabled package being imported, will the tool | ||
30 | decide that the imported package is up-to-date. | ||
31 | |||
32 | This is done to help ensure correctness, but is overly | ||
33 | simplistic and effectively prevents the reuse of built | ||
34 | artifacts that use cgo (or shared runtime, which includes | ||
35 | runtime/cgo). | ||
36 | |||
37 | This patch filters out all compiler flags except those | ||
38 | beginning with '-m'. The default behavior can be restored | ||
39 | by setting the CGO_PEDANTIC environment variable. | ||
40 | |||
41 | Upstream-Status: Inappropriate [OE specific] | ||
42 | |||
43 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
44 | --- | ||
45 | src/cmd/go/internal/envcmd/env.go | 2 +- | ||
46 | src/cmd/go/internal/work/exec.go | 63 ++++++++++++++++++++++++++++----------- | ||
47 | 2 files changed, 46 insertions(+), 19 deletions(-) | ||
48 | |||
49 | diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go | ||
50 | index f891123f9c..ebacfbfdbc 100644 | ||
51 | --- a/src/cmd/go/internal/envcmd/env.go | ||
52 | +++ b/src/cmd/go/internal/envcmd/env.go | ||
53 | @@ -113,7 +113,7 @@ func findEnv(env []cfg.EnvVar, name string) string { | ||
54 | func ExtraEnvVars() []cfg.EnvVar { | ||
55 | var b work.Builder | ||
56 | b.Init() | ||
57 | - cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}) | ||
58 | + cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}, false) | ||
59 | if err != nil { | ||
60 | // Should not happen - b.CFlags was given an empty package. | ||
61 | fmt.Fprintf(os.Stderr, "go: invalid cflags: %v\n", err) | ||
62 | diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go | ||
63 | index c4c1500eb2..b0f6b45647 100644 | ||
64 | --- a/src/cmd/go/internal/work/exec.go | ||
65 | +++ b/src/cmd/go/internal/work/exec.go | ||
66 | @@ -173,6 +173,8 @@ func (b *Builder) Do(root *Action) { | ||
67 | wg.Wait() | ||
68 | } | ||
69 | |||
70 | +var omitGopath = os.Getenv("GOPATH_OMIT_IN_ACTIONID") != "" | ||
71 | + | ||
72 | // buildActionID computes the action ID for a build action. | ||
73 | func (b *Builder) buildActionID(a *Action) cache.ActionID { | ||
74 | p := a.Package | ||
75 | @@ -189,7 +191,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { | ||
76 | // but it does not hide the exact value of $GOPATH. | ||
77 | // Include the full dir in that case. | ||
78 | // Assume b.WorkDir is being trimmed properly. | ||
79 | - if !p.Goroot && !strings.HasPrefix(p.Dir, b.WorkDir) { | ||
80 | + if !p.Goroot && !omitGopath && !strings.HasPrefix(p.Dir, b.WorkDir) { | ||
81 | fmt.Fprintf(h, "dir %s\n", p.Dir) | ||
82 | } | ||
83 | fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch) | ||
84 | @@ -197,13 +199,13 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { | ||
85 | fmt.Fprintf(h, "omitdebug %v standard %v local %v prefix %q\n", p.Internal.OmitDebug, p.Standard, p.Internal.Local, p.Internal.LocalPrefix) | ||
86 | if len(p.CgoFiles)+len(p.SwigFiles) > 0 { | ||
87 | fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo")) | ||
88 | - cppflags, cflags, cxxflags, fflags, _, _ := b.CFlags(p) | ||
89 | - fmt.Fprintf(h, "CC=%q %q %q\n", b.ccExe(), cppflags, cflags) | ||
90 | + cppflags, cflags, cxxflags, fflags, _, _ := b.CFlags(p, true) | ||
91 | + fmt.Fprintf(h, "CC=%q %q %q\n", b.ccExe(true), cppflags, cflags) | ||
92 | if len(p.CXXFiles)+len(p.SwigFiles) > 0 { | ||
93 | - fmt.Fprintf(h, "CXX=%q %q\n", b.cxxExe(), cxxflags) | ||
94 | + fmt.Fprintf(h, "CXX=%q %q\n", b.cxxExe(true), cxxflags) | ||
95 | } | ||
96 | if len(p.FFiles) > 0 { | ||
97 | - fmt.Fprintf(h, "FC=%q %q\n", b.fcExe(), fflags) | ||
98 | + fmt.Fprintf(h, "FC=%q %q\n", b.fcExe(true), fflags) | ||
99 | } | ||
100 | // TODO(rsc): Should we include the SWIG version or Fortran/GCC/G++/Objective-C compiler versions? | ||
101 | } | ||
102 | @@ -1731,33 +1733,33 @@ var ( | ||
103 | // gccCmd returns a gcc command line prefix | ||
104 | // defaultCC is defined in zdefaultcc.go, written by cmd/dist. | ||
105 | func (b *Builder) GccCmd(incdir, workdir string) []string { | ||
106 | - return b.compilerCmd(b.ccExe(), incdir, workdir) | ||
107 | + return b.compilerCmd(b.ccExe(false), incdir, workdir) | ||
108 | } | ||
109 | |||
110 | // gxxCmd returns a g++ command line prefix | ||
111 | // defaultCXX is defined in zdefaultcc.go, written by cmd/dist. | ||
112 | func (b *Builder) GxxCmd(incdir, workdir string) []string { | ||
113 | - return b.compilerCmd(b.cxxExe(), incdir, workdir) | ||
114 | + return b.compilerCmd(b.cxxExe(false), incdir, workdir) | ||
115 | } | ||
116 | |||
117 | // gfortranCmd returns a gfortran command line prefix. | ||
118 | func (b *Builder) gfortranCmd(incdir, workdir string) []string { | ||
119 | - return b.compilerCmd(b.fcExe(), incdir, workdir) | ||
120 | + return b.compilerCmd(b.fcExe(false), incdir, workdir) | ||
121 | } | ||
122 | |||
123 | // ccExe returns the CC compiler setting without all the extra flags we add implicitly. | ||
124 | -func (b *Builder) ccExe() []string { | ||
125 | - return b.compilerExe(origCC, cfg.DefaultCC(cfg.Goos, cfg.Goarch)) | ||
126 | +func (b *Builder) ccExe(filtered bool) []string { | ||
127 | + return b.compilerExe(origCC, cfg.DefaultCC(cfg.Goos, cfg.Goarch), filtered) | ||
128 | } | ||
129 | |||
130 | // cxxExe returns the CXX compiler setting without all the extra flags we add implicitly. | ||
131 | -func (b *Builder) cxxExe() []string { | ||
132 | - return b.compilerExe(origCXX, cfg.DefaultCXX(cfg.Goos, cfg.Goarch)) | ||
133 | +func (b *Builder) cxxExe(filtered bool) []string { | ||
134 | + return b.compilerExe(origCXX, cfg.DefaultCXX(cfg.Goos, cfg.Goarch), filtered) | ||
135 | } | ||
136 | |||
137 | // fcExe returns the FC compiler setting without all the extra flags we add implicitly. | ||
138 | -func (b *Builder) fcExe() []string { | ||
139 | - return b.compilerExe(os.Getenv("FC"), "gfortran") | ||
140 | +func (b *Builder) fcExe(filtered bool) []string { | ||
141 | + return b.compilerExe(os.Getenv("FC"), "gfortran", filtered) | ||
142 | } | ||
143 | |||
144 | // compilerExe returns the compiler to use given an | ||
145 | @@ -1766,11 +1768,14 @@ func (b *Builder) fcExe() []string { | ||
146 | // of the compiler but can have additional arguments if they | ||
147 | // were present in the environment value. | ||
148 | // For example if CC="gcc -DGOPHER" then the result is ["gcc", "-DGOPHER"]. | ||
149 | -func (b *Builder) compilerExe(envValue string, def string) []string { | ||
150 | +func (b *Builder) compilerExe(envValue string, def string, filtered bool) []string { | ||
151 | compiler := strings.Fields(envValue) | ||
152 | if len(compiler) == 0 { | ||
153 | compiler = []string{def} | ||
154 | } | ||
155 | + if filtered { | ||
156 | + return append(compiler[0:1], filterCompilerFlags(compiler[1:])...) | ||
157 | + } | ||
158 | return compiler | ||
159 | } | ||
160 | |||
161 | @@ -1920,8 +1925,23 @@ func envList(key, def string) []string { | ||
162 | return strings.Fields(v) | ||
163 | } | ||
164 | |||
165 | +var filterFlags = os.Getenv("CGO_PEDANTIC") == "" | ||
166 | + | ||
167 | +func filterCompilerFlags(flags []string) []string { | ||
168 | + var newflags []string | ||
169 | + if !filterFlags { | ||
170 | + return flags | ||
171 | + } | ||
172 | + for _, flag := range flags { | ||
173 | + if strings.HasPrefix(flag, "-m") { | ||
174 | + newflags = append(newflags, flag) | ||
175 | + } | ||
176 | + } | ||
177 | + return newflags | ||
178 | +} | ||
179 | + | ||
180 | // CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo. | ||
181 | -func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) { | ||
182 | +func (b *Builder) CFlags(p *load.Package, filtered bool) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) { | ||
183 | defaults := "-g -O2" | ||
184 | |||
185 | if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil { | ||
186 | @@ -1939,6 +1959,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l | ||
187 | if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil { | ||
188 | return | ||
189 | } | ||
190 | + if filtered { | ||
191 | + cppflags = filterCompilerFlags(cppflags) | ||
192 | + cflags = filterCompilerFlags(cflags) | ||
193 | + cxxflags = filterCompilerFlags(cxxflags) | ||
194 | + fflags = filterCompilerFlags(fflags) | ||
195 | + ldflags = filterCompilerFlags(ldflags) | ||
196 | + } | ||
197 | |||
198 | return | ||
199 | } | ||
200 | @@ -1954,7 +1981,7 @@ var cgoRe = regexp.MustCompile(`[/\\:]`) | ||
201 | |||
202 | func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) { | ||
203 | p := a.Package | ||
204 | - cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p) | ||
205 | + cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p, false) | ||
206 | if err != nil { | ||
207 | return nil, nil, err | ||
208 | } | ||
209 | @@ -2306,7 +2333,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) { | ||
210 | |||
211 | // Run SWIG on one SWIG input file. | ||
212 | func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) { | ||
213 | - cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p) | ||
214 | + cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p, false) | ||
215 | if err != nil { | ||
216 | return "", "", err | ||
217 | } | ||
218 | -- | ||
219 | 2.14.1 | ||
220 | |||
diff --git a/meta/recipes-devtools/go/go-1.10/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch b/meta/recipes-devtools/go/go-1.10/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch new file mode 100644 index 0000000000..818fe66700 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch | |||
@@ -0,0 +1,64 @@ | |||
1 | From acd179b49f1fc8d6f7f69e569fb4a56039c725a1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Sat, 17 Feb 2018 05:24:20 -0800 | ||
4 | Subject: [PATCH 3/9] allow GOTOOLDIR to be overridden in the environment | ||
5 | |||
6 | to allow for split host/target build roots | ||
7 | |||
8 | Upstream-Status: Inappropriate [OE specific] | ||
9 | |||
10 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
11 | --- | ||
12 | src/cmd/dist/build.go | 4 +++- | ||
13 | src/cmd/go/internal/cfg/cfg.go | 6 +++++- | ||
14 | src/go/build/build.go | 2 +- | ||
15 | 3 files changed, 9 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go | ||
18 | index 49ed80033e..afc615b5c2 100644 | ||
19 | --- a/src/cmd/dist/build.go | ||
20 | +++ b/src/cmd/dist/build.go | ||
21 | @@ -220,7 +220,9 @@ func xinit() { | ||
22 | workdir = xworkdir() | ||
23 | xatexit(rmworkdir) | ||
24 | |||
25 | - tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) | ||
26 | + if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { | ||
27 | + tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) | ||
28 | + } | ||
29 | } | ||
30 | |||
31 | // compilerEnv returns a map from "goos/goarch" to the | ||
32 | diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go | ||
33 | index 1de4f0dc79..4f6010d660 100644 | ||
34 | --- a/src/cmd/go/internal/cfg/cfg.go | ||
35 | +++ b/src/cmd/go/internal/cfg/cfg.go | ||
36 | @@ -96,7 +96,11 @@ func init() { | ||
37 | // as the tool directory does not move based on environment variables. | ||
38 | // This matches the initialization of ToolDir in go/build, | ||
39 | // except for using GOROOT rather than runtime.GOROOT(). | ||
40 | - build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) | ||
41 | + if s := os.Getenv("GOTOOLDIR"); s != "" { | ||
42 | + build.ToolDir = filepath.Clean(s) | ||
43 | + } else { | ||
44 | + build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) | ||
45 | + } | ||
46 | } | ||
47 | |||
48 | func findGOROOT() string { | ||
49 | diff --git a/src/go/build/build.go b/src/go/build/build.go | ||
50 | index 68fb423983..81b1b32270 100644 | ||
51 | --- a/src/go/build/build.go | ||
52 | +++ b/src/go/build/build.go | ||
53 | @@ -1594,7 +1594,7 @@ func init() { | ||
54 | } | ||
55 | |||
56 | // ToolDir is the directory containing build tools. | ||
57 | -var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) | ||
58 | +var ToolDir = envOr("GOTOOLDIR", filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)) | ||
59 | |||
60 | // IsLocalImport reports whether the import path is | ||
61 | // a local import path, like ".", "..", "./foo", or "../foo". | ||
62 | -- | ||
63 | 2.14.1 | ||
64 | |||
diff --git a/meta/recipes-devtools/go/go-1.10/0004-ld-add-soname-to-shareable-objects.patch b/meta/recipes-devtools/go/go-1.10/0004-ld-add-soname-to-shareable-objects.patch new file mode 100644 index 0000000000..c23ca94290 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0004-ld-add-soname-to-shareable-objects.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | From 85252f0bd8743223eb778edbe9fb31dff17a23d8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Sat, 17 Feb 2018 06:26:10 -0800 | ||
4 | Subject: [PATCH 4/9] ld: add soname to shareable objects | ||
5 | |||
6 | so that OE's shared library dependency handling | ||
7 | can find them. | ||
8 | |||
9 | Upstream-Status: Inappropriate [OE specific] | ||
10 | |||
11 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
12 | --- | ||
13 | src/cmd/link/internal/ld/lib.go | 4 ++++ | ||
14 | 1 file changed, 4 insertions(+) | ||
15 | |||
16 | diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go | ||
17 | index 6dcaf64122..11cbb8a8bb 100644 | ||
18 | --- a/src/cmd/link/internal/ld/lib.go | ||
19 | +++ b/src/cmd/link/internal/ld/lib.go | ||
20 | @@ -1134,6 +1134,7 @@ func (ctxt *Link) hostlink() { | ||
21 | argv = append(argv, "-Wl,-z,relro") | ||
22 | } | ||
23 | argv = append(argv, "-shared") | ||
24 | + argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) | ||
25 | if ctxt.HeadType != objabi.Hwindows { | ||
26 | // Pass -z nodelete to mark the shared library as | ||
27 | // non-closeable: a dlclose will do nothing. | ||
28 | @@ -1145,6 +1146,8 @@ func (ctxt *Link) hostlink() { | ||
29 | argv = append(argv, "-Wl,-z,relro") | ||
30 | } | ||
31 | argv = append(argv, "-shared") | ||
32 | + argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) | ||
33 | + | ||
34 | case BuildModePlugin: | ||
35 | if ctxt.HeadType == objabi.Hdarwin { | ||
36 | argv = append(argv, "-dynamiclib") | ||
37 | @@ -1153,6 +1156,7 @@ func (ctxt *Link) hostlink() { | ||
38 | argv = append(argv, "-Wl,-z,relro") | ||
39 | } | ||
40 | argv = append(argv, "-shared") | ||
41 | + argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) | ||
42 | } | ||
43 | } | ||
44 | |||
45 | -- | ||
46 | 2.14.1 | ||
47 | |||
diff --git a/meta/recipes-devtools/go/go-1.10/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch b/meta/recipes-devtools/go/go-1.10/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch new file mode 100644 index 0000000000..67a93939f5 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch | |||
@@ -0,0 +1,40 @@ | |||
1 | From 16124d84648f4dfdfa4738c5660b5400b30bf9da Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Sat, 17 Feb 2018 06:32:45 -0800 | ||
4 | Subject: [PATCH 5/9] make.bash: override CC when building dist and | ||
5 | go_bootstrap | ||
6 | |||
7 | for handling OE cross-canadian builds. | ||
8 | |||
9 | Upstream-Status: Inappropriate [OE specific] | ||
10 | |||
11 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
12 | --- | ||
13 | src/make.bash | 4 ++-- | ||
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/src/make.bash b/src/make.bash | ||
17 | index 93a5c43d11..3a63682bc4 100755 | ||
18 | --- a/src/make.bash | ||
19 | +++ b/src/make.bash | ||
20 | @@ -162,7 +162,7 @@ if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; then | ||
21 | exit 1 | ||
22 | fi | ||
23 | rm -f cmd/dist/dist | ||
24 | -GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist | ||
25 | +CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist | ||
26 | |||
27 | # -e doesn't propagate out of eval, so check success by hand. | ||
28 | eval $(./cmd/dist/dist env -p || echo FAIL=true) | ||
29 | @@ -193,7 +193,7 @@ fi | ||
30 | # Run dist bootstrap to complete make.bash. | ||
31 | # Bootstrap installs a proper cmd/dist, built with the new toolchain. | ||
32 | # Throw ours, built with Go 1.4, away after bootstrap. | ||
33 | -./cmd/dist/dist bootstrap $buildall $vflag $GO_DISTFLAGS "$@" | ||
34 | +CC="${BUILD_CC:-${CC}}" ./cmd/dist/dist bootstrap $buildall $vflag $GO_DISTFLAGS "$@" | ||
35 | rm -f ./cmd/dist/dist | ||
36 | |||
37 | # DO NOT ADD ANY NEW CODE HERE. | ||
38 | -- | ||
39 | 2.14.1 | ||
40 | |||
diff --git a/meta/recipes-devtools/go/go-1.10/0006-cmd-dist-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go-1.10/0006-cmd-dist-separate-host-and-target-builds.patch new file mode 100644 index 0000000000..9fe6996284 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0006-cmd-dist-separate-host-and-target-builds.patch | |||
@@ -0,0 +1,277 @@ | |||
1 | From 2f07af34697c61decdcfa5b11434451fbcf37704 Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Sat, 17 Feb 2018 10:03:48 -0800 | ||
4 | Subject: [PATCH 6/9] cmd/dist: separate host and target builds | ||
5 | |||
6 | Change the dist tool to allow for OE-style cross- | ||
7 | and cross-canadian builds: | ||
8 | |||
9 | - command flags --host-only and --target only are added; | ||
10 | if one is present, the other changes mentioned below | ||
11 | take effect, and arguments may also be specified on | ||
12 | the command line to enumerate the package(s) to be | ||
13 | built. | ||
14 | |||
15 | - for OE cross builds, go_bootstrap is always built for | ||
16 | the current build host, and is moved, along with the supporting | ||
17 | toolchain (asm, compile, etc.) to a separate 'native_native' | ||
18 | directory under GOROOT/pkg/tool. | ||
19 | |||
20 | - go_bootstrap is not automatically removed after the build, | ||
21 | so it can be reused later (e.g., building both static and | ||
22 | shared runtime). | ||
23 | |||
24 | Note that for --host-only builds, it would be nice to specify | ||
25 | just the "cmd" package to build only the go commands/tools, | ||
26 | the staleness checks in the dist tool will fail if the "std" | ||
27 | library has not also been built. So host-only builds have to | ||
28 | build everything anyway. | ||
29 | |||
30 | Upstream-Status: Inappropriate [OE specific] | ||
31 | |||
32 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
33 | |||
34 | more dist cleanup | ||
35 | --- | ||
36 | src/cmd/dist/build.go | 149 +++++++++++++++++++++++++++++++++++++------------- | ||
37 | 1 file changed, 111 insertions(+), 38 deletions(-) | ||
38 | |||
39 | diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go | ||
40 | index afc615b5c2..36262665b2 100644 | ||
41 | --- a/src/cmd/dist/build.go | ||
42 | +++ b/src/cmd/dist/build.go | ||
43 | @@ -38,6 +38,7 @@ var ( | ||
44 | goldflags string | ||
45 | workdir string | ||
46 | tooldir string | ||
47 | + build_tooldir string | ||
48 | oldgoos string | ||
49 | oldgoarch string | ||
50 | exe string | ||
51 | @@ -49,6 +50,7 @@ var ( | ||
52 | |||
53 | rebuildall bool | ||
54 | defaultclang bool | ||
55 | + crossBuild bool | ||
56 | |||
57 | vflag int // verbosity | ||
58 | ) | ||
59 | @@ -223,6 +225,8 @@ func xinit() { | ||
60 | if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { | ||
61 | tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) | ||
62 | } | ||
63 | + build_tooldir = pathf("%s/pkg/tool/native_native", goroot) | ||
64 | + | ||
65 | } | ||
66 | |||
67 | // compilerEnv returns a map from "goos/goarch" to the | ||
68 | @@ -252,7 +256,6 @@ func compilerEnv(envName, def string) map[string]string { | ||
69 | if gohostos != goos || gohostarch != goarch { | ||
70 | m[gohostos+"/"+gohostarch] = m[""] | ||
71 | } | ||
72 | - m[""] = env | ||
73 | } | ||
74 | |||
75 | for _, goos := range okgoos { | ||
76 | @@ -479,8 +482,10 @@ func setup() { | ||
77 | // We keep it in pkg/, just like the object directory above. | ||
78 | if rebuildall { | ||
79 | xremoveall(tooldir) | ||
80 | + xremoveall(build_tooldir) | ||
81 | } | ||
82 | xmkdirall(tooldir) | ||
83 | + xmkdirall(build_tooldir) | ||
84 | |||
85 | // Remove tool binaries from before the tool/gohostos_gohostarch | ||
86 | xremoveall(pathf("%s/bin/tool", goroot)) | ||
87 | @@ -1130,11 +1135,29 @@ func cmdbootstrap() { | ||
88 | |||
89 | var noBanner bool | ||
90 | var debug bool | ||
91 | + var hostOnly bool | ||
92 | + var targetOnly bool | ||
93 | + var toBuild = []string { "std", "cmd" } | ||
94 | + | ||
95 | flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all") | ||
96 | flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process") | ||
97 | flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner") | ||
98 | + flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target") | ||
99 | + flag.BoolVar(&targetOnly, "target-only", targetOnly, "build only target binaries, not host") | ||
100 | |||
101 | - xflagparse(0) | ||
102 | + xflagparse(-1) | ||
103 | + | ||
104 | + if (hostOnly && targetOnly) { | ||
105 | + fatalf("specify only one of --host-only or --target-only\n") | ||
106 | + } | ||
107 | + crossBuild = hostOnly || targetOnly | ||
108 | + if flag.NArg() > 0 { | ||
109 | + if crossBuild { | ||
110 | + toBuild = flag.Args() | ||
111 | + } else { | ||
112 | + fatalf("package names not permitted without --host-only or --target-only\n") | ||
113 | + } | ||
114 | + } | ||
115 | |||
116 | if debug { | ||
117 | // cmd/buildid is used in debug mode. | ||
118 | @@ -1182,8 +1205,13 @@ func cmdbootstrap() { | ||
119 | xprintf("\n") | ||
120 | } | ||
121 | |||
122 | - gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now | ||
123 | - goldflags = os.Getenv("GO_LDFLAGS") | ||
124 | + // For split host/target cross/cross-canadian builds, we don't | ||
125 | + // want to be setting these flags until after we have compiled | ||
126 | + // the toolchain that runs on the build host. | ||
127 | + if ! crossBuild { | ||
128 | + gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now | ||
129 | + goldflags = os.Getenv("GO_LDFLAGS") | ||
130 | + } | ||
131 | goBootstrap := pathf("%s/go_bootstrap", tooldir) | ||
132 | cmdGo := pathf("%s/go", gobin) | ||
133 | if debug { | ||
134 | @@ -1212,7 +1240,11 @@ func cmdbootstrap() { | ||
135 | xprintf("\n") | ||
136 | } | ||
137 | xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n") | ||
138 | - os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) | ||
139 | + if crossBuild { | ||
140 | + os.Setenv("CC", defaultcc[""]) | ||
141 | + } else { | ||
142 | + os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) | ||
143 | + } | ||
144 | goInstall(goBootstrap, append([]string{"-i"}, toolchain...)...) | ||
145 | if debug { | ||
146 | run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") | ||
147 | @@ -1249,45 +1281,82 @@ func cmdbootstrap() { | ||
148 | } | ||
149 | checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) | ||
150 | |||
151 | - if goos == oldgoos && goarch == oldgoarch { | ||
152 | - // Common case - not setting up for cross-compilation. | ||
153 | - timelog("build", "toolchain") | ||
154 | - if vflag > 0 { | ||
155 | - xprintf("\n") | ||
156 | + if crossBuild { | ||
157 | + gogcflags = os.Getenv("GO_GCFLAGS") | ||
158 | + goldflags = os.Getenv("GO_LDFLAGS") | ||
159 | + tool_files, _ := filepath.Glob(pathf("%s/*", tooldir)) | ||
160 | + for _, f := range tool_files { | ||
161 | + copyfile(pathf("%s/%s", build_tooldir, filepath.Base(f)), f, writeExec) | ||
162 | + xremove(f) | ||
163 | + } | ||
164 | + os.Setenv("GOTOOLDIR", build_tooldir) | ||
165 | + goBootstrap = pathf("%s/go_bootstrap", build_tooldir) | ||
166 | + if hostOnly { | ||
167 | + timelog("build", "host toolchain") | ||
168 | + if vflag > 0 { | ||
169 | + xprintf("\n") | ||
170 | + } | ||
171 | + xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) | ||
172 | + goInstall(goBootstrap, toBuild...) | ||
173 | + checkNotStale(goBootstrap, toBuild...) | ||
174 | + // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary | ||
175 | + | ||
176 | + timelog("build", "target toolchain") | ||
177 | + if vflag > 0 { | ||
178 | + xprintf("\n") | ||
179 | + } | ||
180 | + } else if targetOnly { | ||
181 | + goos = oldgoos | ||
182 | + goarch = oldgoarch | ||
183 | + os.Setenv("GOOS", goos) | ||
184 | + os.Setenv("GOARCH", goarch) | ||
185 | + os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) | ||
186 | + xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) | ||
187 | + goInstall(goBootstrap, toBuild...) | ||
188 | + checkNotStale(goBootstrap, toBuild...) | ||
189 | + // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary | ||
190 | } | ||
191 | - xprintf("Building packages and commands for %s/%s.\n", goos, goarch) | ||
192 | } else { | ||
193 | - // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH. | ||
194 | - // Finish GOHOSTOS/GOHOSTARCH installation and then | ||
195 | - // run GOOS/GOARCH installation. | ||
196 | - timelog("build", "host toolchain") | ||
197 | - if vflag > 0 { | ||
198 | - xprintf("\n") | ||
199 | + if goos == oldgoos && goarch == oldgoarch { | ||
200 | + // Common case - not setting up for cross-compilation. | ||
201 | + timelog("build", "toolchain") | ||
202 | + if vflag > 0 { | ||
203 | + xprintf("\n") | ||
204 | + } | ||
205 | + xprintf("Building packages and commands for %s/%s.\n", goos, goarch) | ||
206 | + } else { | ||
207 | + // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH. | ||
208 | + // Finish GOHOSTOS/GOHOSTARCH installation and then | ||
209 | + // run GOOS/GOARCH installation. | ||
210 | + timelog("build", "host toolchain") | ||
211 | + if vflag > 0 { | ||
212 | + xprintf("\n") | ||
213 | + } | ||
214 | + xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch) | ||
215 | + goInstall(goBootstrap, "std", "cmd") | ||
216 | + checkNotStale(goBootstrap, "std", "cmd") | ||
217 | + checkNotStale(cmdGo, "std", "cmd") | ||
218 | + | ||
219 | + timelog("build", "target toolchain") | ||
220 | + if vflag > 0 { | ||
221 | + xprintf("\n") | ||
222 | + } | ||
223 | + goos = oldgoos | ||
224 | + goarch = oldgoarch | ||
225 | + os.Setenv("GOOS", goos) | ||
226 | + os.Setenv("GOARCH", goarch) | ||
227 | + os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) | ||
228 | + xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch) | ||
229 | } | ||
230 | - xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch) | ||
231 | goInstall(goBootstrap, "std", "cmd") | ||
232 | checkNotStale(goBootstrap, "std", "cmd") | ||
233 | checkNotStale(cmdGo, "std", "cmd") | ||
234 | - | ||
235 | - timelog("build", "target toolchain") | ||
236 | - if vflag > 0 { | ||
237 | - xprintf("\n") | ||
238 | + if debug { | ||
239 | + run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") | ||
240 | + run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch)) | ||
241 | + checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) | ||
242 | + copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) | ||
243 | } | ||
244 | - goos = oldgoos | ||
245 | - goarch = oldgoarch | ||
246 | - os.Setenv("GOOS", goos) | ||
247 | - os.Setenv("GOARCH", goarch) | ||
248 | - os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) | ||
249 | - xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch) | ||
250 | - } | ||
251 | - goInstall(goBootstrap, "std", "cmd") | ||
252 | - checkNotStale(goBootstrap, "std", "cmd") | ||
253 | - checkNotStale(cmdGo, "std", "cmd") | ||
254 | - if debug { | ||
255 | - run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") | ||
256 | - run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch)) | ||
257 | - checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) | ||
258 | - copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) | ||
259 | } | ||
260 | |||
261 | // Check that there are no new files in $GOROOT/bin other than | ||
262 | @@ -1305,7 +1374,11 @@ func cmdbootstrap() { | ||
263 | } | ||
264 | |||
265 | // Remove go_bootstrap now that we're done. | ||
266 | - xremove(pathf("%s/go_bootstrap", tooldir)) | ||
267 | + // Except that for split host/target cross-builds, we need to | ||
268 | + // keep it. | ||
269 | + if ! crossBuild { | ||
270 | + xremove(pathf("%s/go_bootstrap", tooldir)) | ||
271 | + } | ||
272 | |||
273 | // Print trailing banner unless instructed otherwise. | ||
274 | if !noBanner { | ||
275 | -- | ||
276 | 2.14.1 | ||
277 | |||
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 | |||
diff --git a/meta/recipes-devtools/go/go-1.10/0008-cmd-internal-obj-arm64-fix-branch-too-far-with-TBZ-l.patch b/meta/recipes-devtools/go/go-1.10/0008-cmd-internal-obj-arm64-fix-branch-too-far-with-TBZ-l.patch new file mode 100644 index 0000000000..1e754178d5 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0008-cmd-internal-obj-arm64-fix-branch-too-far-with-TBZ-l.patch | |||
@@ -0,0 +1,58 @@ | |||
1 | From 41b90ed7af10a071ccfeede6a429e0d80518436d Mon Sep 17 00:00:00 2001 | ||
2 | From: Cherry Zhang <cherryyz@google.com> | ||
3 | Date: Sat, 17 Feb 2018 10:31:39 -0500 | ||
4 | Subject: [PATCH 8/9] cmd/internal/obj/arm64: fix branch-too-far with TBZ like | ||
5 | instructions | ||
6 | |||
7 | The compiler now emits TBZ like instructions, but the assembler's | ||
8 | too-far-branch patch code didn't include that case. Add it. | ||
9 | |||
10 | Fixes #23889. | ||
11 | |||
12 | Change-Id: Ib75f9250c660b9fb652835fbc83263a5d5073dc5 | ||
13 | --- | ||
14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
15 | Upstream-Status: Backport | ||
16 | |||
17 | src/cmd/internal/obj/arm64/asm7.go | 11 +++++++++-- | ||
18 | src/cmd/internal/obj/arm64/asm_test.go | 1 + | ||
19 | 2 files changed, 10 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go | ||
22 | index ca81238c93..b1ee552489 100644 | ||
23 | --- a/src/cmd/internal/obj/arm64/asm7.go | ||
24 | +++ b/src/cmd/internal/obj/arm64/asm7.go | ||
25 | @@ -696,9 +696,16 @@ func span7(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { | ||
26 | o = c.oplook(p) | ||
27 | |||
28 | /* very large branches */ | ||
29 | - if (o.type_ == 7 || o.type_ == 39) && p.Pcond != nil { // 7: BEQ and like, 39: CBZ and like | ||
30 | + if (o.type_ == 7 || o.type_ == 39 || o.type_ == 40) && p.Pcond != nil { // 7: BEQ and like, 39: CBZ and like, 40: TBZ and like | ||
31 | otxt := p.Pcond.Pc - pc | ||
32 | - if otxt <= -(1<<18)+10 || otxt >= (1<<18)-10 { | ||
33 | + var toofar bool | ||
34 | + switch o.type_ { | ||
35 | + case 7, 39: // branch instruction encodes 19 bits | ||
36 | + toofar = otxt <= -(1<<20)+10 || otxt >= (1<<20)-10 | ||
37 | + case 40: // branch instruction encodes 14 bits | ||
38 | + toofar = otxt <= -(1<<15)+10 || otxt >= (1<<15)-10 | ||
39 | + } | ||
40 | + if toofar { | ||
41 | q := c.newprog() | ||
42 | q.Link = p.Link | ||
43 | p.Link = q | ||
44 | diff --git a/src/cmd/internal/obj/arm64/asm_test.go b/src/cmd/internal/obj/arm64/asm_test.go | ||
45 | index 369c48f510..3e0c9c13a6 100644 | ||
46 | --- a/src/cmd/internal/obj/arm64/asm_test.go | ||
47 | +++ b/src/cmd/internal/obj/arm64/asm_test.go | ||
48 | @@ -52,6 +52,7 @@ func TestLarge(t *testing.T) { | ||
49 | // gen generates a very large program, with a very far conditional branch. | ||
50 | func gen(buf *bytes.Buffer) { | ||
51 | fmt.Fprintln(buf, "TEXT f(SB),0,$0-0") | ||
52 | + fmt.Fprintln(buf, "TBZ $5, R0, label") | ||
53 | fmt.Fprintln(buf, "CBZ R0, label") | ||
54 | fmt.Fprintln(buf, "BEQ label") | ||
55 | for i := 0; i < 1<<19; i++ { | ||
56 | -- | ||
57 | 2.14.1 | ||
58 | |||
diff --git a/meta/recipes-devtools/go/go-1.10/0009-ld-replace-glibc-dynamic-linker-with-musl.patch b/meta/recipes-devtools/go/go-1.10/0009-ld-replace-glibc-dynamic-linker-with-musl.patch new file mode 100644 index 0000000000..06b00b3cc2 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.10/0009-ld-replace-glibc-dynamic-linker-with-musl.patch | |||
@@ -0,0 +1,130 @@ | |||
1 | From f575d85c4bd9b2903223d6c0dcc38a12775d582f Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Madison <matt@madison.systems> | ||
3 | Date: Sun, 18 Feb 2018 08:24:05 -0800 | ||
4 | Subject: [PATCH 9/9] ld: replace glibc dynamic linker with musl | ||
5 | |||
6 | Rework of patch by Khem Raj <raj.khem@gmail.com> | ||
7 | for go 1.10. Should be applied conditionally on | ||
8 | musl being the system C library. | ||
9 | |||
10 | Upstream-Status: Inappropriate [Real fix should be portable across libcs] | ||
11 | |||
12 | Signed-off-by: Matt Madison <matt@madison.systems> | ||
13 | --- | ||
14 | src/cmd/link/internal/amd64/obj.go | 2 +- | ||
15 | src/cmd/link/internal/arm/obj.go | 2 +- | ||
16 | src/cmd/link/internal/arm64/obj.go | 2 +- | ||
17 | src/cmd/link/internal/mips/obj.go | 2 +- | ||
18 | src/cmd/link/internal/mips64/obj.go | 2 +- | ||
19 | src/cmd/link/internal/ppc64/obj.go | 2 +- | ||
20 | src/cmd/link/internal/s390x/obj.go | 2 +- | ||
21 | src/cmd/link/internal/x86/obj.go | 2 +- | ||
22 | 8 files changed, 8 insertions(+), 8 deletions(-) | ||
23 | |||
24 | diff --git a/src/cmd/link/internal/amd64/obj.go b/src/cmd/link/internal/amd64/obj.go | ||
25 | index 87e809166a..f522a63034 100644 | ||
26 | --- a/src/cmd/link/internal/amd64/obj.go | ||
27 | +++ b/src/cmd/link/internal/amd64/obj.go | ||
28 | @@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
29 | PEreloc1: pereloc1, | ||
30 | TLSIEtoLE: tlsIEtoLE, | ||
31 | |||
32 | - Linuxdynld: "/lib64/ld-linux-x86-64.so.2", | ||
33 | + Linuxdynld: "/lib64/ld-musl-x86-64.so.1", | ||
34 | Freebsddynld: "/libexec/ld-elf.so.1", | ||
35 | Openbsddynld: "/usr/libexec/ld.so", | ||
36 | Netbsddynld: "/libexec/ld.elf_so", | ||
37 | diff --git a/src/cmd/link/internal/arm/obj.go b/src/cmd/link/internal/arm/obj.go | ||
38 | index da16f92345..fd14940ede 100644 | ||
39 | --- a/src/cmd/link/internal/arm/obj.go | ||
40 | +++ b/src/cmd/link/internal/arm/obj.go | ||
41 | @@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
42 | Gentext: gentext, | ||
43 | Machoreloc1: machoreloc1, | ||
44 | |||
45 | - Linuxdynld: "/lib/ld-linux.so.3", // 2 for OABI, 3 for EABI | ||
46 | + Linuxdynld: "/lib/ld-musl-armhf.so.1", | ||
47 | Freebsddynld: "/usr/libexec/ld-elf.so.1", | ||
48 | Openbsddynld: "/usr/libexec/ld.so", | ||
49 | Netbsddynld: "/libexec/ld.elf_so", | ||
50 | diff --git a/src/cmd/link/internal/arm64/obj.go b/src/cmd/link/internal/arm64/obj.go | ||
51 | index 6b386ad737..99863712cc 100644 | ||
52 | --- a/src/cmd/link/internal/arm64/obj.go | ||
53 | +++ b/src/cmd/link/internal/arm64/obj.go | ||
54 | @@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
55 | Gentext: gentext, | ||
56 | Machoreloc1: machoreloc1, | ||
57 | |||
58 | - Linuxdynld: "/lib/ld-linux-aarch64.so.1", | ||
59 | + Linuxdynld: "/lib/ld-musl-aarch64.so.1", | ||
60 | |||
61 | Freebsddynld: "XXX", | ||
62 | Openbsddynld: "XXX", | ||
63 | diff --git a/src/cmd/link/internal/mips/obj.go b/src/cmd/link/internal/mips/obj.go | ||
64 | index c5d3451c39..fd85e6368d 100644 | ||
65 | --- a/src/cmd/link/internal/mips/obj.go | ||
66 | +++ b/src/cmd/link/internal/mips/obj.go | ||
67 | @@ -60,7 +60,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
68 | Gentext: gentext, | ||
69 | Machoreloc1: machoreloc1, | ||
70 | |||
71 | - Linuxdynld: "/lib/ld.so.1", | ||
72 | + Linuxdynld: "/lib/ld-musl-mipsle.so.1", | ||
73 | |||
74 | Freebsddynld: "XXX", | ||
75 | Openbsddynld: "XXX", | ||
76 | diff --git a/src/cmd/link/internal/mips64/obj.go b/src/cmd/link/internal/mips64/obj.go | ||
77 | index 83974e5b56..097224f6da 100644 | ||
78 | --- a/src/cmd/link/internal/mips64/obj.go | ||
79 | +++ b/src/cmd/link/internal/mips64/obj.go | ||
80 | @@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
81 | Gentext: gentext, | ||
82 | Machoreloc1: machoreloc1, | ||
83 | |||
84 | - Linuxdynld: "/lib64/ld64.so.1", | ||
85 | + Linuxdynld: "/lib64/ld-musl-mips64le.so.1", | ||
86 | Freebsddynld: "XXX", | ||
87 | Openbsddynld: "XXX", | ||
88 | Netbsddynld: "XXX", | ||
89 | diff --git a/src/cmd/link/internal/ppc64/obj.go b/src/cmd/link/internal/ppc64/obj.go | ||
90 | index 273d9b42cb..a503abe8ea 100644 | ||
91 | --- a/src/cmd/link/internal/ppc64/obj.go | ||
92 | +++ b/src/cmd/link/internal/ppc64/obj.go | ||
93 | @@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
94 | Machoreloc1: machoreloc1, | ||
95 | |||
96 | // TODO(austin): ABI v1 uses /usr/lib/ld.so.1, | ||
97 | - Linuxdynld: "/lib64/ld64.so.1", | ||
98 | + Linuxdynld: "/lib64/ld-musl-powerpc64le.so.1", | ||
99 | |||
100 | Freebsddynld: "XXX", | ||
101 | Openbsddynld: "XXX", | ||
102 | diff --git a/src/cmd/link/internal/s390x/obj.go b/src/cmd/link/internal/s390x/obj.go | ||
103 | index 9ac7eb8217..3825ff7abe 100644 | ||
104 | --- a/src/cmd/link/internal/s390x/obj.go | ||
105 | +++ b/src/cmd/link/internal/s390x/obj.go | ||
106 | @@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
107 | Gentext: gentext, | ||
108 | Machoreloc1: machoreloc1, | ||
109 | |||
110 | - Linuxdynld: "/lib64/ld64.so.1", | ||
111 | + Linuxdynld: "/lib64/ld-musl-s390x.so.1", | ||
112 | |||
113 | // not relevant for s390x | ||
114 | Freebsddynld: "XXX", | ||
115 | diff --git a/src/cmd/link/internal/x86/obj.go b/src/cmd/link/internal/x86/obj.go | ||
116 | index 6a744dc04e..d81f392549 100644 | ||
117 | --- a/src/cmd/link/internal/x86/obj.go | ||
118 | +++ b/src/cmd/link/internal/x86/obj.go | ||
119 | @@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) { | ||
120 | Machoreloc1: machoreloc1, | ||
121 | PEreloc1: pereloc1, | ||
122 | |||
123 | - Linuxdynld: "/lib/ld-linux.so.2", | ||
124 | + Linuxdynld: "/lib/ld-musl-i386.so.1", | ||
125 | Freebsddynld: "/usr/libexec/ld-elf.so.1", | ||
126 | Openbsddynld: "/usr/libexec/ld.so", | ||
127 | Netbsddynld: "/usr/libexec/ld.elf_so", | ||
128 | -- | ||
129 | 2.14.1 | ||
130 | |||