[PATCH/RFC] kernel-defaults.mk: get rid of BuildID

Paul Spooren mail at aparcar.org
Tue Apr 5 06:11:27 PDT 2022


>> +	$(SED) -i $(LINUX_DIR)/Makefile -e 's/--build-id=.*/--build-id=0x$(LINUX_VERMAGIC)/g’

This doesn’t fly since LINUX_VERMAGIC (based on .vermagic) is based on the Kernel configuration and only available after the Configuration step. I moved it from the Prepare to the end of Configuration and it works fine:

diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk
index 1e82f7d739..63da2ea038 100644
--- a/include/kernel-defaults.mk
+++ b/include/kernel-defaults.mk
@@ -119,6 +119,7 @@ define Kernel/Configure/Default
        $(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(KERNEL_MAKE) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install
        grep '=[ym]' $(LINUX_DIR)/.config.set | LC_ALL=C sort | $(MKHASH) md5 > $(LINUX_DIR)/.vermagic
+       $(SED) "s/--build-id=.*/--build-id=0x$$$$(cat $(LINUX_DIR)/.vermagic)/g" $(LINUX_DIR)/Makefile

It works as expected:

ubuntu at primary:~/a$ cat /home/ubuntu/a/build_dir/target-x86_64_musl/linux-x86_64/linux-5.10.109/Makefile | grep build-id
KBUILD_LDFLAGS_MODULE += --build-id=0xc096cf71d9bd3c319494033a0e38394b

ubuntu at primary:~$ file kernela 
kernela: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[md5/uuid]=c096cf71d9bd3c319494033a0e38394b, stripped

ubuntu at primary:~/a$ make -C target/linux val.LINUX_VERMAGIC
make: Entering directory '/home/ubuntu/a/target/linux'
make: Leaving directory '/home/ubuntu/a/target/linux’


More information about the openwrt-devel mailing list