eclass/linux-mod-r1: Sync with Gentoo

It's from Gentoo commit 8dd431f54fa807b44b23777066a2284c685a51f2.
This commit is contained in:
Flatcar Buildbot 2025-06-16 07:10:27 +00:00 committed by Krzesimir Nowak
parent 9a667a4359
commit 74faaae76a

View File

@ -351,6 +351,8 @@ linux-mod-r1_pkg_setup() {
_modules_set_makeargs
_modules_prepare_cross
_modules_sanity_gccplugins
}
@ -668,6 +670,36 @@ _modules_check_migration() {
# - ECONF_PARAMS: documented but was a no-op in linux-mod too
}
# @FUNCTION: _modules_prepare_cross
# @INTERNAL
# @DESCRIPTION:
# Checks whether modpost works locally as it might have been built for a
# different architecture. If it doesn't work, it is built in a new
# environment and KV_OUT_DIR is repointed there.
_modules_prepare_cross() {
# modpost should do nothing successfully when called without args.
if ! "${KV_OUT_DIR}"/scripts/mod/modpost &>/dev/null; then
# Try to run make modules_prepare in a new separate output directory.
# This cannot be done if the source directory is not clean. In that
# case, copy the whole source directory.
if [[ -e ${KV_DIR}/.config ]]; then
cp -rLT --reflink=auto -- "${KV_DIR}" "${WORKDIR}"/extmod-build || die
emake -C "${WORKDIR}"/extmod-build "${MODULES_MAKEARGS[@]}" modules_prepare \
KBUILD_OUTPUT=
else
mkdir -- "${WORKDIR}"/extmod-build || die
cp -- "${KV_OUT_DIR}"/{.config,Module.symvers} "${WORKDIR}"/extmod-build || die
# KV_OUT_DIR may have been prepared with install-extmod-build, which
# doesn't include all the files needed to call make modules_prepare,
# so use the Makefile from the full kernel sources.
emake -C "${WORKDIR}"/extmod-build "${MODULES_MAKEARGS[@]}" modules_prepare \
KBUILD_OUTPUT="${WORKDIR}"/extmod-build -f "${KERNEL_MAKEFILE}"
fi
KV_OUT_DIR=${WORKDIR}/extmod-build
KBUILD_OUTPUT=${KBUILD_OUTPUT+${KV_OUT_DIR}}
fi
}
# @FUNCTION: _modules_prepare_kernel
# @INTERNAL
# @DESCRIPTION:
@ -1259,6 +1291,7 @@ _modules_set_makeargs() {
# unrealistic when building modules that often have slow releases,
# but note that the kernel will still pass some -Werror=bad-thing
CONFIG_WERROR=
CONFIG_OBJTOOL_WERROR=
# these are only needed if using these arguments for installing, lets
# eclass handle strip, sign, compress, and depmod (CONFIG_ should