linux: fix Module.symvers generation

Building the kernel separately, after the modules have been built, has
the side-effect that modpost (called from scripts/link-vmlinux.sh in
the kernel tree) generates a Module.symvers files containing only the
in-kernel symbols:

  # modpost vmlinux.o to check for section mismatches
  ${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o

This causes undefined symbol warnings when building external
modules/drivers and these drivers reference symbols from modules.
eg when building RTL8812AU for RPi2:
WARNING: "cfg80211_put_bss" [.../RTL8812AU-ff2f1dd/8812au.ko] undefined!
...

When building the kernel in the usual way (by just running "make")
this problem does not occur because the default kernel build target
includes "modules", which is built after the kernel. So Modules.symvers
generated from link-kernel.sh will later be replaced by the symvers
from modpost.

The easiest way to fix this is to add "modules" to the kernel image
build target. The actual modules build is a no-op (as they've been built
just before), but modpost will be triggered after the kernel build
and we get a correct Module.symvers file - and external modules/drivers
build without warnings.

Signed-off-by: Matthias Reichl <hias@horus.com>
This commit is contained in:
Matthias Reichl 2018-08-23 13:40:39 +02:00
parent b56a1afd85
commit b463f26f67

View File

@ -216,7 +216,10 @@ make_target() {
done
fi
kernel_make $KERNEL_TARGET $KERNEL_MAKE_EXTRACMD
# the modules target is required to get a proper Module.symvers
# file with symbols from built-in and external modules.
# Without that it'll contain only the symbols from the kernel
kernel_make $KERNEL_TARGET $KERNEL_MAKE_EXTRACMD modules
if [ "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then
DTB_BLOBS=($(ls arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*.dtb 2>/dev/null || true))