From 31cfacb1749776bf0c2b2bc16c5d5ec065d3977a Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 5 Jul 2024 14:19:11 +0100 Subject: [PATCH 1/8] Stop trying to create lib->lib64 symlink We stopped using profiles with a lib->lib64 symlink a while ago, so there is no point in checking for this any more. We weren't checking against the target SDK architecture anyway. Signed-off-by: James Le Cuirot --- bootstrap_sdk | 11 +---------- build_library/set_lsb_release | 1 + build_library/toolchain_util.sh | 4 ---- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/bootstrap_sdk b/bootstrap_sdk index 834506ee6d2..0c636beda2b 100755 --- a/bootstrap_sdk +++ b/bootstrap_sdk @@ -65,16 +65,7 @@ ROOT_OVERLAY=${TEMPDIR}/stage4_overlay if [[ "$STAGES" =~ stage4 ]]; then info "Setting release to ${FLATCAR_VERSION}" rm -rf "${ROOT_OVERLAY}" - # need to setup the lib->lib64 symlink correctly - libdir=$(get_sdk_libdir) - mkdir -p "${ROOT_OVERLAY}/usr/${libdir}" - if [[ "${libdir}" != lib ]]; then - if [[ "$(get_sdk_symlink_lib)" == "yes" ]]; then - ln -s "${libdir}" "${ROOT_OVERLAY}/usr/lib" - else - mkdir -p "${ROOT_OVERLAY}/usr/lib" - fi - fi + mkdir -p "${ROOT_OVERLAY}" "${BUILD_LIBRARY_DIR}/set_lsb_release" \ --root "${ROOT_OVERLAY}" fi diff --git a/build_library/set_lsb_release b/build_library/set_lsb_release index 17d7c186e26..2323a0ae774 100755 --- a/build_library/set_lsb_release +++ b/build_library/set_lsb_release @@ -42,6 +42,7 @@ sudo ln -sf "../usr/share/flatcar/lsb-release" "${ROOT_FS_DIR}/etc/lsb-release" # And the new standard, os-release # https://www.freedesktop.org/software/systemd/man/os-release.html +sudo mkdir -p "${ROOT_FS_DIR}/usr/lib" sudo_clobber "${ROOT_FS_DIR}/usr/lib/os-release" < Date: Fri, 5 Jul 2024 15:05:53 +0100 Subject: [PATCH 2/8] Stop creating /usr/lib64/os-release compatibility symlink We currently put an os-release symlink in lib64, but we shouldn't assume that the architecture will even have a lib64 directory. I doubt this compatibility symlink was needed anyway. Gentoo doesn't have one, and applications are supposed to check /etc/os-release. I can find almost no reference to /usr/lib64/os-release anywhere, let alone in Flatcar. Signed-off-by: James Le Cuirot --- build_library/set_lsb_release | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build_library/set_lsb_release b/build_library/set_lsb_release index 2323a0ae774..dbe64d335bc 100755 --- a/build_library/set_lsb_release +++ b/build_library/set_lsb_release @@ -61,10 +61,6 @@ CPE_NAME="cpe:2.3:o:${BRANDING_OS_ID}-linux:${BRANDING_OS_ID}_linux:${FLATCAR_VE EOF sudo ln -sf "../usr/lib/os-release" "${ROOT_FS_DIR}/etc/os-release" sudo ln -sf "../../lib/os-release" "${ROOT_FS_DIR}/usr/share/flatcar/os-release" -# Compat for split of lib64 into lib and lib64 -if [ ! -e "${ROOT_FS_DIR}/usr/lib64/os-release" ]; then - sudo ln -sf "../lib/os-release" "${ROOT_FS_DIR}/usr/lib64/os-release" -fi # Create the defaults for the coreos configuration files in the usr directory sudo_clobber "${ROOT_FS_DIR}/usr/share/flatcar/release" < Date: Mon, 15 Jul 2024 12:03:01 +0100 Subject: [PATCH 3/8] Support building the SDK for arm64 Catalyst 4 adds support for building with QEMU, so I initially leveraged this, but it turned out to be very much slower than emulating the amd64 SDK on arm64, where an arm64 build could then be mostly run without emulation. I have kept the code for the slower approach anyway since it is small and may be useful to somebody. There were several places where we assumed that amd64 was native and arm64 required emulation via QEMU. The scripts are now more architecture-agnostic, paving the way for riscv support later. We no longer set QEMU_LD_PREFIX because it prevents the SDK itself from being emulated. It also assumes there is only one non-native target, which may not always be the case. bubblewrap does a better job of running binaries under QEMU. Signed-off-by: James Le Cuirot --- build_library/build_image_util.sh | 29 +++----------- build_library/catalyst.sh | 15 ++++++++ build_library/portage/env/releng/qemu | 1 + build_library/portage/package.env/qemu | 1 + build_library/prod_image_util.sh | 1 + common.sh | 38 ------------------- .../coreos/config/env/dev-lang/rust | 3 +- .../profiles/coreos/amd64/sdk/package.use | 3 ++ .../profiles/coreos/arm64/sdk/package.use | 3 ++ .../coreos/arm64/sdk/transition/parent | 2 + .../profiles/coreos/targets/sdk/make.defaults | 6 --- .../profiles/coreos/targets/sdk/package.use | 2 +- setup_board | 26 ++++++++++--- 13 files changed, 54 insertions(+), 76 deletions(-) create mode 100644 build_library/portage/env/releng/qemu create mode 100644 build_library/portage/package.env/qemu create mode 100644 sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/package.use create mode 100644 sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/transition/parent diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index e87f3d34934..2dac5608fd4 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -102,32 +102,13 @@ zip_update_tools() { --arch "$(get_sdk_arch)" --output-dir "${BUILD_DIR}" --zip-name "${update_zip}" } -# ldconfig cannot generate caches for non-native arches. -# Use qemu & the native ldconfig to work around that. -# http://code.google.com/p/chromium/issues/detail?id=378377 run_ldconfig() { - local root_fs_dir=$1 - case ${ARCH} in - arm64) - sudo qemu-aarch64 "${root_fs_dir}"/usr/sbin/ldconfig -r "${root_fs_dir}";; - x86|amd64) - sudo ldconfig -r "${root_fs_dir}";; - *) - die "Unable to run ldconfig for ARCH ${ARCH}" - esac + # This wrapper is created by setup_board. + sudo "ldconfig-${BOARD}" -r "$1" } run_localedef() { - local root_fs_dir="$1" loader=() - case ${ARCH} in - arm64) - loader=( qemu-aarch64 -L "${root_fs_dir}" );; - amd64) - loader=( "${root_fs_dir}/usr/lib64/ld-linux-x86-64.so.2" \ - --library-path "${root_fs_dir}/usr/lib64" );; - *) - die "Unable to run localedef for ARCH ${ARCH}";; - esac + local root_fs_dir="$1" info "Generating C.UTF-8 locale..." local i18n="${root_fs_dir}/usr/share/i18n" # localedef will silently fall back to /usr/share/i18n if missing so @@ -135,8 +116,8 @@ run_localedef() { [[ -f "${i18n}/charmaps/UTF-8.gz" ]] || die [[ -f "${i18n}/locales/C" ]] || die sudo mkdir -p "${root_fs_dir}/usr/lib/locale" - sudo I18NPATH="${i18n}" "${loader[@]}" "${root_fs_dir}/usr/bin/localedef" \ - --prefix="${root_fs_dir}" --charmap=UTF-8 --inputfile=C C.UTF-8 + sudo I18NPATH="${i18n}" "bwrap-${BOARD}" "${root_fs_dir}" /usr/bin/localedef \ + --charmap=UTF-8 --inputfile=C C.UTF-8 } # Basic command to emerge binary packages into the target image. diff --git a/build_library/catalyst.sh b/build_library/catalyst.sh index 3e792417bed..c4055cee63a 100644 --- a/build_library/catalyst.sh +++ b/build_library/catalyst.sh @@ -25,6 +25,7 @@ BINPKGS= DISTDIR= TEMPDIR= STAGES= +unset QEMU DEFINE_string catalyst_root "${DEFAULT_CATALYST_ROOT}" \ "Path to directory for all catalyst images and other files." @@ -97,6 +98,7 @@ cflags: -O2 -pipe cxxflags: -O2 -pipe ldflags: -Wl,-O2 -Wl,--as-needed source_subpath: ${SEED} +${QEMU+interpreter: $(type -P "${QEMU}")} EOF } @@ -207,6 +209,16 @@ catalyst_init() { SEED="seed/${FLAGS_seed_tarball##*/}" SEED="${SEED%.tar.*}" fi + + # Emulate the build, if needed. Note the SDK itself may already be emulated, + # so check the requested arch against the kernel's real arch, not uname -m. + if [[ ${ARCH} != $(get_portage_arch "$(< /proc/sys/kernel/arch)") ]]; then + case "${ARCH}" in + amd64) QEMU=qemu-x86_64 ;; + arm64) QEMU=qemu-aarch64 ;; + riscv) QEMU=qemu-riscv64 ;; + esac + fi } write_configs() { @@ -226,6 +238,9 @@ write_configs() { ln -sfT '/mnt/host/source/src/third_party/coreos-overlay/coreos/user-patches' \ "${TEMPDIR}"/portage/patches + + [[ -n ${QEMU} ]] || + rm "${TEMPDIR}"/portage/package.env/qemu } build_stage() { diff --git a/build_library/portage/env/releng/qemu b/build_library/portage/env/releng/qemu new file mode 100644 index 00000000000..de86517db4d --- /dev/null +++ b/build_library/portage/env/releng/qemu @@ -0,0 +1 @@ +FEATURES="-pid-sandbox -network-sandbox -ipc-sandbox" diff --git a/build_library/portage/package.env/qemu b/build_library/portage/package.env/qemu new file mode 100644 index 00000000000..60c290a8ba7 --- /dev/null +++ b/build_library/portage/package.env/qemu @@ -0,0 +1 @@ +*/* releng/qemu diff --git a/build_library/prod_image_util.sh b/build_library/prod_image_util.sh index b6d760fba2a..d45936f06da 100755 --- a/build_library/prod_image_util.sh +++ b/build_library/prod_image_util.sh @@ -139,6 +139,7 @@ create_prod_image() { sudo rm -rf "${BUILD_DIR}/root_fs_dir2" # clean-ups of things we do not need + sudo find ${root_fs_dir}/usr/bin -empty -delete # Bind mounts created by bwrap sudo rm ${root_fs_dir}/etc/csh.env sudo rm -rf ${root_fs_dir}/etc/env.d sudo rm -rf ${root_fs_dir}/usr/include diff --git a/common.sh b/common.sh index 3dbb8040dc3..0cff99ed563 100644 --- a/common.sh +++ b/common.sh @@ -51,9 +51,6 @@ fi # Turn on bash debug support if available for backtraces. shopt -s extdebug 2>/dev/null -# Source qemu library path -. /etc/profile.d/qemu-aarch64.sh 2> /dev/null || true - # Output a backtrace all the way back to the raw invocation, suppressing # only the _dump_trace frame itself. _dump_trace() { @@ -992,38 +989,3 @@ BOAT echo -e "${V_VIDOFF}" die "$* failed" } - -# The binfmt_misc support in the kernel is required. -# The aarch64 binaries should be executed through -# "/usr/bin/qemu-aarch64-static" -setup_qemu_static() { - local root_fs_dir="$1" - case "${BOARD}" in - amd64-usr) return 0;; - arm64-usr) - if [[ -f "${root_fs_dir}/sbin/ldconfig" ]]; then - sudo cp /usr/bin/qemu-aarch64 "${root_fs_dir}"/usr/bin/qemu-aarch64-static - echo export QEMU_LD_PREFIX=\"/build/arm64-usr/\" | sudo tee /etc/profile.d/qemu-aarch64.sh - . /etc/profile.d/qemu-aarch64.sh - else - die "Missing basic layout in target rootfs" - fi - ;; - *) die "Unsupported arch" ;; - esac -} - -clean_qemu_static() { - local root_fs_dir="$1" - case "${BOARD}" in - amd64-usr) return 0;; - arm64-usr) - if [[ -f "${root_fs_dir}/usr/bin/qemu-aarch64-static" ]]; then - sudo rm "${root_fs_dir}"/usr/bin/qemu-aarch64-static - else - die "File not found" - fi - ;; - *) die "Unsupported arch" ;; - esac -} diff --git a/sdk_container/src/third_party/coreos-overlay/coreos/config/env/dev-lang/rust b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/dev-lang/rust index c467aedeada..d72efdb3d5e 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos/config/env/dev-lang/rust +++ b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/dev-lang/rust @@ -2,5 +2,6 @@ INSTALL_MASK+=" *rustdoc*" I_KNOW_WHAT_I_AM_DOING_CROSS=1 RUST_CROSS_TARGETS=( - $(aarch64-cros-linux-gnu-gcc --version >/dev/null && echo "AArch64:aarch64-unknown-linux-gnu:aarch64-cros-linux-gnu") + $(use arm64 || { aarch64-cros-linux-gnu-gcc --version &>/dev/null && echo "AArch64:aarch64-unknown-linux-gnu:aarch64-cros-linux-gnu"; }) + $(use amd64 || { x86_64-cros-linux-gnu-gcc --version &>/dev/null && echo "X86:x86_64-unknown-linux-gnu:x86_64-cros-linux-gnu" ; }) ) diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/sdk/package.use b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/sdk/package.use index e69de29bb2d..21b5b3ee045 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/sdk/package.use +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/sdk/package.use @@ -0,0 +1,3 @@ +# Don't build the user space emulator for this arch. It's not needed and gets in +# the way when using Catalyst with QEMU. +app-emulation/qemu -qemu_user_targets_x86_64 diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/package.use b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/package.use new file mode 100644 index 00000000000..c3e3f1eaed4 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/package.use @@ -0,0 +1,3 @@ +# Don't build the user space emulator for this arch. It's not needed and gets in +# the way when using Catalyst with QEMU. +app-emulation/qemu -qemu_user_targets_aarch64 diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/transition/parent b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/transition/parent new file mode 100644 index 00000000000..627544f8c19 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/arm64/sdk/transition/parent @@ -0,0 +1,2 @@ +.. +:coreos/targets/sdk/transition diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/make.defaults b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/make.defaults index 3fb2f4e9a72..5a6fa0111d9 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/make.defaults +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/make.defaults @@ -5,12 +5,6 @@ USE="cros_host expat man -pam" # Enable CPU architectures needed by Rust builds LLVM_TARGETS="X86 AArch64" -# Both x86_64 and i386 targets are required for grub testing -QEMU_SOFTMMU_TARGETS="x86_64 i386 aarch64" - -# For cross build support. -QEMU_USER_TARGETS="aarch64" - # add cros_host to bootstrapping USE flags so SDK / toolchains bootstrapping # will use vim's vimrc instead of baselayouts', BOOTSTRAP_USE="$BOOTSTRAP_USE cros_host" diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/package.use b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/package.use index 641b433bda1..2108e23b8b9 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/package.use +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/package.use @@ -12,7 +12,7 @@ app-crypt/gnupg smartcard usb # for qemu app-arch/bzip2 static-libs -app-emulation/qemu -doc -jpeg ncurses python static-user virtfs qemu_softmmu_targets_x86_64 qemu_softmmu_targets_aarch64 +app-emulation/qemu -doc -jpeg ncurses python static-user virtfs qemu_softmmu_targets_aarch64 qemu_softmmu_targets_x86_64 qemu_user_targets_aarch64 qemu_user_targets_x86_64 dev-libs/glib static-libs dev-libs/libaio static-libs dev-libs/libpcre2 static-libs diff --git a/setup_board b/setup_board index 3924776ca89..9cfbc061bf9 100755 --- a/setup_board +++ b/setup_board @@ -92,6 +92,13 @@ generate_all_wrappers() { # the board arch matches the SDK arch and therefore emulation is unnecessary. qemu=$(type -P "qemu-${BOARD_CHOST%%-*}") || unset qemu + # If emulation is necessary, then we need to create a placeholder to bind + # mount QEMU onto now. This avoids needing root to do it later. + if [[ -n ${qemu-} ]]; then + sudo mkdir -p "${BOARD_ROOT}${qemu%/*}" + sudo touch "${BOARD_ROOT}${qemu}" + fi + info "Generating wrapper scripts" for wrapper in emerge ebuild eclean equery portageq \ @@ -113,8 +120,20 @@ exec ${BOARD_CHOST}-gdb -iex 'set sysroot ${BOARD_ROOT}' "\$@" EOF wrappers+=( "${wrapper}" ) + # A general purpose wrapper for effectively chrooting using bubblewrap, + # together with emulation by QEMU if necessary. + wrapper="/usr/local/bin/bwrap-${BOARD_VARIANT}" + sudo_clobber "${wrapper}" < "$GCLIENT_ROOT/src/scripts/.default_board" fi From 4c22eca9251a118d4b21332b3fc1e2dc05ad7959 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Thu, 22 May 2025 15:20:28 +0100 Subject: [PATCH 4/8] profiles: We don't use wrappers in the board sysroot anymore Signed-off-by: James Le Cuirot --- .../coreos-overlay/profiles/coreos/base/profile.bashrc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/profile.bashrc b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/profile.bashrc index 6165f45d053..b8dfb442218 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/profile.bashrc +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/profile.bashrc @@ -1,8 +1,6 @@ # Dumping ground for build-time helpers to utilize since SYSROOT/tmp/ # can be nuked at any time. CROS_BUILD_BOARD_TREE="${SYSROOT}/build" -CROS_BUILD_BOARD_BIN="${CROS_BUILD_BOARD_TREE}/bin" - CROS_ADDONS_TREE="/mnt/host/source/src/third_party/coreos-overlay/coreos" # Are we merging for the board sysroot, or for the SDK, or for @@ -118,12 +116,6 @@ cros_setup_hooks() { } cros_setup_hooks -# Since we're storing the wrappers in a board sysroot, make sure that -# is actually in our PATH. -cros_pre_pkg_setup_sysroot_build_bin_dir() { - PATH+=":${CROS_BUILD_BOARD_BIN}" -} - # Avoid modifications of the preexisting users - these are provided by # our baselayout and usermod can't change anything there anyway (it # complains that the user is not in /etc/passwd). From acee470d2a309abf5dbd32362e68eccc71ad2708 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Mon, 23 Feb 2026 18:11:58 +0000 Subject: [PATCH 5/8] sys-apps/iucode_tool: Use unstable 2.3.1-r2 for a cross-compile fix Signed-off-by: James Le Cuirot --- .../profiles/coreos/base/package.accept_keywords | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.accept_keywords b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.accept_keywords index da882263582..10369819597 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.accept_keywords +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.accept_keywords @@ -137,3 +137,6 @@ sys-apps/azure-vm-utils # Our own ebuild fixing issues in Gentoo, hopefully will be fixed # there too eventually. =sys-libs/libselinux-3.8.1-r3 ~amd64 ~arm64 + +# Needed to build this amd64-specific package on other arches. +=sys-apps/iucode_tool-2.3.1-r2 ~amd64 ~arm64 From 26f37b2cf24ae84483ede7d94a662fc39c70b345 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 13 Mar 2026 09:48:34 +0000 Subject: [PATCH 6/8] eclasses: Sync with Gentoo Signed-off-by: James Le Cuirot --- .../portage-stable/eclass/go-env.eclass | 113 +++++++++++++----- .../portage-stable/eclass/go-module.eclass | 15 +-- .../eclass/toolchain-funcs.eclass | 4 +- 3 files changed, 83 insertions(+), 49 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass b/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass index b2b240b5ef2..3dca4ffc39c 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass @@ -1,4 +1,4 @@ -# Copyright 2023-2025 Gentoo Authors +# Copyright 2023-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: go-env.eclass @@ -20,7 +20,7 @@ esac if [[ -z ${_GO_ENV_ECLASS} ]]; then _GO_ENV_ECLASS=1 -inherit flag-o-matic toolchain-funcs +inherit flag-o-matic multiprocessing toolchain-funcs # @FUNCTION: go-env_set_compile_environment # @DESCRIPTION: @@ -33,35 +33,63 @@ inherit flag-o-matic toolchain-funcs # (e.g. "emerge-aarch64-cross-linux-gnu foo" run on x86_64 will emerge "foo" for x86_64 # instead of aarch64) go-env_set_compile_environment() { - tc-export CC CXX PKG_CONFIG + tc-export AR CC CXX FC PKG_CONFIG + + # The following GOFLAGS should be used for all builds. + # -x prints commands as they are executed + # -v prints the names of packages as they are compiled + # -modcacherw makes the build cache read/write + # -buildvcs=false omits version control information + # -buildmode=pie builds position independent executables + export \ + GOFLAGS="-x -v -modcacherw -buildvcs=false" \ + GOMAXPROCS=$(get_makeopts_jobs) \ + GOARCH=$(go-env_goarch) \ + GOOS=$(go-env_goos) + + case ${GOARCH} in + 386|amd64|arm*|ppc64le|s390*) GOFLAGS+=" -buildmode=pie" ;; + esac + + case ${GOARCH} in + 386) export GO386=$(go-env_go386) ;; + arm|armbe) export GOARM=$(go-env_goarm) ;; + mips64*) export GOMIPS64=$(go-env_gomips) ;; + mips*) export GOMIPS=$(go-env_gomips) ;; + esac - export GOARCH="$(go-env_goarch)" - use arm && export GOARM=$(go-env_goarm) - use x86 && export GO386=$(go-env_go386) + # Don't modify the non-Go variables outside this function. + local -I $(all-flag-vars) - # XXX: Hack for checking ICE (bug #912152, gcc PR113204) if tc-is-gcc ; then + # XXX: Hack for checking ICE (bug #912152, gcc PR113204) # For either USE=debug or an unreleased compiler, non-default # checking will trigger. - if has_version -b "sys-devel/gcc[debug]" || [[ $(gcc-minor-version) -eq 0 ]] ; then - filter-lto - fi + $(tc-getCC) -v 2>&1 | grep -Eqe "--enable-checking=\S*\byes\b" && filter-lto + + # bug #929219 + replace-flags -g3 -g + replace-flags -ggdb3 -ggdb fi - export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}" - export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}" - export CGO_CXXFLAGS="${CGO_CXXFLAGS:-$CXXFLAGS}" - export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}" + export \ + CGO_CFLAGS=${CFLAGS} \ + CGO_CPPFLAGS=${CPPFLAGS} \ + CGO_CXXFLAGS=${CXXFLAGS} \ + CGO_LDFLAGS=${LDFLAGS} +} - # bug #929219 - if tc-is-gcc ; then - CGO_CFLAGS=$( - CFLAGS=${CGO_CFLAGS} - replace-flags -g3 -g - replace-flags -ggdb3 -ggdb - printf %s "${CFLAGS}" - ) - fi +# @FUNCTION: go-env_run +# @DESCRIPTION: +# Run the given command under a localised environment configured by +# go-env_set_compile_environment(). +go-env_run() { + local -I AR CC CXX FC PKG_CONFIG \ + GO{FLAGS,MAXPROCS,ARCH,386,ARM,MIPS,MIPS64} \ + CGO_{CFLAGS,CPPFLAGS,CXXFLAGS,LDFLAGS} + + go-env_set_compile_environment + "${@}" } # @FUNCTION: go-env_goos @@ -129,19 +157,38 @@ go-env_go386() { } # @FUNCTION: go-env_goarm -# @USAGE: [CHOST-value] +# @USAGE: [tuple] # @DESCRIPTION: -# Returns the appropriate GOARM setting for the CHOST given, or the default -# CHOST. +# Returns the appropriate GOARM setting for given target or CHOST. go-env_goarm() { - case "${1:-${CHOST}}" in - armv5*) echo 5;; - armv6*) echo 6;; - armv7*) echo 7;; - *) - die "unknown GOARM for ${1:-${CHOST}}" - ;; + local CTARGET=${1:-${CHOST}} + + case ${CTARGET} in + armv5*) echo -n 5 ;; + armv6*) echo -n 6 ;; + armv7*) echo -n 7 ;; + *) die "unknown GOARM for ${CTARGET}" ;; esac + + if [[ $(tc-is-softfloat) == no ]]; then + echo ,hardfloat + else + echo ,softfloat + fi +} + +# @FUNCTION: go-env_gomips +# @USAGE: [tuple] +# @DESCRIPTION: +# Returns the appropriate GOMIPS or GOMIPS64 setting for given target or CHOST. +go-env_gomips() { + local CTARGET=${1:-${CHOST}} + + if [[ $(tc-is-softfloat) == no ]]; then + echo hardfloat + else + echo softfloat + fi } fi diff --git a/sdk_container/src/third_party/portage-stable/eclass/go-module.eclass b/sdk_container/src/third_party/portage-stable/eclass/go-module.eclass index 2399fb56e9a..5294f50d8ad 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/go-module.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/go-module.eclass @@ -68,7 +68,7 @@ esac if [[ -z ${_GO_MODULE_ECLASS} ]]; then _GO_MODULE_ECLASS=1 -inherit multiprocessing toolchain-funcs go-env +inherit toolchain-funcs go-env if [[ ! ${GO_OPTIONAL} ]]; then BDEPEND=">=dev-lang/go-1.20:=" @@ -93,14 +93,6 @@ export GOCACHE="${T}/go-build" # See "go help environment" for information on this setting export GOMODCACHE="${WORKDIR}/go-mod" -# The following go flags should be used for all builds. -# -buildmode=pie builds position independent executables -# -buildvcs=false omits version control information -# -modcacherw makes the build cache read/write -# -v prints the names of packages as they are compiled -# -x prints commands as they are executed -export GOFLAGS="-buildvcs=false -modcacherw -v -x" - # Do not complain about CFLAGS etc since go projects do not use them. QA_FLAGS_IGNORED='.*' @@ -362,11 +354,6 @@ go-module_setup_proxy() { # 3. Otherwise, call 'ego mod verify' and then do a normal unpack. # Set compile env via go-env. go-module_src_unpack() { - if use amd64 || use arm || use arm64 || - ( use ppc64 && [[ $(tc-endian) == "little" ]] ) || use s390 || use x86; then - GOFLAGS="-buildmode=pie ${GOFLAGS}" - fi - GOFLAGS="${GOFLAGS} -p=$(makeopts_jobs)" if [[ "${#EGO_SUM[@]}" -gt 0 ]]; then eqawarn "QA Notice: This ebuild uses EGO_SUM which is deprecated" eqawarn "Please migrate to a dependency tarball" diff --git a/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass b/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass index 89da26b867b..2b57fc11870 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass @@ -402,6 +402,7 @@ tc-env_build() { PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \ RANLIB=$(tc-getBUILD_RANLIB) \ READELF=$(tc-getBUILD_READELF) \ + CHOST=${CBUILD:-${CHOST}} \ "$@" } @@ -445,8 +446,7 @@ tc-env_build() { # @CODE econf_build() { local CBUILD=${CBUILD:-${CHOST}} - econf_env() { CHOST=${CBUILD} econf "$@"; } - tc-env_build econf_env "$@" + tc-env_build econf "$@" } # @FUNCTION: tc-ld-is-bfd From 0bec7ab7b0ad3ae7bde208c10bf483343c2f31aa Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 13 Mar 2026 09:51:21 +0000 Subject: [PATCH 7/8] app-containers/containerd: Sync with Gentoo Signed-off-by: James Le Cuirot --- .../app-containers/containerd/containerd-2.2.1.ebuild | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/app-containers/containerd/containerd-2.2.1.ebuild b/sdk_container/src/third_party/portage-stable/app-containers/containerd/containerd-2.2.1.ebuild index d89df32ae78..f54c461b036 100644 --- a/sdk_container/src/third_party/portage-stable/app-containers/containerd/containerd-2.2.1.ebuild +++ b/sdk_container/src/third_party/portage-stable/app-containers/containerd/containerd-2.2.1.ebuild @@ -63,16 +63,10 @@ src_compile() { VERSION=v${PV} ) - # The Go env is already set, but reset it for CBUILD in a subshell to allow - # building the man pages when cross-compiling. - ( - CHOST="${CBUILD}" go-env_set_compile_environment - # race condition in man target https://bugs.gentoo.org/765100 - tc-env_build emake "${myemakeargs[@]}" man -j1 #nowarn - ) - emake "${myemakeargs[@]}" all + # race condition in man target https://bugs.gentoo.org/765100 + tc-env_build go-env_run emake "${myemakeargs[@]}" man -j1 #nowarn } src_install() { From 23b84073ea79f992f1c173c44300f0eb616189ed Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 13 Mar 2026 09:53:21 +0000 Subject: [PATCH 8/8] app-containers/docker-cli: Sync with Gentoo and backport fix to stable Signed-off-by: James Le Cuirot --- .../docker-cli/docker-cli-28.4.0.ebuild | 18 +++++++++--------- .../docker-cli/docker-cli-29.1.3.ebuild | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-28.4.0.ebuild b/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-28.4.0.ebuild index 67619a487c9..058f0fcb4e5 100644 --- a/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-28.4.0.ebuild +++ b/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-28.4.0.ebuild @@ -3,7 +3,7 @@ EAPI=8 -inherit shell-completion go-module +inherit shell-completion go-env go-module toolchain-funcs MY_PV=${PV/_/-} # update this on every bump @@ -43,14 +43,14 @@ src_prepare() { src_compile() { export DISABLE_WARN_OUTSIDE_CONTAINER=1 - # setup CFLAGS and LDFLAGS for separate build target - # see https://github.com/tianon/docker-overlay/pull/10 - CGO_CFLAGS+=" -I${ESYSROOT}/usr/include" - CGO_LDFLAGS+=" -L${ESYSROOT}/usr/$(get_libdir)" - emake \ - VERSION="${PV}" \ - GITCOMMIT="${GIT_COMMIT}" \ - dynbinary manpages + + myemakeargs=( + VERSION="${PV}" + GITCOMMIT="${GIT_COMMIT}" + ) + + emake "${myemakeargs[@]}" dynbinary + tc-env_build go-env_run emake "${myemakeargs[@]}" manpages } src_install() { diff --git a/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-29.1.3.ebuild b/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-29.1.3.ebuild index b2243019f9d..54a36776e73 100644 --- a/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-29.1.3.ebuild +++ b/sdk_container/src/third_party/portage-stable/app-containers/docker-cli/docker-cli-29.1.3.ebuild @@ -3,7 +3,7 @@ EAPI=8 -inherit shell-completion go-module +inherit shell-completion go-env go-module toolchain-funcs MY_PV=${PV/_/-} # update this on every bump @@ -32,14 +32,14 @@ src_prepare() { src_compile() { export DISABLE_WARN_OUTSIDE_CONTAINER=1 - # setup CFLAGS and LDFLAGS for separate build target - # see https://github.com/tianon/docker-overlay/pull/10 - CGO_CFLAGS+=" -I${ESYSROOT}/usr/include" - CGO_LDFLAGS+=" -L${ESYSROOT}/usr/$(get_libdir)" - emake \ - VERSION="${PV}" \ - GITCOMMIT="${GIT_COMMIT}" \ - dynbinary manpages + + myemakeargs=( + VERSION="${PV}" + GITCOMMIT="${GIT_COMMIT}" + ) + + emake "${myemakeargs[@]}" dynbinary + tc-env_build go-env_run emake "${myemakeargs[@]}" manpages } src_install() {