diff --git a/conf/layer.conf b/conf/layer.conf index c80145d8d86e2febb9b6c9072212dab31a0e62de..ec1679ffd49e110c9c6c818cf1b74b7fbe236dd2 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -16,6 +16,9 @@ BBFILES_DYNAMIC += " \ raspberrypi:${LAYERDIR}/dynamic-layers/raspberrypi/*/*/*.bbappend \ " +# Backported go from Yocto 5.2 (walnascar). +GOVERSION = "1.24%" + BB_VERBOSE_LOGS = "True" # This should only be incremented on significant changes that will # cause compatibility issues with other layers @@ -23,4 +26,4 @@ LAYERVERSION_pypcc = "1" LAYERSERIES_COMPAT_pypcc = "styhead scarthgap" -LAYERDEPENDS_pypcc = "swupdate" \ No newline at end of file +LAYERDEPENDS_pypcc = "swupdate" diff --git a/kas-pypcc-rpi.yml b/kas-pypcc-rpi.yml index 76a98bc756b70be3382306b19cf159ec7aefae27..ea3c0d5ae99022ad290c11b8a3fd91c9990516f0 100644 --- a/kas-pypcc-rpi.yml +++ b/kas-pypcc-rpi.yml @@ -86,7 +86,7 @@ local_conf_header: DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit" VIRTUAL-RUNTIME_init_manager = "systemd" VIRTUAL-RUNTIME_initscripts = "systemd-compat-units" - IMAGE_INSTALL:append = "node-exporter chrony-exporter ntp python3-pypcc python3-halibut-ipconfig vcgencmd dtc i2c-tools swupdate swupdate-www libgpiod libgpiod-tools libgpiod-dev kernel-module-i2c-gpio" + IMAGE_INSTALL:append = "consul-exporter node-exporter chrony-exporter ntp python3-pypcc python3-halibut-ipconfig vcgencmd dtc i2c-tools swupdate swupdate-www libgpiod libgpiod-tools libgpiod-dev kernel-module-i2c-gpio" IMAGE_FSTYPES = "tar.bz2 ext4 ext4.gz wic.bz2 wic.bmap" SWUPDATE_IMAGES_FSTYPES[core-image-full-cmdline] = ".ubifs" IMAGE_BOOT_FILES:append = "halibut.dtbo;overlays/halibut.dtbo" diff --git a/recipes-devtools/go/go-1.24.4.inc b/recipes-devtools/go/go-1.24.4.inc new file mode 100644 index 0000000000000000000000000000000000000000..eff3f2f605c36a4e5ae786da4106c1ab9bdab2ac --- /dev/null +++ b/recipes-devtools/go/go-1.24.4.inc @@ -0,0 +1,20 @@ +require go-common.inc + +FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/go:" + +LIC_FILES_CHKSUM = "file://LICENSE;md5=7998cb338f82d15c0eff93b7004d272a" + +SRC_URI += "\ + file://0001-cmd-go-make-content-based-hash-generation-less-pedan.patch \ + file://0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch \ + file://0003-ld-add-soname-to-shareable-objects.patch \ + 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-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-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch \ + file://6d265b008e3d106b2706645e5a88cd8e2fb98953.patch \ +" +SRC_URI[main.sha256sum] = "5a86a83a31f9fa81490b8c5420ac384fd3d95a3e71fba665c7b3f95d1dfef2b4" diff --git a/recipes-devtools/go/go-binary-native_1.24.4.bb b/recipes-devtools/go/go-binary-native_1.24.4.bb new file mode 100644 index 0000000000000000000000000000000000000000..9f788536c4a8e611a3194109f7e12a9ff751d651 --- /dev/null +++ b/recipes-devtools/go/go-binary-native_1.24.4.bb @@ -0,0 +1,50 @@ +# 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=7998cb338f82d15c0eff93b7004d272a" + +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] = "77e5da33bb72aeaef1ba4418b6fe511bc4d041873cbf82e5aa6318740df98717" +SRC_URI[go_linux_arm64.sha256sum] = "d5501ee5aca0f258d5fe9bfaed401958445014495dc115f202d43d5210b45241" +SRC_URI[go_linux_ppc64le.sha256sum] = "9ca4afef813a2578c23843b640ae0290aa54b2e3c950a6cc4c99e16a57dec2ec" + +UPSTREAM_CHECK_URI = "https://golang.org/dl/" +UPSTREAM_CHECK_REGEX = "go(?P<pver>\d+(\.\d+)+)\.linux" + +CVE_PRODUCT = "golang:go" + +S = "${WORKDIR}/go" + +inherit goarch native + +do_compile() { + : +} + +make_wrapper() { + rm -f ${D}${bindir}/$1 + cat <<END >${D}${bindir}/$1 +#!/bin/bash +here=\`dirname \$0\` +export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}" +\$here/../lib/go/bin/$1 "\$@" +END + chmod +x ${D}${bindir}/$1 +} + +do_install() { + find ${S} -depth -type d -name testdata -exec rm -rf {} + + + install -d ${D}${bindir} ${D}${libdir}/go + cp --preserve=mode,timestamps -R ${S}/ ${D}${libdir}/ + + for f in ${S}/bin/* + do + make_wrapper `basename $f` + done +} diff --git a/recipes-devtools/go/go-common.inc b/recipes-devtools/go/go-common.inc new file mode 100644 index 0000000000000000000000000000000000000000..ca8469dbd91e20118b158898a92d8da839908c7e --- /dev/null +++ b/recipes-devtools/go/go-common.inc @@ -0,0 +1,46 @@ +SUMMARY = "Go programming language compiler" +DESCRIPTION = " The Go programming language is an open source project to make \ + programmers more productive. Go is expressive, concise, clean, and\ + efficient. Its concurrency mechanisms make it easy to write programs\ + that get the most out of multicore and networked machines, while its\ + novel type system enables flexible and modular program construction.\ + Go compiles quickly to machine code yet has the convenience of\ + garbage collection and the power of run-time reflection. It's a\ + fast, statically typed, compiled language that feels like a\ + dynamically typed, interpreted language." + +HOMEPAGE = " http://golang.org/" +LICENSE = "BSD-3-Clause" + +inherit goarch + +SRC_URI = "https://golang.org/dl/go${PV}.src.tar.gz;name=main" +S = "${WORKDIR}/go" +B = "${S}" +UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)\.src\.tar" + +# all recipe variants are created from the same product +CVE_PRODUCT = "golang:go" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +SSTATE_SCAN_CMD = "true" + +export GOROOT_OVERRIDE = "1" +export GOTMPDIR ?= "${WORKDIR}/build-tmp" +GOTMPDIR[vardepvalue] = "" +export CGO_ENABLED = "1" + +export GOHOSTOS ?= "${BUILD_GOOS}" +export GOHOSTARCH ?= "${BUILD_GOARCH}" +export GOROOT_BOOTSTRAP ?= "${STAGING_LIBDIR_NATIVE}/go" +export GOOS ?= "${TARGET_GOOS}" +export GOARCH ?= "${TARGET_GOARCH}" +export GOARM ?= "${TARGET_GOARM}" +export GO386 ?= "${TARGET_GO386}" +export GOMIPS ?= "${TARGET_GOMIPS}" + +export GODEBUG = "gocachehash=1" + +do_compile:prepend() { + BUILD_CC=${BUILD_CC} +} diff --git a/recipes-devtools/go/go-cross-canadian.inc b/recipes-devtools/go/go-cross-canadian.inc new file mode 100644 index 0000000000000000000000000000000000000000..ff6c063d69eb391cf95c1d7f05c9db36440611e1 --- /dev/null +++ b/recipes-devtools/go/go-cross-canadian.inc @@ -0,0 +1,61 @@ +inherit cross-canadian + +DEPENDS = "go-native virtual/${HOST_PREFIX}go virtual/nativesdk-${HOST_PREFIX}go-runtime \ + virtual/nativesdk-cross-cc virtual/nativesdk-libc \ + virtual/nativesdk-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}=${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 = '-extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS} ${HOST_CC_ARCH} ${LDFLAGS}"' + +do_configure[noexec] = "1" + +do_compile() { + export CC_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS}" + export CXX_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gxx --sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS}" + cd src + ./make.bash --target-only --no-banner + cd ${B} +} +do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" + + +make_wrapper() { + rm -f ${D}${bindir}/$2 + cat <<END >${D}${bindir}/$2 +#!/bin/sh +here=\`dirname \$0\` +native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\` +export GOARCH="${TARGET_GOARCH}" +export GOOS="${TARGET_GOOS}" +test -n "\$GOARM" || export GOARM="${TARGET_GOARM}" +test -n "\$GO386" || export GO386="${TARGET_GO386}" +test -n "\$GOMIPS" || export GOMIPS="${TARGET_GOMIPS}" +export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}" +test -n "\$GOROOT" || export GOROOT="\$OECORE_TARGET_SYSROOT/${target_libdir}/go" +\$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@" +END + chmod +x ${D}${bindir}/$2 +} + +do_install() { + install -d ${D}${libdir}/go/pkg/tool + cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/ + install -d ${D}${bindir} ${D}${libdir}/go/bin + for f in ${B}/${GO_BUILD_BINDIR}/* + do + base=`basename $f` + install -m755 $f ${D}${libdir}/go/bin + make_wrapper $base ${TARGET_PREFIX}$base + done +} diff --git a/recipes-devtools/go/go-cross-canadian_1.24.4.bb b/recipes-devtools/go/go-cross-canadian_1.24.4.bb new file mode 100644 index 0000000000000000000000000000000000000000..7ac9449e47668d93b6ab99d4e75de3f6a23586c3 --- /dev/null +++ b/recipes-devtools/go/go-cross-canadian_1.24.4.bb @@ -0,0 +1,2 @@ +require go-cross-canadian.inc +require go-${PV}.inc diff --git a/recipes-devtools/go/go-cross.inc b/recipes-devtools/go/go-cross.inc new file mode 100644 index 0000000000000000000000000000000000000000..a0fbdbe3b9385f3572ff5bb3aec99087768931d7 --- /dev/null +++ b/recipes-devtools/go/go-cross.inc @@ -0,0 +1,52 @@ +inherit cross + +PROVIDES = "virtual/${TUNE_PKGARCH}-go" +DEPENDS = "go-native" + +PN = "go-cross-${TUNE_PKGARCH}" + +export GOCACHE = "${B}/.cache" +CC = "${@d.getVar('BUILD_CC').strip()}" + +do_configure[noexec] = "1" + +do_compile() { + export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" + export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" + cd src + ./make.bash --host-only --no-banner + cd ${B} +} +do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" + +make_wrapper() { + rm -f ${D}${bindir}/$2 + cat <<END >${D}${bindir}/$2 +#!/bin/bash +here=\`dirname \$0\` +export GOARCH="${TARGET_GOARCH}" +export GOOS="${TARGET_GOOS}" +export GOARM="\${GOARM:-${TARGET_GOARM}}" +export GO386="\${GO386:-${TARGET_GO386}}" +export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}" +\$here/../../lib/${CROSS_TARGET_SYS_DIR}/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 --preserve=mode,timestamps -R ${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 ${TARGET_PREFIX}$base + done +} diff --git a/recipes-devtools/go/go-cross_1.24.4.bb b/recipes-devtools/go/go-cross_1.24.4.bb new file mode 100644 index 0000000000000000000000000000000000000000..80b5a03f6ca7813f91f3e6f87e7f43db1949c904 --- /dev/null +++ b/recipes-devtools/go/go-cross_1.24.4.bb @@ -0,0 +1,2 @@ +require go-cross.inc +require go-${PV}.inc diff --git a/recipes-devtools/go/go-crosssdk.inc b/recipes-devtools/go/go-crosssdk.inc new file mode 100644 index 0000000000000000000000000000000000000000..4f19025ba7f0b18f279c62216a8ac0fe30eef7d1 --- /dev/null +++ b/recipes-devtools/go/go-crosssdk.inc @@ -0,0 +1,44 @@ +inherit crosssdk + +DEPENDS = "go-native virtual/nativesdk-cross-cc virtual/nativesdk-compilerlibs virtual/nativesdk-cross-binutils" +PN = "go-crosssdk-${SDK_SYS}" +PROVIDES = "virtual/${TARGET_PREFIX}go" + +export GOCACHE = "${B}/.cache" + +do_configure[noexec] = "1" + +do_compile() { + export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" + export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" + cd src + ./make.bash --host-only --no-banner + cd ${B} +} +do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" + +make_wrapper() { + rm -f ${D}${bindir}/$2 + cat <<END >${D}${bindir}/$2 +#!/bin/bash +here=\`dirname \$0\` +export GOARCH="${TARGET_GOARCH}" +export GOOS="${TARGET_GOOS}" +\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" +END + chmod +x ${D}${bindir}/$2 +} + +do_install() { + install -d ${D}${libdir}/go + install -d ${D}${libdir}/go/bin + install -d ${D}${libdir}/go/pkg/tool + install -d ${D}${bindir} + cp --preserve=mode,timestamps -R ${S}/pkg/tool/${BUILD_GOTUPLE} ${D}${libdir}/go/pkg/tool/ + for f in ${B}/bin/* + do + base=`basename $f` + install -m755 $f ${D}${libdir}/go/bin + make_wrapper $base ${TARGET_PREFIX}$base + done +} diff --git a/recipes-devtools/go/go-crosssdk_1.24.4.bb b/recipes-devtools/go/go-crosssdk_1.24.4.bb new file mode 100644 index 0000000000000000000000000000000000000000..1857c8a57723cbbeb59a7e8a8f0334a036119f49 --- /dev/null +++ b/recipes-devtools/go/go-crosssdk_1.24.4.bb @@ -0,0 +1,2 @@ +require go-crosssdk.inc +require go-${PV}.inc diff --git a/recipes-devtools/go/go-runtime.inc b/recipes-devtools/go/go-runtime.inc new file mode 100644 index 0000000000000000000000000000000000000000..e5f17337bcb100d9b57b09a28166fef6ac9f5a68 --- /dev/null +++ b/recipes-devtools/go/go-runtime.inc @@ -0,0 +1,94 @@ +DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" +DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go" +PROVIDES = "virtual/${TARGET_PREFIX}go-runtime" + +DEBUG_PREFIX_MAP = "\ + -fdebug-prefix-map=${STAGING_DIR_HOST}= \ + -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ +" + +export CGO_CFLAGS = "${CFLAGS}" +export CGO_CPPFLAGS = "${CPPFLAGS}" +export CGO_CXXFLAGS = "${CXXFLAGS}" +# Filter out -fdebug-prefix-map options as they clash with the GO's build system +export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" +export GOCACHE = "${B}/.cache" + +GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}" +GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"' + +do_configure() { + : +} + +do_configure:libc-musl() { + rm -f ${S}/src/runtime/race/*.syso +} + +do_compile() { + export CC_FOR_${TARGET_GOTUPLE}="${CC}" + export CXX_FOR_${TARGET_GOTUPLE}="${CXX}" + + cd src + ./make.bash --target-only --no-banner std + if [ -n "${GO_DYNLINK}" ]; then + export GOTOOLDIR="${B}/pkg/tool/native_native" + CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \ + $GOTOOLDIR/go_bootstrap install -linkshared -trimpath -buildmode=shared ${GO_SHLIB_LDFLAGS} std + fi + cd ${B} +} +do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" + +do_install() { + install -d ${D}${libdir}/go/src + cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ + if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then + rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE} + rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE} + fi + rm -rf ${D}${libdir}/go/pkg/tool + rm -rf ${D}${libdir}/go/pkg/obj + rm -rf ${D}${libdir}/go/pkg/bootstrap + # the cmd directory is built for the native arch so if BUILD == TARGET + rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}/cmd + find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do + cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/ + done + find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; + rm -f ${D}${libdir}/go/src/cmd/dist/dist + rm -f ${D}${libdir}/go/src/cmd/cgo/zdefaultcc.go + rm -f ${D}${libdir}/go/src/cmd/go/internal/cfg/zdefaultcc.go + +} + +ALLOW_EMPTY:${PN} = "1" +FILES:${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" +FILES:${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.shlibname \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.shlibname \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.shlibname \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.shlibname \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.shlibname \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.shlibname \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.a \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.a \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.a \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.a \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.a \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.a \ + ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.a \ +" +FILES:${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}" + +# Go sources include some scripts and pre-built binaries for +# multiple architectures. The static .a files for dynamically-linked +# runtime are also required in -dev. +INSANE_SKIP:${PN}-dev = "staticdev file-rdeps arch" + +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_SYSROOT_STRIP = "1" + +BBCLASSEXTEND = "nativesdk" diff --git a/recipes-devtools/go/go-runtime_1.24.4.bb b/recipes-devtools/go/go-runtime_1.24.4.bb new file mode 100644 index 0000000000000000000000000000000000000000..63464a15014af089c21a12bacd8cf7df4be7ed0d --- /dev/null +++ b/recipes-devtools/go/go-runtime_1.24.4.bb @@ -0,0 +1,3 @@ +require go-${PV}.inc +require go-runtime.inc + diff --git a/recipes-devtools/go/go-target.inc b/recipes-devtools/go/go-target.inc new file mode 100644 index 0000000000000000000000000000000000000000..981c7abd313725958bde6b442d82afba4058c6c3 --- /dev/null +++ b/recipes-devtools/go/go-target.inc @@ -0,0 +1,53 @@ +DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" +DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go go-native" + +DEBUG_PREFIX_MAP = "\ + -fdebug-prefix-map=${STAGING_DIR_HOST}= \ + -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ +" + +export CGO_CFLAGS = "${CFLAGS}" +export CGO_CPPFLAGS = "${CPPFLAGS}" +export CGO_CXXFLAGS = "${CXXFLAGS}" +# Filter out -fdebug-prefix-map options as they clash with the GO's build system +export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" + +export GOCACHE = "${B}/.cache" +export GO_LDFLAGS = "" +export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath" +CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}" + +do_configure[noexec] = "1" + +do_compile() { + export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}" + export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}" + + cd src + ./make.bash --target-only --no-banner + cd ${B} +} +do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" + +do_install() { + install -d ${D}${libdir}/go/pkg/tool + cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/ + install -d ${D}${libdir}/go/src + cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/ + find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; + install -d ${D}${libdir}/go/bin + install -d ${D}${bindir} + for f in ${B}/${GO_BUILD_BINDIR}/*; do + name=`basename $f` + install -m 0755 $f ${D}${libdir}/go/bin/ + ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/ + done + rm -rf ${D}${libdir}/go/src +} + +PACKAGES = "${PN} ${PN}-dev" +FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}" +RDEPENDS:${PN} = "go-runtime" +INSANE_SKIP:${PN} = "ldflags" + +BBCLASSEXTEND = "nativesdk" diff --git a/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch b/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch new file mode 100644 index 0000000000000000000000000000000000000000..86e941b9701c2615a534a1e5fc303ea6539841e6 --- /dev/null +++ b/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch @@ -0,0 +1,172 @@ +From 51c04a9a19dec5a48fa0f38324dc2480b7a859e4 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Sat, 22 Feb 2025 03:24:48 -0800 +Subject: [PATCH 01/11] 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. +This same mechanism is used to maintain a built-artifact +cache for speeding up builds. + +However, the hashes it generates include information that +doesn't work well with OE, nor with using a shared runtime +library. + +First, it embeds path names to source files, unless +building within GOROOT. This prevents the building +of a package in GOPATH for later staging into GOROOT. + +This patch adds support for the environment variable +GOPATH_OMIT_IN_ACTIONID. If present, path name +embedding is disabled. + +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> + +Rebase to 1.23.4 +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + 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 7c370d427f..c2441f7695 100644 +--- a/src/cmd/go/internal/envcmd/env.go ++++ b/src/cmd/go/internal/envcmd/env.go +@@ -219,7 +219,7 @@ func ExtraEnvVarsCostly() []cfg.EnvVar { + } + }() + +- cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}) ++ cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}, false) + 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 7b073165d5..1f618be0bb 100644 +--- a/src/cmd/go/internal/work/exec.go ++++ b/src/cmd/go/internal/work/exec.go +@@ -237,6 +237,8 @@ func (b *Builder) Do(ctx context.Context, root *Action) { + writeActionGraph() + } + ++var omitGopath = os.Getenv("GOPATH_OMIT_IN_ACTIONID") != "" ++ + // buildActionID computes the action ID for a build action. + func (b *Builder) buildActionID(a *Action) cache.ActionID { + p := a.Package +@@ -258,7 +260,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) + } +- } else if p.Goroot { ++ } else if p.Goroot || omitGopath { + // The Go compiler always hides the exact value of $GOROOT + // when building things in GOROOT. + // +@@ -293,9 +295,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")) +- cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p) ++ cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true) + +- ccExe := b.ccExe() ++ ccExe := filterCompilerFlags(b.ccExe(), true) + fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags) + // Include the C compiler tool ID so that if the C + // compiler changes we rebuild the package. +@@ -303,14 +305,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 { +- cxxExe := b.cxxExe() ++ cxxExe := filterCompilerFlags(b.cxxExe(), true) + fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags) + if cxxID, _, err := b.gccToolID(cxxExe[0], "c++"); err == nil { + fmt.Fprintf(h, "CXX ID=%q\n", cxxID) + } + } + if len(p.FFiles) > 0 { +- fcExe := b.fcExe() ++ fcExe := filterCompilerFlags(b.fcExe(), true) + fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags) + if fcID, _, err := b.gccToolID(fcExe[0], "f95"); err == nil { + fmt.Fprintf(h, "FC ID=%q\n", fcID) +@@ -327,7 +329,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { + } + } + 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. +@@ -2659,8 +2661,25 @@ func envList(key, def string) []string { + return args + } + ++var filterFlags = os.Getenv("CGO_PEDANTIC") == "" ++ ++func filterCompilerFlags(flags []string, keepfirst bool) []string { ++ var newflags []string ++ var realkeepfirst bool = keepfirst ++ if !filterFlags { ++ return flags ++ } ++ for _, flag := range flags { ++ if strings.HasPrefix(flag, "-m") || realkeepfirst { ++ newflags = append(newflags, flag) ++ realkeepfirst = false ++ } ++ } ++ return newflags ++} ++ + // CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo. +-func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) { ++func (b *Builder) CFlags(p *load.Package, filtered bool) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) { + if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil { + return + } +@@ -2676,6 +2695,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 + } ++ if filtered { ++ cppflags = filterCompilerFlags(cppflags, false) ++ cflags = filterCompilerFlags(cflags, false) ++ cxxflags = filterCompilerFlags(cxxflags, false) ++ fflags = filterCompilerFlags(fflags, false) ++ ldflags = filterCompilerFlags(ldflags, false) ++ } + + return + } +@@ -2693,7 +2719,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 + } +@@ -3256,7 +3282,7 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx + p := a.Package + sh := b.Shell(a) + +- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p) ++ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p, false) + if err != nil { + return "", "", err + } +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch b/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch new file mode 100644 index 0000000000000000000000000000000000000000..7e86d8cd6b2be41f69da4ee41373f33f2b71c263 --- /dev/null +++ b/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch @@ -0,0 +1,56 @@ +From fdad9a0ea659cf2281a0df16b0f69f179605ec9a 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 02/11] cmd/go: Allow GOTOOLDIR to be overridden in the + environment + +to allow for split host/target build roots + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> +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 1f467647f5..b62e518030 100644 +--- a/src/cmd/dist/build.go ++++ b/src/cmd/dist/build.go +@@ -280,7 +280,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) ++ } + + 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 3b9f27e91d..ec043c1530 100644 +--- a/src/cmd/go/internal/cfg/cfg.go ++++ b/src/cmd/go/internal/cfg/cfg.go +@@ -248,7 +248,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. +- build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH) ++ if s := os.Getenv("GOTOOLDIR"); s != "" { ++ build.ToolDir = filepath.Clean(s) ++ } else { ++ build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH) ++ } + } + } + } +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch b/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch new file mode 100644 index 0000000000000000000000000000000000000000..86a4bb1ea5d13913e319834dcb8cb83e96efa198 --- /dev/null +++ b/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch @@ -0,0 +1,51 @@ +From 1546d837c69b654754ee137af1fa1c2f7500cfa2 Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:16:32 +0430 +Subject: [PATCH 03/11] ld: add soname to shareable objects + +so that OE's shared library dependency handling +can find them. + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> +Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> +--- + 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 2d8f964f35..dfc72e02c0 100644 +--- a/src/cmd/link/internal/ld/lib.go ++++ b/src/cmd/link/internal/ld/lib.go +@@ -1624,6 +1624,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 { + argv = addASLRargs(argv, *flagAslr) + } else { +@@ -1639,6 +1640,7 @@ func (ctxt *Link) hostlink() { + argv = append(argv, "-Wl,-z,relro") + } + argv = append(argv, "-shared") ++ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile))) + case BuildModePlugin: + if ctxt.HeadType == objabi.Hdarwin { + argv = append(argv, "-dynamiclib") +@@ -1647,6 +1649,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))) + } + } + +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch b/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch new file mode 100644 index 0000000000000000000000000000000000000000..abbb7bda2bd7f48098f94f9479613c91833e96a0 --- /dev/null +++ b/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch @@ -0,0 +1,48 @@ +From b41aaa851f0074682fcd4bf07c891fbdf0fdf70c Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Sat, 22 Feb 2025 03:14:37 -0800 +Subject: [PATCH 04/11] make.bash: override CC when building dist and + go_bootstrap + +for handling OE cross-canadian builds. + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> +Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> + +Rebase to 1.23.4 +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + src/make.bash | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/make.bash b/src/make.bash +index b67ae1529f..b59cdabd09 100755 +--- a/src/make.bash ++++ b/src/make.bash +@@ -153,7 +153,7 @@ fi + export GOROOT_BOOTSTRAP + + bootstrapenv() { +- GOROOT="$GOROOT_BOOTSTRAP" GO111MODULE=off GOENV=off GOOS= GOARCH= GOEXPERIMENT= GOFLAGS= "$@" ++ CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" GO111MODULE=off GOENV=off GOOS= GOARCH= GOEXPERIMENT= GOFLAGS= "$@" + } + + export GOROOT="$(cd .. && pwd)" +@@ -216,7 +216,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. +-./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@" ++CC="${BUILD_CC:-${CC}}" ./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@" + rm -f ./cmd/dist/dist + + # DO NOT ADD ANY NEW CODE HERE. +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch b/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch new file mode 100644 index 0000000000000000000000000000000000000000..f7c3108a9851c7b5eb102b0464e0f7e3c3a94167 --- /dev/null +++ b/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch @@ -0,0 +1,224 @@ +From 12bf824f8b7e85f05434aa00e866e883a551aaeb Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Fri, 28 Feb 2025 19:09:17 -0800 +Subject: [PATCH 05/11] cmd/dist: separate host and target builds + +Change the dist tool to allow for OE-style cross- +and cross-canadian builds: + + - command flags --host-only and --target only are added; + if one is present, the other changes mentioned below + take effect, and arguments may also be specified on + the command line to enumerate the package(s) to be + built. + + - for OE cross builds, go_bootstrap is always built for + the current build host, and is moved, along with the supporting + toolchain (asm, compile, etc.) to a separate 'native_native' + directory under GOROOT/pkg/tool. + + - go_bootstrap is not automatically removed after the build, + so it can be reused later (e.g., building both static and + shared runtime). + +Note that for --host-only builds, it would be nice to specify +just the "cmd" package to build only the go commands/tools, +the staleness checks in the dist tool will fail if the "std" +library has not also been built. So host-only builds have to +build everything anyway. + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Rework the patch to avoid identation, it breaks formatting rules but +makes the changes more obvious and maintainable. +Jose Quaresma <jose.quaresma@foundries.io> +Richard Purdie <richard.purdie@linuxfoundation.org> + +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> + +Rebase to 1.24.0 +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + 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 b62e518030..0c54d82300 100644 +--- a/src/cmd/dist/build.go ++++ b/src/cmd/dist/build.go +@@ -49,6 +49,7 @@ var ( + gofips140 string + workdir string + tooldir string ++ build_tooldir string + oldgoos string + oldgoarch string + oldgocache string +@@ -61,6 +62,7 @@ var ( + rebuildall bool + noOpt bool + isRelease bool ++ crossBuild bool + + vflag int // verbosity + ) +@@ -286,6 +288,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 +@@ -547,8 +551,10 @@ func setup() { + goosGoarch := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch) + if rebuildall { + xremoveall(goosGoarch) ++ xremoveall(build_tooldir) + } + xmkdirall(goosGoarch) ++ xmkdirall(build_tooldir) + xatexit(func() { + if files := xreaddir(goosGoarch); len(files) == 0 { + xremove(goosGoarch) +@@ -1411,14 +1417,20 @@ func cmdbootstrap() { + defer timelog("end", "dist bootstrap") + + 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") ++ flag.BoolVar(&targetOnly, "target-only", targetOnly, "build only target binaries, not host") + +- xflagparse(0) ++ xflagparse(-1) + + if noClean { + xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n") +@@ -1430,6 +1442,18 @@ func cmdbootstrap() { + "Use the -force flag to build anyway.\n", goos, goarch) + } + ++ if hostOnly && targetOnly { ++ fatalf("specify only one of --host-only or --target-only\n") ++ } ++ crossBuild = hostOnly || targetOnly ++ if flag.NArg() > 0 { ++ if crossBuild { ++ toBuild = flag.Args() ++ } else { ++ fatalf("package names not permitted without --host-only or --target-only\n") ++ } ++ } ++ + // 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 +@@ -1513,9 +1537,14 @@ func cmdbootstrap() { + xprintf("\n") + } + ++ // 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 ++} + goBootstrap := pathf("%s/go_bootstrap", tooldir) + if debug { + run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") +@@ -1543,7 +1572,11 @@ func cmdbootstrap() { + xprintf("\n") + } + xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n") ++if !crossBuild { + os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch)) ++} else { ++ os.Setenv("CC", defaultcc[""]) ++} + // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT. + os.Setenv("GOEXPERIMENT", goexperiment) + // No need to enable PGO for toolchain2. +@@ -1596,6 +1629,7 @@ func cmdbootstrap() { + os.Setenv("GOCACHE", oldgocache) + } + ++if !crossBuild { + if goos == oldgoos && goarch == oldgoarch { + // Common case - not setting up for cross-compilation. + timelog("build", "toolchain") +@@ -1639,6 +1673,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)) ++ for _, f := range tool_files { ++ copyfile(pathf("%s/%s", build_tooldir, filepath.Base(f)), f, writeExec) ++ xremove(f) ++ } ++ os.Setenv("GOTOOLDIR", build_tooldir) ++ goBootstrap = pathf("%s/go_bootstrap", build_tooldir) ++ if hostOnly { ++ timelog("build", "host toolchain") ++ if vflag > 0 { ++ xprintf("\n") ++ } ++ xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) ++ 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") ++ if vflag > 0 { ++ xprintf("\n") ++ } ++ } else if targetOnly { ++ goos = oldgoos ++ goarch = oldgoarch ++ os.Setenv("GOOS", goos) ++ os.Setenv("GOARCH", goarch) ++ os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch)) ++ xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch) ++ goInstall(toolenv(), goBootstrap, toBuild...) ++ checkNotStale(toolenv(), goBootstrap, toBuild...) ++ // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary ++ } ++} + + // Check that there are no new files in $GOROOT/bin other than + // go and gofmt and $GOOS_$GOARCH (target bin when cross-compiling). +@@ -1661,8 +1731,12 @@ func cmdbootstrap() { + } + } + ++ // Except that for split host/target cross-builds, we need to ++ // keep it. ++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.25.1 + diff --git a/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch b/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch new file mode 100644 index 0000000000000000000000000000000000000000..b29da334ec9a39ddf35844fdd5e09c366238691a --- /dev/null +++ b/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch @@ -0,0 +1,114 @@ +From ba3caa9f969bac2b937f8f1ffed4a3679cd16ec7 Mon Sep 17 00:00:00 2001 +From: Alex Kube <alexander.j.kube@gmail.com> +Date: Wed, 23 Oct 2019 21:18:56 +0430 +Subject: [PATCH 06/11] 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 +be read-only and the go runtime has been built as a shared +library, since we don't want every application to be rebuilding +the shared runtime - particularly in cross-build/packaging +setups, since that would lead to 'abi mismatch' runtime errors. + +This patch prevents the install and linkshared actions from +installing to GOROOT unless overridden with the GOROOT_OVERRIDE +environment variable. + +Adapted to Go 1.13 from patches originally submitted to +the meta/recipes-devtools/go tree by +Matt Madison <matt@madison.systems>. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> +Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> +--- + src/cmd/go/internal/work/action.go | 3 +++ + src/cmd/go/internal/work/build.go | 6 ++++++ + src/cmd/go/internal/work/exec.go | 25 +++++++++++++++++++++++++ + 3 files changed, 34 insertions(+) + +diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go +index 44bb9f8c1e..87ac4e30e5 100644 +--- a/src/cmd/go/internal/work/action.go ++++ b/src/cmd/go/internal/work/action.go +@@ -837,6 +837,9 @@ func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) { + if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] { + continue + } ++ if goRootPrecious && (p1.Standard || p1.Goroot) { ++ continue ++ } + haveShlib[filepath.Base(p1.Shlib)] = true + // TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild, + // we'll end up building an overall library or executable that depends at runtime +diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go +index 3508d51fbb..77f5e7241a 100644 +--- a/src/cmd/go/internal/work/build.go ++++ b/src/cmd/go/internal/work/build.go +@@ -238,6 +238,8 @@ See also: go install, go get, go clean. + + const concurrentGCBackendCompilationEnabledByDefault = true + ++var goRootPrecious bool = true ++ + func init() { + // break init cycle + CmdBuild.Run = runBuild +@@ -251,6 +253,10 @@ func init() { + AddCoverFlags(CmdBuild, nil) + AddCoverFlags(CmdInstall, nil) + } ++ ++ if x := os.Getenv("GOROOT_OVERRIDE"); x != "" { ++ goRootPrecious = false ++ } + } + + // 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 1f618be0bb..651fa64582 100644 +--- a/src/cmd/go/internal/work/exec.go ++++ b/src/cmd/go/internal/work/exec.go +@@ -552,6 +552,23 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) { + return err + } + ++ if goRootPrecious && (a.Package.Standard || a.Package.Goroot) { ++ _, err := os.Stat(a.Package.Target) ++ if err == nil { ++ a.built = a.Package.Target ++ a.Target = a.Package.Target ++ a.buildID = b.fileHash(a.Package.Target) ++ a.Package.Stale = false ++ a.Package.StaleReason = "GOROOT-resident package" ++ return nil ++ } ++ a.Package.Stale = true ++ a.Package.StaleReason = "missing or invalid GOROOT-resident package" ++ if b.IsCmdList { ++ return nil ++ } ++ } ++ + if err := sh.Mkdir(a.Objdir); err != nil { + return err + } +@@ -1747,6 +1764,14 @@ func (b *Builder) linkShared(ctx context.Context, a *Action) (err error) { + return err + } + ++ if goRootPrecious && a.Package != nil { ++ p := a.Package ++ if p.Standard || p.Goroot { ++ err := fmt.Errorf("attempting to install package %s into read-only GOROOT", p.ImportPath) ++ return err ++ } ++ } ++ + if err := b.Shell(a).Mkdir(a.Objdir); err != nil { + return err + } +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch b/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch new file mode 100644 index 0000000000000000000000000000000000000000..9a701c7a6bbdf2369884d2c2da53b677e7f1a205 --- /dev/null +++ b/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch @@ -0,0 +1,63 @@ +From 2197f813c9cff65eedef44473872ec5ea9ced227 Mon Sep 17 00:00:00 2001 +From: Changqing Li <changqing.li@windriver.com> +Date: Tue, 27 Feb 2024 18:06:51 +0800 +Subject: [PATCH 07/11] 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 <changqing.li@windriver.com> +Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> +--- + 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 651fa64582..586079afb4 100644 +--- a/src/cmd/go/internal/work/exec.go ++++ b/src/cmd/go/internal/work/exec.go +@@ -1426,6 +1426,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) { +@@ -1436,7 +1459,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. +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch b/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch new file mode 100644 index 0000000000000000000000000000000000000000..a9cb2a4b84835e454fff368c89317a4db35f7dcd --- /dev/null +++ b/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch @@ -0,0 +1,46 @@ +From e5752b239707df8ad7a72dc60420e01c5912d606 Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin <alex.kanavin@gmail.com> +Date: Tue, 10 Nov 2020 16:33:27 +0000 +Subject: [PATCH 08/11] src/cmd/dist/buildgo.go: do not hardcode host compilers + into target binaries + +These come from $CC/$CXX on the build host and are not useful on targets; +additionally as they contain host specific paths, this helps reproducibility. + +Upstream-Status: Inappropriate [needs upstream discussion] + +Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> +Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> +--- + 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 884e9d729a..2f52edacfe 100644 +--- a/src/cmd/dist/buildgo.go ++++ b/src/cmd/dist/buildgo.go +@@ -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) +- buf.WriteString(defaultCCFunc("DefaultCC", defaultcc)) +- buf.WriteString(defaultCCFunc("DefaultCXX", defaultcxx)) ++ buf.WriteString(defaultCCFunc("DefaultCC", map[string]string{"":"gcc"})) ++ buf.WriteString(defaultCCFunc("DefaultCXX", map[string]string{"":"g++"})) + writefile(buf.String(), file, writeSkipSame) + return + } +@@ -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) +- buf.WriteString(defaultCCFunc("defaultCC", defaultcc)) +- buf.WriteString(defaultCCFunc("defaultCXX", defaultcxx)) ++ buf.WriteString(defaultCCFunc("defaultCC", map[string]string{"":"gcc"})) ++ buf.WriteString(defaultCCFunc("defaultCXX", map[string]string{"":"g++"})) + writefile(buf.String(), file, writeSkipSame) + } + +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch b/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch new file mode 100644 index 0000000000000000000000000000000000000000..d47c4b1d315bb5d3f09b41f58be0bbf596affad8 --- /dev/null +++ b/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch @@ -0,0 +1,61 @@ +From 79a1c80ed43f2a541bcab665656a4e2bb87baab3 Mon Sep 17 00:00:00 2001 +From: Richard Purdie <richard.purdie@linuxfoundation.org> +Date: Sat, 2 Jul 2022 23:08:13 +0100 +Subject: [PATCH 09/11] 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 +on mips/ppc. + +Upstream-Status: Submitted [https://github.com/golang/go/pull/56410] + +Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> +Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> +--- + 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 15f6b2e87b..47c5b865a1 100644 +--- a/src/cmd/go/internal/load/pkg.go ++++ b/src/cmd/go/internal/load/pkg.go +@@ -2291,6 +2291,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 ++ for _, flag := range strings.Fields(flags) { ++ if strings.HasPrefix(flag, "--sysroot") || strings.HasPrefix(flag, "-fmacro-prefix-map") || strings.HasPrefix(flag, "-fdebug-prefix-map") { ++ continue ++ } ++ newflags = append(newflags, flag) ++ } ++ return strings.Join(newflags, " ") ++} ++ + // 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 +@@ -2398,7 +2409,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS 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). +@@ -2444,7 +2455,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"} { +- appendSetting(name, cfg.Getenv(name)) ++ appendSetting(name, filterCompilerFlags(cfg.Getenv(name))) + } + } + appendSetting("GOARCH", cfg.BuildContext.GOARCH) +-- +2.25.1 + diff --git a/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch b/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch new file mode 100644 index 0000000000000000000000000000000000000000..2c2f0cbfb57ee4c2788ef1471be3037cae6b26d8 --- /dev/null +++ b/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch @@ -0,0 +1,51 @@ +From c4215b5ca69a7626d97cf9b7ebc460c2b5b9148b Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@windriver.com> +Date: Fri, 28 Feb 2025 19:13:18 -0800 +Subject: [PATCH 10/11] cmd/go: clear GOROOT for func ldShared when -trimpath + is used + +In commit [cmd: remove support for GOROOT_FINAL][1], it clear GOROOT +for func ld when -trimpath is used. [2] + +This commit do the same thing for func ldShared, otherwise run go_bootstrap +with -trimpath does not remove build path directory from the generated share +libarary + + $ ./make.bash --target-only --no-banner std + $ go_bootstrap install -linkshared -buildmode=shared -trimpath std + $ grep "$(pwd)" ./pkg/linux_amd64_dynlink/libstd.so + Binary file ./pkg/linux_amd64_dynlink/libstd.so matches + +[1] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98 +[2] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98#diff-cab5921f94f2667bb0bc1b935d2d46b4c03541b4351b33438ab7290b94dea212R669 + +Upstream-Status: Submitted [https://go-review.googlesource.com/c/go/+/653895] + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + src/cmd/go/internal/work/gc.go | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go +index 3a173efee8..8b7a44e031 100644 +--- a/src/cmd/go/internal/work/gc.go ++++ b/src/cmd/go/internal/work/gc.go +@@ -728,7 +728,14 @@ func (gcToolchain) ldShared(b *Builder, root *Action, toplevelactions []*Action, + // the output file path is recorded in the .gnu.version_d section. + dir, targetPath := filepath.Split(targetPath) + +- return b.Shell(root).run(dir, targetPath, nil, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags) ++ env := []string{} ++ // When -trimpath is used, GOROOT is cleared ++ if cfg.BuildTrimpath { ++ env = append(env, "GOROOT=") ++ } else { ++ env = append(env, "GOROOT="+cfg.GOROOT) ++ } ++ return b.Shell(root).run(dir, targetPath, env, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags) + } + + func (gcToolchain) cc(b *Builder, a *Action, ofile, cfile string) error { +-- +2.25.1 + diff --git a/recipes-devtools/go/go/6d265b008e3d106b2706645e5a88cd8e2fb98953.patch b/recipes-devtools/go/go/6d265b008e3d106b2706645e5a88cd8e2fb98953.patch new file mode 100644 index 0000000000000000000000000000000000000000..58bd00fc7386d9645ff4e02996843a96f3223231 --- /dev/null +++ b/recipes-devtools/go/go/6d265b008e3d106b2706645e5a88cd8e2fb98953.patch @@ -0,0 +1,54 @@ +From 6d265b008e3d106b2706645e5a88cd8e2fb98953 Mon Sep 17 00:00:00 2001 +From: Dirk Müller <dirk@dmllr.de> +Date: Wed, 09 Mar 2022 17:47:23 +0100 +Subject: [PATCH] cmd/link: stop forcing binutils-gold dependency on aarch64 + +The bfd linker appears to be working just fine at least in version +2.41 or above. Reject the known broken one instead, which +avoids an architecture specific linker dependency that +is cumbersome for distributions. + +Fixes #22040. + +Change-Id: I9f377e47c22ef20497479c0978c053ed5de46a38 + +Upstream-Status: Submitted [https://go-review.googlesource.com/c/go/+/391115] +--- + src/cmd/link/internal/ld/lib.go | 21 --------------------- + 1 file changed, 21 deletions(-) + +diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go +index dfc72e02c0..2a2a304113 100644 +--- a/src/cmd/link/internal/ld/lib.go ++++ b/src/cmd/link/internal/ld/lib.go +@@ -1673,27 +1673,6 @@ func (ctxt *Link) hostlink() { + // Use lld to avoid errors from default linker (issue #38838) + altLinker = "lld" + } +- +- if ctxt.Arch.InFamily(sys.ARM64) && buildcfg.GOOS == "linux" { +- // On ARM64, the GNU linker will fail with +- // -znocopyreloc if it thinks a COPY relocation is +- // required. Switch to gold. +- // https://sourceware.org/bugzilla/show_bug.cgi?id=19962 +- // https://go.dev/issue/22040 +- altLinker = "gold" +- +- // If gold is not installed, gcc will silently switch +- // back to ld.bfd. So we parse the version information +- // and provide a useful error if gold is missing. +- name, args := flagExtld[0], flagExtld[1:] +- args = append(args, "-fuse-ld=gold", "-Wl,--version") +- cmd := exec.Command(name, args...) +- if out, err := cmd.CombinedOutput(); err == nil { +- if !bytes.Contains(out, []byte("GNU gold")) { +- log.Fatalf("ARM64 external linker must be gold (issue #15696, 22040), but is not: %s", out) +- } +- } +- } + } + if ctxt.Arch.Family == sys.ARM64 && buildcfg.GOOS == "freebsd" { + // Switch to ld.bfd on freebsd/arm64. +-- +2.25.1 + diff --git a/recipes-devtools/go/go_1.24.4.bb b/recipes-devtools/go/go_1.24.4.bb new file mode 100644 index 0000000000000000000000000000000000000000..75aca6f650298dbd5f24f4c1dcb4cdc20be625c6 --- /dev/null +++ b/recipes-devtools/go/go_1.24.4.bb @@ -0,0 +1,20 @@ +require go-${PV}.inc +require go-target.inc + +inherit linuxloader + +CGO_LDFLAGS:append = " -no-pie" + +export GO_LDSO = "${@get_linuxloader(d)}" +export CC_FOR_TARGET = "gcc" +export CXX_FOR_TARGET = "g++" + +PROVIDES += "golang==${PV}" + +# 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') or 'riscv32' in d.getVar('TARGET_ARCH'): + d.appendVar('INSANE_SKIP:%s' % d.getVar('PN'), " textrel") +} + diff --git a/recipes/chrony-exporter_0.12.0.bb b/recipes/chrony-exporter_0.12.1.bb similarity index 97% rename from recipes/chrony-exporter_0.12.0.bb rename to recipes/chrony-exporter_0.12.1.bb index 9fac602a572f8882bca6d0fcbcf6b034745a9f77..c82976cfaeb548e3cc5fc5d8651dd27fbcd41266 100644 --- a/recipes/chrony-exporter_0.12.0.bb +++ b/recipes/chrony-exporter_0.12.1.bb @@ -11,7 +11,7 @@ SRC_URI = " \ file://files/chrony_exporter.socket \ file://files/chrony_exporter.sysconfig \ " -SRCREV = "f95d00763f6291742e51326402102ffd68d6d5cf" +SRCREV = "3d4d40f6ada1f43e9c9194b5ddc01f522a6e98c4" GO_IMPORT = "github.com/SuperQ/chrony_exporter" GO_INSTALL = "src/${GO_IMPORT}/" diff --git a/recipes/consul-exporter_0.13.0.bb b/recipes/consul-exporter_0.13.0.bb new file mode 100644 index 0000000000000000000000000000000000000000..3ec0bc29a15731c947c2742f1c4d197aba960b7c --- /dev/null +++ b/recipes/consul-exporter_0.13.0.bb @@ -0,0 +1,47 @@ +SUMMARY = "Export Consul service health to Prometheus." +HOMEPAGE = "https://github.com/prometheus/consul_exporter" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${S}/${GO_INSTALL}/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" +SRC_URI = " \ + git://github.com/prometheus/consul_exporter.git;branch=release-1.8;protocol=https \ + file://files/consul_exporter.service \ + file://files/consul_exporter.socket \ + file://files/consul_exporter.sysconfig \ +" +SRCREV = "11bf27e69dc302f4004bd67cb1ee3c0bf3832929" + +GO_IMPORT = "github.com/prometheus/consul_exporter" +GO_INSTALL = "src/${GO_IMPORT}/" + +inherit go go-mod + +export GO111MODULE = "on" +export GOPROXY = "https://proxy.golang.org" + +FILES:${PN} += "\ + ${systemd_unitdir}/system/consul_exporter.service \ + ${systemd_unitdir}/system/consul_exporter.socket \ + ${systemd_unitdir}/system/multi-user.target.wants/consul_exporter.service \ + ${systemd_unitdir}/system/sockets.target.wants/consul_exporter.socket \ + ${sysconfdir}/sysconfig/consul_exporter \ +" + +USERADD_PACKAGES = "${PN}" +USERADD_PARAM:${PN} = "--system --no-create-home --user-group --home-dir ${sysconfdir}/${BPN}-1 --shell /bin/nologin consul_exporter" + +do_install() { + install -Dm755 bin/linux_arm64/consul_exporter ${D}${bindir}/consul_exporter + + install -Dm644 ${WORKDIR}/files/consul_exporter.service ${D}${systemd_unitdir}/system/consul_exporter.service + install -d ${D}${systemd_unitdir}/system/multi-user.target.wants + ln -sf ../consul_exporter.service ${D}${systemd_unitdir}/system/multi-user.target.wants/consul_exporter.service + + install -Dm644 ${WORKDIR}/files/consul_exporter.socket ${D}${systemd_unitdir}/system/consul_exporter.socket + install -d ${D}${systemd_unitdir}/system/sockets.target.wants + ln -sf ../consul_exporter.socket ${D}${systemd_unitdir}/system/sockets.target.wants/consul_exporter.socket + + install -Dm644 ${WORKDIR}/files/consul_exporter.sysconfig ${D}${sysconfdir}/sysconfig/consul_exporter +} diff --git a/recipes/files/consul_exporter.service b/recipes/files/consul_exporter.service new file mode 100644 index 0000000000000000000000000000000000000000..e5a58c6adc6fd7266dc2fb0ec3a33eebad13ddd4 --- /dev/null +++ b/recipes/files/consul_exporter.service @@ -0,0 +1,11 @@ +[Unit] +Description=Consul Exporter +Requires=consul_exporter.socket + +[Service] +User=consul_exporter +EnvironmentFile=/etc/sysconfig/consul_exporter +ExecStart=/usr/sbin/consul_exporter --web.systemd-socket $OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/recipes/files/consul_exporter.socket b/recipes/files/consul_exporter.socket new file mode 100644 index 0000000000000000000000000000000000000000..0589c46858f772d6cfc9391e87749bb6527b7661 --- /dev/null +++ b/recipes/files/consul_exporter.socket @@ -0,0 +1,8 @@ +[Unit] +Description=Consul Exporter + +[Socket] +ListenStream=9107 + +[Install] +WantedBy=sockets.target diff --git a/recipes/files/consul_exporter.sysconfig b/recipes/files/consul_exporter.sysconfig new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/recipes/node-exporter_1.9.1.bb b/recipes/node-exporter_1.9.1.bb index 83d5f5149667bbeba88bacc4e044e3220f7d032b..d8e221124bc954a08641d875dc955db93a36d913 100644 --- a/recipes/node-exporter_1.9.1.bb +++ b/recipes/node-exporter_1.9.1.bb @@ -6,12 +6,12 @@ LIC_FILES_CHKSUM = "file://${S}/${GO_INSTALL}/LICENSE;md5=86d3f3a95c324c9479bd89 FILESEXTRAPATHS:prepend := "${THISDIR}:" SRC_URI = " \ - git://github.com/prometheus/node_exporter.git;branch=release-1.8;protocol=https \ + git://github.com/prometheus/node_exporter.git;branch=release-1.9;protocol=https \ file://files/node_exporter.service \ file://files/node_exporter.socket \ file://files/node_exporter.sysconfig \ " -SRCREV = "f1e0e8360aa60b6cb5e5cc1560bed348fc2c1895" +SRCREV = "f2ec547b49af53815038a50265aa2adcd1275959" GO_IMPORT = "github.com/prometheus/node_exporter" GO_INSTALL = "src/${GO_IMPORT}/"