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/0006-cmd-dist-separate-host-and-target-builds.patch | |
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/0006-cmd-dist-separate-host-and-target-builds.patch')
-rw-r--r-- | meta/recipes-devtools/go/go-1.10/0006-cmd-dist-separate-host-and-target-builds.patch | 277 |
1 files changed, 277 insertions, 0 deletions
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 | |||