Skip to content

Commit

Permalink
backport-go: Backport GO version from 1.20.1 to 1.22.5
Browse files Browse the repository at this point in the history
This commit update the GO version to 1.22.5. This GO version
is compatible until Scarthgap Yocto Release.

The commit changes the following files:
    - compat/dunfell/backport-go/go/go-1.20.1.inc -> compat/dunfell/backport-go/go/go-1.22.5.inc
    - compat/dunfell/backport-go/go/go-binary-native_1.20.1.bb -> compat/dunfell/backport-go/go/go-binary-native_1.22.5.bb
    - compat/dunfell/backport-go/go/go-common.inc
    - compat/dunfell/backport-go/go/go-cross-canadian.inc
    - compat/dunfell/backport-go/go/go-cross-canadian_1.20.1.bb -> compat/dunfell/backport-go/go/go-cross-canadian_1.22.5.bb
    - compat/dunfell/backport-go/go/go-cross_1.20.1.bb -> compat/dunfell/backport-go/go/go-cross_1.22.5.bb
    - compat/dunfell/backport-go/go/go-crosssdk.inc
    - compat/dunfell/backport-go/go/go-crosssdk_1.20.1.bb -> compat/dunfell/backport-go/go/go-crosssdk_1.22.5.bb
    - compat/dunfell/backport-go/go/go-native_1.20.1.bb
    - compat/dunfell/backport-go/go/go-native_1.22.5.bb
    - compat/dunfell/backport-go/go/go-runtime.inc
    - compat/dunfell/backport-go/go/go-runtime_1.20.1.bb -> compat/dunfell/backport-go/go/go-runtime_1.22.5.bb
    - compat/dunfell/backport-go/go/go-target.inc
    - compat/dunfell/backport-go/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
    - compat/dunfell/backport-go/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch
    - compat/dunfell/backport-go/go/go/0003-ld-add-soname-to-shareable-objects.patch
    - compat/dunfell/backport-go/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch
    - compat/dunfell/backport-go/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
    - compat/dunfell/backport-go/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch
    - compat/dunfell/backport-go/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch
    - compat/dunfell/backport-go/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch
    - compat/dunfell/backport-go/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch
    - compat/dunfell/backport-go/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch
    - compat/dunfell/backport-go/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch
    - compat/dunfell/backport-go/go/go/CVE-2023-24532.patch
    - compat/dunfell/backport-go/go/go_1.20.1.bb -> compat/dunfell/backport-go/go/go_1.22.5.bb
    - compat/dunfell/conf/layer.conf

Signed-off-by: Rodrigo M. Duarte <rodrigo.duarte@ossystems.com.br>
  • Loading branch information
mdrodrigo committed Aug 14, 2024
1 parent 76dfc2d commit 89616d8
Show file tree
Hide file tree
Showing 27 changed files with 231 additions and 650 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ SRC_URI += "\
file://0004-make.bash-override-CC-when-building-dist-and-go_boot.patch \
file://0005-cmd-dist-separate-host-and-target-builds.patch \
file://0006-cmd-go-make-GOROOT-precious-by-default.patch \
file://0007-exec.go-do-not-write-linker-flags-into-buildids.patch \
file://0007-exec.go-filter-out-build-specific-paths-from-linker-.patch \
file://0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \
file://0009-go-Filter-build-paths-on-staticly-linked-arches.patch \
file://0010-cmd-compile-re-compile-instantiated-generic-methods-.patch \
file://CVE-2023-24532.patch \
"
SRC_URI[main.sha256sum] = "b5c1a3af52c385a6d1c76aed5361cf26459023980d0320de7658bae3915831a2"
SRC_URI[main.sha256sum] = "ac9c723f224969aee624bc34fd34c9e13f2a212d75c71c807de644bb46e112f6"
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ PROVIDES = "go-native"

# Checksums available at https://go.dev/dl/
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] = "000a5b1fca4f75895f78befeb2eecf10bfff3c428597f3f1e69133b63b911b02"
SRC_URI[go_linux_arm64.sha256sum] = "5e5e2926733595e6f3c5b5ad1089afac11c1490351855e87849d0e7702b1ec2e"
SRC_URI[go_linux_ppc64le.sha256sum] = "85cfd4b89b48c94030783b6e9e619e35557862358b846064636361421d0b0c52"
SRC_URI[go_linux_amd64.sha256sum] = "904b924d435eaea086515bc63235b192ea441bd8c9b198c507e85009e6e4c7f0"
SRC_URI[go_linux_arm64.sha256sum] = "8d21325bfcf431be3660527c1a39d3d9ad71535fabdf5041c826e44e31642b5a"
SRC_URI[go_linux_ppc64le.sha256sum] = "5312bb420ac0b59175a58927e70b4660b14ab7319aab54398b6071fabcbfbb09"

