1

Kbuild fixes for v6.12 (2nd)

- Fix a memory leak in modpost
 
  - Resolve build issues when cross-compiling RPM and Debian packages
 
  - Fix another regression in Kconfig
 
  - Fix incorrect MODULE_ALIAS() output in modpost
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmcnmigVHG1hc2FoaXJv
 eUBrZXJuZWwub3JnAAoJED2LAQed4NsGClEP/1H6H3VPp3s5AYE1elWXXZH4c42Q
 PLJQhNOBFWIaEIbaK/eCMd24vUQl/pb3b80MkeE7XILuQxzeQYIHQ7X1+iYsgDFV
 96wzNP2Z7GpI1JzldWndAKSVMtfIiQHkFhZIwErJRVwDvFyH9ro0Smso5HnwfVql
 ycsGZE4jfTMrMwgobj4WtgOgdBQb6c04w4MCcxgX3f4Zk4YyTlDzLWQMvSWklWVd
 k9mW3T1JSTl5zvHlDK7kuosdXYrUtONleNbiYyxDRFUfKhPeJkiSq5ia/F83VhLL
 Fh7xRNIF7Em9Mzs42if/uuOW2ouq6JuePHFhdf+0rQIyxDFcTIOHojozrYkBPQEb
 MjO/JDLrll2ydfz4Lvreu0JoV3kPW58pM9Re29fYUPTmrtYeZWKS6TS2VfzOEEUs
 Z4xMn1oQuRDR7tnEB2OdPTkaYzlALtMXMyl4/MK6pQ4EiToFth7Syb4W0ILnp1SA
 Dn27yEqIlrWP12B5OceJNzN4QmNySodnFu+K1acSRxCIKAJyfbcF2FTuZuZx5B8P
 6fPHIdYBSOUWSJGDGEqLxLPgcp9zcXLA3MNIx9Lk97m0F5AxLXA+0HCwx7t4KZH9
 fHjcaGJS6LR5Y5bVcu/a7W+MVB3o8+vy6tsnciiBI70MJn0ywqHhDns3Tu+pMP5C
 Rgx1M1GGTOvBWnI2
 =QPqn
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-fixes-v6.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Fix a memory leak in modpost

 - Resolve build issues when cross-compiling RPM and Debian packages

 - Fix another regression in Kconfig

 - Fix incorrect MODULE_ALIAS() output in modpost

* tag 'kbuild-fixes-v6.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  modpost: fix input MODULE_DEVICE_TABLE() built for 64-bit on 32-bit host
  modpost: fix acpi MODULE_DEVICE_TABLE built with mismatched endianness
  kconfig: show sub-menu entries even if the prompt is hidden
  kbuild: deb-pkg: add pkg.linux-upstream.nokerneldbg build profile
  kbuild: deb-pkg: add pkg.linux-upstream.nokernelheaders build profile
  kbuild: rpm-pkg: disable kernel-devel package when cross-compiling
  sumversion: Fix a memory leak in get_src_version()
This commit is contained in:
Linus Torvalds 2024-11-03 08:29:02 -10:00
commit a33ab3f94f
7 changed files with 39 additions and 16 deletions

View File

@ -62,6 +62,10 @@ rpm-sources: linux.tar.gz
PHONY += rpm-pkg srcrpm-pkg binrpm-pkg PHONY += rpm-pkg srcrpm-pkg binrpm-pkg
ifneq ($(CC),$(HOSTCC))
rpm-no-devel = --without=devel
endif
rpm-pkg: private build-type := a rpm-pkg: private build-type := a
srcrpm-pkg: private build-type := s srcrpm-pkg: private build-type := s
binrpm-pkg: private build-type := b binrpm-pkg: private build-type := b
@ -72,7 +76,8 @@ rpm-pkg srcrpm-pkg binrpm-pkg: rpmbuild/SPECS/kernel.spec
--define='_topdir $(abspath rpmbuild)' \ --define='_topdir $(abspath rpmbuild)' \
$(if $(filter a b, $(build-type)), \ $(if $(filter a b, $(build-type)), \
--target $(UTS_MACHINE)-linux --build-in-place --noprep --define='_smp_mflags %{nil}' \ --target $(UTS_MACHINE)-linux --build-in-place --noprep --define='_smp_mflags %{nil}' \
$$(rpm -q rpm >/dev/null 2>&1 || echo --nodeps)) \ $$(rpm -q rpm >/dev/null 2>&1 || echo --nodeps) \
$(rpm-no-devel)) \
$(RPMOPTS)) $(RPMOPTS))
# deb-pkg srcdeb-pkg bindeb-pkg # deb-pkg srcdeb-pkg bindeb-pkg

