diff options
Diffstat (limited to 'meta/recipes-devtools/go')
52 files changed, 664 insertions, 1392 deletions
diff --git a/meta/recipes-devtools/go/go-1.11/0001-allow-CC-and-CXX-to-have-multiple-words.patch b/meta/recipes-devtools/go/go-1.11/0001-allow-CC-and-CXX-to-have-multiple-words.patch deleted file mode 100644 index 4442858c83..0000000000 --- a/meta/recipes-devtools/go/go-1.11/0001-allow-CC-and-CXX-to-have-multiple-words.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 7cc519aa5f84cf8fc7ac8c10fc69aa8040330ea0 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Mon, 19 Feb 2018 08:49:33 -0800 -Subject: [PATCH] allow CC and CXX to have multiple words - -Upstream-Status: Inappropriate [OE specific] - -Signed-off-by: Matt Madison <matt@madison.systems> - ---- - src/cmd/go/internal/envcmd/env.go | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go -index afadbad..cedbfbf 100644 ---- a/src/cmd/go/internal/envcmd/env.go -+++ b/src/cmd/go/internal/envcmd/env.go -@@ -85,11 +85,11 @@ func MkEnv() []cfg.EnvVar { - - cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch) - if env := strings.Fields(os.Getenv("CC")); len(env) > 0 { -- cc = env[0] -+ cc = strings.Join(env, " ") - } - cxx := cfg.DefaultCXX(cfg.Goos, cfg.Goarch) - if env := strings.Fields(os.Getenv("CXX")); len(env) > 0 { -- cxx = env[0] -+ cxx = strings.Join(env, " ") - } - env = append(env, cfg.EnvVar{Name: "CC", Value: cc}) - env = append(env, cfg.EnvVar{Name: "CXX", Value: cxx}) diff --git a/meta/recipes-devtools/go/go-1.11/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch b/meta/recipes-devtools/go/go-1.11/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch deleted file mode 100644 index b6ca40edee..0000000000 --- a/meta/recipes-devtools/go/go-1.11/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 5c32c38bf19b24f0aadd78012d17ff5caa82151e Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Sat, 17 Feb 2018 05:24:20 -0800 -Subject: [PATCH] allow GOTOOLDIR to be overridden in the environment - -to allow for split host/target build roots - -Upstream-Status: Inappropriate [OE specific] - -Signed-off-by: Matt Madison <matt@madison.systems> - ---- - src/cmd/dist/build.go | 4 +++- - src/cmd/go/internal/cfg/cfg.go | 7 +++++-- - 2 files changed, 8 insertions(+), 3 deletions(-) - -Index: go/src/cmd/dist/build.go -=================================================================== ---- go.orig/src/cmd/dist/build.go -+++ go/src/cmd/dist/build.go -@@ -228,7 +228,9 @@ func xinit() { - workdir = xworkdir() - xatexit(rmworkdir) - -- tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) -+ if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { -+ tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) -+ } - } - - // compilerEnv returns a map from "goos/goarch" to the -Index: go/src/cmd/go/internal/cfg/cfg.go -=================================================================== ---- go.orig/src/cmd/go/internal/cfg/cfg.go -+++ go/src/cmd/go/internal/cfg/cfg.go -@@ -116,7 +116,11 @@ func init() { - // variables. This matches the initialization of ToolDir in - // go/build, except for using GOROOT rather than - // runtime.GOROOT. -- build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) -+ if s := os.Getenv("GOTOOLDIR"); s != "" { -+ build.ToolDir = filepath.Clean(s) -+ } else { -+ build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) -+ } - } - } - diff --git a/meta/recipes-devtools/go/go-1.11/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch b/meta/recipes-devtools/go/go-1.11/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.11/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 1bf15aa8fb773604b2524cfdab493fa4d8fa9285 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Sat, 17 Feb 2018 06:32:45 -0800 -Subject: [PATCH] make.bash: override CC when building dist and go_bootstrap - -for handling OE cross-canadian builds. - -Upstream-Status: Inappropriate [OE specific] - -Signed-off-by: Matt Madison <matt@madison.systems> - ---- - src/make.bash | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/make.bash b/src/make.bash -index 78882d9..25943d0 100755 ---- a/src/make.bash -+++ b/src/make.bash -@@ -163,7 +163,7 @@ if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; then - exit 1 - fi - rm -f cmd/dist/dist --GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist -+CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist - - # -e doesn't propagate out of eval, so check success by hand. - eval $(./cmd/dist/dist env -p || echo FAIL=true) -@@ -194,7 +194,7 @@ fi - # Run dist bootstrap to complete make.bash. - # Bootstrap installs a proper cmd/dist, built with the new toolchain. - # Throw ours, built with Go 1.4, away after bootstrap. --./cmd/dist/dist bootstrap $buildall $vflag $GO_DISTFLAGS "$@" -+CC="${BUILD_CC:-${CC}}" ./cmd/dist/dist bootstrap $buildall $vflag $GO_DISTFLAGS "$@" - rm -f ./cmd/dist/dist - - # DO NOT ADD ANY NEW CODE HERE. diff --git a/meta/recipes-devtools/go/go-1.11/0009-ld-replace-glibc-dynamic-linker-with-musl.patch b/meta/recipes-devtools/go/go-1.11/0009-ld-replace-glibc-dynamic-linker-with-musl.patch deleted file mode 100644 index fd67375c7f..0000000000 --- a/meta/recipes-devtools/go/go-1.11/0009-ld-replace-glibc-dynamic-linker-with-musl.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 35ea4be34e94912b00837e0f7c7385f2e98fe769 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Sun, 18 Feb 2018 08:24:05 -0800 -Subject: [PATCH] ld: replace glibc dynamic linker with musl - -Rework of patch by Khem Raj <raj.khem@gmail.com> -for go 1.10. Should be applied conditionally on -musl being the system C library. - -Upstream-Status: Inappropriate [Real fix should be portable across libcs] - -Signed-off-by: Matt Madison <matt@madison.systems> - ---- - src/cmd/link/internal/amd64/obj.go | 2 +- - src/cmd/link/internal/arm/obj.go | 2 +- - src/cmd/link/internal/arm64/obj.go | 2 +- - src/cmd/link/internal/mips/obj.go | 2 +- - src/cmd/link/internal/mips64/obj.go | 2 +- - src/cmd/link/internal/ppc64/obj.go | 2 +- - src/cmd/link/internal/s390x/obj.go | 2 +- - src/cmd/link/internal/x86/obj.go | 2 +- - 8 files changed, 8 insertions(+), 8 deletions(-) - -diff --git a/src/cmd/link/internal/amd64/obj.go b/src/cmd/link/internal/amd64/obj.go -index 87e8091..f522a63 100644 ---- a/src/cmd/link/internal/amd64/obj.go -+++ b/src/cmd/link/internal/amd64/obj.go -@@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) { - PEreloc1: pereloc1, - TLSIEtoLE: tlsIEtoLE, - -- Linuxdynld: "/lib64/ld-linux-x86-64.so.2", -+ Linuxdynld: "/lib64/ld-musl-x86-64.so.1", - Freebsddynld: "/libexec/ld-elf.so.1", - Openbsddynld: "/usr/libexec/ld.so", - Netbsddynld: "/libexec/ld.elf_so", -diff --git a/src/cmd/link/internal/arm/obj.go b/src/cmd/link/internal/arm/obj.go -index 788be68..1d2b90e 100644 ---- a/src/cmd/link/internal/arm/obj.go -+++ b/src/cmd/link/internal/arm/obj.go -@@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) { - Gentext: gentext, - Machoreloc1: machoreloc1, - -- Linuxdynld: "/lib/ld-linux.so.3", // 2 for OABI, 3 for EABI -+ Linuxdynld: "/lib/ld-musl-armhf.so.1", - Freebsddynld: "/usr/libexec/ld-elf.so.1", - Openbsddynld: "/usr/libexec/ld.so", - Netbsddynld: "/libexec/ld.elf_so", -diff --git a/src/cmd/link/internal/arm64/obj.go b/src/cmd/link/internal/arm64/obj.go -index 405d22d..b115659 100644 ---- a/src/cmd/link/internal/arm64/obj.go -+++ b/src/cmd/link/internal/arm64/obj.go -@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) { - Gentext: gentext, - Machoreloc1: machoreloc1, - -- Linuxdynld: "/lib/ld-linux-aarch64.so.1", -+ Linuxdynld: "/lib/ld-musl-aarch64.so.1", - - Freebsddynld: "XXX", - Openbsddynld: "XXX", -diff --git a/src/cmd/link/internal/mips/obj.go b/src/cmd/link/internal/mips/obj.go -index c5d3451..fd85e63 100644 ---- a/src/cmd/link/internal/mips/obj.go -+++ b/src/cmd/link/internal/mips/obj.go -@@ -60,7 +60,7 @@ func Init() (*sys.Arch, ld.Arch) { - Gentext: gentext, - Machoreloc1: machoreloc1, - -- Linuxdynld: "/lib/ld.so.1", -+ Linuxdynld: "/lib/ld-musl-mipsle.so.1", - - Freebsddynld: "XXX", - Openbsddynld: "XXX", -diff --git a/src/cmd/link/internal/mips64/obj.go b/src/cmd/link/internal/mips64/obj.go -index 83974e5..097224f 100644 ---- a/src/cmd/link/internal/mips64/obj.go -+++ b/src/cmd/link/internal/mips64/obj.go -@@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) { - Gentext: gentext, - Machoreloc1: machoreloc1, - -- Linuxdynld: "/lib64/ld64.so.1", -+ Linuxdynld: "/lib64/ld-musl-mips64le.so.1", - Freebsddynld: "XXX", - Openbsddynld: "XXX", - Netbsddynld: "XXX", -diff --git a/src/cmd/link/internal/ppc64/obj.go b/src/cmd/link/internal/ppc64/obj.go -index 273d9b4..a503abe 100644 ---- a/src/cmd/link/internal/ppc64/obj.go -+++ b/src/cmd/link/internal/ppc64/obj.go -@@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) { - Machoreloc1: machoreloc1, - - // TODO(austin): ABI v1 uses /usr/lib/ld.so.1, -- Linuxdynld: "/lib64/ld64.so.1", -+ Linuxdynld: "/lib64/ld-musl-powerpc64le.so.1", - - Freebsddynld: "XXX", - Openbsddynld: "XXX", -diff --git a/src/cmd/link/internal/s390x/obj.go b/src/cmd/link/internal/s390x/obj.go -index 9ac7eb8..3825ff7 100644 ---- a/src/cmd/link/internal/s390x/obj.go -+++ b/src/cmd/link/internal/s390x/obj.go -@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) { - Gentext: gentext, - Machoreloc1: machoreloc1, - -- Linuxdynld: "/lib64/ld64.so.1", -+ Linuxdynld: "/lib64/ld-musl-s390x.so.1", - - // not relevant for s390x - Freebsddynld: "XXX", -diff --git a/src/cmd/link/internal/x86/obj.go b/src/cmd/link/internal/x86/obj.go -index 6a744dc..d81f392 100644 ---- a/src/cmd/link/internal/x86/obj.go -+++ b/src/cmd/link/internal/x86/obj.go -@@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) { - Machoreloc1: machoreloc1, - PEreloc1: pereloc1, - -- Linuxdynld: "/lib/ld-linux.so.2", -+ Linuxdynld: "/lib/ld-musl-i386.so.1", - Freebsddynld: "/usr/libexec/ld-elf.so.1", - Openbsddynld: "/usr/libexec/ld.so", - Netbsddynld: "/usr/libexec/ld.elf_so", diff --git a/meta/recipes-devtools/go/go-1.11.inc b/meta/recipes-devtools/go/go-1.17.8.inc index d03e26cea0..649c09ec1d 100644 --- a/meta/recipes-devtools/go/go-1.11.inc +++ b/meta/recipes-devtools/go/go-1.17.8.inc @@ -1,9 +1,6 @@ require go-common.inc -GO_BASEVERSION = "1.11" -GO_MINOR = ".4" -PV .= "${GO_MINOR}" -FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/go-${GO_BASEVERSION}:" +FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/go-1.18:" LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707" @@ -16,8 +13,13 @@ SRC_URI += "\ file://0006-cmd-dist-separate-host-and-target-builds.patch \ file://0007-cmd-go-make-GOROOT-precious-by-default.patch \ file://0008-use-GOBUILDMODE-to-set-buildmode.patch \ + file://0009-Revert-cmd-go-make-sure-CC-and-CXX-are-absolute.patch \ + file://0001-exec.go-do-not-write-linker-flags-into-buildids.patch \ + file://0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \ " -SRC_URI_append_libc-musl = " file://0009-ld-replace-glibc-dynamic-linker-with-musl.patch" +SRC_URI[main.sha256sum] = "2effcd898140da79a061f3784ca4f8d8b13d811fb2abe9dad2404442dabbdf7a" -SRC_URI[main.md5sum] = "a77697673215be465d1b583680ef2318" -SRC_URI[main.sha256sum] = "4cfd42720a6b1e79a8024895fa6607b69972e8e32446df76d6ce79801bbadb15" +# Upstream don't believe it is a signifiant real world issue and will only +# fix in 1.17 onwards where we can drop this. +# https://github.com/golang/go/issues/30999#issuecomment-910470358 +CVE_CHECK_IGNORE += "CVE-2021-29923" diff --git a/meta/recipes-devtools/go/go-1.18/0001-allow-CC-and-CXX-to-have-multiple-words.patch b/meta/recipes-devtools/go/go-1.18/0001-allow-CC-and-CXX-to-have-multiple-words.patch new file mode 100644 index 0000000000..5f4823be22 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.18/0001-allow-CC-and-CXX-to-have-multiple-words.patch @@ -0,0 +1,33 @@ +From 9e3dc44cdfa58d96504d0a789dc82617dd5bef55 Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:01:13 +0430 +Subject: [PATCH 1/9] cmd/go: Allow CC and CXX to have multiple words + +Upstream-Status: Inappropriate [OE specific] + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> + +--- + src/cmd/go/internal/envcmd/env.go | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/src/cmd/go/internal/envcmd/env.go ++++ b/src/cmd/go/internal/envcmd/env.go +@@ -103,11 +103,11 @@ func MkEnv() []cfg.EnvVar { + + cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch) + if env := strings.Fields(cfg.Getenv("CC")); len(env) > 0 { +- cc = env[0] ++ cc = strings.Join(env, " ") + } + cxx := cfg.DefaultCXX(cfg.Goos, cfg.Goarch) + if env := strings.Fields(cfg.Getenv("CXX")); len(env) > 0 { +- cxx = env[0] ++ cxx = strings.Join(env, " ") + } + env = append(env, cfg.EnvVar{Name: "AR", Value: envOr("AR", "ar")}) + env = append(env, cfg.EnvVar{Name: "CC", Value: cc}) diff --git a/meta/recipes-devtools/go/go-1.18/0001-exec.go-do-not-write-linker-flags-into-buildids.patch b/meta/recipes-devtools/go/go-1.18/0001-exec.go-do-not-write-linker-flags-into-buildids.patch new file mode 100644 index 0000000000..20b6636f65 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.18/0001-exec.go-do-not-write-linker-flags-into-buildids.patch @@ -0,0 +1,41 @@ +From bdd69b55387f80c8df18d0af5008bf5e1a66be6a Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin <alex.kanavin@gmail.com> +Date: Mon, 23 Nov 2020 19:22:04 +0000 +Subject: [PATCH] exec.go: do not write linker flags into buildids + +The flags can contain build-specific paths, breaking reproducibility. + +To make this acceptable to upstream, we probably need to trim the flags, +removing those known to be buildhost-specific. + +Upstream-Status: Inappropriate [needs upstream discussion] +Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> +--- + src/cmd/go/internal/work/exec.go | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go +index 696db23..727d40b 100644 +--- a/src/cmd/go/internal/work/exec.go ++++ b/src/cmd/go/internal/work/exec.go +@@ -1136,7 +1136,7 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID { + } + + // Toolchain-dependent configuration, shared with b.linkSharedActionID. +- b.printLinkerConfig(h, p) ++ //b.printLinkerConfig(h, p) + + // Input files. + for _, a1 := range a.Deps { +@@ -1418,7 +1418,7 @@ func (b *Builder) linkSharedActionID(a *Action) cache.ActionID { + fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch) + + // Toolchain-dependent configuration, shared with b.linkActionID. +- b.printLinkerConfig(h, nil) ++ //b.printLinkerConfig(h, nil) + + // Input files. + for _, a1 := range a.Deps { +-- +2.17.1 + diff --git a/meta/recipes-devtools/go/go-1.18/0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch b/meta/recipes-devtools/go/go-1.18/0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch new file mode 100644 index 0000000000..257454a67d --- /dev/null +++ b/meta/recipes-devtools/go/go-1.18/0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch @@ -0,0 +1,41 @@ +From 2055a46b396e272616c0b2273903e02c3b49a2ff Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin <alex.kanavin@gmail.com> +Date: Tue, 10 Nov 2020 16:33:27 +0000 +Subject: [PATCH] src/cmd/dist/buildgo.go: do not hardcode host compilers into + target binaries + +These come from $CC/$CXX on the build host and are not useful on targets; +additionally as they contain host specific paths, this helps reproducibility. + +Upstream-Status: Inappropriate [needs upstream discussion] +Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> +--- + src/cmd/dist/buildgo.go | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/cmd/dist/buildgo.go b/src/cmd/dist/buildgo.go +index caafc13..4eb1c96 100644 +--- a/src/cmd/dist/buildgo.go ++++ b/src/cmd/dist/buildgo.go +@@ -34,8 +34,8 @@ func mkzdefaultcc(dir, file string) { + fmt.Fprintf(&buf, "package cfg\n") + fmt.Fprintln(&buf) + fmt.Fprintf(&buf, "const DefaultPkgConfig = `%s`\n", defaultpkgconfig) +- buf.WriteString(defaultCCFunc("DefaultCC", defaultcc)) +- buf.WriteString(defaultCCFunc("DefaultCXX", defaultcxx)) ++ buf.WriteString(defaultCCFunc("DefaultCC", map[string]string{"":"gcc"})) ++ buf.WriteString(defaultCCFunc("DefaultCXX", map[string]string{"":"g++"})) + writefile(buf.String(), file, writeSkipSame) + return + } +@@ -46,8 +46,8 @@ func mkzdefaultcc(dir, file string) { + fmt.Fprintf(&buf, "package main\n") + fmt.Fprintln(&buf) + fmt.Fprintf(&buf, "const defaultPkgConfig = `%s`\n", defaultpkgconfig) +- buf.WriteString(defaultCCFunc("defaultCC", defaultcc)) +- buf.WriteString(defaultCCFunc("defaultCXX", defaultcxx)) ++ buf.WriteString(defaultCCFunc("defaultCC", map[string]string{"":"gcc"})) ++ buf.WriteString(defaultCCFunc("defaultCXX", map[string]string{"":"g++"})) + writefile(buf.String(), file, writeSkipSame) + } + diff --git a/meta/recipes-devtools/go/go-1.11/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch b/meta/recipes-devtools/go/go-1.18/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch index 66b8561874..42cd568ef9 100644 --- a/meta/recipes-devtools/go/go-1.11/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch +++ b/meta/recipes-devtools/go/go-1.18/0002-cmd-go-make-content-based-hash-generation-less-pedan.patch @@ -1,8 +1,10 @@ -From 47db69e20ed66fb62b01affd83d829654b829893 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Mon, 19 Feb 2018 08:50:59 -0800 +From c403b45995c5daa6747ac4d95b39bc9a6feb2cda Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:14:22 +0430 Subject: [PATCH] cmd/go: make content-based hash generation less pedantic +Upstream-Status: Inappropriate [OE specific] + Go 1.10's build tool now uses content-based hashes to determine when something should be built or re-built. This same mechanism is used to maintain a built-artifact @@ -38,20 +40,21 @@ This patch filters out all compiler flags except those beginning with '-m'. The default behavior can be restored by setting the CGO_PEDANTIC environment variable. -Upstream-Status: Inappropriate [OE specific] - -Signed-off-by: Matt Madison <matt@madison.systems> +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> --- src/cmd/go/internal/envcmd/env.go | 2 +- - src/cmd/go/internal/work/exec.go | 63 ++++++++++++++++++++++--------- - 2 files changed, 46 insertions(+), 19 deletions(-) + src/cmd/go/internal/work/exec.go | 66 ++++++++++++++++++++++--------- + 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go -index cedbfbf..5763a0d 100644 +index 20d0587..ff6f0d8 100644 --- a/src/cmd/go/internal/envcmd/env.go +++ b/src/cmd/go/internal/envcmd/env.go -@@ -128,7 +128,7 @@ func ExtraEnvVars() []cfg.EnvVar { +@@ -160,7 +160,7 @@ func ExtraEnvVars() []cfg.EnvVar { func ExtraEnvVarsCostly() []cfg.EnvVar { var b work.Builder b.Init() @@ -61,46 +64,57 @@ index cedbfbf..5763a0d 100644 // Should not happen - b.CFlags was given an empty package. fmt.Fprintf(os.Stderr, "go: invalid cflags: %v\n", err) diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go -index 12e1527..e41bfac 100644 +index 5a225fb..a37872e 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go -@@ -174,6 +174,8 @@ func (b *Builder) Do(root *Action) { - wg.Wait() - } +@@ -38,6 +38,8 @@ import ( + "cmd/go/internal/trace" + ) +var omitGopath = os.Getenv("GOPATH_OMIT_IN_ACTIONID") != "" + - // buildActionID computes the action ID for a build action. - func (b *Builder) buildActionID(a *Action) cache.ActionID { - p := a.Package -@@ -190,7 +192,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { - // but it does not hide the exact value of $GOPATH. - // Include the full dir in that case. + // actionList returns the list of actions in the dag rooted at root + // as visited in a depth-first post-order traversal. + func actionList(root *Action) []*Action { +@@ -229,7 +231,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { // Assume b.WorkDir is being trimmed properly. -- if !p.Goroot && !strings.HasPrefix(p.Dir, b.WorkDir) { -+ if !p.Goroot && !omitGopath && !strings.HasPrefix(p.Dir, b.WorkDir) { + // When -trimpath is used with a package built from the module cache, + // use the module path and version instead of the directory. +- if !p.Goroot && !cfg.BuildTrimpath && !strings.HasPrefix(p.Dir, b.WorkDir) { ++ if !p.Goroot && !omitGopath && !cfg.BuildTrimpath && !strings.HasPrefix(p.Dir, b.WorkDir) { fmt.Fprintf(h, "dir %s\n", p.Dir) + } else if cfg.BuildTrimpath && p.Module != nil { + fmt.Fprintf(h, "module %s@%s\n", p.Module.Path, p.Module.Version) +@@ -248,9 +250,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { } - fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch) -@@ -201,13 +203,13 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { - } - if len(p.CgoFiles)+len(p.SwigFiles) > 0 { + if len(p.CgoFiles)+len(p.SwigFiles)+len(p.SwigCXXFiles) > 0 { fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo")) - cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p) -- fmt.Fprintf(h, "CC=%q %q %q %q\n", b.ccExe(), cppflags, cflags, ldflags) + cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true) -+ fmt.Fprintf(h, "CC=%q %q %q %q\n", b.ccExe(true), cppflags, cflags, ldflags) - if len(p.CXXFiles)+len(p.SwigFiles) > 0 { -- fmt.Fprintf(h, "CXX=%q %q\n", b.cxxExe(), cxxflags) -+ fmt.Fprintf(h, "CXX=%q %q\n", b.cxxExe(true), cxxflags) + +- ccExe := b.ccExe() ++ ccExe := b.ccExe(true) + fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags) + // Include the C compiler tool ID so that if the C + // compiler changes we rebuild the package. +@@ -263,14 +265,14 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { + } } - if len(p.FFiles) > 0 { -- fmt.Fprintf(h, "FC=%q %q\n", b.fcExe(), fflags) -+ fmt.Fprintf(h, "FC=%q %q\n", b.fcExe(true), fflags) + if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 { +- cxxExe := b.cxxExe() ++ cxxExe := b.cxxExe(true) + fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags) + if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil { + fmt.Fprintf(h, "CXX ID=%q\n", cxxID) + } } - // TODO(rsc): Should we include the SWIG version or Fortran/GCC/G++/Objective-C compiler versions? - } -@@ -2096,33 +2098,33 @@ var ( + if len(p.FFiles) > 0 { +- fcExe := b.fcExe() ++ fcExe := b.fcExe(true) + fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags) + if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil { + fmt.Fprintf(h, "FC ID=%q\n", fcID) +@@ -2438,33 +2440,48 @@ var ( // gccCmd returns a gcc command line prefix // defaultCC is defined in zdefaultcc.go, written by cmd/dist. func (b *Builder) GccCmd(incdir, workdir string) []string { @@ -137,13 +151,28 @@ index 12e1527..e41bfac 100644 // fcExe returns the FC compiler setting without all the extra flags we add implicitly. -func (b *Builder) fcExe() []string { -- return b.compilerExe(os.Getenv("FC"), "gfortran") +- return b.compilerExe(cfg.Getenv("FC"), "gfortran") +func (b *Builder) fcExe(filtered bool) []string { + return b.compilerExe(os.Getenv("FC"), "gfortran", filtered) ++} ++ ++var filterFlags = os.Getenv("CGO_PEDANTIC") == "" ++ ++func filterCompilerFlags(flags []string) []string { ++ var newflags []string ++ if !filterFlags { ++ return flags ++ } ++ for _, flag := range flags { ++ if strings.HasPrefix(flag, "-m") { ++ newflags = append(newflags, flag) ++ } ++ } ++ return newflags } // compilerExe returns the compiler to use given an -@@ -2131,11 +2133,14 @@ func (b *Builder) fcExe() []string { +@@ -2473,11 +2490,16 @@ func (b *Builder) fcExe() []string { // of the compiler but can have additional arguments if they // were present in the environment value. // For example if CC="gcc -DGOPHER" then the result is ["gcc", "-DGOPHER"]. @@ -151,43 +180,29 @@ index 12e1527..e41bfac 100644 +func (b *Builder) compilerExe(envValue string, def string, filtered bool) []string { compiler := strings.Fields(envValue) if len(compiler) == 0 { - compiler = []string{def} + compiler = strings.Fields(def) } ++ + if filtered { + return append(compiler[0:1], filterCompilerFlags(compiler[1:])...) + } ++ return compiler } -@@ -2285,8 +2290,23 @@ func envList(key, def string) []string { - return strings.Fields(v) +@@ -2667,7 +2689,7 @@ func envList(key, def string) []string { } -+var filterFlags = os.Getenv("CGO_PEDANTIC") == "" -+ -+func filterCompilerFlags(flags []string) []string { -+ var newflags []string -+ if !filterFlags { -+ return flags -+ } -+ for _, flag := range flags { -+ if strings.HasPrefix(flag, "-m") { -+ newflags = append(newflags, flag) -+ } -+ } -+ return newflags -+} -+ // CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo. -func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) { +func (b *Builder) CFlags(p *load.Package, filtered bool) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) { defaults := "-g -O2" if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil { -@@ -2304,6 +2324,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l - if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil { +@@ -2686,6 +2708,14 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l return } + + if filtered { + cppflags = filterCompilerFlags(cppflags) + cflags = filterCompilerFlags(cflags) @@ -195,10 +210,11 @@ index 12e1527..e41bfac 100644 + fflags = filterCompilerFlags(fflags) + ldflags = filterCompilerFlags(ldflags) + } - ++ return } -@@ -2319,7 +2346,7 @@ var cgoRe = regexp.MustCompile(`[/\\:]`) + +@@ -2700,7 +2730,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`) func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) { p := a.Package @@ -207,7 +223,7 @@ index 12e1527..e41bfac 100644 if err != nil { return nil, nil, err } -@@ -2679,7 +2706,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) { +@@ -3151,7 +3181,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) { // Run SWIG on one SWIG input file. func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) { @@ -216,3 +232,6 @@ index 12e1527..e41bfac 100644 if err != nil { return "", "", err } +-- +2.20.1 + diff --git a/meta/recipes-devtools/go/go-1.18/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch b/meta/recipes-devtools/go/go-1.18/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch new file mode 100644 index 0000000000..2a86bdccf3 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.18/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch @@ -0,0 +1,52 @@ +From 8512964c0bfdfc3c9c3805743ea7de551a1d476a Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:15:37 +0430 +Subject: [PATCH] cmd/go: Allow GOTOOLDIR to be overridden in the environment + +to allow for split host/target build roots + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> + +--- + src/cmd/dist/build.go | 4 +++- + src/cmd/go/internal/cfg/cfg.go | 6 +++++- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go +index bec1769..d82f612 100644 +--- a/src/cmd/dist/build.go ++++ b/src/cmd/dist/build.go +@@ -248,7 +248,9 @@ func xinit() { + } + xatexit(rmworkdir) + +- tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) ++ if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { ++ tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) ++ } + } + + // compilerEnv returns a map from "goos/goarch" to the +diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go +index 57a3c1f..825d8c7 100644 +--- a/src/cmd/go/internal/cfg/cfg.go ++++ b/src/cmd/go/internal/cfg/cfg.go +@@ -67,7 +67,11 @@ func defaultContext() build.Context { + // variables. This matches the initialization of ToolDir in + // go/build, except for using ctxt.GOROOT rather than + // runtime.GOROOT. +- build.ToolDir = filepath.Join(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) ++ if s := os.Getenv("GOTOOLDIR"); s != "" { ++ build.ToolDir = filepath.Clean(s) ++ } else { ++ build.ToolDir = filepath.Join(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) ++ } + } + + ctxt.GOPATH = envOr("GOPATH", ctxt.GOPATH) diff --git a/meta/recipes-devtools/go/go-1.11/0004-ld-add-soname-to-shareable-objects.patch b/meta/recipes-devtools/go/go-1.18/0004-ld-add-soname-to-shareable-objects.patch index 004a33a023..cd875f1164 100644 --- a/meta/recipes-devtools/go/go-1.11/0004-ld-add-soname-to-shareable-objects.patch +++ b/meta/recipes-devtools/go/go-1.18/0004-ld-add-soname-to-shareable-objects.patch @@ -1,41 +1,41 @@ -From 55eb8c95a89f32aec16b7764e78e8cf75169dc81 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Sat, 17 Feb 2018 06:26:10 -0800 -Subject: [PATCH] ld: add soname to shareable objects +From bf5cf5301ae5914498454c87293d1df2e1d8489f Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:16:32 +0430 +Subject: [PATCH 4/9] ld: add soname to shareable objects so that OE's shared library dependency handling can find them. -Upstream-Status: Inappropriate [OE specific] +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. -Signed-off-by: Matt Madison <matt@madison.systems> +Upstream-Status: Inappropriate [OE specific] +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> --- - src/cmd/link/internal/ld/lib.go | 4 ++++ - 1 file changed, 4 insertions(+) + src/cmd/link/internal/ld/lib.go | 3 +++ + 1 file changed, 3 insertions(+) -diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go -index 220aab3..703925f 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go -@@ -1135,6 +1135,7 @@ func (ctxt *Link) hostlink() { +@@ -1343,6 +1343,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") + argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) - if ctxt.HeadType != objabi.Hwindows { - // Pass -z nodelete to mark the shared library as - // non-closeable: a dlclose will do nothing. -@@ -1146,6 +1147,8 @@ func (ctxt *Link) hostlink() { + if ctxt.HeadType == objabi.Hwindows { + if *flagAslr { + argv = addASLRargs(argv) +@@ -1358,6 +1359,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") + argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) -+ case BuildModePlugin: if ctxt.HeadType == objabi.Hdarwin { argv = append(argv, "-dynamiclib") -@@ -1154,6 +1157,7 @@ func (ctxt *Link) hostlink() { +@@ -1366,6 +1368,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") diff --git a/meta/recipes-devtools/go/go-1.18/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch b/meta/recipes-devtools/go/go-1.18/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch new file mode 100644 index 0000000000..2845d21382 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.18/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch @@ -0,0 +1,41 @@ +From 153e2dda6103fd9dd871be4bb495a8da5328301e Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:17:16 +0430 +Subject: [PATCH] make.bash: override CC when building dist and go_bootstrap + +for handling OE cross-canadian builds. + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> + +--- + src/make.bash | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/make.bash b/src/make.bash +index 7986125..dd67029 100755 +--- a/src/make.bash ++++ b/src/make.bash +@@ -181,7 +181,7 @@ if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; then + exit 1 + fi + rm -f cmd/dist/dist +-GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" GO111MODULE=off "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist ++CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" GO111MODULE=off "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist + + # -e doesn't propagate out of eval, so check success by hand. + eval $(./cmd/dist/dist env -p || echo FAIL=true) +@@ -206,7 +206,7 @@ fi + # Run dist bootstrap to complete make.bash. + # Bootstrap installs a proper cmd/dist, built with the new toolchain. + # Throw ours, built with Go 1.4, away after bootstrap. +-./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@" ++CC="${BUILD_CC:-${CC}}" ./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@" + rm -f ./cmd/dist/dist + + # DO NOT ADD ANY NEW CODE HERE. diff --git a/meta/recipes-devtools/go/go-1.11/0006-cmd-dist-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go-1.18/0006-cmd-dist-separate-host-and-target-builds.patch index 0c0d5da80a..68e8efc1d2 100644 --- a/meta/recipes-devtools/go/go-1.11/0006-cmd-dist-separate-host-and-target-builds.patch +++ b/meta/recipes-devtools/go/go-1.18/0006-cmd-dist-separate-host-and-target-builds.patch @@ -1,8 +1,10 @@ -From fe0fcaf43ef3aab81541dad2a71b46254dc4cf6a Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Sat, 17 Feb 2018 10:03:48 -0800 +From 7bc891e00be4263311d75aa2b2ee6a3b7b75355f Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:18:12 +0430 Subject: [PATCH] cmd/dist: separate host and target builds +Upstream-Status: Inappropriate [OE specific] + Change the dist tool to allow for OE-style cross- and cross-canadian builds: @@ -27,29 +29,29 @@ the staleness checks in the dist tool will fail if the "std" library has not also been built. So host-only builds have to build everything anyway. -Upstream-Status: Inappropriate [OE specific] +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. -Signed-off-by: Matt Madison <matt@madison.systems> - -more dist cleanup +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> --- - src/cmd/dist/build.go | 153 ++++++++++++++++++++++++++++++------------ - 1 file changed, 111 insertions(+), 42 deletions(-) + src/cmd/dist/build.go | 156 ++++++++++++++++++++++++++++++------------ + 1 file changed, 113 insertions(+), 43 deletions(-) -Index: go/src/cmd/dist/build.go -=================================================================== ---- go.orig/src/cmd/dist/build.go -+++ go/src/cmd/dist/build.go -@@ -39,6 +39,7 @@ var ( - goldflags string +diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go +index d82f612..5c8459c 100644 +--- a/src/cmd/dist/build.go ++++ b/src/cmd/dist/build.go +@@ -43,6 +43,7 @@ var ( + goexperiment string workdir string tooldir string -+ build_tooldir string ++ build_tooldir string oldgoos string oldgoarch string exe string -@@ -50,6 +51,7 @@ var ( +@@ -55,6 +56,7 @@ var ( rebuildall bool defaultclang bool @@ -57,52 +59,49 @@ Index: go/src/cmd/dist/build.go vflag int // verbosity ) -@@ -231,6 +233,8 @@ func xinit() { +@@ -251,6 +253,8 @@ func xinit() { if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) } -+ build_tooldir = pathf("%s/pkg/tool/native_native", goroot) + ++ build_tooldir = pathf("%s/pkg/tool/native_native", goroot) } // compilerEnv returns a map from "goos/goarch" to the -@@ -260,7 +264,6 @@ func compilerEnv(envName, def string) ma - if gohostos != goos || gohostarch != goarch { - m[gohostos+"/"+gohostarch] = m[""] - } -- m[""] = env - } - - for _, goos := range okgoos { -@@ -487,8 +490,10 @@ func setup() { - // We keep it in pkg/, just like the object directory above. +@@ -496,8 +500,10 @@ func setup() { + p := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch) if rebuildall { - xremoveall(tooldir) + xremoveall(p) + xremoveall(build_tooldir) } - xmkdirall(tooldir) + xmkdirall(p) + xmkdirall(build_tooldir) - // Remove tool binaries from before the tool/gohostos_gohostarch - xremoveall(pathf("%s/bin/tool", goroot)) -@@ -1155,11 +1160,29 @@ func cmdbootstrap() { + if goos != gohostos || goarch != gohostarch { + p := pathf("%s/pkg/%s_%s", goroot, goos, goarch) +@@ -1267,17 +1273,35 @@ func cmdbootstrap() { - var noBanner bool + var noBanner, noClean bool var debug bool + var hostOnly bool + var targetOnly bool -+ var toBuild = []string { "std", "cmd" } ++ var toBuild = []string{"std", "cmd"} + flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all") flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process") flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner") + flag.BoolVar(&noClean, "no-clean", noClean, "print deprecation warning") + flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target") + flag.BoolVar(&targetOnly, "target-only", targetOnly, "build only target binaries, not host") - xflagparse(0) + xflagparse(-1) -+ -+ if (hostOnly && targetOnly) { + + if noClean { + xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n") + } + ++ if hostOnly && targetOnly { + fatalf("specify only one of --host-only or --target-only\n") + } + crossBuild = hostOnly || targetOnly @@ -113,26 +112,27 @@ Index: go/src/cmd/dist/build.go + fatalf("package names not permitted without --host-only or --target-only\n") + } + } - - if debug { - // cmd/buildid is used in debug mode. -@@ -1207,8 +1230,13 @@ func cmdbootstrap() { ++ + // Set GOPATH to an internal directory. We shouldn't actually + // need to store files here, since the toolchain won't + // depend on modules outside of vendor directories, but if +@@ -1345,8 +1369,13 @@ func cmdbootstrap() { xprintf("\n") } - gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now -- goldflags = os.Getenv("GO_LDFLAGS") +- goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now + // For split host/target cross/cross-canadian builds, we don't + // want to be setting these flags until after we have compiled + // the toolchain that runs on the build host. -+ if ! crossBuild { ++ if !crossBuild { + gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now -+ goldflags = os.Getenv("GO_LDFLAGS") ++ goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now + } goBootstrap := pathf("%s/go_bootstrap", tooldir) cmdGo := pathf("%s/go", gobin) if debug { -@@ -1237,7 +1265,11 @@ func cmdbootstrap() { +@@ -1375,7 +1404,11 @@ func cmdbootstrap() { xprintf("\n") } xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n") @@ -142,10 +142,10 @@ Index: go/src/cmd/dist/build.go + } else { + os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) + } + // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT. + os.Setenv("GOEXPERIMENT", goexperiment) goInstall(goBootstrap, append([]string{"-i"}, toolchain...)...) - if debug { - run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") -@@ -1274,50 +1306,84 @@ func cmdbootstrap() { +@@ -1414,50 +1447,84 @@ func cmdbootstrap() { } checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) @@ -197,6 +197,8 @@ Index: go/src/cmd/dist/build.go - timelog("build", "host toolchain") - if vflag > 0 { - xprintf("\n") +- } +- xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch) + + if goos == oldgoos && goarch == oldgoarch { + // Common case - not setting up for cross-compilation. @@ -228,8 +230,7 @@ Index: go/src/cmd/dist/build.go + os.Setenv("GOARCH", goarch) + os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) + xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch) - } -- xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch) ++ } goInstall(goBootstrap, "std", "cmd") checkNotStale(goBootstrap, "std", "cmd") checkNotStale(cmdGo, "std", "cmd") @@ -237,7 +238,12 @@ Index: go/src/cmd/dist/build.go - timelog("build", "target toolchain") - if vflag > 0 { - xprintf("\n") -- } ++ if debug { ++ run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") ++ run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch)) ++ checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) ++ copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) + } - goos = oldgoos - goarch = oldgoarch - os.Setenv("GOOS", goos) @@ -258,25 +264,20 @@ Index: go/src/cmd/dist/build.go - run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch)) - checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) - copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) -+ if debug { -+ run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") -+ run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch)) -+ checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) -+ copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) -+ } } // Check that there are no new files in $GOROOT/bin other than -@@ -1335,7 +1401,11 @@ func cmdbootstrap() { +@@ -1474,8 +1541,11 @@ func cmdbootstrap() { + } } - // Remove go_bootstrap now that we're done. +- // Remove go_bootstrap now that we're done. - xremove(pathf("%s/go_bootstrap", tooldir)) + // Except that for split host/target cross-builds, we need to + // keep it. -+ if ! crossBuild { ++ if !crossBuild { + xremove(pathf("%s/go_bootstrap", tooldir)) + } - // Print trailing banner unless instructed otherwise. - if !noBanner { + if goos == "android" { + // Make sure the exec wrapper will sync a fresh $GOROOT to the device. diff --git a/meta/recipes-devtools/go/go-1.11/0007-cmd-go-make-GOROOT-precious-by-default.patch b/meta/recipes-devtools/go/go-1.18/0007-cmd-go-make-GOROOT-precious-by-default.patch index 29ef947abd..4b4d0d4f3d 100644 --- a/meta/recipes-devtools/go/go-1.11/0007-cmd-go-make-GOROOT-precious-by-default.patch +++ b/meta/recipes-devtools/go/go-1.18/0007-cmd-go-make-GOROOT-precious-by-default.patch @@ -1,7 +1,9 @@ -From 7cc60b3887be2d5674b9f5d422d022976cf205e5 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Fri, 2 Mar 2018 06:00:20 -0800 -Subject: [PATCH] cmd/go: make GOROOT precious by default +From 9ba507e076c744f4d394418e4a849e68cd426a4a Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:18:56 +0430 +Subject: [PATCH 7/9] cmd/go: make GOROOT precious by default + +Upstream-Status: Inappropriate [OE specific] The go build tool normally rebuilds whatever it detects is stale. This can be a problem when GOROOT is intended to @@ -14,21 +16,20 @@ This patch prevents the install and linkshared actions from installing to GOROOT unless overridden with the GOROOT_OVERRIDE environment variable. -Upstream-Status: Inappropriate [OE specific] - -Signed-off-by: Matt Madison <matt@madison.systems> +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> --- src/cmd/go/internal/work/action.go | 3 +++ - src/cmd/go/internal/work/build.go | 5 +++++ + src/cmd/go/internal/work/build.go | 6 ++++++ src/cmd/go/internal/work/exec.go | 25 +++++++++++++++++++++++++ - 3 files changed, 33 insertions(+) + 3 files changed, 34 insertions(+) -Index: go/src/cmd/go/internal/work/action.go -=================================================================== ---- go.orig/src/cmd/go/internal/work/action.go -+++ go/src/cmd/go/internal/work/action.go -@@ -600,6 +600,9 @@ func (b *Builder) addTransitiveLinkDeps( +--- a/src/cmd/go/internal/work/action.go ++++ b/src/cmd/go/internal/work/action.go +@@ -670,6 +670,9 @@ func (b *Builder) addTransitiveLinkDeps( if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] { continue } @@ -38,22 +39,21 @@ Index: go/src/cmd/go/internal/work/action.go haveShlib[filepath.Base(p1.Shlib)] = true // TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild, // we'll end up building an overall library or executable that depends at runtime -Index: go/src/cmd/go/internal/work/build.go -=================================================================== ---- go.orig/src/cmd/go/internal/work/build.go -+++ go/src/cmd/go/internal/work/build.go -@@ -147,6 +147,7 @@ See also: go install, go get, go clean. - } +--- a/src/cmd/go/internal/work/build.go ++++ b/src/cmd/go/internal/work/build.go +@@ -167,6 +167,8 @@ See also: go install, go get, go clean. const concurrentGCBackendCompilationEnabledByDefault = true -+var goRootPrecious bool = true ++var goRootPrecious bool = true ++ func init() { // break init cycle -@@ -160,6 +161,10 @@ func init() { + CmdBuild.Run = runBuild +@@ -179,6 +181,10 @@ func init() { - AddBuildFlags(CmdBuild) - AddBuildFlags(CmdInstall) + AddBuildFlags(CmdBuild, DefaultBuildFlags) + AddBuildFlags(CmdInstall, DefaultBuildFlags) + + if x := os.Getenv("GOROOT_OVERRIDE"); x != "" { + goRootPrecious = false @@ -61,12 +61,10 @@ Index: go/src/cmd/go/internal/work/build.go } // Note that flags consulted by other parts of the code -Index: go/src/cmd/go/internal/work/exec.go -=================================================================== ---- go.orig/src/cmd/go/internal/work/exec.go -+++ go/src/cmd/go/internal/work/exec.go -@@ -436,6 +436,23 @@ func (b *Builder) build(a *Action) (err - return fmt.Errorf("missing or invalid binary-only package; expected file %q", a.Package.Target) +--- a/src/cmd/go/internal/work/exec.go ++++ b/src/cmd/go/internal/work/exec.go +@@ -468,6 +468,23 @@ func (b *Builder) build(a *Action) (err + return errors.New("binary-only packages are no longer supported") } + if goRootPrecious && (a.Package.Standard || a.Package.Goroot) { @@ -89,8 +87,8 @@ Index: go/src/cmd/go/internal/work/exec.go if err := b.Mkdir(a.Objdir); err != nil { return err } -@@ -1438,6 +1455,14 @@ func BuildInstallFunc(b *Builder, a *Act - return nil +@@ -1520,6 +1537,14 @@ func BuildInstallFunc(b *Builder, a *Act + return err } + if goRootPrecious && a.Package != nil { diff --git a/meta/recipes-devtools/go/go-1.11/0008-use-GOBUILDMODE-to-set-buildmode.patch b/meta/recipes-devtools/go/go-1.18/0008-use-GOBUILDMODE-to-set-buildmode.patch index 225cf439c5..4e5d5021d6 100644 --- a/meta/recipes-devtools/go/go-1.11/0008-use-GOBUILDMODE-to-set-buildmode.patch +++ b/meta/recipes-devtools/go/go-1.18/0008-use-GOBUILDMODE-to-set-buildmode.patch @@ -1,7 +1,10 @@ -From 0e0c247f0caec23528889ff09d98348cba9028f1 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Fri, 26 Oct 2018 15:02:32 +0800 -Subject: [PATCH] use GOBUILDMODE to set buildmode +From 971b5626339ce0c4d57f9721c9a81af566c5a044 Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:19:26 +0430 +Subject: [PATCH 8/9] cmd/go: Use GOBUILDMODE to set buildmode + +Upstream-Status: Denied [upstream choose antoher solution: `17a256b +cmd/go: -buildmode=pie for android/arm'] While building go itself, the go build system does not support to set `-buildmode=pie' from environment. @@ -10,28 +13,30 @@ Add GOBUILDMODE to support it which make PIE executables the default build mode, as PIE executables are required as of Yocto Refers: https://groups.google.com/forum/#!topic/golang-dev/gRCe5URKewI -Upstream-Status: Denied [upstream choose antoher solution: `17a256b -cmd/go: -buildmode=pie for android/arm'] -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Hongxu Jia <hongxu.jia@windriver.com> + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> --- - src/cmd/go/internal/work/build.go | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) + src/cmd/go/internal/work/build.go | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) -Index: go/src/cmd/go/internal/work/build.go -=================================================================== ---- go.orig/src/cmd/go/internal/work/build.go -+++ go/src/cmd/go/internal/work/build.go -@@ -223,7 +223,11 @@ func AddBuildFlags(cmd *base.Command) { +--- a/src/cmd/go/internal/work/build.go ++++ b/src/cmd/go/internal/work/build.go +@@ -254,7 +254,13 @@ func AddBuildFlags(cmd *base.Command, ma cmd.Flag.Var(&load.BuildAsmflags, "asmflags", "") cmd.Flag.Var(buildCompiler{}, "compiler", "") - cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "") ++ + if bm := os.Getenv("GOBUILDMODE"); bm != "" { + cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", bm, "") + } else { + cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "") + } ++ cmd.Flag.Var(&load.BuildGcflags, "gcflags", "") cmd.Flag.Var(&load.BuildGccgoflags, "gccgoflags", "") - cmd.Flag.StringVar(&cfg.BuildMod, "mod", "", "") + if mask&OmitModFlag == 0 { diff --git a/meta/recipes-devtools/go/go-1.18/0009-Revert-cmd-go-make-sure-CC-and-CXX-are-absolute.patch b/meta/recipes-devtools/go/go-1.18/0009-Revert-cmd-go-make-sure-CC-and-CXX-are-absolute.patch new file mode 100644 index 0000000000..f857b72234 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.18/0009-Revert-cmd-go-make-sure-CC-and-CXX-are-absolute.patch @@ -0,0 +1,94 @@ +From 66a45dae3af140662e17ef85c2e6fe40270a2553 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Mon, 22 Feb 2021 17:54:01 -0800 +Subject: [PATCH] Revert "cmd/go: make sure CC and CXX are absolute" + +OE uses CC/CXX values which consists of cmpiler and options together, +secondly, the environment is canned so this check add little value to OE +based builds + +Fixes go-runtime build issues + +go install: CXX environment variable is relative; must be absolute path: powerpc64le-yoe-linux-musl-g++ -mlittle-endian -mhard-float -m64 -mabi=elfv2 -mcpu=power9 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/mnt/b/yoe/master/build/tmp/work/ppc64p9le-yoe-linux-musl/go/1.16-r0/recipe-sysroot + +This reverts commit aa161e799df7e1eba99d2be10271e76b6f758142. + +Upstream-Status: Inappropriate [OE-Specific] +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + src/cmd/go/internal/envcmd/env.go | 5 ----- + src/cmd/go/internal/work/init.go | 6 ------ + src/cmd/go/testdata/script/env_write.txt | 24 ------------------------ + 3 files changed, 35 deletions(-) + +diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go +index ff6f0d8..43b94e7 100644 +--- a/src/cmd/go/internal/envcmd/env.go ++++ b/src/cmd/go/internal/envcmd/env.go +@@ -457,11 +457,6 @@ func checkEnvWrite(key, val string) error { + if !filepath.IsAbs(val) && val != "" { + return fmt.Errorf("GOPATH entry is relative; must be absolute path: %q", val) + } +- // Make sure CC and CXX are absolute paths +- case "CC", "CXX", "GOMODCACHE": +- if !filepath.IsAbs(val) && val != "" && val != filepath.Base(val) { +- return fmt.Errorf("%s entry is relative; must be absolute path: %q", key, val) +- } + } + + if !utf8.ValidString(val) { +diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go +index 37a3e2d..316b0cf 100644 +--- a/src/cmd/go/internal/work/init.go ++++ b/src/cmd/go/internal/work/init.go +@@ -39,12 +39,6 @@ func BuildInit() { + cfg.BuildPkgdir = p + } + +- // Make sure CC and CXX are absolute paths +- for _, key := range []string{"CC", "CXX"} { +- if path := cfg.Getenv(key); !filepath.IsAbs(path) && path != "" && path != filepath.Base(path) { +- base.Fatalf("go %s: %s environment variable is relative; must be absolute path: %s\n", flag.Args()[0], key, path) +- } +- } + } + + func instrumentInit() { +diff --git a/src/cmd/go/testdata/script/env_write.txt b/src/cmd/go/testdata/script/env_write.txt +index b5e9739..566c876 100644 +--- a/src/cmd/go/testdata/script/env_write.txt ++++ b/src/cmd/go/testdata/script/env_write.txt +@@ -129,30 +129,6 @@ go env -w GOTMPDIR= + go env GOTMPDIR + stdout ^$ + +-# go env -w rejects relative CC values +-[!windows] go env -w CC=/usr/bin/clang +-go env -w CC=clang +-[!windows] ! go env -w CC=./clang +-[!windows] ! go env -w CC=bin/clang +-[!windows] stderr 'go env -w: CC entry is relative; must be absolute path' +- +-[windows] go env -w CC=$WORK\bin\clang +-[windows] ! go env -w CC=.\clang +-[windows] ! go env -w CC=bin\clang +-[windows] stderr 'go env -w: CC entry is relative; must be absolute path' +- +-# go env -w rejects relative CXX values +-[!windows] go env -w CC=/usr/bin/cpp +-go env -w CXX=cpp +-[!windows] ! go env -w CXX=./cpp +-[!windows] ! go env -w CXX=bin/cpp +-[!windows] stderr 'go env -w: CXX entry is relative; must be absolute path' +- +-[windows] go env -w CXX=$WORK\bin\cpp +-[windows] ! go env -w CXX=.\cpp +-[windows] ! go env -w CXX=bin\cpp +-[windows] stderr 'go env -w: CXX entry is relative; must be absolute path' +- + # go env -w/-u checks validity of GOOS/ARCH combinations + env GOOS= + env GOARCH= +-- +2.20.1 + diff --git a/meta/recipes-devtools/go/go-1.9.inc b/meta/recipes-devtools/go/go-1.9.inc deleted file mode 100644 index ba1eaa051a..0000000000 --- a/meta/recipes-devtools/go/go-1.9.inc +++ /dev/null @@ -1,27 +0,0 @@ -require go-common.inc - -GO_BASEVERSION = "1.9" -GO_MINOR = ".7" -PV .= "${GO_MINOR}" - -FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/go-${GO_BASEVERSION}:" - -LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707" - -SRC_URI += "\ - file://0001-make.bash-quote-CC_FOR_TARGET.patch \ - file://0002-cmd-go-fix-CC-and-CXX-environment-variable-construct.patch \ - file://0003-make.bash-better-separate-host-and-target-builds.patch \ - file://0004-cmd-go-allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch \ - file://0005-cmd-go-make-GOROOT-precious-by-default.patch \ - file://0006-make.bash-add-GOTOOLDIR_BOOTSTRAP-environment-variab.patch \ - file://0007-ld-add-soname-to-shareable-objects.patch \ - file://0008-make.bash-add-GOHOSTxx-indirection-for-cross-canadia.patch \ - file://0009-cmd-go-buildmode-pie-forces-external-linking-mode-on.patch \ - file://0010-make.bash-override-CC-when-building-dist-and-go_boot.patch \ - file://0011-use-GOBUILDMODE-to-set-buildmode.patch \ -" -SRC_URI_append_libc-musl = " file://set-external-linker.patch" - -SRC_URI[main.md5sum] = "3c2cf876ed6612a022574a565206c6ea" -SRC_URI[main.sha256sum] = "582814fa45e8ecb0859a208e517b48aa0ad951e3b36c7fff203d834e0ef27722" diff --git a/meta/recipes-devtools/go/go-1.9/0001-make.bash-quote-CC_FOR_TARGET.patch b/meta/recipes-devtools/go/go-1.9/0001-make.bash-quote-CC_FOR_TARGET.patch deleted file mode 100644 index 7800975e48..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0001-make.bash-quote-CC_FOR_TARGET.patch +++ /dev/null @@ -1,32 +0,0 @@ -From d24734ad44006791fd48fc45ea34fe608ff672fb Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Wed, 13 Sep 2017 08:04:23 -0700 -Subject: [PATCH 1/7] make.bash: quote CC_FOR_TARGET - -For OE cross-builds, $CC_FOR_TARGET has more than -one word and needs to be quoted. - -Upstream-Status: Pending - -Signed-off-by: Khem Raj <raj.khem@gmail.com> -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/make.bash | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/make.bash b/src/make.bash -index 71e7531..dcf3256 100755 ---- a/src/make.bash -+++ b/src/make.bash -@@ -175,7 +175,7 @@ echo "##### Building packages and commands for $GOOS/$GOARCH." - - old_bin_files=$(cd $GOROOT/bin && echo *) - --CC=$CC_FOR_TARGET "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd -+CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd - - # Check that there are no new files in $GOROOT/bin other than go and gofmt - # and $GOOS_$GOARCH (a directory used when cross-compiling). --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0002-cmd-go-fix-CC-and-CXX-environment-variable-construct.patch b/meta/recipes-devtools/go/go-1.9/0002-cmd-go-fix-CC-and-CXX-environment-variable-construct.patch deleted file mode 100644 index a4e42261c3..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0002-cmd-go-fix-CC-and-CXX-environment-variable-construct.patch +++ /dev/null @@ -1,67 +0,0 @@ -From a7170d32a13aead608abd18996f6dab2e2a631b5 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Wed, 13 Sep 2017 08:06:37 -0700 -Subject: [PATCH 2/7] cmd/go: fix CC and CXX environment variable construction - -For OE cross-builds, CC and CXX have multiple words, and -we need their complete definitions when setting up the -environment during Go builds. - -Upstream-Status: Pending - -Signed-off-by: Khem Raj <raj.khem@gmail.com> -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/cmd/go/internal/envcmd/env.go | 4 ++-- - src/cmd/go/internal/work/build.go | 12 ++++++++++++ - 2 files changed, 14 insertions(+), 2 deletions(-) - -diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go -index 43d4334..529d21d 100644 ---- a/src/cmd/go/internal/envcmd/env.go -+++ b/src/cmd/go/internal/envcmd/env.go -@@ -74,10 +74,10 @@ func MkEnv() []cfg.EnvVar { - } - - cmd := b.GccCmd(".") -- env = append(env, cfg.EnvVar{Name: "CC", Value: cmd[0]}) -+ env = append(env, cfg.EnvVar{Name: "CC", Value: strings.Join(b.GccCmdForReal(), " ")}) - env = append(env, cfg.EnvVar{Name: "GOGCCFLAGS", Value: strings.Join(cmd[3:], " ")}) - cmd = b.GxxCmd(".") -- env = append(env, cfg.EnvVar{Name: "CXX", Value: cmd[0]}) -+ env = append(env, cfg.EnvVar{Name: "CXX", Value: strings.Join(b.GxxCmdForReal(), " ")}) - - if cfg.BuildContext.CgoEnabled { - env = append(env, cfg.EnvVar{Name: "CGO_ENABLED", Value: "1"}) -diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go -index 7d667ff..85df0b3 100644 ---- a/src/cmd/go/internal/work/build.go -+++ b/src/cmd/go/internal/work/build.go -@@ -3127,12 +3127,24 @@ func (b *Builder) GccCmd(objdir string) []string { - return b.ccompilerCmd("CC", cfg.DefaultCC, objdir) - } - -+// gccCmd returns a gcc command line prefix -+// defaultCC is defined in zdefaultcc.go, written by cmd/dist. -+func (b *Builder) GccCmdForReal() []string { -+ return envList("CC", cfg.DefaultCC) -+} -+ - // gxxCmd returns a g++ command line prefix - // defaultCXX is defined in zdefaultcc.go, written by cmd/dist. - func (b *Builder) GxxCmd(objdir string) []string { - return b.ccompilerCmd("CXX", cfg.DefaultCXX, objdir) - } - -+// gxxCmd returns a g++ command line prefix -+// defaultCXX is defined in zdefaultcc.go, written by cmd/dist. -+func (b *Builder) GxxCmdForReal() []string { -+ return envList("CXX", cfg.DefaultCXX) -+} -+ - // gfortranCmd returns a gfortran command line prefix. - func (b *Builder) gfortranCmd(objdir string) []string { - return b.ccompilerCmd("FC", "gfortran", objdir) --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0003-make.bash-better-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go-1.9/0003-make.bash-better-separate-host-and-target-builds.patch deleted file mode 100644 index ffd9f2359c..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0003-make.bash-better-separate-host-and-target-builds.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 31e88f06af7ab787d8fe0c1ca625193e1799e167 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Wed, 13 Sep 2017 08:12:04 -0700 -Subject: [PATCH 3/7] make.bash: better separate host and target builds - -Fore OE cross-builds, the simple checks in make.bash are -insufficient for distinguishing host and target build -environments, so add some options for telling the -script which parts are being built. - -Upstream-Status: Pending - -Signed-off-by: Khem Raj <raj.khem@gmail.com> -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/make.bash | 51 ++++++++++++++++++++++++++++----------------------- - 1 file changed, 28 insertions(+), 23 deletions(-) - -diff --git a/src/make.bash b/src/make.bash -index dcf3256..9553623 100755 ---- a/src/make.bash -+++ b/src/make.bash -@@ -156,13 +156,22 @@ if [ "$1" = "--no-clean" ]; then - buildall="" - shift - fi --./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap -+do_host_build="yes" -+do_target_build="yes" -+if [ "$1" = "--target-only" ]; then -+ do_host_build="no" -+ shift -+elif [ "$1" = "--host-only" ]; then -+ do_target_build="no" -+ shift -+fi - --# Delay move of dist tool to now, because bootstrap may clear tool directory. --mv cmd/dist/dist "$GOTOOLDIR"/dist --echo -+if [ "$do_host_build" = "yes" ]; then -+ ./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap -+ # Delay move of dist tool to now, because bootstrap may clear tool directory. -+ mv cmd/dist/dist "$GOTOOLDIR"/dist -+ echo - --if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then - echo "##### Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH." - # CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however, - # use the host compiler, CC, from `cmd/dist/dist env` instead. -@@ -171,24 +180,20 @@ if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then - echo - fi - --echo "##### Building packages and commands for $GOOS/$GOARCH." -- --old_bin_files=$(cd $GOROOT/bin && echo *) -- --CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd -- --# Check that there are no new files in $GOROOT/bin other than go and gofmt --# and $GOOS_$GOARCH (a directory used when cross-compiling). --(cd $GOROOT/bin && for f in *; do -- if ! expr " $old_bin_files go gofmt ${GOOS}_${GOARCH} " : ".* $f " >/dev/null 2>/dev/null; then -- echo 1>&2 "ERROR: unexpected new file in $GOROOT/bin: $f" -- exit 1 -- fi --done) -- --echo -- --rm -f "$GOTOOLDIR"/go_bootstrap -+if [ "$do_target_build" = "yes" ]; then -+ GO_INSTALL="${GO_TARGET_INSTALL:-std cmd}" -+ echo "##### Building packages and commands for $GOOS/$GOARCH." -+ if [ "$GOHOSTOS" = "$GOOS" -a "$GOHOSTARCH" = "$GOARCH" -a "$do_host_build" = "yes" ]; then -+ rm -rf ./host-tools -+ mkdir ./host-tools -+ mv "$GOTOOLDIR"/* ./host-tools -+ GOTOOLDIR="$PWD/host-tools" -+ fi -+ GOTOOLDIR="$GOTOOLDIR" CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v ${GO_INSTALL} -+ echo -+ -+ rm -f "$GOTOOLDIR"/go_bootstrap -+fi - - if [ "$1" != "--no-banner" ]; then - "$GOTOOLDIR"/dist banner --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0004-cmd-go-allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch b/meta/recipes-devtools/go/go-1.9/0004-cmd-go-allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch deleted file mode 100644 index 180b06a4d3..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0004-cmd-go-allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 1369178b497b12088ec4c2794606cc9f14cc327c Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Wed, 13 Sep 2017 08:15:03 -0700 -Subject: [PATCH 4/7] cmd/go: allow GOTOOLDIR to be overridden in the - environment - -For OE cross-builds, host-side tools reside in the native -GOROOT, not the target GOROOT. Allow GOTOOLDIR to be set -in the environment to allow that split, rather than always -computing GOTOOLDIR relative to the GOROOT setting. - -Upstream-Status: Pending - -Signed-off-by: Khem Raj <raj.khem@gmail.com> -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/cmd/go/internal/cfg/cfg.go | 7 ++++++- - src/cmd/go/internal/work/build.go | 2 +- - src/go/build/build.go | 2 +- - 3 files changed, 8 insertions(+), 3 deletions(-) - -diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go -index b3ad1ce..c1dc974 100644 ---- a/src/cmd/go/internal/cfg/cfg.go -+++ b/src/cmd/go/internal/cfg/cfg.go -@@ -91,7 +91,12 @@ func init() { - // as the tool directory does not move based on environment variables. - // This matches the initialization of ToolDir in go/build, - // except for using GOROOT rather than runtime.GOROOT(). -- build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) -+ s := os.Getenv("GOTOOLDIR") -+ if s == "" { -+ build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) -+ } else { -+ build.ToolDir = s -+ } - } - - func findGOROOT() string { -diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go -index 85df0b3..7b9a69e 100644 ---- a/src/cmd/go/internal/work/build.go -+++ b/src/cmd/go/internal/work/build.go -@@ -1337,7 +1337,7 @@ func (b *Builder) build(a *Action) (err error) { - } - - var cgoExe string -- if a.cgo != nil && a.cgo.Target != "" { -+ if a.cgo != nil && a.cgo.Target != "" && os.Getenv("GOTOOLDIR") == "" { - cgoExe = a.cgo.Target - } else { - cgoExe = base.Tool("cgo") -diff --git a/src/go/build/build.go b/src/go/build/build.go -index fd89871..e16145b 100644 ---- a/src/go/build/build.go -+++ b/src/go/build/build.go -@@ -1588,7 +1588,7 @@ func init() { - } - - // ToolDir is the directory containing build tools. --var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) -+var ToolDir = envOr("GOTOOLDIR", filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)) - - // IsLocalImport reports whether the import path is - // a local import path, like ".", "..", "./foo", or "../foo". --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0005-cmd-go-make-GOROOT-precious-by-default.patch b/meta/recipes-devtools/go/go-1.9/0005-cmd-go-make-GOROOT-precious-by-default.patch deleted file mode 100644 index 6e93bcb6ce..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0005-cmd-go-make-GOROOT-precious-by-default.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 44f961975dac6cf464a77b5f6dd0c47cc192c4fd Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Wed, 13 Sep 2017 08:19:52 -0700 -Subject: [PATCH 5/7] cmd/go: make GOROOT precious by default - -For OE builds, we never want packages that have -already been installed into the build root to be -modified, so prevent the go build tool from checking -if they should be rebuilt. - -Also add an environment variable to override this -behavior, just for building the Go runtime. - -Upstream-Status: Pending - -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/cmd/go/internal/load/pkg.go | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go -index 60de666..2660d3f 100644 ---- a/src/cmd/go/internal/load/pkg.go -+++ b/src/cmd/go/internal/load/pkg.go -@@ -1530,6 +1530,13 @@ func isStale(p *Package) (bool, string) { - return true, "build ID mismatch" - } - -+ // For OE builds, make anything in GOROOT non-stale, -+ // to prevent a package build from overwriting the -+ // build root. -+ if p.Goroot && os.Getenv("GOROOT_OVERRIDE") != "1" { -+ return false, "GOROOT-resident packages do not get rebuilt" -+ } -+ - // Package is stale if a dependency is. - for _, p1 := range p.Internal.Deps { - if p1.Stale { --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0006-make.bash-add-GOTOOLDIR_BOOTSTRAP-environment-variab.patch b/meta/recipes-devtools/go/go-1.9/0006-make.bash-add-GOTOOLDIR_BOOTSTRAP-environment-variab.patch deleted file mode 100644 index f0f564044b..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0006-make.bash-add-GOTOOLDIR_BOOTSTRAP-environment-variab.patch +++ /dev/null @@ -1,36 +0,0 @@ -From aae74d1045ca03306ba4159206ee3bac72bcdfbb Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Wed, 13 Sep 2017 08:23:23 -0700 -Subject: [PATCH 6/7] make.bash: add GOTOOLDIR_BOOTSTRAP environment variable - -For cross-canadian builds, we need to use the native -GOTOOLDIR during the bootstrap phase, so provide a way -to pass that setting into the build script. - -Upstream-Status: Pending - -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/make.bash | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/make.bash b/src/make.bash -index 9553623..2e6fb05 100755 ---- a/src/make.bash -+++ b/src/make.bash -@@ -172,10 +172,11 @@ if [ "$do_host_build" = "yes" ]; then - mv cmd/dist/dist "$GOTOOLDIR"/dist - echo - -+ GOTOOLDIR_BOOTSTRAP="${GOTOOLDIR_BOOTSTRAP:-$GOTOOLDIR}" - echo "##### Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH." - # CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however, - # use the host compiler, CC, from `cmd/dist/dist env` instead. -- CC=$CC GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \ -+ CC=$CC GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH GOTOOLDIR="$GOTOOLDIR_BOOTSTRAP" \ - "$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd - echo - fi --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0007-ld-add-soname-to-shareable-objects.patch b/meta/recipes-devtools/go/go-1.9/0007-ld-add-soname-to-shareable-objects.patch deleted file mode 100644 index 6459782d81..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0007-ld-add-soname-to-shareable-objects.patch +++ /dev/null @@ -1,46 +0,0 @@ -From e957c3458d53e37bf416f51d2f8bf54c195e50f5 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Wed, 13 Sep 2017 08:27:02 -0700 -Subject: [PATCH 7/7] ld: add soname to shareable objects - -Shared library handling in OE depends on the inclusion -of an soname header, so update the go linker to add that -header for both internal and external linking. - -Upstream-Status: Pending - -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/cmd/link/internal/ld/lib.go | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go -index 0234105..0b9e2d0 100644 ---- a/src/cmd/link/internal/ld/lib.go -+++ b/src/cmd/link/internal/ld/lib.go -@@ -1124,12 +1124,14 @@ func (l *Link) hostlink() { - // Pass -z nodelete to mark the shared library as - // non-closeable: a dlclose will do nothing. - argv = append(argv, "-shared", "-Wl,-z,nodelete") -+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) - } - case BuildmodeShared: - if UseRelro() { - argv = append(argv, "-Wl,-z,relro") - } - argv = append(argv, "-shared") -+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) - case BuildmodePlugin: - if Headtype == objabi.Hdarwin { - argv = append(argv, "-dynamiclib") -@@ -1138,6 +1140,7 @@ func (l *Link) hostlink() { - argv = append(argv, "-Wl,-z,relro") - } - argv = append(argv, "-shared") -+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) - } - } - --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0008-make.bash-add-GOHOSTxx-indirection-for-cross-canadia.patch b/meta/recipes-devtools/go/go-1.9/0008-make.bash-add-GOHOSTxx-indirection-for-cross-canadia.patch deleted file mode 100644 index 0977c78350..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0008-make.bash-add-GOHOSTxx-indirection-for-cross-canadia.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 03e6c339d4fb712fbb8c4ca6ef2fc7100dcdb3d7 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Thu, 14 Sep 2017 05:38:10 -0700 -Subject: [PATCH 8/8] make.bash: add GOHOSTxx indirection for cross-canadian - builds - -Add environment variables for specifying the host OS/arch -that we are building the compiler for, so it can differ from -the build host OS/arch. - -Upstream-Status: Pending - -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/make.bash | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/make.bash b/src/make.bash -index 2e6fb05..0bdadc6 100755 ---- a/src/make.bash -+++ b/src/make.bash -@@ -173,6 +173,8 @@ if [ "$do_host_build" = "yes" ]; then - echo - - GOTOOLDIR_BOOTSTRAP="${GOTOOLDIR_BOOTSTRAP:-$GOTOOLDIR}" -+ GOHOSTOS="${GOHOSTOS_CROSS:-$GOHOSTOS}" -+ GOHOSTARCH="${GOHOSTARCH_CROSS:-$GOHOSTARCH}" - echo "##### Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH." - # CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however, - # use the host compiler, CC, from `cmd/dist/dist env` instead. --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0009-cmd-go-buildmode-pie-forces-external-linking-mode-on.patch b/meta/recipes-devtools/go/go-1.9/0009-cmd-go-buildmode-pie-forces-external-linking-mode-on.patch deleted file mode 100644 index aa5fcfdd23..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0009-cmd-go-buildmode-pie-forces-external-linking-mode-on.patch +++ /dev/null @@ -1,47 +0,0 @@ -From aae44527c8065d54f6acaf87c82cba1ac96fae59 Mon Sep 17 00:00:00 2001 -From: Ian Lance Taylor <iant@golang.org> -Date: Fri, 18 Aug 2017 17:46:03 -0700 -Subject: [PATCH] cmd/go: -buildmode=pie forces external linking mode on all - systems - -The go tool assumed that -buildmode=pie implied internal linking on -linux-amd64. However, that was changed by CL 36417 for issue #18968. - -Fixes #21452 - -Change-Id: I8ed13aea52959cc5c53223f4c41ba35329445545 -Reviewed-on: https://go-review.googlesource.com/57231 -Run-TryBot: Ian Lance Taylor <iant@golang.org> -TryBot-Result: Gobot Gobot <gobot@golang.org> -Reviewed-by: Avelino <t@avelino.xxx> -Reviewed-by: Rob Pike <r@golang.org> ---- -Upstream-Status: Backport -Signed-off-by: Khem Raj <raj.khem@gmail.com> - - src/cmd/go/internal/load/pkg.go | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go -index 2660d3f..d40773b 100644 ---- a/src/cmd/go/internal/load/pkg.go -+++ b/src/cmd/go/internal/load/pkg.go -@@ -954,11 +954,12 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package - - if cfg.BuildContext.CgoEnabled && p.Name == "main" && !p.Goroot { - // Currently build modes c-shared, pie (on systems that do not -- // support PIE with internal linking mode), plugin, and -- // -linkshared force external linking mode, as of course does -+ // support PIE with internal linking mode (currently all -+ // systems: issue #18968)), plugin, and -linkshared force -+ // external linking mode, as of course does - // -ldflags=-linkmode=external. External linking mode forces - // an import of runtime/cgo. -- pieCgo := cfg.BuildBuildmode == "pie" && (cfg.BuildContext.GOOS != "linux" || cfg.BuildContext.GOARCH != "amd64") -+ pieCgo := cfg.BuildBuildmode == "pie" - linkmodeExternal := false - for i, a := range cfg.BuildLdflags { - if a == "-linkmode=external" { --- -2.14.1 - diff --git a/meta/recipes-devtools/go/go-1.9/0010-make.bash-override-CC-when-building-dist-and-go_boot.patch b/meta/recipes-devtools/go/go-1.9/0010-make.bash-override-CC-when-building-dist-and-go_boot.patch deleted file mode 100644 index 83fd78c3d7..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0010-make.bash-override-CC-when-building-dist-and-go_boot.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 21d83dd9499e5be30eea28dd7034d1ea2a01c838 Mon Sep 17 00:00:00 2001 -From: Matt Madison <matt@madison.systems> -Date: Tue, 14 Nov 2017 07:38:42 -0800 -Subject: [PATCH 10/10] make.bash: override CC when building dist and - go_bootstrap - -For cross-canadian builds, dist and go_bootstrap -run on the build host, so CC needs to point to the -build host's C compiler. Add a BUILD_CC environment -for this, falling back to $CC if not present. - -Upstream-Status: Pending - -Signed-off-by: Matt Madison <matt@madison.systems> ---- - src/make.bash | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/make.bash b/src/make.bash -index 0bdadc6..f199349 100755 ---- a/src/make.bash -+++ b/src/make.bash -@@ -131,7 +131,7 @@ if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; then - exit 1 - fi - rm -f cmd/dist/dist --GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist -+CC=${BUILD_CC:-${CC}} GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist - - # -e doesn't propagate out of eval, so check success by hand. - eval $(./cmd/dist/dist env -p || echo FAIL=true) -@@ -167,7 +167,7 @@ elif [ "$1" = "--host-only" ]; then - fi - - if [ "$do_host_build" = "yes" ]; then -- ./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap -+ CC=${BUILD_CC:-${CC}} ./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap - # Delay move of dist tool to now, because bootstrap may clear tool directory. - mv cmd/dist/dist "$GOTOOLDIR"/dist - echo --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/0011-use-GOBUILDMODE-to-set-buildmode.patch b/meta/recipes-devtools/go/go-1.9/0011-use-GOBUILDMODE-to-set-buildmode.patch deleted file mode 100644 index da93dc5c14..0000000000 --- a/meta/recipes-devtools/go/go-1.9/0011-use-GOBUILDMODE-to-set-buildmode.patch +++ /dev/null @@ -1,40 +0,0 @@ -From b928fafab1d9425aae9341806bd2f6178ba1da1f Mon Sep 17 00:00:00 2001 -From: Hongxu Jia <hongxu.jia@windriver.com> -Date: Fri, 26 Oct 2018 16:32:50 +0800 -Subject: [PATCH] use GOBUILDMODE to set buildmode - -While building go itself, the go build system does not support -to set `-buildmode=pie' from environment. - -Add GOBUILDMODE to support it which make PIE executables the default -build mode, as PIE executables are required as of Yocto - -Refers: https://groups.google.com/forum/#!topic/golang-dev/gRCe5URKewI -Upstream-Status: Denied [upstream choose antoher solution: `17a256b -cmd/go: -buildmode=pie for android/arm'] - -Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> ---- - src/cmd/go/internal/work/build.go | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go -index b276de5..1683e7e 100644 ---- a/src/cmd/go/internal/work/build.go -+++ b/src/cmd/go/internal/work/build.go -@@ -211,7 +211,11 @@ func AddBuildFlags(cmd *base.Command) { - - cmd.Flag.Var((*base.StringsFlag)(&buildAsmflags), "asmflags", "") - cmd.Flag.Var(buildCompiler{}, "compiler", "") -- cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "") -+ if bm := os.Getenv("GOBUILDMODE"); bm != "" { -+ cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", bm, "") -+ } else { -+ cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "") -+ } - cmd.Flag.Var((*base.StringsFlag)(&buildGcflags), "gcflags", "") - cmd.Flag.Var((*base.StringsFlag)(&buildGccgoflags), "gccgoflags", "") - cmd.Flag.StringVar(&cfg.BuildContext.InstallSuffix, "installsuffix", "", "") --- -2.7.4 - diff --git a/meta/recipes-devtools/go/go-1.9/set-external-linker.patch b/meta/recipes-devtools/go/go-1.9/set-external-linker.patch deleted file mode 100644 index d6bd7fa39c..0000000000 --- a/meta/recipes-devtools/go/go-1.9/set-external-linker.patch +++ /dev/null @@ -1,111 +0,0 @@ -Change the dynamic linker hardcoding to use musl when not using glibc -this should be applied conditional to musl being the system C library - -Upstream-Status: Inappropriate [Real Fix should be portable across libcs] - -Signed-off-by: Khem Raj <raj.khem@gmail.com> - -Index: go/src/cmd/link/internal/amd64/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/amd64/obj.go -+++ go/src/cmd/link/internal/amd64/obj.go -@@ -67,7 +67,7 @@ func Init() { - ld.Thearch.Append64 = ld.Append64l - ld.Thearch.TLSIEtoLE = tlsIEtoLE - -- ld.Thearch.Linuxdynld = "/lib64/ld-linux-x86-64.so.2" -+ ld.Thearch.Linuxdynld = "/lib/ld-musl-x86_64.so.1" - ld.Thearch.Freebsddynld = "/libexec/ld-elf.so.1" - ld.Thearch.Openbsddynld = "/usr/libexec/ld.so" - ld.Thearch.Netbsddynld = "/libexec/ld.elf_so" -Index: go/src/cmd/link/internal/arm/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/arm/obj.go -+++ go/src/cmd/link/internal/arm/obj.go -@@ -63,7 +63,7 @@ func Init() { - ld.Thearch.Append32 = ld.Append32l - ld.Thearch.Append64 = ld.Append64l - -- ld.Thearch.Linuxdynld = "/lib/ld-linux.so.3" // 2 for OABI, 3 for EABI -+ ld.Thearch.Linuxdynld = "/lib/ld-musl-armhf.so.1" - ld.Thearch.Freebsddynld = "/usr/libexec/ld-elf.so.1" - ld.Thearch.Openbsddynld = "/usr/libexec/ld.so" - ld.Thearch.Netbsddynld = "/libexec/ld.elf_so" -Index: go/src/cmd/link/internal/arm64/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/arm64/obj.go -+++ go/src/cmd/link/internal/arm64/obj.go -@@ -62,7 +62,7 @@ func Init() { - ld.Thearch.Append32 = ld.Append32l - ld.Thearch.Append64 = ld.Append64l - -- ld.Thearch.Linuxdynld = "/lib/ld-linux-aarch64.so.1" -+ ld.Thearch.Linuxdynld = "/lib/ld-musl-aarch64.so.1" - - ld.Thearch.Freebsddynld = "XXX" - ld.Thearch.Openbsddynld = "XXX" -Index: go/src/cmd/link/internal/mips/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/mips/obj.go -+++ go/src/cmd/link/internal/mips/obj.go -@@ -77,7 +77,7 @@ func Init() { - ld.Thearch.Append64 = ld.Append64b - } - -- ld.Thearch.Linuxdynld = "/lib/ld.so.1" -+ ld.Thearch.Linuxdynld = "/lib/ld-musl-mipsle.so.1" - - ld.Thearch.Freebsddynld = "XXX" - ld.Thearch.Openbsddynld = "XXX" -Index: go/src/cmd/link/internal/mips64/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/mips64/obj.go -+++ go/src/cmd/link/internal/mips64/obj.go -@@ -75,7 +75,7 @@ func Init() { - ld.Thearch.Append64 = ld.Append64b - } - -- ld.Thearch.Linuxdynld = "/lib64/ld64.so.1" -+ ld.Thearch.Linuxdynld = "/lib64/ld-musl-mips64le.so.1" - - ld.Thearch.Freebsddynld = "XXX" - ld.Thearch.Openbsddynld = "XXX" -Index: go/src/cmd/link/internal/ppc64/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/ppc64/obj.go -+++ go/src/cmd/link/internal/ppc64/obj.go -@@ -77,7 +77,7 @@ func Init() { - } - - // TODO(austin): ABI v1 uses /usr/lib/ld.so.1 -- ld.Thearch.Linuxdynld = "/lib64/ld64.so.1" -+ ld.Thearch.Linuxdynld = "/lib/ld-musl-powerpc64le.so.1" - - ld.Thearch.Freebsddynld = "XXX" - ld.Thearch.Openbsddynld = "XXX" -Index: go/src/cmd/link/internal/s390x/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/s390x/obj.go -+++ go/src/cmd/link/internal/s390x/obj.go -@@ -62,7 +62,7 @@ func Init() { - ld.Thearch.Append32 = ld.Append32b - ld.Thearch.Append64 = ld.Append64b - -- ld.Thearch.Linuxdynld = "/lib64/ld64.so.1" -+ ld.Thearch.Linuxdynld = "/lib/ld-musl-s390x.so.1" - - // not relevant for s390x - ld.Thearch.Freebsddynld = "XXX" -Index: go/src/cmd/link/internal/x86/obj.go -=================================================================== ---- go.orig/src/cmd/link/internal/x86/obj.go -+++ go/src/cmd/link/internal/x86/obj.go -@@ -63,7 +63,7 @@ func Init() { - ld.Thearch.Append32 = ld.Append32l - ld.Thearch.Append64 = ld.Append64l - -- ld.Thearch.Linuxdynld = "/lib/ld-linux.so.2" -+ ld.Thearch.Linuxdynld = "/lib/ld-musl-i386.so.1" - ld.Thearch.Freebsddynld = "/usr/libexec/ld-elf.so.1" - ld.Thearch.Openbsddynld = "/usr/libexec/ld.so" - ld.Thearch.Netbsddynld = "/usr/libexec/ld.elf_so" diff --git a/meta/recipes-devtools/go/go-binary-native_1.17.8.bb b/meta/recipes-devtools/go/go-binary-native_1.17.8.bb new file mode 100644 index 0000000000..1b85cd50d6 --- /dev/null +++ b/meta/recipes-devtools/go/go-binary-native_1.17.8.bb @@ -0,0 +1,46 @@ +# This recipe is for bootstrapping our go-cross from a prebuilt binary of Go from golang.org. + +SUMMARY = "Go programming language compiler (upstream binary for bootstrap)" +HOMEPAGE = " http://golang.org/" +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707" + +PROVIDES = "go-native" + +SRC_URI = "https://dl.google.com/go/go${PV}.${BUILD_GOOS}-${BUILD_GOARCH}.tar.gz;name=go_${BUILD_GOTUPLE}" +SRC_URI[go_linux_amd64.sha256sum] = "980e65a863377e69fd9b67df9d8395fd8e93858e7a24c9f55803421e453f4f99" +SRC_URI[go_linux_arm64.sha256sum] = "57a9171682e297df1a5bd287be056ed0280195ad079af90af16dcad4f64710cb" + +UPSTREAM_CHECK_URI = "https://golang.org/dl/" +UPSTREAM_CHECK_REGEX = "go(?P<pver>\d+(\.\d+)+)\.linux" + +S = "${WORKDIR}/go" + +inherit goarch native + +do_compile() { + : +} + +make_wrapper() { + rm -f ${D}${bindir}/$1 + cat <<END >${D}${bindir}/$1 +#!/bin/bash +here=\`dirname \$0\` +export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}" +\$here/../lib/go/bin/$1 "\$@" +END + chmod +x ${D}${bindir}/$1 +} + +do_install() { + find ${S} -depth -type d -name testdata -exec rm -rf {} + + + install -d ${D}${bindir} ${D}${libdir}/go + cp --preserve=mode,timestamps -R ${S}/ ${D}${libdir}/ + + for f in ${S}/bin/* + do + make_wrapper `basename $f` + done +} diff --git a/meta/recipes-devtools/go/go-common.inc b/meta/recipes-devtools/go/go-common.inc index 11d55c4d36..83f8db7b39 100644 --- a/meta/recipes-devtools/go/go-common.inc +++ b/meta/recipes-devtools/go/go-common.inc @@ -14,7 +14,7 @@ LICENSE = "BSD-3-Clause" inherit goarch -SRC_URI = "http://golang.org/dl/go${PV}.src.tar.gz;name=main" +SRC_URI = "https://golang.org/dl/go${PV}.src.tar.gz;name=main" S = "${WORKDIR}/go" B = "${S}" UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)\.src\.tar" @@ -23,11 +23,22 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1" SSTATE_SCAN_CMD = "true" export GOROOT_OVERRIDE = "1" -export GOTMPDIR ?= "${WORKDIR}/go-tmp" +export GOTMPDIR ?= "${WORKDIR}/build-tmp" GOTMPDIR[vardepvalue] = "" -export GOCACHE = "off" export CGO_ENABLED = "1" -do_compile_prepend() { +export GOHOSTOS ?= "${BUILD_GOOS}" +export GOHOSTARCH ?= "${BUILD_GOARCH}" +export GOROOT_BOOTSTRAP ?= "${STAGING_LIBDIR_NATIVE}/go" +export GOOS ?= "${TARGET_GOOS}" +export GOARCH ?= "${TARGET_GOARCH}" +export GOARM ?= "${TARGET_GOARM}" +export GO386 ?= "${TARGET_GO386}" +export GOMIPS ?= "${TARGET_GOMIPS}" +export GOROOT_FINAL ?= "${libdir}/go" + +export GODEBUG = "gocachehash=1" + +do_compile:prepend() { BUILD_CC=${BUILD_CC} } diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc index 0bc5dce8a1..c1aa987427 100644 --- a/meta/recipes-devtools/go/go-cross-canadian.inc +++ b/meta/recipes-devtools/go/go-cross-canadian.inc @@ -5,11 +5,15 @@ DEPENDS = "go-native virtual/${HOST_PREFIX}go-crosssdk virtual/nativesdk-${HOST_ virtual/nativesdk-${HOST_PREFIX}compilerlibs" PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}" -export GOHOSTOS = "${BUILD_GOOS}" -export GOHOSTARCH = "${BUILD_GOARCH}" -export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" +# it uses gcc on build machine during go-cross-canadian bootstrap, but +# the gcc version may be old and not support option '-fmacro-prefix-map' +# which is one of default values of DEBUG_PREFIX_MAP +DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ + -fdebug-prefix-map=${STAGING_DIR_HOST}= \ + -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ + " + export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}" -export GOROOT_FINAL = "${libdir}/go" export CGO_CFLAGS = "${CFLAGS}" export CGO_LDFLAGS = "${LDFLAGS}" export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS} ${HOST_CC_ARCH} ${LDFLAGS}"' @@ -17,13 +21,12 @@ export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "-- do_configure[noexec] = "1" do_compile() { - export CC_FOR_${HOST_GOOS}_${HOST_GOARCH}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" - export CXX_FOR_${HOST_GOOS}_${HOST_GOARCH}="${HOST_PREFIX}gxx --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" + export CC_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" + export CXX_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gxx --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" cd src ./make.bash --host-only --no-banner cd ${B} } -do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" diff --git a/meta/recipes-devtools/go/go-cross-canadian_1.11.bb b/meta/recipes-devtools/go/go-cross-canadian_1.17.8.bb index 7ac9449e47..7ac9449e47 100644 --- a/meta/recipes-devtools/go/go-cross-canadian_1.11.bb +++ b/meta/recipes-devtools/go/go-cross-canadian_1.17.8.bb diff --git a/meta/recipes-devtools/go/go-cross-canadian_1.9.bb b/meta/recipes-devtools/go/go-cross-canadian_1.9.bb deleted file mode 100644 index 367a967056..0000000000 --- a/meta/recipes-devtools/go/go-cross-canadian_1.9.bb +++ /dev/null @@ -1,12 +0,0 @@ -require go-cross-canadian.inc -require go-${PV}.inc - -export GOHOSTOS_CROSS = "${HOST_GOOS}" -export GOHOSTARCH_CROSS = "${HOST_GOARCH}" -export CC_FOR_TARGET = "${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" -export CXX_FOR_TARGET = "${HOST_PREFIX}g++ --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" - -do_compile_prepend() { - export GOBIN="${B}/bin" - export TMPDIR="$GOTMPDIR" -} diff --git a/meta/recipes-devtools/go/go-cross.inc b/meta/recipes-devtools/go/go-cross.inc index 6d9aa5c2dd..a0fbdbe3b9 100644 --- a/meta/recipes-devtools/go/go-cross.inc +++ b/meta/recipes-devtools/go/go-cross.inc @@ -5,28 +5,18 @@ DEPENDS = "go-native" PN = "go-cross-${TUNE_PKGARCH}" -export GOHOSTOS = "${BUILD_GOOS}" -export GOHOSTARCH = "${BUILD_GOARCH}" -export GOOS = "${TARGET_GOOS}" -export GOARCH = "${TARGET_GOARCH}" -export GOARM = "${TARGET_GOARM}" -export GO386 = "${TARGET_GO386}" -export GOMIPS = "${TARGET_GOMIPS}" -export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" -export GOROOT_FINAL = "${libdir}/go" -export GOCACHE = "off" +export GOCACHE = "${B}/.cache" CC = "${@d.getVar('BUILD_CC').strip()}" do_configure[noexec] = "1" do_compile() { - export CC_FOR_${GOOS}_${GOARCH}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" - export CXX_FOR_${GOOS}_${GOARCh}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" + export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" + export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" cd src ./make.bash --host-only --no-banner cd ${B} } -do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" make_wrapper() { diff --git a/meta/recipes-devtools/go/go-cross_1.11.bb b/meta/recipes-devtools/go/go-cross_1.17.8.bb index 80b5a03f6c..80b5a03f6c 100644 --- a/meta/recipes-devtools/go/go-cross_1.11.bb +++ b/meta/recipes-devtools/go/go-cross_1.17.8.bb diff --git a/meta/recipes-devtools/go/go-cross_1.9.bb b/meta/recipes-devtools/go/go-cross_1.9.bb deleted file mode 100644 index 4739c7d5c4..0000000000 --- a/meta/recipes-devtools/go/go-cross_1.9.bb +++ /dev/null @@ -1,10 +0,0 @@ -require go-cross.inc -require go-${PV}.inc - -export CC_FOR_TARGET = "${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" -export CXX_FOR_TARGET = "${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" - -do_compile_prepend() { - export GOBIN="${B}/bin" - export TMPDIR="$GOTMPDIR" -} diff --git a/meta/recipes-devtools/go/go-crosssdk.inc b/meta/recipes-devtools/go/go-crosssdk.inc index 94f6fb8eb7..cd23cca2fe 100644 --- a/meta/recipes-devtools/go/go-crosssdk.inc +++ b/meta/recipes-devtools/go/go-crosssdk.inc @@ -4,23 +4,15 @@ DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TA PN = "go-crosssdk-${SDK_SYS}" PROVIDES = "virtual/${TARGET_PREFIX}go-crosssdk" -export GOHOSTOS = "${BUILD_GOOS}" -export GOHOSTARCH = "${BUILD_GOARCH}" -export GOOS = "${TARGET_GOOS}" -export GOARCH = "${TARGET_GOARCH}" -export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" -export GOROOT_FINAL = "${libdir}/go" - do_configure[noexec] = "1" do_compile() { - export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" - export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" + export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" + export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" cd src ./make.bash --host-only --no-banner cd ${B} } -do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" make_wrapper() { diff --git a/meta/recipes-devtools/go/go-crosssdk_1.11.bb b/meta/recipes-devtools/go/go-crosssdk_1.17.8.bb index 1857c8a577..1857c8a577 100644 --- a/meta/recipes-devtools/go/go-crosssdk_1.11.bb +++ b/meta/recipes-devtools/go/go-crosssdk_1.17.8.bb diff --git a/meta/recipes-devtools/go/go-crosssdk_1.9.bb b/meta/recipes-devtools/go/go-crosssdk_1.9.bb deleted file mode 100644 index 3ac629bd41..0000000000 --- a/meta/recipes-devtools/go/go-crosssdk_1.9.bb +++ /dev/null @@ -1,11 +0,0 @@ -require go-crosssdk.inc -require go-${PV}.inc - -export CC_FOR_TARGET = "${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" -export CXX_FOR_TARGET = "${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" -export GO_INSTALL = "cmd" - -do_compile_prepend() { - export GOBIN="${B}/bin" - export TMPDIR="$GOTMPDIR" -} diff --git a/meta/recipes-devtools/go/go-dep/0001-Add-support-for-mips-mips64.patch b/meta/recipes-devtools/go/go-dep/0001-Add-support-for-mips-mips64.patch deleted file mode 100644 index 34ec9876f8..0000000000 --- a/meta/recipes-devtools/go/go-dep/0001-Add-support-for-mips-mips64.patch +++ /dev/null @@ -1,54 +0,0 @@ -From f0fb80604385ae3266a472601ef685896b4cc0af Mon Sep 17 00:00:00 2001 -From: Vladimir Stefanovic <vladimir.stefanovic@imgtec.com> -Date: Fri, 17 Feb 2017 20:44:43 +0100 -Subject: [PATCH] Add support for mips, mips64 - ---- -Upstream-Status: Submitted -Signed-off-by: Khem Raj <raj.khem@gmail.com> - - vendor/github.com/boltdb/bolt/bolt_mips64x.go | 12 ++++++++++++ - vendor/github.com/boltdb/bolt/bolt_mipsx.go | 12 ++++++++++++ - 2 files changed, 24 insertions(+) - create mode 100644 vendor/github.com/boltdb/bolt/bolt_mips64x.go - create mode 100644 vendor/github.com/boltdb/bolt/bolt_mipsx.go - -diff --git a/vendor/github.com/boltdb/bolt/bolt_mips64x.go b/vendor/github.com/boltdb/bolt/bolt_mips64x.go -new file mode 100644 -index 00000000..134b578b ---- /dev/null -+++ b/vendor/github.com/boltdb/bolt/bolt_mips64x.go -@@ -0,0 +1,12 @@ -+// +build mips64 mips64le -+ -+package bolt -+ -+// maxMapSize represents the largest mmap size supported by Bolt. -+const maxMapSize = 0x8000000000 // 512GB -+ -+// maxAllocSize is the size used when creating array pointers. -+const maxAllocSize = 0x7FFFFFFF -+ -+// Are unaligned load/stores broken on this arch? -+var brokenUnaligned = false -diff --git a/vendor/github.com/boltdb/bolt/bolt_mipsx.go b/vendor/github.com/boltdb/bolt/bolt_mipsx.go -new file mode 100644 -index 00000000..d5ecb059 ---- /dev/null -+++ b/vendor/github.com/boltdb/bolt/bolt_mipsx.go -@@ -0,0 +1,12 @@ -+// +build mips mipsle -+ -+package bolt -+ -+// maxMapSize represents the largest mmap size supported by Bolt. -+const maxMapSize = 0x40000000 // 1GB -+ -+// maxAllocSize is the size used when creating array pointers. -+const maxAllocSize = 0xFFFFFFF -+ -+// Are unaligned load/stores broken on this arch? -+var brokenUnaligned = false --- -2.14.1 - diff --git a/meta/recipes-devtools/go/go-dep_0.5.0.bb b/meta/recipes-devtools/go/go-dep_0.5.0.bb deleted file mode 100644 index cfc2186b31..0000000000 --- a/meta/recipes-devtools/go/go-dep_0.5.0.bb +++ /dev/null @@ -1,35 +0,0 @@ -SUMMARY = "Dependency management tool for Golang" -HOMEPAGE = "https://github.com/golang/dep" -LICENSE = "BSD-3-Clause" -LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=1bad315647751fab0007812f70d42c0d" - -GO_IMPORT = "github.com/golang/dep" -SRC_URI = "git://${GO_IMPORT} \ - file://0001-Add-support-for-mips-mips64.patch;patchdir=src/github.com/golang/dep \ - " - -# Points to 0.5.0 tag -SRCREV = "224a564abe296670b692fe08bb63a3e4c4ad7978" - -inherit go - -GO_INSTALL = "${GO_IMPORT}/cmd/dep" - -RDEPENDS_${PN}-dev += "bash" - -BBCLASSEXTEND = "native nativesdk" - -# for x86 ends with textrel in ${PN} -# http://errors.yoctoproject.org/Errors/Details/185630/ -# ERROR: QA Issue: ELF binary '/work/i586-oe-linux/go-dep/0.4.1-r0/packages-split/go-dep/usr/bin/dep' has relocations in .text [textrel] -INSANE_SKIP_${PN} += "textrel" - -# for aarch64 ends with textrel in ${PN}-ptest -# http://errors.yoctoproject.org/Errors/Details/185632/ -# ERROR: QA Issue: ELF binary '/work/aarch64-oe-linux/go-dep/0.4.1-r0/packages-split/go-dep-ptest/usr/lib/go-dep/ptest/github.com/golang/dep/cmd/dep/dep.test' has relocations in .text [textrel] -INSANE_SKIP_${PN}-ptest += "textrel" - -# For compiling ptest on mips and mips64, the current go-dep version fails with the go 1.11 toolchain. -# error message: vet config not found -PTEST_ENABLED_mips = "0" -PTEST_ENABLED_mips64 = "0" diff --git a/meta/recipes-devtools/go/go-native_1.11.bb b/meta/recipes-devtools/go/go-native_1.11.bb deleted file mode 100644 index bbf3c0dd73..0000000000 --- a/meta/recipes-devtools/go/go-native_1.11.bb +++ /dev/null @@ -1,2 +0,0 @@ -require ${PN}.inc -require go-${PV}.inc diff --git a/meta/recipes-devtools/go/go-native.inc b/meta/recipes-devtools/go/go-native_1.17.8.bb index 207708745e..76c0ab73a6 100644 --- a/meta/recipes-devtools/go/go-native.inc +++ b/meta/recipes-devtools/go/go-native_1.17.8.bb @@ -1,7 +1,11 @@ +# This recipe builds a native Go (written in Go) by first building an old Go 1.4 +# (written in C). However this old Go does not support all hosts platforms. + +require go-${PV}.inc + inherit native -SRC_URI_append = " https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz;name=bootstrap;subdir=go1.4" -SRC_URI[bootstrap.md5sum] = "dbf727a4b0e365bf88d97cbfde590016" +SRC_URI:append = " https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz;name=bootstrap;subdir=go1.4" SRC_URI[bootstrap.sha256sum] = "f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52" export GOOS = "${BUILD_GOOS}" @@ -23,7 +27,6 @@ do_compile() { ./make.bash ${GOMAKEARGS} cd ${B} } -do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin" do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin" make_wrapper() { diff --git a/meta/recipes-devtools/go/go-native_1.9.bb b/meta/recipes-devtools/go/go-native_1.9.bb deleted file mode 100644 index 8621e1df32..0000000000 --- a/meta/recipes-devtools/go/go-native_1.9.bb +++ /dev/null @@ -1,4 +0,0 @@ -require ${PN}.inc -require go-${PV}.inc - -GOMAKEARGS = "--host-only --no-banner" diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc index c219aa3789..e18339cddb 100644 --- a/meta/recipes-devtools/go/go-runtime.inc +++ b/meta/recipes-devtools/go/go-runtime.inc @@ -1,20 +1,18 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" -DEPENDS_class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk" +DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk" PROVIDES = "virtual/${TARGET_PREFIX}go-runtime" -export GOHOSTOS = "${BUILD_GOOS}" -export GOHOSTARCH = "${BUILD_GOARCH}" -export GOOS = "${TARGET_GOOS}" -export GOARCH = "${TARGET_GOARCH}" -export GOARM = "${TARGET_GOARM}" -export GO386 = "${TARGET_GO386}" -export GOMIPS = "${TARGET_GOMIPS}" -export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" -export GOROOT_FINAL = "${libdir}/go" +DEBUG_PREFIX_MAP = "\ + -fdebug-prefix-map=${STAGING_DIR_HOST}= \ + -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ +" + export CGO_CFLAGS = "${CFLAGS}" export CGO_CPPFLAGS = "${CPPFLAGS}" export CGO_CXXFLAGS = "${CXXFLAGS}" -export CGO_LDFLAGS = "${LDFLAGS}" +# Filter out -fdebug-prefix-map options as they clash with the GO's build system +export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" +export GOCACHE = "${B}/.cache" GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}" GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"' @@ -23,24 +21,23 @@ do_configure() { : } -do_configure_libc-musl() { +do_configure:libc-musl() { rm -f ${S}/src/runtime/race/*.syso } do_compile() { - export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}" - export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}" + export CC_FOR_${TARGET_GOTUPLE}="${CC}" + export CXX_FOR_${TARGET_GOTUPLE}="${CXX}" cd src ./make.bash --target-only --no-banner std if [ -n "${GO_DYNLINK}" ]; then export GOTOOLDIR="${B}/pkg/tool/native_native" - CC="$CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \ + CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \ $GOTOOLDIR/go_bootstrap install -linkshared -buildmode=shared ${GO_SHLIB_LDFLAGS} std fi cd ${B} } -do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" do_install() { @@ -58,11 +55,14 @@ do_install() { done find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; rm -f ${D}${libdir}/go/src/cmd/dist/dist + rm -f ${D}${libdir}/go/src/cmd/cgo/zdefaultcc.go + rm -f ${D}${libdir}/go/src/cmd/go/internal/cfg/zdefaultcc.go + } -ALLOW_EMPTY_${PN} = "1" -FILES_${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" -FILES_${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ +ALLOW_EMPTY:${PN} = "1" +FILES:${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" +FILES:${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \ ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.shlibname \ ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.shlibname \ @@ -78,12 +78,12 @@ FILES_${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.a \ ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.a \ " -FILES_${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}" +FILES:${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}" # Go sources include some scripts and pre-built binaries for # multiple architectures. The static .a files for dynamically-linked # runtime are also required in -dev. -INSANE_SKIP_${PN}-dev = "staticdev file-rdeps arch" +INSANE_SKIP:${PN}-dev = "staticdev file-rdeps arch" INHIBIT_PACKAGE_STRIP = "1" INHIBIT_PACKAGE_DEBUG_SPLIT = "1" diff --git a/meta/recipes-devtools/go/go-runtime_1.11.bb b/meta/recipes-devtools/go/go-runtime_1.17.8.bb index 43b68b4e46..63464a1501 100644 --- a/meta/recipes-devtools/go/go-runtime_1.11.bb +++ b/meta/recipes-devtools/go/go-runtime_1.17.8.bb @@ -1,2 +1,3 @@ require go-${PV}.inc require go-runtime.inc + diff --git a/meta/recipes-devtools/go/go-runtime_1.9.bb b/meta/recipes-devtools/go/go-runtime_1.9.bb deleted file mode 100644 index d5279ea897..0000000000 --- a/meta/recipes-devtools/go/go-runtime_1.9.bb +++ /dev/null @@ -1,23 +0,0 @@ -require go-${PV}.inc -require go-runtime.inc - -export GO_TARGET_INSTALL = "std" -export CC_FOR_TARGET = "${CC}" -export CXX_FOR_TARGET = "${CXX}" - -do_compile() { - export GOBIN="${B}/bin" - export TMPDIR="$GOTMPDIR" - export CC=$BUILD_CC - - cd src - CGO_CFLAGS="${BUILD_CFLAGS}" CGO_LDFLAGS="${BUILD_LDFLAGS}" ./make.bash --host-only - cp ${B}/pkg/tool/${BUILD_GOTUPLE}/go_bootstrap ${B} - rm -rf ${B}/pkg/${TARGET_GOTUPLE} - ./make.bash --target-only - if [ -n "${GO_DYNLINK}" ]; then - cp ${B}/go_bootstrap ${B}/pkg/tool/${BUILD_GOTUPLE} - GO_FLAGS="-buildmode=shared" GO_LDFLAGS="-extldflags \"${LDFLAGS}\"" ./make.bash --target-only - fi - cd ${B} -} diff --git a/meta/recipes-devtools/go/go-target.inc b/meta/recipes-devtools/go/go-target.inc index 379f87b498..d085643036 100644 --- a/meta/recipes-devtools/go/go-target.inc +++ b/meta/recipes-devtools/go/go-target.inc @@ -1,20 +1,23 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" -DEPENDS_class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native" - -export GOHOSTOS = "${BUILD_GOOS}" -export GOHOSTARCH = "${BUILD_GOARCH}" -export GOOS = "${TARGET_GOOS}" -export GOARCH = "${TARGET_GOARCH}" -export GOARM = "${TARGET_GOARM}" -export GO386 = "${TARGET_GO386}" -export GOMIPS = "${TARGET_GOMIPS}" -export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" -export GOROOT_FINAL = "${libdir}/go" +DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native" + +DEBUG_PREFIX_MAP = "\ + -fdebug-prefix-map=${STAGING_DIR_HOST}= \ + -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ +" + +export CGO_CFLAGS = "${CFLAGS}" +export CGO_CPPFLAGS = "${CPPFLAGS}" +export CGO_CXXFLAGS = "${CXXFLAGS}" +# Filter out -fdebug-prefix-map options as they clash with the GO's build system +export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" + +export GOCACHE = "${B}/.cache" GO_LDFLAGS = "" -GO_LDFLAGS_class-nativesdk = "-linkmode external" +GO_LDFLAGS:class-nativesdk = "-linkmode external" export GO_LDFLAGS -CC_append_class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}" +CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}" do_configure[noexec] = "1" @@ -26,7 +29,6 @@ do_compile() { ./make.bash --target-only --no-banner cd ${B} } -do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" do_install() { @@ -42,12 +44,12 @@ do_install() { install -m 0755 $f ${D}${libdir}/go/bin/ ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/ done + rm -rf ${D}${libdir}/go/src } PACKAGES = "${PN} ${PN}-dev" -FILES_${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}" -FILES_${PN}-dev = "${libdir}/go" -RDEPENDS_${PN}-dev = "perl bash" -INSANE_SKIP_${PN} = "ldflags" +FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}" +RDEPENDS:${PN} = "go-runtime" +INSANE_SKIP:${PN} = "ldflags" BBCLASSEXTEND = "nativesdk" diff --git a/meta/recipes-devtools/go/go_1.11.bb b/meta/recipes-devtools/go/go_1.11.bb deleted file mode 100644 index 42cdb0430a..0000000000 --- a/meta/recipes-devtools/go/go_1.11.bb +++ /dev/null @@ -1,14 +0,0 @@ -require go-${PV}.inc -require go-target.inc - -export GOBUILDMODE="" - -# Add pie to GOBUILDMODE to satisfy "textrel" QA checking, but mips -# doesn't support -buildmode=pie, so skip the QA checking for mips and its -# variants. -python() { - if 'mips' in d.getVar('TARGET_ARCH'): - d.appendVar('INSANE_SKIP_%s' % d.getVar('PN'), " textrel") - else: - d.setVar('GOBUILDMODE', 'pie') -} diff --git a/meta/recipes-devtools/go/go_1.17.8.bb b/meta/recipes-devtools/go/go_1.17.8.bb new file mode 100644 index 0000000000..34dc89bb0c --- /dev/null +++ b/meta/recipes-devtools/go/go_1.17.8.bb @@ -0,0 +1,17 @@ +require go-${PV}.inc +require go-target.inc + +inherit linuxloader + +export GOBUILDMODE="" +export GO_LDSO = "${@get_linuxloader(d)}" +export CC_FOR_TARGET = "gcc" +export CXX_FOR_TARGET = "g++" + +# mips/rv64 doesn't support -buildmode=pie, so skip the QA checking for mips/riscv32 and its +# variants. +python() { + if 'mips' in d.getVar('TARGET_ARCH',True) or 'riscv32' in d.getVar('TARGET_ARCH',True): + d.appendVar('INSANE_SKIP:%s' % d.getVar('PN',True), " textrel") +} + diff --git a/meta/recipes-devtools/go/go_1.9.bb b/meta/recipes-devtools/go/go_1.9.bb deleted file mode 100644 index c23ea0c1ae..0000000000 --- a/meta/recipes-devtools/go/go_1.9.bb +++ /dev/null @@ -1,28 +0,0 @@ -require go-${PV}.inc -require go-target.inc - -export GO_TARGET_INSTALL = "cmd" -export GO_FLAGS = "-a" -export CC_FOR_TARGET = "${CC}" -export CXX_FOR_TARGET = "${CXX}" -export GOBUILDMODE="" - -do_compile() { - export GOBIN="${B}/bin" - export TMPDIR="$GOTMPDIR" - export CC=$BUILD_CC - - cd src - ./make.bash - cd ${B} -} - -# Add pie to GOBUILDMODE to satisfy "textrel" QA checking, but mips -# doesn't support -buildmode=pie, so skip the QA checking for mips and its -# variants. -python() { - if 'mips' in d.getVar('TARGET_ARCH'): - d.appendVar('INSANE_SKIP_%s' % d.getVar('PN'), " textrel") - else: - d.setVar('GOBUILDMODE', 'pie') -} |