UPSTREAM_CHECK_URI = "https://golang.org/dl/"
UPSTREAM_CHECK_REGEX = "go(?P<pver>\d+(\.\d+)+)\.linux"

CVE_PRODUCT = "go"
CVE_PRODUCT = "golang:go"

S = "${WORKDIR}/go"

Expand Down
2 changes: 1 addition & 1 deletion compat/dunfell/backport-go/go/go-common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ B = "${S}"
UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)\.src\.tar"

# all recipe variants are created from the same product
CVE_PRODUCT = "go"
CVE_PRODUCT = "golang:go"

INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
SSTATE_SCAN_CMD = "true"
Expand Down
8 changes: 4 additions & 4 deletions compat/dunfell/backport-go/go/go-cross-canadian.inc
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
inherit cross-canadian

DEPENDS = "go-native virtual/${HOST_PREFIX}go-crosssdk virtual/nativesdk-${HOST_PREFIX}go-runtime \
virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-libc \
DEPENDS = "go-native virtual/${HOST_PREFIX}go virtual/nativesdk-${HOST_PREFIX}go-runtime \
virtual/${HOST_PREFIX}gcc virtual/nativesdk-libc \
virtual/nativesdk-${HOST_PREFIX}compilerlibs"
PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"

# 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} \
DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR} \
-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 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}"'
export GO_LDFLAGS = '-extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS} ${HOST_CC_ARCH} ${LDFLAGS}"'

do_configure[noexec] = "1"

Expand Down
4 changes: 2 additions & 2 deletions compat/dunfell/backport-go/go/go-crosssdk.inc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
inherit crosssdk

DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils-crosssdk"
DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils"
PN = "go-crosssdk-${SDK_SYS}"
PROVIDES = "virtual/${TARGET_PREFIX}go-crosssdk"
PROVIDES = "virtual/${TARGET_PREFIX}go"

export GOCACHE = "${B}/.cache"

Expand Down
58 changes: 0 additions & 58 deletions compat/dunfell/backport-go/go/go-native_1.20.1.bb

This file was deleted.

1 change: 1 addition & 0 deletions compat/dunfell/backport-go/go/go-native_1.22.5.bb
4 changes: 2 additions & 2 deletions compat/dunfell/backport-go/go/go-runtime.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go"
PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"

DEBUG_PREFIX_MAP = "\
Expand All @@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-pr
export GOCACHE = "${B}/.cache"

GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"'
GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'

