From 89616d81d3916825a89e5fecd3c340ca0b3768bd Mon Sep 17 00:00:00 2001 From: "Rodrigo M. Duarte" Date: Wed, 14 Aug 2024 15:49:37 -0300 Subject: [PATCH] backport-go: Backport GO version from 1.20.1 to 1.22.5 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 --- .../go/{go-1.20.1.inc => go-1.22.5.inc} | 6 +- ...e_1.20.1.bb => go-binary-native_1.22.5.bb} | 8 +- compat/dunfell/backport-go/go/go-common.inc | 2 +- .../backport-go/go/go-cross-canadian.inc | 8 +- ..._1.20.1.bb => go-cross-canadian_1.22.5.bb} | 0 ...{go-cross_1.20.1.bb => go-cross_1.22.5.bb} | 0 compat/dunfell/backport-go/go/go-crosssdk.inc | 4 +- ...osssdk_1.20.1.bb => go-crosssdk_1.22.5.bb} | 0 .../backport-go/go/go-native_1.20.1.bb | 58 ----- .../backport-go/go/go-native_1.22.5.bb | 1 + compat/dunfell/backport-go/go/go-runtime.inc | 4 +- ...runtime_1.20.1.bb => go-runtime_1.22.5.bb} | 0 compat/dunfell/backport-go/go/go-target.inc | 6 +- ...ent-based-hash-generation-less-pedan.patch | 46 ++-- ...OOLDIR-to-be-overridden-in-the-envir.patch | 21 +- ...3-ld-add-soname-to-shareable-objects.patch | 16 +- ...de-CC-when-building-dist-and-go_boot.patch | 19 +- ...dist-separate-host-and-target-builds.patch | 202 ++++++----------- ...d-go-make-GOROOT-precious-by-default.patch | 34 ++- ...not-write-linker-flags-into-buildids.patch | 41 ---- ...ut-build-specific-paths-from-linker-.patch | 59 +++++ ...ldgo.go-do-not-hardcode-host-compile.patch | 17 +- ...uild-paths-on-staticly-linked-arches.patch | 26 +-- ...ompile-instantiated-generic-methods-.patch | 90 -------- .../backport-go/go/go/CVE-2023-24532.patch | 208 ------------------ .../go/{go_1.20.1.bb => go_1.22.5.bb} | 2 +- compat/dunfell/conf/layer.conf | 3 +- 27 files changed, 231 insertions(+), 650 deletions(-) rename compat/dunfell/backport-go/go/{go-1.20.1.inc => go-1.22.5.inc} (72%) rename compat/dunfell/backport-go/go/{go-binary-native_1.20.1.bb => go-binary-native_1.22.5.bb} (76%) rename compat/dunfell/backport-go/go/{go-cross-canadian_1.20.1.bb => go-cross-canadian_1.22.5.bb} (100%) rename compat/dunfell/backport-go/go/{go-cross_1.20.1.bb => go-cross_1.22.5.bb} (100%) rename compat/dunfell/backport-go/go/{go-crosssdk_1.20.1.bb => go-crosssdk_1.22.5.bb} (100%) delete mode 100644 compat/dunfell/backport-go/go/go-native_1.20.1.bb create mode 120000 compat/dunfell/backport-go/go/go-native_1.22.5.bb rename compat/dunfell/backport-go/go/{go-runtime_1.20.1.bb => go-runtime_1.22.5.bb} (100%) delete mode 100644 compat/dunfell/backport-go/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch create mode 100644 compat/dunfell/backport-go/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch delete mode 100644 compat/dunfell/backport-go/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch delete mode 100644 compat/dunfell/backport-go/go/go/CVE-2023-24532.patch rename compat/dunfell/backport-go/go/{go_1.20.1.bb => go_1.22.5.bb} (92%) diff --git a/compat/dunfell/backport-go/go/go-1.20.1.inc b/compat/dunfell/backport-go/go/go-1.22.5.inc similarity index 72% rename from compat/dunfell/backport-go/go/go-1.20.1.inc rename to compat/dunfell/backport-go/go/go-1.22.5.inc index b1f5692..7f7d837 100644 --- a/compat/dunfell/backport-go/go/go-1.20.1.inc +++ b/compat/dunfell/backport-go/go/go-1.22.5.inc @@ -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" diff --git a/compat/dunfell/backport-go/go/go-binary-native_1.20.1.bb b/compat/dunfell/backport-go/go/go-binary-native_1.22.5.bb similarity index 76% rename from compat/dunfell/backport-go/go/go-binary-native_1.20.1.bb rename to compat/dunfell/backport-go/go/go-binary-native_1.22.5.bb index 2393345..b00857f 100644 --- a/compat/dunfell/backport-go/go/go-binary-native_1.20.1.bb +++ b/compat/dunfell/backport-go/go/go-binary-native_1.22.5.bb @@ -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\d+(\.\d+)+)\.linux" -CVE_PRODUCT = "go" +CVE_PRODUCT = "golang:go" S = "${WORKDIR}/go" diff --git a/compat/dunfell/backport-go/go/go-common.inc b/compat/dunfell/backport-go/go/go-common.inc index 96e32ee..db16579 100644 --- a/compat/dunfell/backport-go/go/go-common.inc +++ b/compat/dunfell/backport-go/go/go-common.inc @@ -20,7 +20,7 @@ B = "${S}" UPSTREAM_CHECK_REGEX = "(?P\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" diff --git a/compat/dunfell/backport-go/go/go-cross-canadian.inc b/compat/dunfell/backport-go/go/go-cross-canadian.inc index 5a80cef..dd485b6 100644 --- a/compat/dunfell/backport-go/go/go-cross-canadian.inc +++ b/compat/dunfell/backport-go/go/go-cross-canadian.inc @@ -1,14 +1,14 @@ 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}= \ " @@ -16,7 +16,7 @@ DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDP 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" diff --git a/compat/dunfell/backport-go/go/go-cross-canadian_1.20.1.bb b/compat/dunfell/backport-go/go/go-cross-canadian_1.22.5.bb similarity index 100% rename from compat/dunfell/backport-go/go/go-cross-canadian_1.20.1.bb rename to compat/dunfell/backport-go/go/go-cross-canadian_1.22.5.bb diff --git a/compat/dunfell/backport-go/go/go-cross_1.20.1.bb b/compat/dunfell/backport-go/go/go-cross_1.22.5.bb similarity index 100% rename from compat/dunfell/backport-go/go/go-cross_1.20.1.bb rename to compat/dunfell/backport-go/go/go-cross_1.22.5.bb diff --git a/compat/dunfell/backport-go/go/go-crosssdk.inc b/compat/dunfell/backport-go/go/go-crosssdk.inc index 7669386..1293900 100644 --- a/compat/dunfell/backport-go/go/go-crosssdk.inc +++ b/compat/dunfell/backport-go/go/go-crosssdk.inc @@ -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" diff --git a/compat/dunfell/backport-go/go/go-crosssdk_1.20.1.bb b/compat/dunfell/backport-go/go/go-crosssdk_1.22.5.bb similarity index 100% rename from compat/dunfell/backport-go/go/go-crosssdk_1.20.1.bb rename to compat/dunfell/backport-go/go/go-crosssdk_1.22.5.bb diff --git a/compat/dunfell/backport-go/go/go-native_1.20.1.bb b/compat/dunfell/backport-go/go/go-native_1.20.1.bb deleted file mode 100644 index ddf25b2..0000000 --- a/compat/dunfell/backport-go/go/go-native_1.20.1.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 += "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/compat/dunfell/backport-go/go/go-native_1.22.5.bb b/compat/dunfell/backport-go/go/go-native_1.22.5.bb new file mode 120000 index 0000000..e14a0d9 --- /dev/null +++ b/compat/dunfell/backport-go/go/go-native_1.22.5.bb @@ -0,0 +1 @@ +go-binary-native_1.22.5.bb \ No newline at end of file diff --git a/compat/dunfell/backport-go/go/go-runtime.inc b/compat/dunfell/backport-go/go/go-runtime.inc index 02601f7..413cf6d 100644 --- a/compat/dunfell/backport-go/go/go-runtime.inc +++ b/compat/dunfell/backport-go/go/go-runtime.inc @@ -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 = "\ @@ -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() { : diff --git a/compat/dunfell/backport-go/go/go-runtime_1.20.1.bb b/compat/dunfell/backport-go/go/go-runtime_1.22.5.bb similarity index 100% rename from compat/dunfell/backport-go/go/go-runtime_1.20.1.bb rename to compat/dunfell/backport-go/go/go-runtime_1.22.5.bb diff --git a/compat/dunfell/backport-go/go/go-target.inc b/compat/dunfell/backport-go/go/go-target.inc index ed09cfe..981c7ab 100644 --- a/compat/dunfell/backport-go/go/go-target.inc +++ b/compat/dunfell/backport-go/go/go-target.inc @@ -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}= \ @@ -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}" diff --git a/compat/dunfell/backport-go/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch b/compat/dunfell/backport-go/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch index 56487e3..a8e5d6e 100644 --- a/compat/dunfell/backport-go/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +++ b/compat/dunfell/backport-go/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch @@ -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 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. @@ -25,16 +25,17 @@ Upstream-Status: Inappropriate [OE specific] Signed-off-by: Alex Kube Signed-off-by: Matt Madison Signed-off-by: Khem Raj +Signed-off-by: Jose Quaresma --- 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 { } }() @@ -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() } @@ -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) } @@ -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")) @@ -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 { @@ -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 } @@ -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 } @@ -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 - diff --git a/compat/dunfell/backport-go/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch b/compat/dunfell/backport-go/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch index 6abd424..a69ada4 100644 --- a/compat/dunfell/backport-go/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch +++ b/compat/dunfell/backport-go/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch @@ -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 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 @@ -13,16 +12,17 @@ Matt Madison . Upstream-Status: Inappropriate [OE specific] Signed-off-by: Alexander J Kube +Signed-off-by: Jose Quaresma --- 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) @@ -30,14 +30,14 @@ index c36a12e..5d31718 100644 + 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. @@ -50,6 +50,3 @@ index 3257140..bb46253 100644 } } } --- -2.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0003-ld-add-soname-to-shareable-objects.patch b/compat/dunfell/backport-go/go/go/0003-ld-add-soname-to-shareable-objects.patch index 2bc7d19..abc5faa 100644 --- a/compat/dunfell/backport-go/go/go/0003-ld-add-soname-to-shareable-objects.patch +++ b/compat/dunfell/backport-go/go/go/0003-ld-add-soname-to-shareable-objects.patch @@ -1,7 +1,7 @@ -From c7536a820f713013ab1d4acef74a4c8bd970bf8f Mon Sep 17 00:00:00 2001 +From 01fe178b292db12d811811ff2d8d56b225e4b5e8 Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:16:32 +0430 -Subject: [PATCH 3/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,15 +13,16 @@ Matt Madison . Upstream-Status: Inappropriate [OE specific] Signed-off-by: Alexander J Kube +Signed-off-by: Jose Quaresma --- 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 c073017..e60d39a 100644 +index eab74dc..ae9bbc9 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go -@@ -1491,6 +1491,7 @@ func (ctxt *Link) hostlink() { +@@ -1576,6 +1576,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") @@ -29,7 +30,7 @@ index c073017..e60d39a 100644 if ctxt.HeadType == objabi.Hwindows { argv = addASLRargs(argv, *flagAslr) } else { -@@ -1506,6 +1507,7 @@ func (ctxt *Link) hostlink() { +@@ -1591,6 +1592,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") @@ -37,7 +38,7 @@ index c073017..e60d39a 100644 case BuildModePlugin: if ctxt.HeadType == objabi.Hdarwin { argv = append(argv, "-dynamiclib") -@@ -1514,6 +1516,7 @@ func (ctxt *Link) hostlink() { +@@ -1599,6 +1601,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-z,relro") } argv = append(argv, "-shared") @@ -45,6 +46,3 @@ index c073017..e60d39a 100644 } } --- -2.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch b/compat/dunfell/backport-go/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch index 85e42f7..9df43c4 100644 --- a/compat/dunfell/backport-go/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch +++ b/compat/dunfell/backport-go/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch @@ -1,8 +1,7 @@ -From 31ff609cc3d3bfcc2f2257fda1dbaafaec31eb0b Mon Sep 17 00:00:00 2001 +From e47d157631d1b97403f253c63d361b7380b32c22 Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:17:16 +0430 -Subject: [PATCH 4/9] make.bash: override CC when building dist and - go_bootstrap +Subject: [PATCH] make.bash: override CC when building dist and go_bootstrap for handling OE cross-canadian builds. @@ -13,24 +12,25 @@ Matt Madison . Upstream-Status: Inappropriate [OE specific] Signed-off-by: Alexander J Kube +Signed-off-by: Jose Quaresma --- src/make.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/make.bash b/src/make.bash -index c07f39b..6ca7242 100755 +index 76ad516..074e129 100755 --- a/src/make.bash +++ b/src/make.bash -@@ -194,7 +194,7 @@ if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; then +@@ -198,7 +198,7 @@ if [[ "$GOROOT_BOOTSTRAP" == "$GOROOT" ]]; then exit 1 fi rm -f cmd/dist/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 +-GOROOT="$GOROOT_BOOTSTRAP" nogoenv "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist ++CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" nogoenv "$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) -@@ -219,7 +219,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 the bootstrap toolchain, away after bootstrap. @@ -39,6 +39,3 @@ index c07f39b..6ca7242 100755 rm -f ./cmd/dist/dist # DO NOT ADD ANY NEW CODE HERE. --- -2.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0005-cmd-dist-separate-host-and-target-builds.patch b/compat/dunfell/backport-go/go/go/0005-cmd-dist-separate-host-and-target-builds.patch index 2959844..bc25d08 100644 --- a/compat/dunfell/backport-go/go/go/0005-cmd-dist-separate-host-and-target-builds.patch +++ b/compat/dunfell/backport-go/go/go/0005-cmd-dist-separate-host-and-target-builds.patch @@ -1,9 +1,7 @@ -From 7a191e5191c8b813e929caedb3f3918bb08692a1 Mon Sep 17 00:00:00 2001 +From bae1cec790ff17c4c93a2f8fda27036e5e021f6d Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:18:12 +0430 -Subject: [PATCH 5/9] cmd/dist: separate host and target builds - -Upstream-Status: Inappropriate [OE specific] +Subject: [PATCH] cmd/dist: separate host and target builds Change the dist tool to allow for OE-style cross- and cross-canadian builds: @@ -33,41 +31,49 @@ Adapted to Go 1.13 from patches originally submitted to the meta/recipes-devtools/go tree by Matt Madison . +Rework the patch to avoid identation, it breaks formatting rules but +makes the changes more obvious and maintainable. +Jose Quaresma +Richard Purdie + +Upstream-Status: Inappropriate [OE specific] + Signed-off-by: Alexander J Kube +Signed-off-by: Jose Quaresma --- - src/cmd/dist/build.go | 152 +++++++++++++++++++++++++++++++----------- - 1 file changed, 113 insertions(+), 39 deletions(-) + src/cmd/dist/build.go | 76 ++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go -index 5d31718..1c7f308 100644 +index 06ee4de..016b1dd 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go -@@ -44,6 +44,7 @@ var ( +@@ -46,6 +46,7 @@ var ( goexperiment string workdir string tooldir string + build_tooldir string oldgoos string oldgoarch string - exe string -@@ -55,6 +56,7 @@ var ( - rebuildall bool - defaultclang bool - noOpt bool -+ crossBuild bool + oldgocache string +@@ -58,6 +59,7 @@ var ( + rebuildall bool + noOpt bool + isRelease bool ++ crossBuild bool vflag int // verbosity ) -@@ -267,6 +269,8 @@ func xinit() { - if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { - tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) - } +@@ -265,6 +267,8 @@ func xinit() { + + goversion := findgoversion() + isRelease = strings.HasPrefix(goversion, "release.") || strings.HasPrefix(goversion, "go") + + build_tooldir = pathf("%s/pkg/tool/native_native", goroot) } // compilerEnv returns a map from "goos/goarch" to the -@@ -468,8 +472,10 @@ func setup() { +@@ -499,8 +503,10 @@ func setup() { goosGoarch := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch) if rebuildall { xremoveall(goosGoarch) @@ -78,16 +84,18 @@ index 5d31718..1c7f308 100644 xatexit(func() { if files := xreaddir(goosGoarch); len(files) == 0 { xremove(goosGoarch) -@@ -1276,17 +1282,35 @@ func cmdbootstrap() { +@@ -1338,14 +1344,20 @@ func cmdbootstrap() { + defer timelog("end", "dist bootstrap") - var noBanner, noClean bool - var debug bool + var debug, distpack, force, noBanner, noClean bool + var hostOnly bool + var targetOnly bool + var toBuild = []string{"std", "cmd"} + flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all") flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process") + flag.BoolVar(&distpack, "distpack", distpack, "write distribution files to pkg/distpack") + flag.BoolVar(&force, "force", force, "build even if the port is marked as broken") 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") @@ -98,6 +106,8 @@ index 5d31718..1c7f308 100644 if noClean { xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n") +@@ -1357,6 +1369,18 @@ func cmdbootstrap() { + "Use the -force flag to build anyway.\n", goos, goarch) } + if hostOnly && targetOnly { @@ -115,47 +125,46 @@ index 5d31718..1c7f308 100644 // 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 -@@ -1354,9 +1378,14 @@ func cmdbootstrap() { +@@ -1434,9 +1458,14 @@ func cmdbootstrap() { xprintf("\n") } -- gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now -- setNoOpt() -- 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 { -+ gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now -+ setNoOpt() -+ goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now -+ } ++if !crossBuild { + gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now + setNoOpt() + goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now ++} goBootstrap := pathf("%s/go_bootstrap", tooldir) - cmdGo := pathf("%s/go", gorootBin) if debug { -@@ -1385,7 +1414,11 @@ func cmdbootstrap() { + run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") +@@ -1464,7 +1493,11 @@ func cmdbootstrap() { xprintf("\n") } xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n") -- os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) -+ if crossBuild { ++if !crossBuild { + os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch)) ++} else { + os.Setenv("CC", defaultcc[""]) -+ } 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, toolchain...) -@@ -1421,46 +1454,84 @@ func cmdbootstrap() { - copyfile(pathf("%s/compile3", tooldir), pathf("%s/compile", tooldir), writeExec) + // No need to enable PGO for toolchain2. +@@ -1517,6 +1550,7 @@ func cmdbootstrap() { + os.Setenv("GOCACHE", oldgocache) } -- if goos == oldgoos && goarch == oldgoarch { -- // Common case - not setting up for cross-compilation. -- timelog("build", "toolchain") -- if vflag > 0 { -- xprintf("\n") -+ if crossBuild { ++if !crossBuild { + if goos == oldgoos && goarch == oldgoarch { + // Common case - not setting up for cross-compilation. + timelog("build", "toolchain") +@@ -1560,6 +1594,42 @@ func cmdbootstrap() { + checkNotStale(toolenv(), goBootstrap, toolchain...) + copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) + } ++} else { + gogcflags = os.Getenv("GO_GCFLAGS") + goldflags = os.Getenv("GO_LDFLAGS") + tool_files, _ := filepath.Glob(pathf("%s/*", tooldir)) @@ -171,8 +180,8 @@ index 5d31718..1c7f308 100644 + xprintf("\n") + } + xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) -+ goInstall(goBootstrap, toBuild...) -+ checkNotStale(goBootstrap, toBuild...) ++ goInstall(toolenv(), goBootstrap, toBuild...) ++ checkNotStale(toolenv(), goBootstrap, toBuild...) + // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary + + timelog("build", "target toolchain") @@ -184,99 +193,26 @@ index 5d31718..1c7f308 100644 + goarch = oldgoarch + os.Setenv("GOOS", goos) + os.Setenv("GOARCH", goarch) -+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) ++ os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch)) + xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) -+ goInstall(goBootstrap, toBuild...) -+ checkNotStale(goBootstrap, toBuild...) ++ goInstall(toolenv(), goBootstrap, toBuild...) ++ checkNotStale(toolenv(), goBootstrap, toBuild...) + // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary - } -- xprintf("Building packages and commands for %s/%s.\n", goos, goarch) - } else { -- // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH. -- // Finish GOHOSTOS/GOHOSTARCH installation and then -- // run GOOS/GOARCH installation. -- timelog("build", "host toolchain") -- if vflag > 0 { -- xprintf("\n") -+ -+ if goos == oldgoos && goarch == oldgoarch { -+ // Common case - not setting up for cross-compilation. -+ timelog("build", "toolchain") -+ if vflag > 0 { -+ xprintf("\n") -+ } -+ xprintf("Building packages and commands for %s/%s.\n", goos, goarch) -+ } else { -+ // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH. -+ // Finish GOHOSTOS/GOHOSTARCH installation and then -+ // run GOOS/GOARCH installation. -+ timelog("build", "host toolchain") -+ if vflag > 0 { -+ xprintf("\n") -+ } -+ xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch) -+ goInstall(goBootstrap, "std", "cmd") -+ checkNotStale(goBootstrap, "std", "cmd") -+ checkNotStale(cmdGo, "std", "cmd") -+ -+ timelog("build", "target toolchain") -+ if vflag > 0 { -+ xprintf("\n") -+ } -+ goos = oldgoos -+ goarch = oldgoarch -+ os.Setenv("GOOS", goos) -+ 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") - -- 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) -- os.Setenv("GOARCH", goarch) -- os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch)) -- xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch) -- } -- targets := []string{"std", "cmd"} -- goInstall(goBootstrap, targets...) -- checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...) -- checkNotStale(goBootstrap, targets...) -- checkNotStale(cmdGo, targets...) -- if debug { -- run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") -- 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 -@@ -1477,8 +1548,11 @@ func cmdbootstrap() { + // go and gofmt and $GOOS_$GOARCH (target bin when cross-compiling). +@@ -1582,8 +1652,12 @@ func cmdbootstrap() { } } -- // 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 { -+ xremove(pathf("%s/go_bootstrap", tooldir)) -+ } ++if !crossBuild { + // Remove go_bootstrap now that we're done. + xremove(pathf("%s/go_bootstrap"+exe, tooldir)) ++} if goos == "android" { // Make sure the exec wrapper will sync a fresh $GOROOT to the device. --- -2.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch b/compat/dunfell/backport-go/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch index 38b28b9..4a57b07 100644 --- a/compat/dunfell/backport-go/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch +++ b/compat/dunfell/backport-go/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch @@ -1,9 +1,7 @@ -From efab470498bb0a30ee2d00455a0c8c10459f6347 Mon Sep 17 00:00:00 2001 +From a31db6f78d851741aea1e76132a84a24138a5bc6 Mon Sep 17 00:00:00 2001 From: Alex Kube Date: Wed, 23 Oct 2019 21:18:56 +0430 -Subject: [PATCH 6/9] cmd/go: make GOROOT precious by default - -Upstream-Status: Inappropriate [OE specific] +Subject: [PATCH] cmd/go: make GOROOT precious by default The go build tool normally rebuilds whatever it detects is stale. This can be a problem when GOROOT is intended to @@ -20,7 +18,10 @@ Adapted to Go 1.13 from patches originally submitted to the meta/recipes-devtools/go tree by Matt Madison . +Upstream-Status: Inappropriate [OE specific] + Signed-off-by: Alexander J Kube +Signed-off-by: Jose Quaresma --- src/cmd/go/internal/work/action.go | 3 +++ src/cmd/go/internal/work/build.go | 6 ++++++ @@ -28,10 +29,10 @@ Signed-off-by: Alexander J Kube 3 files changed, 34 insertions(+) diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go -index 8beb134..68a8cfe 100644 +index a59072e..9e35ebd 100644 --- a/src/cmd/go/internal/work/action.go +++ b/src/cmd/go/internal/work/action.go -@@ -718,6 +718,9 @@ func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) { +@@ -754,6 +754,9 @@ func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) { if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] { continue } @@ -42,10 +43,10 @@ index 8beb134..68a8cfe 100644 // 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 diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go -index 2f2860a..8cc6166 100644 +index 408edb5..3d60252 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go -@@ -217,6 +217,8 @@ See also: go install, go get, go clean. +@@ -233,6 +233,8 @@ See also: go install, go get, go clean. const concurrentGCBackendCompilationEnabledByDefault = true @@ -54,7 +55,7 @@ index 2f2860a..8cc6166 100644 func init() { // break init cycle CmdBuild.Run = runBuild -@@ -230,6 +232,10 @@ func init() { +@@ -246,6 +248,10 @@ func init() { AddCoverFlags(CmdBuild, nil) AddCoverFlags(CmdInstall, nil) } @@ -66,11 +67,11 @@ index 2f2860a..8cc6166 100644 // Note that flags consulted by other parts of the code diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go -index 7e4fcb3..d83b31b 100644 +index 9724cd0..544df46 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go -@@ -527,6 +527,23 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) { - return errors.New("binary-only packages are no longer supported") +@@ -544,6 +544,23 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) { + return err } + if goRootPrecious && (a.Package.Standard || a.Package.Goroot) { @@ -90,10 +91,10 @@ index 7e4fcb3..d83b31b 100644 + } + } + - if err := b.Mkdir(a.Objdir); err != nil { + if err := sh.Mkdir(a.Objdir); err != nil { return err } -@@ -1624,6 +1641,14 @@ func (b *Builder) linkShared(ctx context.Context, a *Action) (err error) { +@@ -1737,6 +1754,14 @@ func (b *Builder) linkShared(ctx context.Context, a *Action) (err error) { return err } @@ -105,9 +106,6 @@ index 7e4fcb3..d83b31b 100644 + } + } + - if err := b.Mkdir(a.Objdir); err != nil { + if err := b.Shell(a).Mkdir(a.Objdir); err != nil { return err } --- -2.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch b/compat/dunfell/backport-go/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch deleted file mode 100644 index a821cf0..0000000 --- a/compat/dunfell/backport-go/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0ba747e6a4b251a0d9eed0cfd8f8c491bb508040 Mon Sep 17 00:00:00 2001 -From: Alexander Kanavin -Date: Mon, 23 Nov 2020 19:22:04 +0000 -Subject: [PATCH 7/9] 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 ---- - 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 d83b31b..a646fbb 100644 ---- a/src/cmd/go/internal/work/exec.go -+++ b/src/cmd/go/internal/work/exec.go -@@ -1312,7 +1312,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 { -@@ -1607,7 +1607,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.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch b/compat/dunfell/backport-go/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch new file mode 100644 index 0000000..2fdd529 --- /dev/null +++ b/compat/dunfell/backport-go/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch @@ -0,0 +1,59 @@ +From 1097a07b097043e15fe29a85326dbd196401244a Mon Sep 17 00:00:00 2001 +From: Changqing Li +Date: Tue, 27 Feb 2024 18:06:51 +0800 +Subject: [PATCH] exec.go: filter out build-specific paths from linker flags + +The flags can contain build-specific paths, breaking reproducibility. +Filter out options that have build-specific paths. + +Upstream-Status: Inappropriate [ Not perfect for upstream ] + +Signed-off-by: Changqing Li +Signed-off-by: Jose Quaresma +--- + src/cmd/go/internal/work/exec.go | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go +index 544df46..c8f297c 100644 +--- a/src/cmd/go/internal/work/exec.go ++++ b/src/cmd/go/internal/work/exec.go +@@ -1401,6 +1401,29 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID { + return h.Sum() + } + ++func filterLinkerFlags(flags []string) []string { ++ var newflags []string ++ var skipflag bool ++ skipflag = false ++ for i, flag := range flags { ++ if skipflag == true { ++ skipflag = false ++ continue ++ } ++ if strings.HasPrefix(flag, "--sysroot") || strings.HasPrefix(flag, "-fmacro-prefix-map") || strings.HasPrefix(flag, "-fdebug-prefix-map") || strings.HasPrefix(flag, "-ffile-prefix-map") || strings.HasPrefix(flag, "-fcanon-prefix-map") || strings.HasPrefix(flag, "-fprofile-prefix-map") || strings.HasPrefix(flag, "-Wl,-rpath-link"){ ++ continue ++ } else if strings.HasPrefix(flag, "-extldflags") { ++ skipflag = true ++ newflags = append(newflags, flag) ++ var filterd_Extldflags []string = filterLinkerFlags(strings.Split(flags[i+1], " ")) ++ newflags = append(newflags, strings.Join(filterd_Extldflags, " ")) ++ } else { ++ newflags = append(newflags, flag) ++ } ++ } ++ return newflags ++} ++ + // printLinkerConfig prints the linker config into the hash h, + // as part of the computation of a linker-related action ID. + func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { +@@ -1411,7 +1434,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { + case "gc": + fmt.Fprintf(h, "link %s %q %s\n", b.toolID("link"), forcedLdflags, ldBuildmode) + if p != nil { +- fmt.Fprintf(h, "linkflags %q\n", p.Internal.Ldflags) ++ fmt.Fprintf(h, "linkflags %q\n", filterLinkerFlags(p.Internal.Ldflags)) + } + + // GOARM, GOMIPS, etc. diff --git a/compat/dunfell/backport-go/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch b/compat/dunfell/backport-go/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch index fe830ce..4c1f0ca 100644 --- a/compat/dunfell/backport-go/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch +++ b/compat/dunfell/backport-go/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch @@ -1,23 +1,25 @@ -From 1cbb416538a9c7c3fbedcb23f4d90d5c48becca8 Mon Sep 17 00:00:00 2001 +From e5af6155f2d6e0758d11d6c12d6f47ea8e65b141 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Tue, 10 Nov 2020 16:33:27 +0000 -Subject: [PATCH 8/9] src/cmd/dist/buildgo.go: do not hardcode host compilers - into target binaries +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 +Signed-off-by: Jose Quaresma --- 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 29b0167..63a49f0 100644 +index 884e9d7..2f52eda 100644 --- a/src/cmd/dist/buildgo.go +++ b/src/cmd/dist/buildgo.go -@@ -33,8 +33,8 @@ func mkzdefaultcc(dir, file string) { +@@ -51,8 +51,8 @@ func mkzdefaultcc(dir, file string) { fmt.Fprintf(&buf, "package cfg\n") fmt.Fprintln(&buf) fmt.Fprintf(&buf, "const DefaultPkgConfig = `%s`\n", defaultpkgconfig) @@ -28,7 +30,7 @@ index 29b0167..63a49f0 100644 writefile(buf.String(), file, writeSkipSame) return } -@@ -45,8 +45,8 @@ func mkzdefaultcc(dir, file string) { +@@ -62,8 +62,8 @@ func mkzdefaultcc(dir, file string) { fmt.Fprintf(&buf, "package main\n") fmt.Fprintln(&buf) fmt.Fprintf(&buf, "const defaultPkgConfig = `%s`\n", defaultpkgconfig) @@ -39,6 +41,3 @@ index 29b0167..63a49f0 100644 writefile(buf.String(), file, writeSkipSame) } --- -2.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch b/compat/dunfell/backport-go/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch index 705c922..d939cb4 100644 --- a/compat/dunfell/backport-go/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch +++ b/compat/dunfell/backport-go/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch @@ -1,7 +1,7 @@ -From 18011f72125bbea273d07ee5d792ac0ce6059572 Mon Sep 17 00:00:00 2001 +From 6bdd6405ce63c7aa4b35cd85833d03c7f1b9109a Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 2 Jul 2022 23:08:13 +0100 -Subject: [PATCH 9/9] go: Filter build paths on staticly linked arches +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 @@ -11,17 +11,18 @@ on mips/ppc. Upstream-Status: Submitted [https://github.com/golang/go/pull/56410] Signed-off-by: Richard Purdie +Signed-off-by: Jose Quaresma --- 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 56a4e5e..22edbdb 100644 +index 1549800..f41fb2c 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go -@@ -2266,6 +2266,17 @@ func (p *Package) collectDeps() { - // to their VCS information (vcsStatusError). - var vcsStatusCache par.Cache +@@ -2277,6 +2277,17 @@ func appendBuildSetting(info *debug.BuildInfo, key, value string) { + info.Settings = append(info.Settings, debug.BuildSetting{Key: key, Value: value}) + } +func filterCompilerFlags(flags string) string { + var newflags []string @@ -34,10 +35,10 @@ index 56a4e5e..22edbdb 100644 + return strings.Join(newflags, " ") +} + - // 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. -@@ -2372,7 +2383,7 @@ func (p *Package) setBuildInfo(autoVCS bool) { + // setBuildInfo gathers build information and sets it into + // p.Internal.BuildInfo, which will later be formatted as a string and embedded + // in the binary. setBuildInfo should only be called on a main package with no +@@ -2384,7 +2395,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) { if gcflags := BuildGcflags.String(); gcflags != "" && cfg.BuildContext.Compiler == "gc" { appendSetting("-gcflags", gcflags) } @@ -46,7 +47,7 @@ index 56a4e5e..22edbdb 100644 // 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). -@@ -2418,7 +2429,7 @@ func (p *Package) setBuildInfo(autoVCS bool) { +@@ -2427,7 +2438,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS 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"} { @@ -55,6 +56,3 @@ index 56a4e5e..22edbdb 100644 } } appendSetting("GOARCH", cfg.BuildContext.GOARCH) --- -2.30.2 - diff --git a/compat/dunfell/backport-go/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch b/compat/dunfell/backport-go/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch deleted file mode 100644 index f9ac202..0000000 --- a/compat/dunfell/backport-go/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 7a3bb16b43efba73674629eae4369f9004e37f22 Mon Sep 17 00:00:00 2001 -From: Cuong Manh Le -Date: Sat, 18 Mar 2023 00:53:07 +0700 -Subject: [PATCH] cmd/compile: re-compile instantiated generic methods in - linkshared mode - -For G[T] that was seen and compiled in imported package, it is not added -to typecheck.Target.Decls, prevent wasting compile time re-creating -DUPOKS symbols. However, the linker do not support a type symbol -referencing a method symbol across DSO boundary. That causes unreachable -sym error when building under -linkshared mode. - -To fix it, always re-compile generic methods in linkshared mode. - -Fixes #58966 - -Change-Id: I894b417cfe8234ae1fe809cc975889345df22cef -Reviewed-on: https://go-review.googlesource.com/c/go/+/477375 -Run-TryBot: Cuong Manh Le -Reviewed-by: Cherry Mui -Reviewed-by: Matthew Dempsky -TryBot-Result: Gopher Robot - -Upstream-Status: Backport [https://github.com/golang/go/commit/bcd82125f85c7c552493e863fa1bb14e6c444557] - -Signed-off-by: Jose Quaresma ---- - misc/cgo/testshared/shared_test.go | 7 ++++++- - misc/cgo/testshared/testdata/issue58966/main.go | 15 +++++++++++++++ - src/cmd/compile/internal/noder/unified.go | 6 +++++- - 3 files changed, 26 insertions(+), 2 deletions(-) - create mode 100644 misc/cgo/testshared/testdata/issue58966/main.go - -diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go -index b14fb1cb3a..03da8f9435 100644 ---- a/misc/cgo/testshared/shared_test.go -+++ b/misc/cgo/testshared/shared_test.go -@@ -1112,8 +1112,13 @@ func TestStd(t *testing.T) { - t.Skip("skip in short mode") - } - t.Parallel() -+ tmpDir := t.TempDir() - // Use a temporary pkgdir to not interfere with other tests, and not write to GOROOT. - // Cannot use goCmd as it runs with cloned GOROOT which is incomplete. - runWithEnv(t, "building std", []string{"GOROOT=" + oldGOROOT}, -- filepath.Join(oldGOROOT, "bin", "go"), "install", "-buildmode=shared", "-pkgdir="+t.TempDir(), "std") -+ filepath.Join(oldGOROOT, "bin", "go"), "install", "-buildmode=shared", "-pkgdir="+tmpDir, "std") -+ -+ // Issue #58966. -+ runWithEnv(t, "testing issue #58966", []string{"GOROOT=" + oldGOROOT}, -+ filepath.Join(oldGOROOT, "bin", "go"), "run", "-linkshared", "-pkgdir="+tmpDir, "./issue58966/main.go") - } -diff --git a/misc/cgo/testshared/testdata/issue58966/main.go b/misc/cgo/testshared/testdata/issue58966/main.go -new file mode 100644 -index 0000000000..2d923c3607 ---- /dev/null -+++ b/misc/cgo/testshared/testdata/issue58966/main.go -@@ -0,0 +1,15 @@ -+// Copyright 2023 The Go Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style -+// license that can be found in the LICENSE file. -+ -+package main -+ -+import "crypto/elliptic" -+ -+var curve elliptic.Curve -+ -+func main() { -+ switch curve { -+ case elliptic.P224(): -+ } -+} -diff --git a/src/cmd/compile/internal/noder/unified.go b/src/cmd/compile/internal/noder/unified.go -index ed97a09302..25136e6aad 100644 ---- a/src/cmd/compile/internal/noder/unified.go -+++ b/src/cmd/compile/internal/noder/unified.go -@@ -158,7 +158,11 @@ func readBodies(target *ir.Package, duringInlining bool) { - // Instantiated generic function: add to Decls for typechecking - // and compilation. - if fn.OClosure == nil && len(pri.dict.targs) != 0 { -- if duringInlining { -+ // cmd/link does not support a type symbol referencing a method symbol -+ // across DSO boundary, so force re-compiling methods on a generic type -+ // even it was seen from imported package in linkshared mode, see #58966. -+ canSkipNonGenericMethod := !(base.Ctxt.Flag_linkshared && ir.IsMethod(fn)) -+ if duringInlining && canSkipNonGenericMethod { - inlDecls = append(inlDecls, fn) - } else { - target.Decls = append(target.Decls, fn) diff --git a/compat/dunfell/backport-go/go/go/CVE-2023-24532.patch b/compat/dunfell/backport-go/go/go/CVE-2023-24532.patch deleted file mode 100644 index 22f080d..0000000 --- a/compat/dunfell/backport-go/go/go/CVE-2023-24532.patch +++ /dev/null @@ -1,208 +0,0 @@ -From 602eeaab387f24a4b28c5eccbb50fa934f3bc3c4 Mon Sep 17 00:00:00 2001 -From: Filippo Valsorda -Date: Mon, 13 Feb 2023 15:16:27 +0100 -Subject: [PATCH] [release-branch.go1.20] crypto/internal/nistec: reduce P-256 - scalar - -Unlike the rest of nistec, the P-256 assembly doesn't use complete -addition formulas, meaning that p256PointAdd[Affine]Asm won't return the -correct value if the two inputs are equal. - -This was (undocumentedly) ignored in the scalar multiplication loops -because as long as the input point is not the identity and the scalar is -lower than the order of the group, the addition inputs can't be the same. - -As part of the math/big rewrite, we went however from always reducing -the scalar to only checking its length, under the incorrect assumption -that the scalar multiplication loop didn't require reduction. - -Added a reduction, and while at it added it in P256OrdInverse, too, to -enforce a universal reduction invariant on p256OrdElement values. - -Note that if the input point is the infinity, the code currently still -relies on undefined behavior, but that's easily tested to behave -acceptably, and will be addressed in a future CL. - -Updates #58647 -Fixes #58720 -Fixes CVE-2023-24532 - -(Filed with the "safe APIs like complete addition formulas are good" dept.) - -Change-Id: I7b2c75238440e6852be2710fad66ff1fdc4e2b24 -Reviewed-on: https://go-review.googlesource.com/c/go/+/471255 -TryBot-Result: Gopher Robot -Reviewed-by: Roland Shoemaker -Run-TryBot: Filippo Valsorda -Auto-Submit: Filippo Valsorda -Reviewed-by: Damien Neil -(cherry picked from commit 203e59ad41bd288e1d92b6f617c2f55e70d3c8e3) -Reviewed-on: https://go-review.googlesource.com/c/go/+/471695 -Reviewed-by: Dmitri Shuralyov -Auto-Submit: Dmitri Shuralyov -Reviewed-by: Filippo Valsorda -Run-TryBot: Roland Shoemaker - -CVE: CVE-2023-24532 -Upstream-Status: Backport [602eeaab387f24a4b28c5eccbb50fa934f3bc3c4] -Signed-off-by: Ross Burton - ---- - src/crypto/internal/nistec/nistec_test.go | 81 +++++++++++++++++++++++ - src/crypto/internal/nistec/p256_asm.go | 17 +++++ - src/crypto/internal/nistec/p256_ordinv.go | 1 + - 3 files changed, 99 insertions(+) - -diff --git a/src/crypto/internal/nistec/nistec_test.go b/src/crypto/internal/nistec/nistec_test.go -index 309f68be16a9f..9103608c18a0f 100644 ---- a/src/crypto/internal/nistec/nistec_test.go -+++ b/src/crypto/internal/nistec/nistec_test.go -@@ -8,6 +8,7 @@ import ( - "bytes" - "crypto/elliptic" - "crypto/internal/nistec" -+ "fmt" - "internal/testenv" - "math/big" - "math/rand" -@@ -165,6 +166,86 @@ func testEquivalents[P nistPoint[P]](t *testing.T, newPoint func() P, c elliptic - } - } - -+func TestScalarMult(t *testing.T) { -+ t.Run("P224", func(t *testing.T) { -+ testScalarMult(t, nistec.NewP224Point, elliptic.P224()) -+ }) -+ t.Run("P256", func(t *testing.T) { -+ testScalarMult(t, nistec.NewP256Point, elliptic.P256()) -+ }) -+ t.Run("P384", func(t *testing.T) { -+ testScalarMult(t, nistec.NewP384Point, elliptic.P384()) -+ }) -+ t.Run("P521", func(t *testing.T) { -+ testScalarMult(t, nistec.NewP521Point, elliptic.P521()) -+ }) -+} -+ -+func testScalarMult[P nistPoint[P]](t *testing.T, newPoint func() P, c elliptic.Curve) { -+ G := newPoint().SetGenerator() -+ checkScalar := func(t *testing.T, scalar []byte) { -+ p1, err := newPoint().ScalarBaseMult(scalar) -+ fatalIfErr(t, err) -+ p2, err := newPoint().ScalarMult(G, scalar) -+ fatalIfErr(t, err) -+ if !bytes.Equal(p1.Bytes(), p2.Bytes()) { -+ t.Error("[k]G != ScalarBaseMult(k)") -+ } -+ -+ d := new(big.Int).SetBytes(scalar) -+ d.Sub(c.Params().N, d) -+ d.Mod(d, c.Params().N) -+ g1, err := newPoint().ScalarBaseMult(d.FillBytes(make([]byte, len(scalar)))) -+ fatalIfErr(t, err) -+ g1.Add(g1, p1) -+ if !bytes.Equal(g1.Bytes(), newPoint().Bytes()) { -+ t.Error("[N - k]G + [k]G != ∞") -+ } -+ } -+ -+ byteLen := len(c.Params().N.Bytes()) -+ bitLen := c.Params().N.BitLen() -+ t.Run("0", func(t *testing.T) { checkScalar(t, make([]byte, byteLen)) }) -+ t.Run("1", func(t *testing.T) { -+ checkScalar(t, big.NewInt(1).FillBytes(make([]byte, byteLen))) -+ }) -+ t.Run("N-1", func(t *testing.T) { -+ checkScalar(t, new(big.Int).Sub(c.Params().N, big.NewInt(1)).Bytes()) -+ }) -+ t.Run("N", func(t *testing.T) { checkScalar(t, c.Params().N.Bytes()) }) -+ t.Run("N+1", func(t *testing.T) { -+ checkScalar(t, new(big.Int).Add(c.Params().N, big.NewInt(1)).Bytes()) -+ }) -+ t.Run("all1s", func(t *testing.T) { -+ s := new(big.Int).Lsh(big.NewInt(1), uint(bitLen)) -+ s.Sub(s, big.NewInt(1)) -+ checkScalar(t, s.Bytes()) -+ }) -+ if testing.Short() { -+ return -+ } -+ for i := 0; i < bitLen; i++ { -+ t.Run(fmt.Sprintf("1<<%d", i), func(t *testing.T) { -+ s := new(big.Int).Lsh(big.NewInt(1), uint(i)) -+ checkScalar(t, s.FillBytes(make([]byte, byteLen))) -+ }) -+ } -+ // Test N+1...N+32 since they risk overlapping with precomputed table values -+ // in the final additions. -+ for i := int64(2); i <= 32; i++ { -+ t.Run(fmt.Sprintf("N+%d", i), func(t *testing.T) { -+ checkScalar(t, new(big.Int).Add(c.Params().N, big.NewInt(i)).Bytes()) -+ }) -+ } -+} -+ -+func fatalIfErr(t *testing.T, err error) { -+ t.Helper() -+ if err != nil { -+ t.Fatal(err) -+ } -+} -+ - func BenchmarkScalarMult(b *testing.B) { - b.Run("P224", func(b *testing.B) { - benchmarkScalarMult(b, nistec.NewP224Point().SetGenerator(), 28) -diff --git a/src/crypto/internal/nistec/p256_asm.go b/src/crypto/internal/nistec/p256_asm.go -index 6ea161eb49953..99a22b833f028 100644 ---- a/src/crypto/internal/nistec/p256_asm.go -+++ b/src/crypto/internal/nistec/p256_asm.go -@@ -364,6 +364,21 @@ func p256PointDoubleAsm(res, in *P256Point) - // Montgomery domain (with R 2²⁵⁶) as four uint64 limbs in little-endian order. - type p256OrdElement [4]uint64 - -+// p256OrdReduce ensures s is in the range [0, ord(G)-1]. -+func p256OrdReduce(s *p256OrdElement) { -+ // Since 2 * ord(G) > 2²⁵⁶, we can just conditionally subtract ord(G), -+ // keeping the result if it doesn't underflow. -+ t0, b := bits.Sub64(s[0], 0xf3b9cac2fc632551, 0) -+ t1, b := bits.Sub64(s[1], 0xbce6faada7179e84, b) -+ t2, b := bits.Sub64(s[2], 0xffffffffffffffff, b) -+ t3, b := bits.Sub64(s[3], 0xffffffff00000000, b) -+ tMask := b - 1 // zero if subtraction underflowed -+ s[0] ^= (t0 ^ s[0]) & tMask -+ s[1] ^= (t1 ^ s[1]) & tMask -+ s[2] ^= (t2 ^ s[2]) & tMask -+ s[3] ^= (t3 ^ s[3]) & tMask -+} -+ - // Add sets q = p1 + p2, and returns q. The points may overlap. - func (q *P256Point) Add(r1, r2 *P256Point) *P256Point { - var sum, double P256Point -@@ -393,6 +408,7 @@ func (r *P256Point) ScalarBaseMult(scalar []byte) (*P256Point, error) { - } - scalarReversed := new(p256OrdElement) - p256OrdBigToLittle(scalarReversed, (*[32]byte)(scalar)) -+ p256OrdReduce(scalarReversed) - - r.p256BaseMult(scalarReversed) - return r, nil -@@ -407,6 +423,7 @@ func (r *P256Point) ScalarMult(q *P256Point, scalar []byte) (*P256Point, error) - } - scalarReversed := new(p256OrdElement) - p256OrdBigToLittle(scalarReversed, (*[32]byte)(scalar)) -+ p256OrdReduce(scalarReversed) - - r.Set(q).p256ScalarMult(scalarReversed) - return r, nil -diff --git a/src/crypto/internal/nistec/p256_ordinv.go b/src/crypto/internal/nistec/p256_ordinv.go -index 86a7a230bdce8..1274fb7fd3f5c 100644 ---- a/src/crypto/internal/nistec/p256_ordinv.go -+++ b/src/crypto/internal/nistec/p256_ordinv.go -@@ -25,6 +25,7 @@ func P256OrdInverse(k []byte) ([]byte, error) { - - x := new(p256OrdElement) - p256OrdBigToLittle(x, (*[32]byte)(k)) -+ p256OrdReduce(x) - - // Inversion is implemented as exponentiation by n - 2, per Fermat's little theorem. - // diff --git a/compat/dunfell/backport-go/go/go_1.20.1.bb b/compat/dunfell/backport-go/go/go_1.22.5.bb similarity index 92% rename from compat/dunfell/backport-go/go/go_1.20.1.bb rename to compat/dunfell/backport-go/go/go_1.22.5.bb index 587ee55..46f5fbc 100644 --- a/compat/dunfell/backport-go/go/go_1.20.1.bb +++ b/compat/dunfell/backport-go/go/go_1.22.5.bb @@ -3,7 +3,7 @@ require go-target.inc inherit linuxloader -CGO_LDFLAGS:append:mips = " -no-pie" +CGO_LDFLAGS:append = " -no-pie" export GO_LDSO = "${@get_linuxloader(d)}" export CC_FOR_TARGET = "gcc" diff --git a/compat/dunfell/conf/layer.conf b/compat/dunfell/conf/layer.conf index b7da378..f4042b3 100644 --- a/compat/dunfell/conf/layer.conf +++ b/compat/dunfell/conf/layer.conf @@ -4,6 +4,7 @@ BBFILES += "${LAYERDIR}/compat/${LAYERSERIES_CORENAMES}/*/*/*.bb \ " # The shellhub-agent requires Go 1.20+ -GOVERSION = "1.20%" +GOVERSION = "1.22%" +export GOPROXY ??= "https://proxy.golang.org,direct" PREFERRED_PROVIDER_go-native = "go-binary-native" PREFERRED_VERSION_go-binary-native = "${GOVERSION}"