Re: nm vmlinux error in arch/arm reappears after upgrade to make 4.4

From: Masahiro Yamada
Date: Sat Jan 07 2023 - 02:20:19 EST


On Sat, Jan 7, 2023 at 9:29 AM Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>
> Hi Masahiro,
>
> My distribution recently updated their version of make to 4.4 from 4.3,
> after which I notice the following error from nm when building ARCH=arm
> kernels, which I thought that this was supposed to be resolved with
> commit 3ec8a5b33dea ("kbuild: do not export LDFLAGS_vmlinux") but the
> tree clearly has this and it is not visible while just running clean (I
> have to build zImage to see it):


Presumably, this is a different issue than 3ec8a5b33dea


>
> $ git show -s --format='%h ("%s")'
> 512dee0c00ad ("Merge tag 'x86-urgent-2023-01-04' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")
>
> $ make --version | head -1
> GNU Make 4.4
>
> $ make -skj"$(nproc)" ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- O=build defconfig zImage
> arm-linux-gnueabi-nm: 'arch/arm/boot/compressed/../../../../vmlinux': No such file
>
> vs.
>
> $ make --version | head -1
> GNU Make 4.3
>
> $ make -skj"$(nproc)" ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- O=build defconfig zImage
>
> I bisected make to see what change causes this and I landed on
> commit 98da874c ("[SV 10593] Export variables to $(shell ...)
> commands") [1], which certainly seems like a reasonable commit to
> blame but I am not sure how exactly it factors in here.
>
> If you need any more information on reproducing this, I am happy to
> provide it (CROSS_COMPILE is just the toolchains from kernel.org).
>
> [1]: https://git.savannah.gnu.org/cgit/make.git/commit/?id=98da874c43035a490cdca81331724f233a3d0c9a
>
> Cheers,
> Nathan



Confirmed, but I still do not understand what
is triggering this.

These are my findings:

- O= option is needed to reproduce it.

- allnoconfig still produces it.

- I do not see it in the incremental builds.
I see it again in the full build after "git clean -fdx".



If I slightly cleaned the code like follows,
this issue disappeared.
($(obj)/../../../../vmlinux is the same as vmlinux)




diff --git a/arch/arm/boot/compressed/Makefile
b/arch/arm/boot/compressed/Makefile
index 2ef651a78fa2..726ecabcef09 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -107,7 +107,7 @@ ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg
asflags-y := -DZIMAGE

# Supply kernel BSS size to the decompressor via a linker symbol.
-KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \
+KBSS_SZ = $(shell echo $$(($$($(NM) vmlinux | \
sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \
-e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) )
LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)










--
Best Regards
Masahiro Yamada