diff options
| author | Paul Spooren | 2026-10-03 20:40:35 +0000 |
|---|---|---|
| committer | Paul Spooren | 2026-10-06 20:05:20 +0000 |
| commit | 5888bd8c576e50fcd2bc9c91a15aba0801195f8d (patch) | |
| tree | 96dcbce4634606a7ca099382227af41f0209c743 | |
| parent | 82ad0727ad89c1f5b3624a55c54d50134d4416fd (diff) | |
kernel: map the toolchain directory out of the debug information
The compressed LoongArch kernel (vmlinuz.efi) differs between builds in
different directories. The code and data of vmlinux are identical, but
its GNU build ID is not: the debug information of vmlinux holds a
single absolute path, the include directory of the compiler, e.g.
/builder/shared-workdir/build/staging_dir/toolchain-loongarch64_generic_gcc-14.4.0_musl/lib/gcc/loongarch64-openwrt-linux-musl/14.4.0/include
asm/loongarch.h includes the compiler's larchintrin.h, so core files
like arch/loongarch/kernel/cpu-probe.c refer to it. The prefix maps of
the kernel cover the build and the staging directory, but not the
toolchain directory. The build ID hashes all of vmlinux, so it depends
on the build directory, and with it the compressed kernel.
Map the toolchain directory as well, like the staging directory.
On loongarch64/generic, vmlinux built without the map holds this one
absolute path, like the published one; built with it, no absolute path
is left, while .text, .rodata and .data stay byte-identical.
Link: https://github.com/openwrt/openwrt/pull/25648
Signed-off-by: Paul Spooren <mail@aparcar.org>
| -rw-r--r-- | include/kernel.mk | 4 | ||||
| -rw-r--r-- | rules.mk | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/include/kernel.mk b/include/kernel.mk index 44be1e6c7c..30557b5640 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -101,8 +101,8 @@ endif KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS) KERNEL_MAKE_FLAGS = \ - KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(IREMAP_STAGING_DIR) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) $(call qstrip,$(CONFIG_KERNEL_CFLAGS))" \ - KAFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(IREMAP_STAGING_DIR)" \ + KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(IREMAP_STAGING_DIR) $(IREMAP_TOOLCHAIN_DIR) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) $(call qstrip,$(CONFIG_KERNEL_CFLAGS))" \ + KAFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(IREMAP_STAGING_DIR) $(IREMAP_TOOLCHAIN_DIR)" \ HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \ CROSS_COMPILE="$(KERNEL_CROSS)" \ ARCH="$(LINUX_KARCH)" \ @@ -194,6 +194,10 @@ fremap = -ffile-prefix-map=$(1)=$(2) remap_staging_dir = $(call $(1),$(STAGING_DIR),staging_dir/$(notdir $(STAGING_DIR))) IREMAP_STAGING_DIR = $(call remap_staging_dir,iremap) +# The compiler's own headers, e.g. larchintrin.h which the LoongArch kernel +# includes, come with the absolute path of the toolchain directory. +IREMAP_TOOLCHAIN_DIR = $(call iremap,$(TOOLCHAIN_DIR),staging_dir/$(notdir $(TOOLCHAIN_DIR))) + PACKAGE_DIR?=$(BIN_DIR)/packages PACKAGE_DIR_ALL?=$(TOPDIR)/staging_dir/packages/$(BOARD) BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME) |