do_configure() {
:
Expand Down
6 changes: 2 additions & 4 deletions compat/dunfell/backport-go/go/go-target.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go go-native"

DEBUG_PREFIX_MAP = "\
-fdebug-prefix-map=${STAGING_DIR_HOST}= \
Expand All @@ -13,9 +13,7 @@ export CGO_CXXFLAGS = "${CXXFLAGS}"
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"
export GO_LDFLAGS
export GO_LDFLAGS = ""
export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath"
CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 10766ca6f4007b96e3f6bf4fb496e5df74397eb9 Mon Sep 17 00:00:00 2001
From 9b3ebef0356594a447906f00fe80584952c08289 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 28 Mar 2022 10:59:03 -0700
Subject: [PATCH 1/9] cmd/go: make content-based hash generation less pedantic
Subject: [PATCH] cmd/go: make content-based hash generation less pedantic

Go 1.10's build tool now uses content-based hashes to
determine when something should be built or re-built.
Expand All @@ -25,16 +25,17 @@ Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Alex Kube <alexander.j.kube@gmail.com>
Signed-off-by: Matt Madison <matt@madison.systems>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/cmd/go/internal/envcmd/env.go | 2 +-
src/cmd/go/internal/work/exec.go | 44 ++++++++++++++++++++++++-------
2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go
index 66ef5ce..fb7448a 100644
index c7c2e83..4a90d9d 100644
--- a/src/cmd/go/internal/envcmd/env.go
+++ b/src/cmd/go/internal/envcmd/env.go
@@ -183,7 +183,7 @@ func ExtraEnvVarsCostly() []cfg.EnvVar {
@@ -189,7 +189,7 @@ func ExtraEnvVarsCostly() []cfg.EnvVar {
}
}()

Expand All @@ -44,10 +45,10 @@ index 66ef5ce..fb7448a 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 d6fa847..7e4fcb3 100644
index e05471b..9724cd0 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -223,6 +223,8 @@ func (b *Builder) Do(ctx context.Context, root *Action) {
@@ -232,6 +232,8 @@ func (b *Builder) Do(ctx context.Context, root *Action) {
writeActionGraph()
}

Expand All @@ -56,7 +57,7 @@ index d6fa847..7e4fcb3 100644
// buildActionID computes the action ID for a build action.
func (b *Builder) buildActionID(a *Action) cache.ActionID {
p := a.Package
@@ -244,7 +246,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
@@ -253,7 +255,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)
}
Expand All @@ -65,7 +66,7 @@ index d6fa847..7e4fcb3 100644
// The Go compiler always hides the exact value of $GOROOT
// when building things in GOROOT.
//
@@ -276,9 +278,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
@@ -285,9 +287,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"))
Expand All @@ -77,7 +78,7 @@ index d6fa847..7e4fcb3 100644
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.
@@ -286,14 +288,14 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
@@ -295,14 +297,14 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
fmt.Fprintf(h, "CC ID=%q\n", ccID)
}
if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
Expand All @@ -94,16 +95,16 @@ index d6fa847..7e4fcb3 100644
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)
@@ -310,7 +312,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
@@ -319,7 +321,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
}
}
if p.Internal.BuildInfo != "" {
- fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo)
+ //fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo)
if p.Internal.BuildInfo != nil {
- fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo.String())
+ //fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo.String())
}

// Configuration specific to compiler toolchain.
@@ -2970,8 +2972,25 @@ func envList(key, def string) []string {
@@ -2679,8 +2681,25 @@ func envList(key, def string) []string {
return args
}

Expand All @@ -130,7 +131,7 @@ index d6fa847..7e4fcb3 100644
if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
return
}
@@ -2987,6 +3006,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
@@ -2696,6 +2715,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
if ldflags, err = buildFlags("LDFLAGS", defaultCFlags, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
return
}
Expand All @@ -144,24 +145,21 @@ index d6fa847..7e4fcb3 100644

return
}
@@ -3002,7 +3028,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) {
@@ -2713,7 +2739,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
p := a.Package
sh := b.Shell(a)

- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p)
+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p, false)
if err != nil {
return nil, nil, err
}
@@ -3510,7 +3536,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
@@ -3268,7 +3294,7 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx
p := a.Package
sh := b.Shell(a)

// 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) {
- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p)
+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p, false)
if err != nil {
return "", "", err
}
--
2.30.2

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
From 5cca2fa5997292a87302bdc7e7ed3231371e98bd Mon Sep 17 00:00:00 2001
From 687ff9d17f756145f9a58413070cccbd488d1ea2 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 2/9] cmd/go: Allow GOTOOLDIR to be overridden in the
environment
Subject: [PATCH] cmd/go: Allow GOTOOLDIR to be overridden in the environment

to allow for split host/target build roots

Expand All @@ -13,31 +12,32 @@ Matt Madison <matt@madison.systems>.
Upstream-Status: Inappropriate [OE specific]

Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
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 c36a12e..5d31718 100644
index 32e59b4..06ee4de 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
@@ -264,7 +264,9 @@ func xinit() {
@@ -259,7 +259,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
goversion := findgoversion()
isRelease = strings.HasPrefix(goversion, "release.") || strings.HasPrefix(goversion, "go")
diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
index 3257140..bb46253 100644
index a8daa2d..393ada3 100644
--- a/src/cmd/go/internal/cfg/cfg.go
+++ b/src/cmd/go/internal/cfg/cfg.go
@@ -229,7 +229,11 @@ func SetGOROOT(goroot string, isTestGo bool) {
@@ -230,7 +230,11 @@ func SetGOROOT(goroot string, isTestGo bool) {
// This matches the initialization of ToolDir in go/build, except for
// using ctxt.GOROOT and the installed GOOS and GOARCH rather than the
// GOROOT, GOOS, and GOARCH reported by the runtime package.
Expand All @@ -50,6 +50,3 @@ index 3257140..bb46253 100644
}
}
}
--
2.30.2

Loading

0 comments on commit 89616d8

Please sign in to comment.