View File

@ -533,6 +533,7 @@ bool menu_is_empty(struct menu *menu)
bool menu_is_visible(struct menu *menu) bool menu_is_visible(struct menu *menu)
{ {
struct menu *child;
struct symbol *sym; struct symbol *sym;
tristate visible; tristate visible;
@ -551,7 +552,17 @@ bool menu_is_visible(struct menu *menu)
} else } else
visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr); visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
return visible != no; if (visible != no)
return true;
if (!sym || sym_get_tristate_value(menu->sym) == no)
return false;
for (child = menu->list; child; child = child->next)
if (menu_is_visible(child))
return true;
return false;
} }
const char *menu_get_prompt(const struct menu *menu) const char *menu_get_prompt(const struct menu *menu)

View File

@ -567,12 +567,12 @@ static int do_acpi_entry(const char *filename,
void *symval, char *alias) void *symval, char *alias)
{ {
DEF_FIELD_ADDR(symval, acpi_device_id, id); DEF_FIELD_ADDR(symval, acpi_device_id, id);
DEF_FIELD_ADDR(symval, acpi_device_id, cls); DEF_FIELD(symval, acpi_device_id, cls);
DEF_FIELD_ADDR(symval, acpi_device_id, cls_msk); DEF_FIELD(symval, acpi_device_id, cls_msk);
if (id && strlen((const char *)*id)) if (id && strlen((const char *)*id))
sprintf(alias, "acpi*:%s:*", *id); sprintf(alias, "acpi*:%s:*", *id);
else if (cls) { else {
int i, byte_shift, cnt = 0; int i, byte_shift, cnt = 0;
unsigned int msk; unsigned int msk;
@ -580,10 +580,10 @@ static int do_acpi_entry(const char *filename,
cnt = 6; cnt = 6;
for (i = 1; i <= 3; i++) { for (i = 1; i <= 3; i++) {
byte_shift = 8 * (3-i); byte_shift = 8 * (3-i);
msk = (*cls_msk >> byte_shift) & 0xFF; msk = (cls_msk >> byte_shift) & 0xFF;
if (msk) if (msk)
sprintf(&alias[cnt], "%02x", sprintf(&alias[cnt], "%02x",
(*cls >> byte_shift) & 0xFF); (cls >> byte_shift) & 0xFF);
else else
sprintf(&alias[cnt], "??"); sprintf(&alias[cnt], "??");
cnt += 2; cnt += 2;
@ -743,7 +743,7 @@ static void do_input(char *alias,
for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++) for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++)
arr[i] = TO_NATIVE(arr[i]); arr[i] = TO_NATIVE(arr[i]);
for (i = min; i < max; i++) for (i = min; i < max; i++)
if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) if (arr[i / BITS_PER_LONG] & (1ULL << (i%BITS_PER_LONG)))
sprintf(alias + strlen(alias), "%X,*", i); sprintf(alias + strlen(alias), "%X,*", i);
} }

View File

@ -392,7 +392,7 @@ out_file:
/* Calc and record src checksum. */ /* Calc and record src checksum. */
void get_src_version(const char *modname, char sum[], unsigned sumlen) void get_src_version(const char *modname, char sum[], unsigned sumlen)
{ {
char *buf; char *buf, *pos;
struct md4_ctx md; struct md4_ctx md;
char *fname; char *fname;
char filelist[PATH_MAX + 1]; char filelist[PATH_MAX + 1];
@ -401,9 +401,10 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
snprintf(filelist, sizeof(filelist), "%s.mod", modname); snprintf(filelist, sizeof(filelist), "%s.mod", modname);
buf = read_text_file(filelist); buf = read_text_file(filelist);
pos = buf;
md4_init(&md); md4_init(&md);
while ((fname = strsep(&buf, "\n"))) { while ((fname = strsep(&pos, "\n"))) {
if (!*fname) if (!*fname)
continue; continue;
if (!(is_static_library(fname)) && if (!(is_static_library(fname)) &&

View File

@ -123,7 +123,7 @@ install_kernel_headers () {
pdir=debian/$1 pdir=debian/$1
version=${1#linux-headers-} version=${1#linux-headers-}
"${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}" CC="${DEB_HOST_GNU_TYPE}-gcc" "${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}"
mkdir -p $pdir/lib/modules/$version/ mkdir -p $pdir/lib/modules/$version/
ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build

View File

@ -44,13 +44,11 @@ mkdir -p "${destdir}"
fi fi
} | tar -c -f - -T - | tar -xf - -C "${destdir}" } | tar -c -f - -T - | tar -xf - -C "${destdir}"
# When ${CC} and ${HOSTCC} differ, we are likely cross-compiling. Rebuild host # When ${CC} and ${HOSTCC} differ, rebuild host programs using ${CC}.
# programs using ${CC}. This assumes CC=${CROSS_COMPILE}gcc, which is usually
# the case for package building. It does not cross-compile when CC=clang.
# #
# This caters to host programs that participate in Kbuild. objtool and # This caters to host programs that participate in Kbuild. objtool and
# resolve_btfids are out of scope. # resolve_btfids are out of scope.
if [ "${CC}" != "${HOSTCC}" ] && is_enabled CONFIG_CC_CAN_LINK; then if [ "${CC}" != "${HOSTCC}" ]; then
echo "Rebuilding host programs with ${CC}..." echo "Rebuilding host programs with ${CC}..."
cat <<-'EOF' > "${destdir}/Kbuild" cat <<-'EOF' > "${destdir}/Kbuild"

View File

@ -179,6 +179,8 @@ fi
echo $debarch > debian/arch echo $debarch > debian/arch
host_gnu=$(dpkg-architecture -a "${debarch}" -q DEB_HOST_GNU_TYPE | sed 's/_/-/g')
# Generate a simple changelog template # Generate a simple changelog template
cat <<EOF > debian/changelog cat <<EOF > debian/changelog
$sourcename ($packageversion) $distribution; urgency=low $sourcename ($packageversion) $distribution; urgency=low
@ -196,7 +198,11 @@ Priority: optional
Maintainer: $maintainer Maintainer: $maintainer
Rules-Requires-Root: no Rules-Requires-Root: no
Build-Depends: debhelper-compat (= 12) Build-Depends: debhelper-compat (= 12)
Build-Depends-Arch: bc, bison, cpio, flex, kmod, libelf-dev:native, libssl-dev:native, rsync Build-Depends-Arch: bc, bison, cpio, flex,
gcc-${host_gnu} <!pkg.${sourcename}.nokernelheaders>,
kmod, libelf-dev:native,
libssl-dev:native, libssl-dev <!pkg.${sourcename}.nokernelheaders>,
rsync
Homepage: https://www.kernel.org/ Homepage: https://www.kernel.org/
Package: $packagename-$version Package: $packagename-$version
@ -224,6 +230,7 @@ cat <<EOF >> debian/control
Package: linux-headers-$version Package: linux-headers-$version
Architecture: $debarch Architecture: $debarch
Build-Profiles: <!pkg.${sourcename}.nokernelheaders>
Description: Linux kernel headers for $version on $debarch Description: Linux kernel headers for $version on $debarch
This package provides kernel header files for $version on $debarch This package provides kernel header files for $version on $debarch
. .
@ -238,6 +245,7 @@ cat <<EOF >> debian/control
Package: linux-image-$version-dbg Package: linux-image-$version-dbg
Section: debug Section: debug
Architecture: $debarch Architecture: $debarch
Build-Profiles: <!pkg.${sourcename}.nokerneldbg>
Description: Linux kernel debugging symbols for $version Description: Linux kernel debugging symbols for $version
This package will come in handy if you need to debug the kernel. It provides This package will come in handy if you need to debug the kernel. It provides
all the necessary debug symbols for the kernel and its modules. all the necessary debug symbols for the kernel and its modules.