From 7d219c244079cad98d735c0735c82a439c3a54e5 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Mon, 8 Aug 2022 08:41:57 +0200 Subject: go: update 1.18.4 -> 1.19 Rebase patches. (From OE-Core rev: 85064fd76c9f19b522f540f26e0fc68bfb0d7f43) Signed-off-by: Alexander Kanavin Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- meta/recipes-devtools/go/go-1.18.4.inc | 18 ------- meta/recipes-devtools/go/go-1.19.inc | 19 +++++++ .../recipes-devtools/go/go-binary-native_1.18.4.bb | 46 ----------------- meta/recipes-devtools/go/go-binary-native_1.19.bb | 46 +++++++++++++++++ .../go/go-cross-canadian_1.18.4.bb | 2 - meta/recipes-devtools/go/go-cross-canadian_1.19.bb | 2 + meta/recipes-devtools/go/go-cross_1.18.4.bb | 2 - meta/recipes-devtools/go/go-cross_1.19.bb | 2 + meta/recipes-devtools/go/go-crosssdk_1.18.4.bb | 2 - meta/recipes-devtools/go/go-crosssdk_1.19.bb | 2 + meta/recipes-devtools/go/go-native_1.18.4.bb | 58 ---------------------- meta/recipes-devtools/go/go-native_1.19.bb | 58 ++++++++++++++++++++++ meta/recipes-devtools/go/go-runtime_1.18.4.bb | 3 -- meta/recipes-devtools/go/go-runtime_1.19.bb | 3 ++ ...-content-based-hash-generation-less-pedan.patch | 39 ++++++++------- ...OLDIR-to-be-overridden-in-the-environment.patch | 18 ++++--- .../0004-ld-add-soname-to-shareable-objects.patch | 17 ++++--- ...verride-CC-when-building-dist-and-go_boot.patch | 12 +++-- ...-cmd-dist-separate-host-and-target-builds.patch | 41 +++++++-------- .../go/go/filter-build-paths.patch | 53 ++++++++++++-------- meta/recipes-devtools/go/go/stack-protector.patch | 32 ++++++++++++ meta/recipes-devtools/go/go_1.18.4.bb | 18 ------- meta/recipes-devtools/go/go_1.19.bb | 18 +++++++ 23 files changed, 284 insertions(+), 227 deletions(-) delete mode 100644 meta/recipes-devtools/go/go-1.18.4.inc create mode 100644 meta/recipes-devtools/go/go-1.19.inc delete mode 100644 meta/recipes-devtools/go/go-binary-native_1.18.4.bb create mode 100644 meta/recipes-devtools/go/go-binary-native_1.19.bb delete mode 100644 meta/recipes-devtools/go/go-cross-canadian_1.18.4.bb create mode 100644 meta/recipes-devtools/go/go-cross-canadian_1.19.bb delete mode 100644 meta/recipes-devtools/go/go-cross_1.18.4.bb create mode 100644 meta/recipes-devtools/go/go-cross_1.19.bb delete mode 100644 meta/recipes-devtools/go/go-crosssdk_1.18.4.bb create mode 100644 meta/recipes-devtools/go/go-crosssdk_1.19.bb delete mode 100644 meta/recipes-devtools/go/go-native_1.18.4.bb create mode 100644 meta/recipes-devtools/go/go-native_1.19.bb delete mode 100644 meta/recipes-devtools/go/go-runtime_1.18.4.bb create mode 100644 meta/recipes-devtools/go/go-runtime_1.19.bb create mode 100644 meta/recipes-devtools/go/go/stack-protector.patch delete mode 100644 meta/recipes-devtools/go/go_1.18.4.bb create mode 100644 meta/recipes-devtools/go/go_1.19.bb (limited to 'meta/recipes-devtools/go') diff --git a/meta/recipes-devtools/go/go-1.18.4.inc b/meta/recipes-devtools/go/go-1.18.4.inc deleted file mode 100644 index bfda15c54f..0000000000 --- a/meta/recipes-devtools/go/go-1.18.4.inc +++ /dev/null @@ -1,18 +0,0 @@ -require go-common.inc - -FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/go:" - -LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707" - -SRC_URI += "\ - file://0001-cmd-go-make-content-based-hash-generation-less-pedan.patch \ - file://0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch \ - file://0004-ld-add-soname-to-shareable-objects.patch \ - file://0005-make.bash-override-CC-when-building-dist-and-go_boot.patch \ - file://0006-cmd-dist-separate-host-and-target-builds.patch \ - file://0007-cmd-go-make-GOROOT-precious-by-default.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 \ - file://filter-build-paths.patch \ -" -SRC_URI[main.sha256sum] = "4525aa6b0e3cecb57845f4060a7075aafc9ab752bb7b6b4cf8a212d43078e1e4" diff --git a/meta/recipes-devtools/go/go-1.19.inc b/meta/recipes-devtools/go/go-1.19.inc new file mode 100644 index 0000000000..f733a807b4 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.19.inc @@ -0,0 +1,19 @@ +require go-common.inc + +FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/go:" + +LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707" + +SRC_URI += "\ + file://0001-cmd-go-make-content-based-hash-generation-less-pedan.patch \ + file://0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch \ + file://0004-ld-add-soname-to-shareable-objects.patch \ + file://0005-make.bash-override-CC-when-building-dist-and-go_boot.patch \ + file://0006-cmd-dist-separate-host-and-target-builds.patch \ + file://0007-cmd-go-make-GOROOT-precious-by-default.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 \ + file://filter-build-paths.patch \ + file://stack-protector.patch \ +" +SRC_URI[main.sha256sum] = "9419cc70dc5a2523f29a77053cafff658ed21ef3561d9b6b020280ebceab28b9" diff --git a/meta/recipes-devtools/go/go-binary-native_1.18.4.bb b/meta/recipes-devtools/go/go-binary-native_1.18.4.bb deleted file mode 100644 index 252c467a00..0000000000 --- a/meta/recipes-devtools/go/go-binary-native_1.18.4.bb +++ /dev/null @@ -1,46 +0,0 @@ -# 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] = "c9b099b68d93f5c5c8a8844a89f8db07eaa58270e3a1e01804f17f4cf8df02f5" -SRC_URI[go_linux_arm64.sha256sum] = "35014d92b50d97da41dade965df7ebeb9a715da600206aa59ce1b2d05527421f" - -UPSTREAM_CHECK_URI = "https://golang.org/dl/" -UPSTREAM_CHECK_REGEX = "go(?P\d+(\.\d+)+)\.linux" - -S = "${WORKDIR}/go" - -inherit goarch native - -do_compile() { - : -} - -make_wrapper() { - rm -f ${D}${bindir}/$1 - cat <${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-binary-native_1.19.bb b/meta/recipes-devtools/go/go-binary-native_1.19.bb new file mode 100644 index 0000000000..ca424a66b8 --- /dev/null +++ b/meta/recipes-devtools/go/go-binary-native_1.19.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] = "464b6b66591f6cf055bc5df90a9750bf5fbc9d038722bb84a9d56a2bea974be6" +SRC_URI[go_linux_arm64.sha256sum] = "efa97fac9574fc6ef6c9ff3e3758fb85f1439b046573bf434cccb5e012bd00c8" + +UPSTREAM_CHECK_URI = "https://golang.org/dl/" +UPSTREAM_CHECK_REGEX = "go(?P\d+(\.\d+)+)\.linux" + +S = "${WORKDIR}/go" + +inherit goarch native + +do_compile() { + : +} + +make_wrapper() { + rm -f ${D}${bindir}/$1 + cat <${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-cross-canadian_1.18.4.bb b/meta/recipes-devtools/go/go-cross-canadian_1.18.4.bb deleted file mode 100644 index 7ac9449e47..0000000000 --- a/meta/recipes-devtools/go/go-cross-canadian_1.18.4.bb +++ /dev/null @@ -1,2 +0,0 @@ -require go-cross-canadian.inc -require go-${PV}.inc diff --git a/meta/recipes-devtools/go/go-cross-canadian_1.19.bb b/meta/recipes-devtools/go/go-cross-canadian_1.19.bb new file mode 100644 index 0000000000..7ac9449e47 --- /dev/null +++ b/meta/recipes-devtools/go/go-cross-canadian_1.19.bb @@ -0,0 +1,2 @@ +require go-cross-canadian.inc +require go-${PV}.inc diff --git a/meta/recipes-devtools/go/go-cross_1.18.4.bb b/meta/recipes-devtools/go/go-cross_1.18.4.bb deleted file mode 100644 index 80b5a03f6c..0000000000 --- a/meta/recipes-devtools/go/go-cross_1.18.4.bb +++ /dev/null @@ -1,2 +0,0 @@ -require go-cross.inc -require go-${PV}.inc diff --git a/meta/recipes-devtools/go/go-cross_1.19.bb b/meta/recipes-devtools/go/go-cross_1.19.bb new file mode 100644 index 0000000000..80b5a03f6c --- /dev/null +++ b/meta/recipes-devtools/go/go-cross_1.19.bb @@ -0,0 +1,2 @@ +require go-cross.inc +require go-${PV}.inc diff --git a/meta/recipes-devtools/go/go-crosssdk_1.18.4.bb b/meta/recipes-devtools/go/go-crosssdk_1.18.4.bb deleted file mode 100644 index 1857c8a577..0000000000 --- a/meta/recipes-devtools/go/go-crosssdk_1.18.4.bb +++ /dev/null @@ -1,2 +0,0 @@ -require go-crosssdk.inc -require go-${PV}.inc diff --git a/meta/recipes-devtools/go/go-crosssdk_1.19.bb b/meta/recipes-devtools/go/go-crosssdk_1.19.bb new file mode 100644 index 0000000000..1857c8a577 --- /dev/null +++ b/meta/recipes-devtools/go/go-crosssdk_1.19.bb @@ -0,0 +1,2 @@ +require go-crosssdk.inc +require go-${PV}.inc diff --git a/meta/recipes-devtools/go/go-native_1.18.4.bb b/meta/recipes-devtools/go/go-native_1.18.4.bb deleted file mode 100644 index 76c0ab73a6..0000000000 --- a/meta/recipes-devtools/go/go-native_1.18.4.bb +++ /dev/null @@ -1,58 +0,0 @@ -# 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.sha256sum] = "f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52" - -export GOOS = "${BUILD_GOOS}" -export GOARCH = "${BUILD_GOARCH}" -CC = "${@d.getVar('BUILD_CC').strip()}" - -GOMAKEARGS ?= "--no-banner" - -do_configure() { - cd ${WORKDIR}/go1.4/go/src - CGO_ENABLED=0 GOROOT=${WORKDIR}/go1.4/go ./make.bash -} - -do_compile() { - export GOROOT_FINAL="${libdir_native}/go" - export GOROOT_BOOTSTRAP="${WORKDIR}/go1.4/go" - - cd src - ./make.bash ${GOMAKEARGS} - cd ${B} -} -do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin" - -make_wrapper() { - rm -f ${D}${bindir}/$2$3 - cat <${D}${bindir}/$2$3 -#!/bin/bash -here=\`dirname \$0\` -export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}" -\$here/../lib/go/bin/$1 "\$@" -END - chmod +x ${D}${bindir}/$2 -} - -do_install() { - install -d ${D}${libdir}/go - cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ - install -d ${D}${libdir}/go/src - (cd ${S}/src; for d in *; do \ - [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \ - done) - find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; - install -d ${D}${bindir} ${D}${libdir}/go/bin - for f in ${B}/bin/* - do - base=`basename $f` - install -m755 $f ${D}${libdir}/go/bin - make_wrapper $base $base - done -} diff --git a/meta/recipes-devtools/go/go-native_1.19.bb b/meta/recipes-devtools/go/go-native_1.19.bb new file mode 100644 index 0000000000..76c0ab73a6 --- /dev/null +++ b/meta/recipes-devtools/go/go-native_1.19.bb @@ -0,0 +1,58 @@ +# 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.sha256sum] = "f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52" + +export GOOS = "${BUILD_GOOS}" +export GOARCH = "${BUILD_GOARCH}" +CC = "${@d.getVar('BUILD_CC').strip()}" + +GOMAKEARGS ?= "--no-banner" + +do_configure() { + cd ${WORKDIR}/go1.4/go/src + CGO_ENABLED=0 GOROOT=${WORKDIR}/go1.4/go ./make.bash +} + +do_compile() { + export GOROOT_FINAL="${libdir_native}/go" + export GOROOT_BOOTSTRAP="${WORKDIR}/go1.4/go" + + cd src + ./make.bash ${GOMAKEARGS} + cd ${B} +} +do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin" + +make_wrapper() { + rm -f ${D}${bindir}/$2$3 + cat <${D}${bindir}/$2$3 +#!/bin/bash +here=\`dirname \$0\` +export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}" +\$here/../lib/go/bin/$1 "\$@" +END + chmod +x ${D}${bindir}/$2 +} + +do_install() { + install -d ${D}${libdir}/go + cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ + install -d ${D}${libdir}/go/src + (cd ${S}/src; for d in *; do \ + [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \ + done) + find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; + install -d ${D}${bindir} ${D}${libdir}/go/bin + for f in ${B}/bin/* + do + base=`basename $f` + install -m755 $f ${D}${libdir}/go/bin + make_wrapper $base $base + done +} diff --git a/meta/recipes-devtools/go/go-runtime_1.18.4.bb b/meta/recipes-devtools/go/go-runtime_1.18.4.bb deleted file mode 100644 index 63464a1501..0000000000 --- a/meta/recipes-devtools/go/go-runtime_1.18.4.bb +++ /dev/null @@ -1,3 +0,0 @@ -require go-${PV}.inc -require go-runtime.inc - diff --git a/meta/recipes-devtools/go/go-runtime_1.19.bb b/meta/recipes-devtools/go/go-runtime_1.19.bb new file mode 100644 index 0000000000..63464a1501 --- /dev/null +++ b/meta/recipes-devtools/go/go-runtime_1.19.bb @@ -0,0 +1,3 @@ +require go-${PV}.inc +require go-runtime.inc + diff --git a/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch b/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch index f9db5df4eb..8cbed93017 100644 --- a/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +++ b/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch @@ -1,4 +1,4 @@ -From 61de6067f5ad127d246543527947a357647f95e5 Mon Sep 17 00:00:00 2001 +From a3db4da51df37d163ff9e8c1e1057280c648c545 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 28 Mar 2022 10:59:03 -0700 Subject: [PATCH] cmd/go: make content-based hash generation less pedantic @@ -25,14 +25,17 @@ Upstream-Status: Inappropriate [OE specific] Signed-off-by: Alex Kube Signed-off-by: Matt Madison Signed-off-by: Khem Raj + --- src/cmd/go/internal/envcmd/env.go | 2 +- - src/cmd/go/internal/work/exec.go | 42 +++++++++++++++++++++++++------ - 2 files changed, 35 insertions(+), 9 deletions(-) + src/cmd/go/internal/work/exec.go | 42 ++++++++++++++++++++++++------- + 2 files changed, 34 insertions(+), 10 deletions(-) +diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go +index 529351d..df791b0 100644 --- a/src/cmd/go/internal/envcmd/env.go +++ b/src/cmd/go/internal/envcmd/env.go -@@ -169,7 +169,7 @@ func ExtraEnvVars() []cfg.EnvVar { +@@ -176,7 +176,7 @@ func ExtraEnvVars() []cfg.EnvVar { func ExtraEnvVarsCostly() []cfg.EnvVar { var b work.Builder b.Init() @@ -41,9 +44,11 @@ Signed-off-by: Khem Raj if err != nil { // 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 c88b315..a06455c 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go -@@ -213,6 +213,8 @@ func (b *Builder) Do(ctx context.Context +@@ -213,6 +213,8 @@ func (b *Builder) Do(ctx context.Context, root *Action) { writeActionGraph() } @@ -52,7 +57,7 @@ Signed-off-by: Khem Raj // buildActionID computes the action ID for a build action. func (b *Builder) buildActionID(a *Action) cache.ActionID { p := a.Package -@@ -234,7 +236,7 @@ func (b *Builder) buildActionID(a *Actio +@@ -234,7 +236,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { if p.Module != nil { fmt.Fprintf(h, "module %s@%s\n", p.Module.Path, p.Module.Version) } @@ -61,7 +66,7 @@ Signed-off-by: Khem Raj // The Go compiler always hides the exact value of $GOROOT // when building things in GOROOT. // -@@ -266,9 +268,9 @@ func (b *Builder) buildActionID(a *Actio +@@ -266,9 +268,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { } if len(p.CgoFiles)+len(p.SwigFiles)+len(p.SwigCXXFiles) > 0 { fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo")) @@ -73,7 +78,7 @@ Signed-off-by: Khem Raj 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. -@@ -281,14 +283,14 @@ func (b *Builder) buildActionID(a *Actio +@@ -281,14 +283,14 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { } } if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 { @@ -90,16 +95,16 @@ Signed-off-by: Khem Raj 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) -@@ -304,7 +306,7 @@ func (b *Builder) buildActionID(a *Actio - fmt.Fprintf(h, "fuzz %q\n", fuzzFlags) +@@ -305,7 +307,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { } } -- fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo) -+ //fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo) + if p.Internal.BuildInfo != "" { +- fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo) ++ //fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo) + } // Configuration specific to compiler toolchain. - switch cfg.BuildToolchainName { -@@ -2679,8 +2681,23 @@ func envList(key, def string) []string { +@@ -2705,8 +2707,23 @@ func envList(key, def string) []string { return args } @@ -124,7 +129,7 @@ Signed-off-by: Khem Raj defaults := "-g -O2" if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil { -@@ -2698,6 +2715,13 @@ func (b *Builder) CFlags(p *load.Package +@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil { return } @@ -138,7 +143,7 @@ Signed-off-by: Khem Raj return } -@@ -2713,7 +2737,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`) +@@ -2739,7 +2763,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 @@ -147,7 +152,7 @@ Signed-off-by: Khem Raj if err != nil { return nil, nil, err } -@@ -3174,7 +3198,7 @@ func (b *Builder) swigIntSize(objdir str +@@ -3246,7 +3270,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) { diff --git a/meta/recipes-devtools/go/go/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch b/meta/recipes-devtools/go/go/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch index c3ccffc3e9..30068d8e74 100644 --- a/meta/recipes-devtools/go/go/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch +++ b/meta/recipes-devtools/go/go/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch @@ -1,4 +1,4 @@ -From 8512964c0bfdfc3c9c3805743ea7de551a1d476a Mon Sep 17 00:00:00 2001 +From 7e0136a882757da0a374ab8592209586eced0e1c Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:15:37 +0430 Subject: [PATCH] cmd/go: Allow GOTOOLDIR to be overridden in the environment @@ -18,9 +18,11 @@ Signed-off-by: Alexander J Kube 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 7c44c4a..3024d0c 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go -@@ -251,7 +251,9 @@ func xinit() { +@@ -264,7 +264,9 @@ func xinit() { } xatexit(rmworkdir) @@ -31,18 +33,20 @@ Signed-off-by: Alexander J Kube } // 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 c6ddfe5..605adb1 100644 --- a/src/cmd/go/internal/cfg/cfg.go +++ b/src/cmd/go/internal/cfg/cfg.go -@@ -76,7 +76,11 @@ func defaultContext() build.Context { +@@ -162,7 +162,11 @@ func SetGOROOT(goroot string) { // variables. This matches the initialization of ToolDir in - // go/build, except for using ctxt.GOROOT rather than + // go/build, except for using BuildContext.GOROOT rather than // runtime.GOROOT. -- build.ToolDir = filepath.Join(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) +- 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(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) ++ build.ToolDir = filepath.Join(goroot, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) + } } + } - ctxt.GOPATH = envOr("GOPATH", gopath(ctxt)) diff --git a/meta/recipes-devtools/go/go/0004-ld-add-soname-to-shareable-objects.patch b/meta/recipes-devtools/go/go/0004-ld-add-soname-to-shareable-objects.patch index 058fa64225..b700634910 100644 --- a/meta/recipes-devtools/go/go/0004-ld-add-soname-to-shareable-objects.patch +++ b/meta/recipes-devtools/go/go/0004-ld-add-soname-to-shareable-objects.patch @@ -1,7 +1,7 @@ -From bf5cf5301ae5914498454c87293d1df2e1d8489f Mon Sep 17 00:00:00 2001 +From 68867eae5d3a51f32b2a2e16374323338408781e Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:16:32 +0430 -Subject: [PATCH 4/9] ld: add soname to shareable objects +Subject: [PATCH] ld: add soname to shareable objects so that OE's shared library dependency handling can find them. @@ -13,21 +13,24 @@ Matt Madison . Upstream-Status: Inappropriate [OE specific] Signed-off-by: Alexander J Kube + --- 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 18910dd..b2e1d36 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go -@@ -1347,6 +1347,7 @@ func (ctxt *Link) hostlink() { +@@ -1459,6 +1459,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 { - if *flagAslr { - argv = addASLRargs(argv) -@@ -1364,6 +1365,7 @@ func (ctxt *Link) hostlink() { + argv = addASLRargs(argv, *flagAslr) + } else { +@@ -1474,6 +1475,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") @@ -35,7 +38,7 @@ Signed-off-by: Alexander J Kube case BuildModePlugin: if ctxt.HeadType == objabi.Hdarwin { argv = append(argv, "-dynamiclib") -@@ -1372,6 +1374,7 @@ func (ctxt *Link) hostlink() { +@@ -1482,6 +1484,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") diff --git a/meta/recipes-devtools/go/go/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch b/meta/recipes-devtools/go/go/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch index a6937672f5..608f1eb5a0 100644 --- a/meta/recipes-devtools/go/go/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch +++ b/meta/recipes-devtools/go/go/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch @@ -1,4 +1,4 @@ -From 153e2dda6103fd9dd871be4bb495a8da5328301e Mon Sep 17 00:00:00 2001 +From 8f020921c464e95ded850950382115154448580a Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:17:16 +0430 Subject: [PATCH] make.bash: override CC when building dist and go_bootstrap @@ -17,18 +17,20 @@ Signed-off-by: Alexander J Kube src/make.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) +diff --git a/src/make.bash b/src/make.bash +index ab2ce19..37ec1fb 100755 --- a/src/make.bash +++ b/src/make.bash -@@ -195,7 +195,7 @@ if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; +@@ -198,7 +198,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 +-GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" GO111MODULE=off GOEXPERIMENT="" GOENV=off GOFLAGS="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist ++CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" GO111MODULE=off GOEXPERIMENT="" GOENV=off GOFLAGS="" "$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) -@@ -220,7 +220,7 @@ fi +@@ -223,7 +223,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. diff --git a/meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch index ee743ab990..2c864baa0e 100644 --- a/meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch +++ b/meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch @@ -1,4 +1,4 @@ -From 7bc891e00be4263311d75aa2b2ee6a3b7b75355f Mon Sep 17 00:00:00 2001 +From ef5fddafdec78cab9963d21736e64d71ca520bcc Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:18:12 +0430 Subject: [PATCH] cmd/dist: separate host and target builds @@ -36,12 +36,14 @@ Matt Madison . Signed-off-by: Alexander J Kube --- - src/cmd/dist/build.go | 156 ++++++++++++++++++++++++++++++------------ - 1 file changed, 113 insertions(+), 43 deletions(-) + src/cmd/dist/build.go | 154 ++++++++++++++++++++++++++++++------------ + 1 file changed, 112 insertions(+), 42 deletions(-) +diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go +index 3024d0c..45ebee0 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go -@@ -44,6 +44,7 @@ var ( +@@ -45,6 +45,7 @@ var ( goexperiment string workdir string tooldir string @@ -49,7 +51,7 @@ Signed-off-by: Alexander J Kube oldgoos string oldgoarch string exe string -@@ -54,6 +55,7 @@ var ( +@@ -55,6 +56,7 @@ var ( rebuildall bool defaultclang bool @@ -57,7 +59,7 @@ Signed-off-by: Alexander J Kube vflag int // verbosity ) -@@ -254,6 +256,8 @@ func xinit() { +@@ -267,6 +269,8 @@ func xinit() { if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) } @@ -66,7 +68,7 @@ Signed-off-by: Alexander J Kube } // compilerEnv returns a map from "goos/goarch" to the -@@ -499,8 +503,10 @@ func setup() { +@@ -468,8 +472,10 @@ func setup() { p := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch) if rebuildall { xremoveall(p) @@ -77,7 +79,7 @@ Signed-off-by: Alexander J Kube if goos != gohostos || goarch != gohostarch { p := pathf("%s/pkg/%s_%s", goroot, goos, goarch) -@@ -1252,17 +1258,35 @@ func cmdbootstrap() { +@@ -1248,17 +1254,35 @@ func cmdbootstrap() { var noBanner, noClean bool var debug bool @@ -114,7 +116,7 @@ Signed-off-by: Alexander J Kube // 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 -@@ -1330,8 +1354,13 @@ func cmdbootstrap() { +@@ -1326,8 +1350,13 @@ func cmdbootstrap() { xprintf("\n") } @@ -128,9 +130,9 @@ Signed-off-by: Alexander J Kube + goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now + } goBootstrap := pathf("%s/go_bootstrap", tooldir) - cmdGo := pathf("%s/go", gobin) + cmdGo := pathf("%s/go", gorootBin) if debug { -@@ -1360,7 +1389,11 @@ func cmdbootstrap() { +@@ -1356,7 +1385,11 @@ func cmdbootstrap() { xprintf("\n") } xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n") @@ -143,7 +145,7 @@ Signed-off-by: Alexander J Kube // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT. os.Setenv("GOEXPERIMENT", goexperiment) goInstall(goBootstrap, append([]string{"-i"}, toolchain...)...) -@@ -1399,50 +1432,84 @@ func cmdbootstrap() { +@@ -1395,50 +1428,84 @@ func cmdbootstrap() { } checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) @@ -235,7 +237,12 @@ Signed-off-by: Alexander J Kube - 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) @@ -256,16 +263,10 @@ Signed-off-by: Alexander J Kube - 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 -@@ -1459,8 +1526,11 @@ func cmdbootstrap() { +@@ -1455,8 +1522,11 @@ func cmdbootstrap() { } } diff --git a/meta/recipes-devtools/go/go/filter-build-paths.patch b/meta/recipes-devtools/go/go/filter-build-paths.patch index caf727714e..a1aa37c2a4 100644 --- a/meta/recipes-devtools/go/go/filter-build-paths.patch +++ b/meta/recipes-devtools/go/go/filter-build-paths.patch @@ -1,3 +1,8 @@ +From 3bdbce685c688a27eece36ccc8be9b50b4849498 Mon Sep 17 00:00:00 2001 +From: Richard Purdie +Date: Sat, 2 Jul 2022 23:08:13 +0100 +Subject: [PATCH] go: Filter build paths on staticly linked arches + Filter out build time paths from ldflags and other flags variables when they're embedded in the go binary so that builds are reproducible regardless of build location. This codepath is hit for statically linked go binaries such as those @@ -6,11 +11,15 @@ on mips/ppc. Upstream-Status: Pending Signed-off-by: Richard Purdie -Index: go/src/cmd/go/internal/load/pkg.go -=================================================================== ---- go.orig/src/cmd/go/internal/load/pkg.go -+++ go/src/cmd/go/internal/load/pkg.go -@@ -2225,6 +2225,17 @@ func (p *Package) collectDeps() { +--- + src/cmd/go/internal/load/pkg.go | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go +index 046f508..353cbc4 100644 +--- a/src/cmd/go/internal/load/pkg.go ++++ b/src/cmd/go/internal/load/pkg.go +@@ -2256,6 +2256,17 @@ func (p *Package) collectDeps() { // to their VCS information (vcsStatusError). var vcsStatusCache par.Cache @@ -28,21 +37,21 @@ Index: go/src/cmd/go/internal/load/pkg.go // setBuildInfo gathers build information, formats it as a string to be // embedded in the binary, then sets p.Internal.BuildInfo to that string. // setBuildInfo should only be called on a main package with no errors. -@@ -2329,7 +2340,7 @@ func (p *Package) setBuildInfo(includeVC - appendSetting("-gcflags", BuildGcflags.String()) - } - if BuildLdflags.present { -- appendSetting("-ldflags", BuildLdflags.String()) -+ appendSetting("-ldflags", filterCompilerFlags(BuildLdflags.String())) - } - if cfg.BuildMSan { - appendSetting("-msan", "true") -@@ -2347,7 +2358,7 @@ func (p *Package) setBuildInfo(includeVC - appendSetting("CGO_ENABLED", cgo) - if cfg.BuildContext.CgoEnabled { - for _, name := range []string{"CGO_CFLAGS", "CGO_CPPFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} { -- appendSetting(name, cfg.Getenv(name)) -+ appendSetting(name, filterCompilerFlags(cfg.Getenv(name))) - } +@@ -2353,7 +2364,7 @@ func (p *Package) setBuildInfo(includeVCS bool) { + if gcflags := BuildGcflags.String(); gcflags != "" && cfg.BuildContext.Compiler == "gc" { + appendSetting("-gcflags", gcflags) + } +- if ldflags := BuildLdflags.String(); ldflags != "" { ++ if ldflags := filterCompilerFlags(BuildLdflags.String()); ldflags != "" { + // https://go.dev/issue/52372: only include ldflags if -trimpath is not set, + // since it can include system paths through various linker flags (notably + // -extar, -extld, and -extldflags). +@@ -2392,7 +2403,7 @@ func (p *Package) setBuildInfo(includeVCS bool) { + // subset of flags that are known not to be paths? + if cfg.BuildContext.CgoEnabled && !cfg.BuildTrimpath { + for _, name := range []string{"CGO_CFLAGS", "CGO_CPPFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} { +- appendSetting(name, cfg.Getenv(name)) ++ appendSetting(name, filterCompilerFlags(cfg.Getenv(name))) } - appendSetting("GOARCH", cfg.BuildContext.GOARCH) + } + appendSetting("GOARCH", cfg.BuildContext.GOARCH) diff --git a/meta/recipes-devtools/go/go/stack-protector.patch b/meta/recipes-devtools/go/go/stack-protector.patch new file mode 100644 index 0000000000..cc92a444a7 --- /dev/null +++ b/meta/recipes-devtools/go/go/stack-protector.patch @@ -0,0 +1,32 @@ +From c537b87782293fe222f2ef5eb1ae818092118e97 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Sun, 07 Aug 2022 19:21:15 -0700 +Subject: [PATCH] runtime/cgo: add -fno-stack-protector to CFLAGS + +Some compilers default to having -fstack-protector on, which breaks +when using internal linking because the linker doesn't know how to +find the support functions. + +Fixes #52919 +Fixes #54313 + +Change-Id: I6f51d5e906503f61fc768ad8e30c163bad135087 +Upstream-Status: Submitted [https://github.com/golang/go/issues/54313] +Signed-off-by: Alexander Kanavin +--- + +diff --git a/src/runtime/cgo/cgo.go b/src/runtime/cgo/cgo.go +index 298aa63..4b7046e 100644 +--- a/src/runtime/cgo/cgo.go ++++ b/src/runtime/cgo/cgo.go +@@ -23,7 +23,9 @@ + #cgo solaris LDFLAGS: -lxnet + #cgo solaris LDFLAGS: -lsocket + +-#cgo CFLAGS: -Wall -Werror ++// We use -fno-stack-protector because internal linking won't find ++// the support functions. See issues #52919 and #54313. ++#cgo CFLAGS: -Wall -Werror -fno-stack-protector + + #cgo solaris CPPFLAGS: -D_POSIX_PTHREAD_SEMANTICS + diff --git a/meta/recipes-devtools/go/go_1.18.4.bb b/meta/recipes-devtools/go/go_1.18.4.bb deleted file mode 100644 index 98977673ee..0000000000 --- a/meta/recipes-devtools/go/go_1.18.4.bb +++ /dev/null @@ -1,18 +0,0 @@ -require go-${PV}.inc -require go-target.inc - -inherit linuxloader - -CGO_LDFLAGS:append:mips = " -no-pie" - -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.19.bb b/meta/recipes-devtools/go/go_1.19.bb new file mode 100644 index 0000000000..98977673ee --- /dev/null +++ b/meta/recipes-devtools/go/go_1.19.bb @@ -0,0 +1,18 @@ +require go-${PV}.inc +require go-target.inc + +inherit linuxloader + +CGO_LDFLAGS:append:mips = " -no-pie" + +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") +} + -- cgit v1.2.3-54-g00ecf