summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorAlex Kube <alexander.j.kube@gmail.com>2019-10-25 23:49:14 +0430
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-11-25 17:57:22 +0000
commit0dd3a42c3d79ca63248fbbab6ba19dd42f11b03f (patch)
tree61e9c463b2d6da3c0fa2623120c73f23facdff5b /meta/recipes-devtools
parent99e3441a912e8b85a26078ef49dcedce8e35dfa1 (diff)
downloadpoky-0dd3a42c3d79ca63248fbbab6ba19dd42f11b03f.tar.gz
go: Remove go-1.12
(From OE-Core rev: 2b76e904a5f7d6479974a179d6d17d6ee9af94e7) Signed-off-by: Alex Kube <alexander.j.kube@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/go/go-1.12.inc24
-rw-r--r--meta/recipes-devtools/go/go-1.12/0001-allow-CC-and-CXX-to-have-multiple-words.patch31
-rw-r--r--meta/recipes-devtools/go/go-1.12/0001-release-branch.go1.12-security-net-textproto-don-t-n.patch163
-rw-r--r--meta/recipes-devtools/go/go-1.12/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch218
-rw-r--r--meta/recipes-devtools/go/go-1.12/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch48
-rw-r--r--meta/recipes-devtools/go/go-1.12/0004-ld-add-soname-to-shareable-objects.patch45
-rw-r--r--meta/recipes-devtools/go/go-1.12/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch37
-rw-r--r--meta/recipes-devtools/go/go-1.12/0006-cmd-dist-separate-host-and-target-builds.patch282
-rw-r--r--meta/recipes-devtools/go/go-1.12/0007-cmd-go-make-GOROOT-precious-by-default.patch106
-rw-r--r--meta/recipes-devtools/go/go-1.12/0008-use-GOBUILDMODE-to-set-buildmode.patch37
-rw-r--r--meta/recipes-devtools/go/go-1.12/0009-ld-replace-glibc-dynamic-linker-with-musl.patch112
-rw-r--r--meta/recipes-devtools/go/go-cross-canadian_1.12.bb2
-rw-r--r--meta/recipes-devtools/go/go-cross_1.12.bb2
-rw-r--r--meta/recipes-devtools/go/go-crosssdk_1.12.bb2
-rw-r--r--meta/recipes-devtools/go/go-native_1.12.bb2
-rw-r--r--meta/recipes-devtools/go/go-runtime_1.12.bb2
-rw-r--r--meta/recipes-devtools/go/go_1.12.bb14
17 files changed, 0 insertions, 1127 deletions
diff --git a/meta/recipes-devtools/go/go-1.12.inc b/meta/recipes-devtools/go/go-1.12.inc
deleted file mode 100644
index ed14b175e6..0000000000
--- a/meta/recipes-devtools/go/go-1.12.inc
+++ /dev/null
@@ -1,24 +0,0 @@
1require go-common.inc
2
3GO_BASEVERSION = "1.12"
4GO_MINOR = ".9"
5PV .= "${GO_MINOR}"
6FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/go-${GO_BASEVERSION}:"
7
8LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707"
9
10SRC_URI += "\
11 file://0001-allow-CC-and-CXX-to-have-multiple-words.patch \
12 file://0002-cmd-go-make-content-based-hash-generation-less-pedan.patch \
13 file://0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch \
14 file://0004-ld-add-soname-to-shareable-objects.patch \
15 file://0005-make.bash-override-CC-when-building-dist-and-go_boot.patch \
16 file://0006-cmd-dist-separate-host-and-target-builds.patch \
17 file://0007-cmd-go-make-GOROOT-precious-by-default.patch \
18 file://0008-use-GOBUILDMODE-to-set-buildmode.patch \
19 file://0001-release-branch.go1.12-security-net-textproto-don-t-n.patch \
20"
21SRC_URI_append_libc-musl = " file://0009-ld-replace-glibc-dynamic-linker-with-musl.patch"
22
23SRC_URI[main.md5sum] = "6132109d4050da349eadc9f7b0304ef4"
24SRC_URI[main.sha256sum] = "ab0e56ed9c4732a653ed22e232652709afbf573e710f56a07f7fdeca578d62fc"
diff --git a/meta/recipes-devtools/go/go-1.12/0001-allow-CC-and-CXX-to-have-multiple-words.patch b/meta/recipes-devtools/go/go-1.12/0001-allow-CC-and-CXX-to-have-multiple-words.patch
deleted file mode 100644
index 4442858c83..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0001-allow-CC-and-CXX-to-have-multiple-words.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1From 7cc519aa5f84cf8fc7ac8c10fc69aa8040330ea0 Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Mon, 19 Feb 2018 08:49:33 -0800
4Subject: [PATCH] allow CC and CXX to have multiple words
5
6Upstream-Status: Inappropriate [OE specific]
7
8Signed-off-by: Matt Madison <matt@madison.systems>
9
10---
11 src/cmd/go/internal/envcmd/env.go | 4 ++--
12 1 file changed, 2 insertions(+), 2 deletions(-)
13
14diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go
15index afadbad..cedbfbf 100644
16--- a/src/cmd/go/internal/envcmd/env.go
17+++ b/src/cmd/go/internal/envcmd/env.go
18@@ -85,11 +85,11 @@ func MkEnv() []cfg.EnvVar {
19
20 cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch)
21 if env := strings.Fields(os.Getenv("CC")); len(env) > 0 {
22- cc = env[0]
23+ cc = strings.Join(env, " ")
24 }
25 cxx := cfg.DefaultCXX(cfg.Goos, cfg.Goarch)
26 if env := strings.Fields(os.Getenv("CXX")); len(env) > 0 {
27- cxx = env[0]
28+ cxx = strings.Join(env, " ")
29 }
30 env = append(env, cfg.EnvVar{Name: "CC", Value: cc})
31 env = append(env, cfg.EnvVar{Name: "CXX", Value: cxx})
diff --git a/meta/recipes-devtools/go/go-1.12/0001-release-branch.go1.12-security-net-textproto-don-t-n.patch b/meta/recipes-devtools/go/go-1.12/0001-release-branch.go1.12-security-net-textproto-don-t-n.patch
deleted file mode 100644
index 7b39dbd734..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0001-release-branch.go1.12-security-net-textproto-don-t-n.patch
+++ /dev/null
@@ -1,163 +0,0 @@
1From 265b691ac440bfb711d8de323346f7d72e620efe Mon Sep 17 00:00:00 2001
2From: Filippo Valsorda <filippo@golang.org>
3Date: Thu, 12 Sep 2019 12:37:36 -0400
4Subject: [PATCH] [release-branch.go1.12-security] net/textproto: don't
5 normalize headers with spaces before the colon
6
7RFC 7230 is clear about headers with a space before the colon, like
8
9X-Answer : 42
10
11being invalid, but we've been accepting and normalizing them for compatibility
12purposes since CL 5690059 in 2012.
13
14On the client side, this is harmless and indeed most browsers behave the same
15to this day. On the server side, this becomes a security issue when the
16behavior doesn't match that of a reverse proxy sitting in front of the server.
17
18For example, if a WAF accepts them without normalizing them, it might be
19possible to bypass its filters, because the Go server would interpret the
20header differently. Worse, if the reverse proxy coalesces requests onto a
21single HTTP/1.1 connection to a Go server, the understanding of the request
22boundaries can get out of sync between them, allowing an attacker to tack an
23arbitrary method and path onto a request by other clients, including
24authentication headers unknown to the attacker.
25
26This was recently presented at multiple security conferences:
27https://portswigger.net/blog/http-desync-attacks-request-smuggling-reborn
28
29net/http servers already reject header keys with invalid characters.
30Simply stop normalizing extra spaces in net/textproto, let it return them
31unchanged like it does for other invalid headers, and let net/http enforce
32RFC 7230, which is HTTP specific. This loses us normalization on the client
33side, but there's no right answer on the client side anyway, and hiding the
34issue sounds worse than letting the application decide.
35
36Fixes CVE-2019-16276
37
38Change-Id: I6d272de827e0870da85d93df770d6a0e161bbcf1
39Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/549719
40Reviewed-by: Brad Fitzpatrick <bradfitz@google.com>
41(cherry picked from commit 1280b868e82bf173ea3e988be3092d160ee66082)
42Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/558776
43Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
44
45CVE: CVE-2019-16276
46
47Upstream-Status: Backport [https://github.com/golang/go/commit/6e6f4aaf70c8b1cc81e65a26332aa9409de03ad8]
48
49Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
50---
51 src/net/http/serve_test.go | 4 ++++
52 src/net/http/transport_test.go | 27 +++++++++++++++++++++++++++
53 src/net/textproto/reader.go | 10 ++--------
54 src/net/textproto/reader_test.go | 13 ++++++-------
55 4 files changed, 39 insertions(+), 15 deletions(-)
56
57diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
58index 6eb0088a96..89bfdfbb82 100644
59--- a/src/net/http/serve_test.go
60+++ b/src/net/http/serve_test.go
61@@ -4748,6 +4748,10 @@ func TestServerValidatesHeaders(t *testing.T) {
62 {"foo\xffbar: foo\r\n", 400}, // binary in header
63 {"foo\x00bar: foo\r\n", 400}, // binary in header
64 {"Foo: " + strings.Repeat("x", 1<<21) + "\r\n", 431}, // header too large
65+ // Spaces between the header key and colon are not allowed.
66+ // See RFC 7230, Section 3.2.4.
67+ {"Foo : bar\r\n", 400},
68+ {"Foo\t: bar\r\n", 400},
69
70 {"foo: foo foo\r\n", 200}, // LWS space is okay
71 {"foo: foo\tfoo\r\n", 200}, // LWS tab is okay
72diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
73index 5c329543e2..5e5438a708 100644
74--- a/src/net/http/transport_test.go
75+++ b/src/net/http/transport_test.go
76@@ -5133,3 +5133,30 @@ func TestTransportIgnores408(t *testing.T) {
77 }
78 t.Fatalf("timeout after %v waiting for Transport connections to die off", time.Since(t0))
79 }
80+
81+func TestInvalidHeaderResponse(t *testing.T) {
82+ setParallel(t)
83+ defer afterTest(t)
84+ cst := newClientServerTest(t, h1Mode, HandlerFunc(func(w ResponseWriter, r *Request) {
85+ conn, buf, _ := w.(Hijacker).Hijack()
86+ buf.Write([]byte("HTTP/1.1 200 OK\r\n" +
87+ "Date: Wed, 30 Aug 2017 19:09:27 GMT\r\n" +
88+ "Content-Type: text/html; charset=utf-8\r\n" +
89+ "Content-Length: 0\r\n" +
90+ "Foo : bar\r\n\r\n"))
91+ buf.Flush()
92+ conn.Close()
93+ }))
94+ defer cst.close()
95+ res, err := cst.c.Get(cst.ts.URL)
96+ if err != nil {
97+ t.Fatal(err)
98+ }
99+ defer res.Body.Close()
100+ if v := res.Header.Get("Foo"); v != "" {
101+ t.Errorf(`unexpected "Foo" header: %q`, v)
102+ }
103+ if v := res.Header.Get("Foo "); v != "bar" {
104+ t.Errorf(`bad "Foo " header value: %q, want %q`, v, "bar")
105+ }
106+}
107diff --git a/src/net/textproto/reader.go b/src/net/textproto/reader.go
108index 2c4f25d5ae..1a5e364cf7 100644
109--- a/src/net/textproto/reader.go
110+++ b/src/net/textproto/reader.go
111@@ -493,18 +493,12 @@ func (r *Reader) ReadMIMEHeader() (MIMEHeader, error) {
112 return m, err
113 }
114
115- // Key ends at first colon; should not have trailing spaces
116- // but they appear in the wild, violating specs, so we remove
117- // them if present.
118+ // Key ends at first colon.
119 i := bytes.IndexByte(kv, ':')
120 if i < 0 {
121 return m, ProtocolError("malformed MIME header line: " + string(kv))
122 }
123- endKey := i
124- for endKey > 0 && kv[endKey-1] == ' ' {
125- endKey--
126- }
127- key := canonicalMIMEHeaderKey(kv[:endKey])
128+ key := canonicalMIMEHeaderKey(kv[:i])
129
130 // As per RFC 7230 field-name is a token, tokens consist of one or more chars.
131 // We could return a ProtocolError here, but better to be liberal in what we
132diff --git a/src/net/textproto/reader_test.go b/src/net/textproto/reader_test.go
133index f85fbdc36d..b92fdcd3c7 100644
134--- a/src/net/textproto/reader_test.go
135+++ b/src/net/textproto/reader_test.go
136@@ -188,11 +188,10 @@ func TestLargeReadMIMEHeader(t *testing.T) {
137 }
138 }
139
140-// Test that we read slightly-bogus MIME headers seen in the wild,
141-// with spaces before colons, and spaces in keys.
142+// TestReadMIMEHeaderNonCompliant checks that we don't normalize headers
143+// with spaces before colons, and accept spaces in keys.
144 func TestReadMIMEHeaderNonCompliant(t *testing.T) {
145- // Invalid HTTP response header as sent by an Axis security
146- // camera: (this is handled by IE, Firefox, Chrome, curl, etc.)
147+ // These invalid headers will be rejected by net/http according to RFC 7230.
148 r := reader("Foo: bar\r\n" +
149 "Content-Language: en\r\n" +
150 "SID : 0\r\n" +
151@@ -202,9 +201,9 @@ func TestReadMIMEHeaderNonCompliant(t *testing.T) {
152 want := MIMEHeader{
153 "Foo": {"bar"},
154 "Content-Language": {"en"},
155- "Sid": {"0"},
156- "Audio Mode": {"None"},
157- "Privilege": {"127"},
158+ "SID ": {"0"},
159+ "Audio Mode ": {"None"},
160+ "Privilege ": {"127"},
161 }
162 if !reflect.DeepEqual(m, want) || err != nil {
163 t.Fatalf("ReadMIMEHeader =\n%v, %v; want:\n%v", m, err, want)
diff --git a/meta/recipes-devtools/go/go-1.12/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch b/meta/recipes-devtools/go/go-1.12/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch
deleted file mode 100644
index 66b8561874..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch
+++ /dev/null
@@ -1,218 +0,0 @@
1From 47db69e20ed66fb62b01affd83d829654b829893 Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Mon, 19 Feb 2018 08:50:59 -0800
4Subject: [PATCH] cmd/go: make content-based hash generation less pedantic
5
6Go 1.10's build tool now uses content-based hashes to
7determine when something should be built or re-built.
8This same mechanism is used to maintain a built-artifact
9cache for speeding up builds.
10
11However, the hashes it generates include information that
12doesn't work well with OE, nor with using a shared runtime
13library.
14
15First, it embeds path names to source files, unless
16building within GOROOT. This prevents the building
17of a package in GOPATH for later staging into GOROOT.
18
19This patch adds support for the environment variable
20GOPATH_OMIT_IN_ACTIONID. If present, path name
21embedding is disabled.
22
23Second, if cgo is enabled, the build ID for cgo-related
24packages will include the current value of the environment
25variables for invoking the compiler (CC, CXX, FC) and
26any CGO_xxFLAGS variables. Only if the settings used
27during a compilation exactly match, character for character,
28the values used for compiling runtime/cgo or any other
29cgo-enabled package being imported, will the tool
30decide that the imported package is up-to-date.
31
32This is done to help ensure correctness, but is overly
33simplistic and effectively prevents the reuse of built
34artifacts that use cgo (or shared runtime, which includes
35runtime/cgo).
36
37This patch filters out all compiler flags except those
38beginning with '-m'. The default behavior can be restored
39by setting the CGO_PEDANTIC environment variable.
40
41Upstream-Status: Inappropriate [OE specific]
42
43Signed-off-by: Matt Madison <matt@madison.systems>
44
45---
46 src/cmd/go/internal/envcmd/env.go | 2 +-
47 src/cmd/go/internal/work/exec.go | 63 ++++++++++++++++++++++---------
48 2 files changed, 46 insertions(+), 19 deletions(-)
49
50diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go
51index cedbfbf..5763a0d 100644
52--- a/src/cmd/go/internal/envcmd/env.go
53+++ b/src/cmd/go/internal/envcmd/env.go
54@@ -128,7 +128,7 @@ func ExtraEnvVars() []cfg.EnvVar {
55 func ExtraEnvVarsCostly() []cfg.EnvVar {
56 var b work.Builder
57 b.Init()
58- cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{})
59+ cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}, false)
60 if err != nil {
61 // Should not happen - b.CFlags was given an empty package.
62 fmt.Fprintf(os.Stderr, "go: invalid cflags: %v\n", err)
63diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
64index 12e1527..e41bfac 100644
65--- a/src/cmd/go/internal/work/exec.go
66+++ b/src/cmd/go/internal/work/exec.go
67@@ -174,6 +174,8 @@ func (b *Builder) Do(root *Action) {
68 wg.Wait()
69 }
70
71+var omitGopath = os.Getenv("GOPATH_OMIT_IN_ACTIONID") != ""
72+
73 // buildActionID computes the action ID for a build action.
74 func (b *Builder) buildActionID(a *Action) cache.ActionID {
75 p := a.Package
76@@ -190,7 +192,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
77 // but it does not hide the exact value of $GOPATH.
78 // Include the full dir in that case.
79 // Assume b.WorkDir is being trimmed properly.
80- if !p.Goroot && !strings.HasPrefix(p.Dir, b.WorkDir) {
81+ if !p.Goroot && !omitGopath && !strings.HasPrefix(p.Dir, b.WorkDir) {
82 fmt.Fprintf(h, "dir %s\n", p.Dir)
83 }
84 fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch)
85@@ -201,13 +203,13 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
86 }
87 if len(p.CgoFiles)+len(p.SwigFiles) > 0 {
88 fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo"))
89- cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p)
90- fmt.Fprintf(h, "CC=%q %q %q %q\n", b.ccExe(), cppflags, cflags, ldflags)
91+ cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
92+ fmt.Fprintf(h, "CC=%q %q %q %q\n", b.ccExe(true), cppflags, cflags, ldflags)
93 if len(p.CXXFiles)+len(p.SwigFiles) > 0 {
94- fmt.Fprintf(h, "CXX=%q %q\n", b.cxxExe(), cxxflags)
95+ fmt.Fprintf(h, "CXX=%q %q\n", b.cxxExe(true), cxxflags)
96 }
97 if len(p.FFiles) > 0 {
98- fmt.Fprintf(h, "FC=%q %q\n", b.fcExe(), fflags)
99+ fmt.Fprintf(h, "FC=%q %q\n", b.fcExe(true), fflags)
100 }
101 // TODO(rsc): Should we include the SWIG version or Fortran/GCC/G++/Objective-C compiler versions?
102 }
103@@ -2096,33 +2098,33 @@ var (
104 // gccCmd returns a gcc command line prefix
105 // defaultCC is defined in zdefaultcc.go, written by cmd/dist.
106 func (b *Builder) GccCmd(incdir, workdir string) []string {
107- return b.compilerCmd(b.ccExe(), incdir, workdir)
108+ return b.compilerCmd(b.ccExe(false), incdir, workdir)
109 }
110
111 // gxxCmd returns a g++ command line prefix
112 // defaultCXX is defined in zdefaultcc.go, written by cmd/dist.
113 func (b *Builder) GxxCmd(incdir, workdir string) []string {
114- return b.compilerCmd(b.cxxExe(), incdir, workdir)
115+ return b.compilerCmd(b.cxxExe(false), incdir, workdir)
116 }
117
118 // gfortranCmd returns a gfortran command line prefix.
119 func (b *Builder) gfortranCmd(incdir, workdir string) []string {
120- return b.compilerCmd(b.fcExe(), incdir, workdir)
121+ return b.compilerCmd(b.fcExe(false), incdir, workdir)
122 }
123
124 // ccExe returns the CC compiler setting without all the extra flags we add implicitly.
125-func (b *Builder) ccExe() []string {
126- return b.compilerExe(origCC, cfg.DefaultCC(cfg.Goos, cfg.Goarch))
127+func (b *Builder) ccExe(filtered bool) []string {
128+ return b.compilerExe(origCC, cfg.DefaultCC(cfg.Goos, cfg.Goarch), filtered)
129 }
130
131 // cxxExe returns the CXX compiler setting without all the extra flags we add implicitly.
132-func (b *Builder) cxxExe() []string {
133- return b.compilerExe(origCXX, cfg.DefaultCXX(cfg.Goos, cfg.Goarch))
134+func (b *Builder) cxxExe(filtered bool) []string {
135+ return b.compilerExe(origCXX, cfg.DefaultCXX(cfg.Goos, cfg.Goarch), filtered)
136 }
137
138 // fcExe returns the FC compiler setting without all the extra flags we add implicitly.
139-func (b *Builder) fcExe() []string {
140- return b.compilerExe(os.Getenv("FC"), "gfortran")
141+func (b *Builder) fcExe(filtered bool) []string {
142+ return b.compilerExe(os.Getenv("FC"), "gfortran", filtered)
143 }
144
145 // compilerExe returns the compiler to use given an
146@@ -2131,11 +2133,14 @@ func (b *Builder) fcExe() []string {
147 // of the compiler but can have additional arguments if they
148 // were present in the environment value.
149 // For example if CC="gcc -DGOPHER" then the result is ["gcc", "-DGOPHER"].
150-func (b *Builder) compilerExe(envValue string, def string) []string {
151+func (b *Builder) compilerExe(envValue string, def string, filtered bool) []string {
152 compiler := strings.Fields(envValue)
153 if len(compiler) == 0 {
154 compiler = []string{def}
155 }
156+ if filtered {
157+ return append(compiler[0:1], filterCompilerFlags(compiler[1:])...)
158+ }
159 return compiler
160 }
161
162@@ -2285,8 +2290,23 @@ func envList(key, def string) []string {
163 return strings.Fields(v)
164 }
165
166+var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
167+
168+func filterCompilerFlags(flags []string) []string {
169+ var newflags []string
170+ if !filterFlags {
171+ return flags
172+ }
173+ for _, flag := range flags {
174+ if strings.HasPrefix(flag, "-m") {
175+ newflags = append(newflags, flag)
176+ }
177+ }
178+ return newflags
179+}
180+
181 // CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo.
182-func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) {
183+func (b *Builder) CFlags(p *load.Package, filtered bool) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) {
184 defaults := "-g -O2"
185
186 if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
187@@ -2304,6 +2324,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
188 if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
189 return
190 }
191+ if filtered {
192+ cppflags = filterCompilerFlags(cppflags)
193+ cflags = filterCompilerFlags(cflags)
194+ cxxflags = filterCompilerFlags(cxxflags)
195+ fflags = filterCompilerFlags(fflags)
196+ ldflags = filterCompilerFlags(ldflags)
197+ }
198
199 return
200 }
201@@ -2319,7 +2346,7 @@ var cgoRe = regexp.MustCompile(`[/\\:]`)
202
203 func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
204 p := a.Package
205- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p)
206+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p, false)
207 if err != nil {
208 return nil, nil, err
209 }
210@@ -2679,7 +2706,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
211
212 // Run SWIG on one SWIG input file.
213 func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
214- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p)
215+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p, false)
216 if err != nil {
217 return "", "", err
218 }
diff --git a/meta/recipes-devtools/go/go-1.12/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch b/meta/recipes-devtools/go/go-1.12/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch
deleted file mode 100644
index b6ca40edee..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From 5c32c38bf19b24f0aadd78012d17ff5caa82151e Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Sat, 17 Feb 2018 05:24:20 -0800
4Subject: [PATCH] allow GOTOOLDIR to be overridden in the environment
5
6to allow for split host/target build roots
7
8Upstream-Status: Inappropriate [OE specific]
9
10Signed-off-by: Matt Madison <matt@madison.systems>
11
12---
13 src/cmd/dist/build.go | 4 +++-
14 src/cmd/go/internal/cfg/cfg.go | 7 +++++--
15 2 files changed, 8 insertions(+), 3 deletions(-)
16
17Index: go/src/cmd/dist/build.go
18===================================================================
19--- go.orig/src/cmd/dist/build.go
20+++ go/src/cmd/dist/build.go
21@@ -228,7 +228,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
32Index: go/src/cmd/go/internal/cfg/cfg.go
33===================================================================
34--- go.orig/src/cmd/go/internal/cfg/cfg.go
35+++ go/src/cmd/go/internal/cfg/cfg.go
36@@ -116,7 +116,11 @@ func init() {
37 // variables. This matches the initialization of ToolDir in
38 // go/build, except for using GOROOT rather than
39 // 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
diff --git a/meta/recipes-devtools/go/go-1.12/0004-ld-add-soname-to-shareable-objects.patch b/meta/recipes-devtools/go/go-1.12/0004-ld-add-soname-to-shareable-objects.patch
deleted file mode 100644
index 004a33a023..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0004-ld-add-soname-to-shareable-objects.patch
+++ /dev/null
@@ -1,45 +0,0 @@
1From 55eb8c95a89f32aec16b7764e78e8cf75169dc81 Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Sat, 17 Feb 2018 06:26:10 -0800
4Subject: [PATCH] ld: add soname to shareable objects
5
6so that OE's shared library dependency handling
7can find them.
8
9Upstream-Status: Inappropriate [OE specific]
10
11Signed-off-by: Matt Madison <matt@madison.systems>
12
13---
14 src/cmd/link/internal/ld/lib.go | 4 ++++
15 1 file changed, 4 insertions(+)
16
17diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
18index 220aab3..703925f 100644
19--- a/src/cmd/link/internal/ld/lib.go
20+++ b/src/cmd/link/internal/ld/lib.go
21@@ -1135,6 +1135,7 @@ func (ctxt *Link) hostlink() {
22 argv = append(argv, "-Wl,-z,relro")
23 }
24 argv = append(argv, "-shared")
25+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile)))
26 if ctxt.HeadType != objabi.Hwindows {
27 // Pass -z nodelete to mark the shared library as
28 // non-closeable: a dlclose will do nothing.
29@@ -1146,6 +1147,8 @@ func (ctxt *Link) hostlink() {
30 argv = append(argv, "-Wl,-z,relro")
31 }
32 argv = append(argv, "-shared")
33+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile)))
34+
35 case BuildModePlugin:
36 if ctxt.HeadType == objabi.Hdarwin {
37 argv = append(argv, "-dynamiclib")
38@@ -1154,6 +1157,7 @@ func (ctxt *Link) hostlink() {
39 argv = append(argv, "-Wl,-z,relro")
40 }
41 argv = append(argv, "-shared")
42+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile)))
43 }
44 }
45
diff --git a/meta/recipes-devtools/go/go-1.12/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch b/meta/recipes-devtools/go/go-1.12/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch
deleted file mode 100644
index ace8de9eae..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From 1bf15aa8fb773604b2524cfdab493fa4d8fa9285 Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Sat, 17 Feb 2018 06:32:45 -0800
4Subject: [PATCH] make.bash: override CC when building dist and go_bootstrap
5
6for handling OE cross-canadian builds.
7
8Upstream-Status: Inappropriate [OE specific]
9
10Signed-off-by: Matt Madison <matt@madison.systems>
11
12---
13 src/make.bash | 4 ++--
14 1 file changed, 2 insertions(+), 2 deletions(-)
15
16diff --git a/src/make.bash b/src/make.bash
17index 78882d9..25943d0 100755
18--- a/src/make.bash
19+++ b/src/make.bash
20@@ -163,7 +163,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@@ -194,7 +194,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.
diff --git a/meta/recipes-devtools/go/go-1.12/0006-cmd-dist-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go-1.12/0006-cmd-dist-separate-host-and-target-builds.patch
deleted file mode 100644
index 0c0d5da80a..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0006-cmd-dist-separate-host-and-target-builds.patch
+++ /dev/null
@@ -1,282 +0,0 @@
1From fe0fcaf43ef3aab81541dad2a71b46254dc4cf6a Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Sat, 17 Feb 2018 10:03:48 -0800
4Subject: [PATCH] cmd/dist: separate host and target builds
5
6Change the dist tool to allow for OE-style cross-
7and 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
24Note that for --host-only builds, it would be nice to specify
25just the "cmd" package to build only the go commands/tools,
26the staleness checks in the dist tool will fail if the "std"
27library has not also been built. So host-only builds have to
28build everything anyway.
29
30Upstream-Status: Inappropriate [OE specific]
31
32Signed-off-by: Matt Madison <matt@madison.systems>
33
34more dist cleanup
35
36---
37 src/cmd/dist/build.go | 153 ++++++++++++++++++++++++++++++------------
38 1 file changed, 111 insertions(+), 42 deletions(-)
39
40Index: go/src/cmd/dist/build.go
41===================================================================
42--- go.orig/src/cmd/dist/build.go
43+++ go/src/cmd/dist/build.go
44@@ -39,6 +39,7 @@ var (
45 goldflags string
46 workdir string
47 tooldir string
48+ build_tooldir string
49 oldgoos string
50 oldgoarch string
51 exe string
52@@ -50,6 +51,7 @@ var (
53
54 rebuildall bool
55 defaultclang bool
56+ crossBuild bool
57
58 vflag int // verbosity
59 )
60@@ -231,6 +233,8 @@ func xinit() {
61 if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
62 tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
63 }
64+ build_tooldir = pathf("%s/pkg/tool/native_native", goroot)
65+
66 }
67
68 // compilerEnv returns a map from "goos/goarch" to the
69@@ -260,7 +264,6 @@ func compilerEnv(envName, def string) ma
70 if gohostos != goos || gohostarch != goarch {
71 m[gohostos+"/"+gohostarch] = m[""]
72 }
73- m[""] = env
74 }
75
76 for _, goos := range okgoos {
77@@ -487,8 +490,10 @@ func setup() {
78 // We keep it in pkg/, just like the object directory above.
79 if rebuildall {
80 xremoveall(tooldir)
81+ xremoveall(build_tooldir)
82 }
83 xmkdirall(tooldir)
84+ xmkdirall(build_tooldir)
85
86 // Remove tool binaries from before the tool/gohostos_gohostarch
87 xremoveall(pathf("%s/bin/tool", goroot))
88@@ -1155,11 +1160,29 @@ func cmdbootstrap() {
89
90 var noBanner bool
91 var debug bool
92+ var hostOnly bool
93+ var targetOnly bool
94+ var toBuild = []string { "std", "cmd" }
95+
96 flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all")
97 flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process")
98 flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner")
99+ flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target")
100+ flag.BoolVar(&targetOnly, "target-only", targetOnly, "build only target binaries, not host")
101
102- xflagparse(0)
103+ xflagparse(-1)
104+
105+ if (hostOnly && targetOnly) {
106+ fatalf("specify only one of --host-only or --target-only\n")
107+ }
108+ crossBuild = hostOnly || targetOnly
109+ if flag.NArg() > 0 {
110+ if crossBuild {
111+ toBuild = flag.Args()
112+ } else {
113+ fatalf("package names not permitted without --host-only or --target-only\n")
114+ }
115+ }
116
117 if debug {
118 // cmd/buildid is used in debug mode.
119@@ -1207,8 +1230,13 @@ func cmdbootstrap() {
120 xprintf("\n")
121 }
122
123- gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now
124- goldflags = os.Getenv("GO_LDFLAGS")
125+ // For split host/target cross/cross-canadian builds, we don't
126+ // want to be setting these flags until after we have compiled
127+ // the toolchain that runs on the build host.
128+ if ! crossBuild {
129+ gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now
130+ goldflags = os.Getenv("GO_LDFLAGS")
131+ }
132 goBootstrap := pathf("%s/go_bootstrap", tooldir)
133 cmdGo := pathf("%s/go", gobin)
134 if debug {
135@@ -1237,7 +1265,11 @@ func cmdbootstrap() {
136 xprintf("\n")
137 }
138 xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n")
139- os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
140+ if crossBuild {
141+ os.Setenv("CC", defaultcc[""])
142+ } else {
143+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
144+ }
145 goInstall(goBootstrap, append([]string{"-i"}, toolchain...)...)
146 if debug {
147 run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
148@@ -1274,50 +1306,84 @@ func cmdbootstrap() {
149 }
150 checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...)
151
152- if goos == oldgoos && goarch == oldgoarch {
153- // Common case - not setting up for cross-compilation.
154- timelog("build", "toolchain")
155- if vflag > 0 {
156- xprintf("\n")
157+ if crossBuild {
158+ gogcflags = os.Getenv("GO_GCFLAGS")
159+ goldflags = os.Getenv("GO_LDFLAGS")
160+ tool_files, _ := filepath.Glob(pathf("%s/*", tooldir))
161+ for _, f := range tool_files {
162+ copyfile(pathf("%s/%s", build_tooldir, filepath.Base(f)), f, writeExec)
163+ xremove(f)
164+ }
165+ os.Setenv("GOTOOLDIR", build_tooldir)
166+ goBootstrap = pathf("%s/go_bootstrap", build_tooldir)
167+ if hostOnly {
168+ timelog("build", "host toolchain")
169+ if vflag > 0 {
170+ xprintf("\n")
171+ }
172+ xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
173+ goInstall(goBootstrap, toBuild...)
174+ checkNotStale(goBootstrap, toBuild...)
175+ // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary
176+
177+ timelog("build", "target toolchain")
178+ if vflag > 0 {
179+ xprintf("\n")
180+ }
181+ } else if targetOnly {
182+ goos = oldgoos
183+ goarch = oldgoarch
184+ os.Setenv("GOOS", goos)
185+ os.Setenv("GOARCH", goarch)
186+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
187+ xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
188+ goInstall(goBootstrap, toBuild...)
189+ checkNotStale(goBootstrap, toBuild...)
190+ // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary
191 }
192- xprintf("Building packages and commands for %s/%s.\n", goos, goarch)
193 } else {
194- // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH.
195- // Finish GOHOSTOS/GOHOSTARCH installation and then
196- // run GOOS/GOARCH installation.
197- timelog("build", "host toolchain")
198- if vflag > 0 {
199- xprintf("\n")
200+
201+ if goos == oldgoos && goarch == oldgoarch {
202+ // Common case - not setting up for cross-compilation.
203+ timelog("build", "toolchain")
204+ if vflag > 0 {
205+ xprintf("\n")
206+ }
207+ xprintf("Building packages and commands for %s/%s.\n", goos, goarch)
208+ } else {
209+ // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH.
210+ // Finish GOHOSTOS/GOHOSTARCH installation and then
211+ // run GOOS/GOARCH installation.
212+ timelog("build", "host toolchain")
213+ if vflag > 0 {
214+ xprintf("\n")
215+ }
216+ xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch)
217+ goInstall(goBootstrap, "std", "cmd")
218+ checkNotStale(goBootstrap, "std", "cmd")
219+ checkNotStale(cmdGo, "std", "cmd")
220+
221+ timelog("build", "target toolchain")
222+ if vflag > 0 {
223+ xprintf("\n")
224+ }
225+ goos = oldgoos
226+ goarch = oldgoarch
227+ os.Setenv("GOOS", goos)
228+ os.Setenv("GOARCH", goarch)
229+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
230+ xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch)
231 }
232- xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch)
233 goInstall(goBootstrap, "std", "cmd")
234 checkNotStale(goBootstrap, "std", "cmd")
235 checkNotStale(cmdGo, "std", "cmd")
236
237- timelog("build", "target toolchain")
238- if vflag > 0 {
239- xprintf("\n")
240- }
241- goos = oldgoos
242- goarch = oldgoarch
243- os.Setenv("GOOS", goos)
244- os.Setenv("GOARCH", goarch)
245- os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
246- xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch)
247- }
248- targets := []string{"std", "cmd"}
249- if goos == "js" && goarch == "wasm" {
250- // Skip the cmd tools for js/wasm. They're not usable.
251- targets = targets[:1]
252- }
253- goInstall(goBootstrap, targets...)
254- checkNotStale(goBootstrap, targets...)
255- checkNotStale(cmdGo, targets...)
256- if debug {
257- run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
258- run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch))
259- checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...)
260- copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec)
261+ if debug {
262+ run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
263+ run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch))
264+ checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...)
265+ copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec)
266+ }
267 }
268
269 // Check that there are no new files in $GOROOT/bin other than
270@@ -1335,7 +1401,11 @@ func cmdbootstrap() {
271 }
272
273 // Remove go_bootstrap now that we're done.
274- xremove(pathf("%s/go_bootstrap", tooldir))
275+ // Except that for split host/target cross-builds, we need to
276+ // keep it.
277+ if ! crossBuild {
278+ xremove(pathf("%s/go_bootstrap", tooldir))
279+ }
280
281 // Print trailing banner unless instructed otherwise.
282 if !noBanner {
diff --git a/meta/recipes-devtools/go/go-1.12/0007-cmd-go-make-GOROOT-precious-by-default.patch b/meta/recipes-devtools/go/go-1.12/0007-cmd-go-make-GOROOT-precious-by-default.patch
deleted file mode 100644
index 29ef947abd..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0007-cmd-go-make-GOROOT-precious-by-default.patch
+++ /dev/null
@@ -1,106 +0,0 @@
1From 7cc60b3887be2d5674b9f5d422d022976cf205e5 Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Fri, 2 Mar 2018 06:00:20 -0800
4Subject: [PATCH] cmd/go: make GOROOT precious by default
5
6The go build tool normally rebuilds whatever it detects is
7stale. This can be a problem when GOROOT is intended to
8be read-only and the go runtime has been built as a shared
9library, since we don't want every application to be rebuilding
10the shared runtime - particularly in cross-build/packaging
11setups, since that would lead to 'abi mismatch' runtime errors.
12
13This patch prevents the install and linkshared actions from
14installing to GOROOT unless overridden with the GOROOT_OVERRIDE
15environment variable.
16
17Upstream-Status: Inappropriate [OE specific]
18
19Signed-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
27Index: 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
41Index: 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
64Index: 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 }
diff --git a/meta/recipes-devtools/go/go-1.12/0008-use-GOBUILDMODE-to-set-buildmode.patch b/meta/recipes-devtools/go/go-1.12/0008-use-GOBUILDMODE-to-set-buildmode.patch
deleted file mode 100644
index 225cf439c5..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0008-use-GOBUILDMODE-to-set-buildmode.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From 0e0c247f0caec23528889ff09d98348cba9028f1 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Fri, 26 Oct 2018 15:02:32 +0800
4Subject: [PATCH] use GOBUILDMODE to set buildmode
5
6While building go itself, the go build system does not support
7to set `-buildmode=pie' from environment.
8
9Add GOBUILDMODE to support it which make PIE executables the default
10build mode, as PIE executables are required as of Yocto
11
12Refers: https://groups.google.com/forum/#!topic/golang-dev/gRCe5URKewI
13Upstream-Status: Denied [upstream choose antoher solution: `17a256b
14cmd/go: -buildmode=pie for android/arm']
15
16Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
17---
18 src/cmd/go/internal/work/build.go | 6 +++++-
19 1 file changed, 5 insertions(+), 1 deletion(-)
20
21Index: go/src/cmd/go/internal/work/build.go
22===================================================================
23--- go.orig/src/cmd/go/internal/work/build.go
24+++ go/src/cmd/go/internal/work/build.go
25@@ -223,7 +223,11 @@ func AddBuildFlags(cmd *base.Command) {
26
27 cmd.Flag.Var(&load.BuildAsmflags, "asmflags", "")
28 cmd.Flag.Var(buildCompiler{}, "compiler", "")
29- cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "")
30+ if bm := os.Getenv("GOBUILDMODE"); bm != "" {
31+ cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", bm, "")
32+ } else {
33+ cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "")
34+ }
35 cmd.Flag.Var(&load.BuildGcflags, "gcflags", "")
36 cmd.Flag.Var(&load.BuildGccgoflags, "gccgoflags", "")
37 cmd.Flag.StringVar(&cfg.BuildMod, "mod", "", "")
diff --git a/meta/recipes-devtools/go/go-1.12/0009-ld-replace-glibc-dynamic-linker-with-musl.patch b/meta/recipes-devtools/go/go-1.12/0009-ld-replace-glibc-dynamic-linker-with-musl.patch
deleted file mode 100644
index 840cf4bbd7..0000000000
--- a/meta/recipes-devtools/go/go-1.12/0009-ld-replace-glibc-dynamic-linker-with-musl.patch
+++ /dev/null
@@ -1,112 +0,0 @@
1From 35ea4be34e94912b00837e0f7c7385f2e98fe769 Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Sun, 18 Feb 2018 08:24:05 -0800
4Subject: [PATCH] ld: replace glibc dynamic linker with musl
5
6Rework of patch by Khem Raj <raj.khem@gmail.com>
7for go 1.10. Should be applied conditionally on
8musl being the system C library.
9
10Upstream-Status: Inappropriate [Real fix should be portable across libcs]
11
12Signed-off-by: Matt Madison <matt@madison.systems>
13
14---
15 src/cmd/link/internal/amd64/obj.go | 2 +-
16 src/cmd/link/internal/arm/obj.go | 2 +-
17 src/cmd/link/internal/arm64/obj.go | 2 +-
18 src/cmd/link/internal/mips/obj.go | 2 +-
19 src/cmd/link/internal/mips64/obj.go | 2 +-
20 src/cmd/link/internal/ppc64/obj.go | 2 +-
21 src/cmd/link/internal/s390x/obj.go | 2 +-
22 src/cmd/link/internal/x86/obj.go | 2 +-
23 8 files changed, 8 insertions(+), 8 deletions(-)
24
25--- a/src/cmd/link/internal/amd64/obj.go
26+++ b/src/cmd/link/internal/amd64/obj.go
27@@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) {
28 PEreloc1: pereloc1,
29 TLSIEtoLE: tlsIEtoLE,
30
31- Linuxdynld: "/lib64/ld-linux-x86-64.so.2",
32+ Linuxdynld: "/lib64/ld-musl-x86-64.so.1",
33 Freebsddynld: "/libexec/ld-elf.so.1",
34 Openbsddynld: "/usr/libexec/ld.so",
35 Netbsddynld: "/libexec/ld.elf_so",
36--- a/src/cmd/link/internal/arm/obj.go
37+++ b/src/cmd/link/internal/arm/obj.go
38@@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) {
39 Machoreloc1: machoreloc1,
40 PEreloc1: pereloc1,
41
42- Linuxdynld: "/lib/ld-linux.so.3", // 2 for OABI, 3 for EABI
43+ Linuxdynld: "/lib/ld-musl-armhf.so.1",
44 Freebsddynld: "/usr/libexec/ld-elf.so.1",
45 Openbsddynld: "/usr/libexec/ld.so",
46 Netbsddynld: "/libexec/ld.elf_so",
47--- a/src/cmd/link/internal/arm64/obj.go
48+++ b/src/cmd/link/internal/arm64/obj.go
49@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) {
50 Gentext: gentext,
51 Machoreloc1: machoreloc1,
52
53- Linuxdynld: "/lib/ld-linux-aarch64.so.1",
54+ Linuxdynld: "/lib/ld-musl-aarch64.so.1",
55
56 Freebsddynld: "XXX",
57 Openbsddynld: "XXX",
58--- a/src/cmd/link/internal/mips/obj.go
59+++ b/src/cmd/link/internal/mips/obj.go
60@@ -60,7 +60,7 @@ func Init() (*sys.Arch, ld.Arch) {
61 Gentext: gentext,
62 Machoreloc1: machoreloc1,
63
64- Linuxdynld: "/lib/ld.so.1",
65+ Linuxdynld: "/lib/ld-musl-mipsle.so.1",
66
67 Freebsddynld: "XXX",
68 Openbsddynld: "XXX",
69--- a/src/cmd/link/internal/mips64/obj.go
70+++ b/src/cmd/link/internal/mips64/obj.go
71@@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) {
72 Gentext: gentext,
73 Machoreloc1: machoreloc1,
74
75- Linuxdynld: "/lib64/ld64.so.1",
76+ Linuxdynld: "/lib64/ld-musl-mips64le.so.1",
77 Freebsddynld: "XXX",
78 Openbsddynld: "XXX",
79 Netbsddynld: "XXX",
80--- a/src/cmd/link/internal/ppc64/obj.go
81+++ b/src/cmd/link/internal/ppc64/obj.go
82@@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) {
83 Machoreloc1: machoreloc1,
84
85 // TODO(austin): ABI v1 uses /usr/lib/ld.so.1,
86- Linuxdynld: "/lib64/ld64.so.1",
87+ Linuxdynld: "/lib64/ld-musl-powerpc64le.so.1",
88
89 Freebsddynld: "XXX",
90 Openbsddynld: "XXX",
91--- a/src/cmd/link/internal/s390x/obj.go
92+++ b/src/cmd/link/internal/s390x/obj.go
93@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) {
94 Gentext: gentext,
95 Machoreloc1: machoreloc1,
96
97- Linuxdynld: "/lib64/ld64.so.1",
98+ Linuxdynld: "/lib64/ld-musl-s390x.so.1",
99
100 // not relevant for s390x
101 Freebsddynld: "XXX",
102--- a/src/cmd/link/internal/x86/obj.go
103+++ b/src/cmd/link/internal/x86/obj.go
104@@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) {
105 Machoreloc1: machoreloc1,
106 PEreloc1: pereloc1,
107
108- Linuxdynld: "/lib/ld-linux.so.2",
109+ Linuxdynld: "/lib/ld-musl-i386.so.1",
110 Freebsddynld: "/usr/libexec/ld-elf.so.1",
111 Openbsddynld: "/usr/libexec/ld.so",
112 Netbsddynld: "/usr/libexec/ld.elf_so",
diff --git a/meta/recipes-devtools/go/go-cross-canadian_1.12.bb b/meta/recipes-devtools/go/go-cross-canadian_1.12.bb
deleted file mode 100644
index 7ac9449e47..0000000000
--- a/meta/recipes-devtools/go/go-cross-canadian_1.12.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require go-cross-canadian.inc
2require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-cross_1.12.bb b/meta/recipes-devtools/go/go-cross_1.12.bb
deleted file mode 100644
index 80b5a03f6c..0000000000
--- a/meta/recipes-devtools/go/go-cross_1.12.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require go-cross.inc
2require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-crosssdk_1.12.bb b/meta/recipes-devtools/go/go-crosssdk_1.12.bb
deleted file mode 100644
index 1857c8a577..0000000000
--- a/meta/recipes-devtools/go/go-crosssdk_1.12.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require go-crosssdk.inc
2require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-native_1.12.bb b/meta/recipes-devtools/go/go-native_1.12.bb
deleted file mode 100644
index bbf3c0dd73..0000000000
--- a/meta/recipes-devtools/go/go-native_1.12.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require ${PN}.inc
2require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-runtime_1.12.bb b/meta/recipes-devtools/go/go-runtime_1.12.bb
deleted file mode 100644
index 43b68b4e46..0000000000
--- a/meta/recipes-devtools/go/go-runtime_1.12.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require go-${PV}.inc
2require go-runtime.inc
diff --git a/meta/recipes-devtools/go/go_1.12.bb b/meta/recipes-devtools/go/go_1.12.bb
deleted file mode 100644
index 42cdb0430a..0000000000
--- a/meta/recipes-devtools/go/go_1.12.bb
+++ /dev/null
@@ -1,14 +0,0 @@
1require go-${PV}.inc
2require go-target.inc
3
4export GOBUILDMODE=""
5
6# Add pie to GOBUILDMODE to satisfy "textrel" QA checking, but mips
7# doesn't support -buildmode=pie, so skip the QA checking for mips and its
8# variants.
9python() {
10 if 'mips' in d.getVar('TARGET_ARCH'):
11 d.appendVar('INSANE_SKIP_%s' % d.getVar('PN'), " textrel")
12 else:
13 d.setVar('GOBUILDMODE', 'pie')
14}