summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch')
-rw-r--r--meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch74
1 files changed, 39 insertions, 35 deletions
diff --git a/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
index aa2df58995..f8dca65ed4 100644
--- a/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
+++ b/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
@@ -1,4 +1,4 @@
1From 7a191e5191c8b813e929caedb3f3918bb08692a1 Mon Sep 17 00:00:00 2001 1From 6dda78d528e60993a4688cd9d49440a726378ac8 Mon Sep 17 00:00:00 2001
2From: Alex Kube <alexander.j.kube@gmail.com> 2From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Wed, 23 Oct 2019 21:18:12 +0430 3Date: Wed, 23 Oct 2019 21:18:12 +0430
4Subject: [PATCH 5/9] cmd/dist: separate host and target builds 4Subject: [PATCH 5/9] cmd/dist: separate host and target builds
@@ -31,8 +31,8 @@ Adapted to Go 1.13 from patches originally submitted to
31the meta/recipes-devtools/go tree by 31the meta/recipes-devtools/go tree by
32Matt Madison <matt@madison.systems>. 32Matt Madison <matt@madison.systems>.
33 33
34Rework the patch to avoid identation, it's more hard to read 34Rework the patch to avoid identation, it's more hard to read but
35but easy to rebase. 35easy to rebase.
36Jose Quaresma <jose.quaresma@foundries.io> 36Jose Quaresma <jose.quaresma@foundries.io>
37 37
38Upstream-Status: Inappropriate [OE specific] 38Upstream-Status: Inappropriate [OE specific]
@@ -44,35 +44,35 @@ Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
44 1 file changed, 75 insertions(+), 1 deletion(-) 44 1 file changed, 75 insertions(+), 1 deletion(-)
45 45
46diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go 46diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
47index 5d3171856a..d0ba54c072 100644 47index adc9fd2..5fff592 100644
48--- a/src/cmd/dist/build.go 48--- a/src/cmd/dist/build.go
49+++ b/src/cmd/dist/build.go 49+++ b/src/cmd/dist/build.go
50@@ -44,6 +44,7 @@ var ( 50@@ -46,6 +46,7 @@ var (
51 goexperiment string 51 goexperiment string
52 workdir string 52 workdir string
53 tooldir string 53 tooldir string
54+ build_tooldir string 54+ build_tooldir string
55 oldgoos string 55 oldgoos string
56 oldgoarch string 56 oldgoarch string
57 exe string 57 oldgocache string
58@@ -55,6 +56,7 @@ var ( 58@@ -58,6 +59,7 @@ var (
59 rebuildall bool 59 rebuildall bool
60 defaultclang bool 60 noOpt bool
61 noOpt bool 61 isRelease bool
62+ crossBuild bool 62+ crossBuild bool
63 63
64 vflag int // verbosity 64 vflag int // verbosity
65 ) 65 )
66@@ -267,6 +269,8 @@ func xinit() { 66@@ -265,6 +267,8 @@ func xinit() {
67 if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { 67
68 tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) 68 goversion := findgoversion()
69 } 69 isRelease = strings.HasPrefix(goversion, "release.") || strings.HasPrefix(goversion, "go")
70+ 70+
71+ build_tooldir = pathf("%s/pkg/tool/native_native", goroot) 71+ build_tooldir = pathf("%s/pkg/tool/native_native", goroot)
72 } 72 }
73 73
74 // compilerEnv returns a map from "goos/goarch" to the 74 // compilerEnv returns a map from "goos/goarch" to the
75@@ -468,8 +472,10 @@ func setup() { 75@@ -499,8 +503,10 @@ func setup() {
76 goosGoarch := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch) 76 goosGoarch := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch)
77 if rebuildall { 77 if rebuildall {
78 xremoveall(goosGoarch) 78 xremoveall(goosGoarch)
@@ -83,16 +83,18 @@ index 5d3171856a..d0ba54c072 100644
83 xatexit(func() { 83 xatexit(func() {
84 if files := xreaddir(goosGoarch); len(files) == 0 { 84 if files := xreaddir(goosGoarch); len(files) == 0 {
85 xremove(goosGoarch) 85 xremove(goosGoarch)
86@@ -1276,17 +1282,35 @@ func cmdbootstrap() { 86@@ -1344,14 +1350,20 @@ func cmdbootstrap() {
87 defer timelog("end", "dist bootstrap")
87 88
88 var noBanner, noClean bool 89 var debug, distpack, force, noBanner, noClean bool
89 var debug bool
90+ var hostOnly bool 90+ var hostOnly bool
91+ var targetOnly bool 91+ var targetOnly bool
92+ var toBuild = []string{"std", "cmd"} 92+ var toBuild = []string{"std", "cmd"}
93+ 93+
94 flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all") 94 flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all")
95 flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process") 95 flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process")
96 flag.BoolVar(&distpack, "distpack", distpack, "write distribution files to pkg/distpack")
97 flag.BoolVar(&force, "force", force, "build even if the port is marked as broken")
96 flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner") 98 flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner")
97 flag.BoolVar(&noClean, "no-clean", noClean, "print deprecation warning") 99 flag.BoolVar(&noClean, "no-clean", noClean, "print deprecation warning")
98+ flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target") 100+ flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target")
@@ -103,6 +105,8 @@ index 5d3171856a..d0ba54c072 100644
103 105
104 if noClean { 106 if noClean {
105 xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n") 107 xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n")
108@@ -1363,6 +1375,18 @@ func cmdbootstrap() {
109 "Use the -force flag to build anyway.\n", goos, goarch)
106 } 110 }
107 111
108+ if hostOnly && targetOnly { 112+ if hostOnly && targetOnly {
@@ -120,7 +124,7 @@ index 5d3171856a..d0ba54c072 100644
120 // Set GOPATH to an internal directory. We shouldn't actually 124 // Set GOPATH to an internal directory. We shouldn't actually
121 // need to store files here, since the toolchain won't 125 // need to store files here, since the toolchain won't
122 // depend on modules outside of vendor directories, but if 126 // depend on modules outside of vendor directories, but if
123@@ -1354,9 +1378,14 @@ func cmdbootstrap() { 127@@ -1440,9 +1464,14 @@ func cmdbootstrap() {
124 xprintf("\n") 128 xprintf("\n")
125 } 129 }
126 130
@@ -133,30 +137,30 @@ index 5d3171856a..d0ba54c072 100644
133 goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now 137 goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now
134+} 138+}
135 goBootstrap := pathf("%s/go_bootstrap", tooldir) 139 goBootstrap := pathf("%s/go_bootstrap", tooldir)
136 cmdGo := pathf("%s/go", gorootBin)
137 if debug { 140 if debug {
138@@ -1385,7 +1414,11 @@ func cmdbootstrap() { 141 run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
142@@ -1470,7 +1499,11 @@ func cmdbootstrap() {
139 xprintf("\n") 143 xprintf("\n")
140 } 144 }
141 xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n") 145 xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n")
142+ if !crossBuild { 146+ if !crossBuild {
143 os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) 147 os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch))
144+} else { 148+} else {
145+ os.Setenv("CC", defaultcc[""]) 149+ os.Setenv("CC", defaultcc[""])
146+ } 150+ }
147 // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT. 151 // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT.
148 os.Setenv("GOEXPERIMENT", goexperiment) 152 os.Setenv("GOEXPERIMENT", goexperiment)
149 goInstall(goBootstrap, toolchain...) 153 // No need to enable PGO for toolchain2.
150@@ -1421,6 +1454,7 @@ func cmdbootstrap() { 154@@ -1523,6 +1556,7 @@ func cmdbootstrap() {
151 copyfile(pathf("%s/compile3", tooldir), pathf("%s/compile", tooldir), writeExec) 155 os.Setenv("GOCACHE", oldgocache)
152 } 156 }
153 157
154+ if !crossBuild { 158+ if !crossBuild {
155 if goos == oldgoos && goarch == oldgoarch { 159 if goos == oldgoos && goarch == oldgoarch {
156 // Common case - not setting up for cross-compilation. 160 // Common case - not setting up for cross-compilation.
157 timelog("build", "toolchain") 161 timelog("build", "toolchain")
158@@ -1462,6 +1496,42 @@ func cmdbootstrap() { 162@@ -1566,6 +1600,42 @@ func cmdbootstrap() {
159 checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) 163 checkNotStale(toolenv(), goBootstrap, toolchain...)
160 copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) 164 copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec)
161 } 165 }
162+} else { 166+} else {
@@ -175,8 +179,8 @@ index 5d3171856a..d0ba54c072 100644
175+ xprintf("\n") 179+ xprintf("\n")
176+ } 180+ }
177+ xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) 181+ xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
178+ goInstall(goBootstrap, toBuild...) 182+ goInstall(toolenv(), goBootstrap, toBuild...)
179+ checkNotStale(goBootstrap, toBuild...) 183+ checkNotStale(toolenv(), goBootstrap, toBuild...)
180+ // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary 184+ // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary
181+ 185+
182+ timelog("build", "target toolchain") 186+ timelog("build", "target toolchain")
@@ -188,17 +192,17 @@ index 5d3171856a..d0ba54c072 100644
188+ goarch = oldgoarch 192+ goarch = oldgoarch
189+ os.Setenv("GOOS", goos) 193+ os.Setenv("GOOS", goos)
190+ os.Setenv("GOARCH", goarch) 194+ os.Setenv("GOARCH", goarch)
191+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) 195+ os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch))
192+ xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) 196+ xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
193+ goInstall(goBootstrap, toBuild...) 197+ goInstall(toolenv(), goBootstrap, toBuild...)
194+ checkNotStale(goBootstrap, toBuild...) 198+ checkNotStale(toolenv(), goBootstrap, toBuild...)
195+ // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary 199+ // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary
196+ } 200+ }
197+ } 201+ }
198 202
199 // Check that there are no new files in $GOROOT/bin other than 203 // Check that there are no new files in $GOROOT/bin other than
200 // go and gofmt and $GOOS_$GOARCH (target bin when cross-compiling). 204 // go and gofmt and $GOOS_$GOARCH (target bin when cross-compiling).
201@@ -1477,8 +1547,12 @@ func cmdbootstrap() { 205@@ -1585,8 +1655,12 @@ func cmdbootstrap() {
202 } 206 }
203 } 207 }
204 208
@@ -206,7 +210,7 @@ index 5d3171856a..d0ba54c072 100644
206+ // keep it. 210+ // keep it.
207+ if !crossBuild { 211+ if !crossBuild {
208 // Remove go_bootstrap now that we're done. 212 // Remove go_bootstrap now that we're done.
209 xremove(pathf("%s/go_bootstrap", tooldir)) 213 xremove(pathf("%s/go_bootstrap"+exe, tooldir))
210+} 214+}
211 215
212 if goos == "android" { 216 if goos == "android" {