Skip to content

Commit 5888bd8

Browse files
committed
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: openwrt/openwrt#25648 Signed-off-by: Paul Spooren <mail@aparcar.org>
1 parent 82ad072 commit 5888bd8

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎include/kernel.mk‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ endif
101101
KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
102102

103103
KERNEL_MAKE_FLAGS = \
104-
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))" \
105-
KAFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(IREMAP_STAGING_DIR)" \
104+
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))" \
105+
KAFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(IREMAP_STAGING_DIR) $(IREMAP_TOOLCHAIN_DIR)" \
106106
HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
107107
CROSS_COMPILE="$(KERNEL_CROSS)" \
108108
ARCH="$(LINUX_KARCH)" \

‎rules.mk‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ fremap = -ffile-prefix-map=$(1)=$(2)
194194
remap_staging_dir = $(call $(1),$(STAGING_DIR),staging_dir/$(notdir $(STAGING_DIR)))
195195
IREMAP_STAGING_DIR = $(call remap_staging_dir,iremap)
196196

197+
# The compiler's own headers, e.g. larchintrin.h which the LoongArch kernel
198+
# includes, come with the absolute path of the toolchain directory.
199+
IREMAP_TOOLCHAIN_DIR = $(call iremap,$(TOOLCHAIN_DIR),staging_dir/$(notdir $(TOOLCHAIN_DIR)))
200+
197201
PACKAGE_DIR?=$(BIN_DIR)/packages
198202
PACKAGE_DIR_ALL?=$(TOPDIR)/staging_dir/packages/$(BOARD)
199203
BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME)

0 commit comments

Comments
 (0)