Skip to content

Commit

Permalink
Merge tag 'kbuild-fixes-v6.6-2' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Fix the module compression with xz so the in-kernel decompressor
   works

 - Document a kconfig idiom to express an optional dependency between
   modules

 - Make modpost, when W=1 is given, detect broken drivers that reference
   .exit.* sections

 - Remove unused code

* tag 'kbuild-fixes-v6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: remove stale code for 'source' symlink in packaging scripts
  modpost: Don't let "driver"s reference .exit.*
  vmlinux.lds.h: remove unused CPU_KEEP and CPU_DISCARD macros
  modpost: add missing else to the "of" check
  Documentation: kbuild: explain handling optional dependencies
  kbuild: Use CRC32 and a 1MiB dictionary for XZ compressed modules
  • Loading branch information
torvalds committed Oct 1, 2023
2 parents d2c5231 + 2d7d1bc commit e81a2da
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 15 deletions.
26 changes: 26 additions & 0 deletions Documentation/kbuild/kconfig-language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,32 @@ above, leading to:
bool "Support for foo hardware"
depends on ARCH_FOO_VENDOR || COMPILE_TEST

Optional dependencies
~~~~~~~~~~~~~~~~~~~~~

Some drivers are able to optionally use a feature from another module
or build cleanly with that module disabled, but cause a link failure
when trying to use that loadable module from a built-in driver.

The most common way to express this optional dependency in Kconfig logic
uses the slightly counterintuitive::

config FOO
tristate "Support for foo hardware"
depends on BAR || !BAR

This means that there is either a dependency on BAR that disallows
the combination of FOO=y with BAR=m, or BAR is completely disabled.
For a more formalized approach if there are multiple drivers that have
the same dependency, a helper symbol can be used, like::

config FOO
tristate "Support for foo hardware"
depends on BAR_OPTIONAL

config BAR_OPTIONAL
def_tristate BAR || !BAR

Kconfig recursive dependency limitations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 0 additions & 7 deletions include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,6 @@
* are handled as text/data or they can be discarded (which
* often happens at runtime)
*/
#ifdef CONFIG_HOTPLUG_CPU
#define CPU_KEEP(sec) *(.cpu##sec)
#define CPU_DISCARD(sec)
#else
#define CPU_KEEP(sec)
#define CPU_DISCARD(sec) *(.cpu##sec)
#endif

#if defined(CONFIG_MEMORY_HOTPLUG)
#define MEM_KEEP(sec) *(.mem##sec)
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile.modinst
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ endif
quiet_cmd_gzip = GZIP $@
cmd_gzip = $(KGZIP) -n -f $<
quiet_cmd_xz = XZ $@
cmd_xz = $(XZ) --lzma2=dict=2MiB -f $<
cmd_xz = $(XZ) --check=crc32 --lzma2=dict=1MiB -f $<
quiet_cmd_zstd = ZSTD $@
cmd_zstd = $(ZSTD) -T0 --rm -f -q $<

Expand Down
2 changes: 1 addition & 1 deletion scripts/mod/file2alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
/* First handle the "special" cases */
if (sym_is(name, namelen, "usb"))
do_usb_table(symval, sym->st_size, mod);
if (sym_is(name, namelen, "of"))
else if (sym_is(name, namelen, "of"))
do_of_table(symval, sym->st_size, mod);
else if (sym_is(name, namelen, "pnp"))
do_pnp_device_entry(symval, sym->st_size, mod);
Expand Down
15 changes: 13 additions & 2 deletions scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,20 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
"*_console")))
return 0;

/* symbols in data sections that may refer to meminit/exit sections */
/* symbols in data sections that may refer to meminit sections */
if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_XXXEXIT_SECTIONS)) &&
match(fromsym, PATTERNS("*driver")))
return 0;

/*
* symbols in data sections must not refer to .exit.*, but there are
* quite a few offenders, so hide these unless for W=1 builds until
* these are fixed.
*/
if (!extra_warn &&
match(fromsec, PATTERNS(DATA_SECTIONS)) &&
match(tosec, PATTERNS(EXIT_SECTIONS)) &&
match(fromsym, PATTERNS("*driver")))
return 0;

Expand Down
1 change: 0 additions & 1 deletion scripts/package/builddeb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ install_linux_image () {

${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build"
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source"

# Install the kernel
if [ "${ARCH}" = um ] ; then
Expand Down
3 changes: 0 additions & 3 deletions scripts/package/kernel.spec
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEA
cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE}
cp .config %{buildroot}/boot/config-%{KERNELRELEASE}
ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source
%if %{with_devel}
%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
%endif
Expand Down Expand Up @@ -101,7 +100,6 @@ fi
%defattr (-, root, root)
/lib/modules/%{KERNELRELEASE}
%exclude /lib/modules/%{KERNELRELEASE}/build
%exclude /lib/modules/%{KERNELRELEASE}/source
/boot/*

%files headers
Expand All @@ -113,5 +111,4 @@ fi
%defattr (-, root, root)
/usr/src/kernels/%{KERNELRELEASE}
/lib/modules/%{KERNELRELEASE}/build
/lib/modules/%{KERNELRELEASE}/source
%endif

0 comments on commit e81a2da

Please sign in to comment.