* [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step
@ 2025-03-11 11:06 Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 1/4] Kbuild/link-vmlinux.sh: Make output file name configurable Ard Biesheuvel
` (4 more replies)
0 siblings, 5 replies; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-11 11:06 UTC (permalink / raw)
To: linux-kernel
Cc: linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada, Ingo Molnar
From: Ard Biesheuvel <ardb@kernel.org>
Kbuild supports an architecture specific Makefile.postlink file that is
invoked for the vmlinux target after it has been built. This Makefile
takes 'vmlinux' (which has just been built) as the target, and mangles
the file and/or constructs other intermediate artifacts from it.
This violates the general philosophy of Make, which is based on rules
and dependencies, and artifacts that are rebuilt only when any of their
dependencies have been updated.
Instead, the different incarnations of vmlinux that are consumed by
different stages of the build should be emitted as distinct files, where
rules and dependencies are used to define one in terms of the other.
This also works around an error observed here [0], where vmlinux is
deleted by Make because a subsequent step that consumes it as input
throws an error.
So refactor the vmlinux shell scripts and build rules so that
architectures that rely on --emit-relocs to construct vmlinux with
static relocations preserved will get a separate vmlinux.unstripped file
carrying those relocations. This removes the need for an imperative
postlink step, given that any rules that depend on the unstripped
vmlinux can now simply depend on vmlinux.unstripped, rather than inject
a build step into Makefile.postlink
S390 should be able to do the same. MIPS and RISC-V perform some
post-build checks on vmlinux, which is reasonable in principle for a
postlink step, although deleting vmlinux when the check fails is equally
unhelpful.
Changes since v1:
- add vmlinux.unstripped to .gitignore and to the 'clean' target
- move cmd_strip_relocs into Makefile.vmlinux
[0] https://lore.kernel.org/all/Z5ARucnUgqjwBnrp@gmail.com/T/#m731ed0206949fc3f39fcc8a7b82fe348a8fc80c4
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Ard Biesheuvel (4):
Kbuild/link-vmlinux.sh: Make output file name configurable
Kbuild: Introduce Kconfig symbol for linking vmlinux with relocations
Kbuild: Create intermediate vmlinux build with relocations preserved
x86: Get rid of Makefile.postlink
.gitignore | 1 +
Makefile | 6 ++-
arch/Kconfig | 7 ++++
arch/mips/Kconfig | 1 +
arch/mips/Makefile | 4 --
arch/mips/Makefile.postlink | 2 +-
arch/riscv/Kconfig | 1 +
arch/riscv/Makefile | 2 +-
arch/riscv/Makefile.postlink | 11 +-----
arch/riscv/boot/Makefile | 5 +--
arch/s390/Kconfig | 1 +
arch/s390/Makefile | 2 +-
arch/s390/Makefile.postlink | 4 +-
arch/x86/Kconfig | 1 +
arch/x86/Makefile | 6 ---
arch/x86/Makefile.postlink | 40 --------------------
arch/x86/boot/compressed/Makefile | 9 +++--
scripts/Makefile.lib | 3 --
scripts/Makefile.vmlinux | 30 +++++++++++----
scripts/link-vmlinux.sh | 11 +++---
20 files changed, 57 insertions(+), 90 deletions(-)
delete mode 100644 arch/x86/Makefile.postlink
--
2.49.0.rc0.332.g42c0ae87b1-goog
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 1/4] Kbuild/link-vmlinux.sh: Make output file name configurable
2025-03-11 11:06 [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Ard Biesheuvel
@ 2025-03-11 11:06 ` Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 2/4] Kbuild: Introduce Kconfig symbol for linking vmlinux with relocations Ard Biesheuvel
` (3 subsequent siblings)
4 siblings, 0 replies; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-11 11:06 UTC (permalink / raw)
To: linux-kernel
Cc: linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada, Ingo Molnar
From: Ard Biesheuvel <ardb@kernel.org>
In order to introduce an intermediate, non-stripped vmlinux build that
can be used by other build steps as an input, pass the output file name
to link-vmlinux.sh via its command line.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
scripts/Makefile.vmlinux | 2 +-
scripts/link-vmlinux.sh | 11 ++++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index 873caaa55313..3523ce3ce3dc 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -69,7 +69,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
# Final link of vmlinux with optional arch pass after final link
cmd_link_vmlinux = \
- $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
+ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
targets += vmlinux
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 56a077d204cf..e55026128e05 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -31,6 +31,7 @@ set -e
LD="$1"
KBUILD_LDFLAGS="$2"
LDFLAGS_vmlinux="$3"
+VMLINUX="$4"
is_enabled() {
grep -q "^$1=y" include/config/auto.conf
@@ -278,7 +279,7 @@ fi
strip_debug=
-vmlinux_link vmlinux
+vmlinux_link "${VMLINUX}"
# fill in BTF IDs
if is_enabled CONFIG_DEBUG_INFO_BTF; then
@@ -290,11 +291,11 @@ if is_enabled CONFIG_DEBUG_INFO_BTF; then
${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} vmlinux
fi
-mksysmap vmlinux System.map
+mksysmap "${VMLINUX}" System.map
if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
- info SORTTAB vmlinux
- if ! sorttable vmlinux; then
+ info SORTTAB "${VMLINUX}"
+ if ! sorttable "${VMLINUX}"; then
echo >&2 Failed to sort kernel tables
exit 1
fi
@@ -310,4 +311,4 @@ if is_enabled CONFIG_KALLSYMS; then
fi
# For fixdep
-echo "vmlinux: $0" > .vmlinux.d
+echo "${VMLINUX}: $0" > ".${VMLINUX}.d"
--
2.49.0.rc0.332.g42c0ae87b1-goog
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 2/4] Kbuild: Introduce Kconfig symbol for linking vmlinux with relocations
2025-03-11 11:06 [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 1/4] Kbuild/link-vmlinux.sh: Make output file name configurable Ard Biesheuvel
@ 2025-03-11 11:06 ` Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved Ard Biesheuvel
` (2 subsequent siblings)
4 siblings, 0 replies; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-11 11:06 UTC (permalink / raw)
To: linux-kernel
Cc: linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada, Ingo Molnar
From: Ard Biesheuvel <ardb@kernel.org>
Some architectures build vmlinux with static relocations preserved, but
strip them again from the final vmlinux image. Arch specific tools
consume these static relocations in order to construct relocation tables
for KASLR.
The fact that vmlinux is created, consumed and subsequently updated goes
against the typical, declarative paradigm used by Make, which is based
on rules and dependencies. So as a first step towards cleaning this up,
introduce a Kconfig symbol to declare that the arch wants to consume the
static relocations emitted into vmlinux. This will be wired up further
in subsequent patches.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
Makefile | 4 ++++
arch/Kconfig | 7 +++++++
arch/mips/Kconfig | 1 +
arch/mips/Makefile | 4 ----
arch/riscv/Kconfig | 1 +
arch/riscv/Makefile | 2 +-
arch/s390/Kconfig | 1 +
arch/s390/Makefile | 2 +-
arch/x86/Kconfig | 1 +
arch/x86/Makefile | 6 ------
10 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index 30dab4c8b012..a3302dce56de 100644
--- a/Makefile
+++ b/Makefile
@@ -1119,6 +1119,10 @@ ifdef CONFIG_LD_ORPHAN_WARN
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
endif
+ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),)
+LDFLAGS_vmlinux += --emit-relocs --discard-none
+endif
+
# Align the bit size of userspace programs with the kernel
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
diff --git a/arch/Kconfig b/arch/Kconfig
index b8a4ff365582..101a13fcde8e 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1695,6 +1695,13 @@ config ARCH_HAS_KERNEL_FPU_SUPPORT
Architectures that select this option can run floating-point code in
the kernel, as described in Documentation/core-api/floating-point.rst.
+config ARCH_VMLINUX_NEEDS_RELOCS
+ bool
+ help
+ Whether the architecture needs vmlinux to be built with static
+ relocations preserved. This is used by some architectures to
+ construct bespoke relocation tables for KASLR.
+
source "kernel/gcov/Kconfig"
source "scripts/gcc-plugins/Kconfig"
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1924f2d83932..5aedbd7afadb 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2617,6 +2617,7 @@ config RELOCATABLE
CPU_MIPS32_R6 || CPU_MIPS64_R6 || \
CPU_P5600 || CAVIUM_OCTEON_SOC || \
CPU_LOONGSON64
+ select ARCH_VMLINUX_NEEDS_RELOCS
help
This builds a kernel image that retains relocation information
so it can be loaded someplace besides the default 1MB.
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index be8cb44a89fd..d9057e29bc62 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -100,10 +100,6 @@ LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
KBUILD_AFLAGS_MODULE += -mlong-calls
KBUILD_CFLAGS_MODULE += -mlong-calls
-ifeq ($(CONFIG_RELOCATABLE),y)
-LDFLAGS_vmlinux += --emit-relocs
-endif
-
cflags-y += -ffreestanding
cflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 7612c52e9b1e..6f5800114416 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -1077,6 +1077,7 @@ config RELOCATABLE
bool "Build a relocatable kernel"
depends on MMU && 64BIT && !XIP_KERNEL
select MODULE_SECTIONS if MODULES
+ select ARCH_VMLINUX_NEEDS_RELOCS
help
This builds a kernel as a Position Independent Executable (PIE),
which retains all relocation metadata required to relocate the
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 13fbc0f94238..6ef0d10e0c50 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -8,7 +8,7 @@
LDFLAGS_vmlinux := -z norelro
ifeq ($(CONFIG_RELOCATABLE),y)
- LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs
+ LDFLAGS_vmlinux += -shared -Bsymbolic -z notext
KBUILD_CFLAGS += -fPIE
endif
ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 9c9ec08d78c7..ea67b7317138 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -630,6 +630,7 @@ endchoice
config RELOCATABLE
def_bool y
+ select ARCH_VMLINUX_NEEDS_RELOCS
help
This builds a kernel image that retains relocation information
so it can be loaded at an arbitrary address.
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 5fae311203c2..d5f4be440879 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -15,7 +15,7 @@ KBUILD_CFLAGS_MODULE += -fPIC
KBUILD_AFLAGS += -m64
KBUILD_CFLAGS += -m64
KBUILD_CFLAGS += -fPIC
-LDFLAGS_vmlinux := -no-pie --emit-relocs --discard-none
+LDFLAGS_vmlinux := -no-pie
extra_tools := relocs
aflags_dwarf := -Wa,-gdwarf-2
KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index be2c311f5118..2005d80ff8d1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2199,6 +2199,7 @@ config RANDOMIZE_BASE
config X86_NEED_RELOCS
def_bool y
depends on RANDOMIZE_BASE || (X86_32 && RELOCATABLE)
+ select ARCH_VMLINUX_NEEDS_RELOCS
config PHYSICAL_ALIGN
hex "Alignment value to which kernel should be aligned"
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5b773b34768d..f65ed6dcd6fb 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -251,12 +251,6 @@ endif
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
-ifdef CONFIG_X86_NEED_RELOCS
-LDFLAGS_vmlinux := --emit-relocs --discard-none
-else
-LDFLAGS_vmlinux :=
-endif
-
#
# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
# the linker to force 2MB page size regardless of the default page size used
--
2.49.0.rc0.332.g42c0ae87b1-goog
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-11 11:06 [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 1/4] Kbuild/link-vmlinux.sh: Make output file name configurable Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 2/4] Kbuild: Introduce Kconfig symbol for linking vmlinux with relocations Ard Biesheuvel
@ 2025-03-11 11:06 ` Ard Biesheuvel
2025-03-13 9:21 ` kernel test robot
2025-04-30 16:03 ` Conor Dooley
2025-03-11 11:06 ` [PATCH v2 4/4] x86: Get rid of Makefile.postlink Ard Biesheuvel
2025-03-15 7:09 ` [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Masahiro Yamada
4 siblings, 2 replies; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-11 11:06 UTC (permalink / raw)
To: linux-kernel
Cc: linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada, Ingo Molnar
From: Ard Biesheuvel <ardb@kernel.org>
The imperative paradigm used to build vmlinux, extract some info from it
or perform some checks on it, and subsequently modify it again goes
against the declarative paradigm that is usually employed for defining
make rules.
In particular, the Makefile.postlink files that consume their input via
an output rule result in some dodgy logic in the decompressor makefiles
for RISC-V and x86, given that the vmlinux.relocs input file needed to
generate the arch-specific relocation tables may not exist or be out of
date, but cannot be constructed using the ordinary Make dependency based
rules, because the info needs to be extracted while vmlinux is in its
ephemeral, non-stripped form.
So instead, for architectures that require the static relocations that
are emitted into vmlinux when passing --emit-relocs to the linker, and
are subsequently stripped out again, introduce an intermediate vmlinux
target called vmlinux.unstripped, and organize the reset of the build
logic accordingly:
- vmlinux.unstripped is created only once, and not updated again
- build rules under arch/*/boot can depend on vmlinux.unstripped without
running the risk of the data disappearing or being out of date
- the final vmlinux generated by the build is not bloated with static
relocations that are never needed again after the build completes.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
.gitignore | 1 +
Makefile | 2 +-
arch/mips/Makefile.postlink | 2 +-
arch/riscv/Makefile.postlink | 11 +-------
arch/riscv/boot/Makefile | 5 +---
arch/s390/Makefile.postlink | 4 +--
arch/x86/Makefile.postlink | 8 +++---
scripts/Makefile.lib | 3 ---
scripts/Makefile.vmlinux | 28 +++++++++++++++-----
9 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5937c74d3dc1..f2f63e47fb88 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,6 +65,7 @@ modules.order
/vmlinux.32
/vmlinux.map
/vmlinux.symvers
+/vmlinux.unstripped
/vmlinux-gdb.py
/vmlinuz
/System.map
diff --git a/Makefile b/Makefile
index a3302dce56de..c07295a980a0 100644
--- a/Makefile
+++ b/Makefile
@@ -1560,7 +1560,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_FILES += vmlinux.symvers modules-only.symvers \
modules.builtin modules.builtin.modinfo modules.nsdeps \
- modules.builtin.ranges vmlinux.o.map \
+ modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
compile_commands.json rust/test \
rust-project.json .vmlinux.objs .vmlinux.export.c \
.builtin-dtbs-list .builtin-dtb.S
diff --git a/arch/mips/Makefile.postlink b/arch/mips/Makefile.postlink
index 6cfdc149d3bc..ea0add7d56b2 100644
--- a/arch/mips/Makefile.postlink
+++ b/arch/mips/Makefile.postlink
@@ -22,7 +22,7 @@ quiet_cmd_relocs = RELOCS $@
# `@true` prevents complaint when there is nothing to be done
-vmlinux: FORCE
+vmlinux vmlinux.unstripped: FORCE
@true
ifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y)
$(call if_changed,ls3_llsc)
diff --git a/arch/riscv/Makefile.postlink b/arch/riscv/Makefile.postlink
index 6b0580949b6a..0e4cf8ad2f14 100644
--- a/arch/riscv/Makefile.postlink
+++ b/arch/riscv/Makefile.postlink
@@ -10,26 +10,17 @@ __archpost:
-include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
-include $(srctree)/scripts/Makefile.lib
quiet_cmd_relocs_check = CHKREL $@
cmd_relocs_check = \
$(CONFIG_SHELL) $(srctree)/arch/riscv/tools/relocs_check.sh "$(OBJDUMP)" "$(NM)" "$@"
-ifdef CONFIG_RELOCATABLE
-quiet_cmd_cp_vmlinux_relocs = CPREL vmlinux.relocs
-cmd_cp_vmlinux_relocs = cp vmlinux vmlinux.relocs
-
-endif
-
# `@true` prevents complaint when there is nothing to be done
-vmlinux: FORCE
+vmlinux vmlinux.unstripped: FORCE
@true
ifdef CONFIG_RELOCATABLE
$(call if_changed,relocs_check)
- $(call if_changed,cp_vmlinux_relocs)
- $(call if_changed,strip_relocs)
endif
clean:
diff --git a/arch/riscv/boot/Makefile b/arch/riscv/boot/Makefile
index b25d524ce5eb..bfc3d0b75b9b 100644
--- a/arch/riscv/boot/Makefile
+++ b/arch/riscv/boot/Makefile
@@ -32,10 +32,7 @@ $(obj)/xipImage: vmlinux FORCE
endif
ifdef CONFIG_RELOCATABLE
-vmlinux.relocs: vmlinux
- @ (! [ -f vmlinux.relocs ] && echo "vmlinux.relocs can't be found, please remove vmlinux and try again") || true
-
-$(obj)/Image: vmlinux.relocs FORCE
+$(obj)/Image: vmlinux.unstripped FORCE
else
$(obj)/Image: vmlinux FORCE
endif
diff --git a/arch/s390/Makefile.postlink b/arch/s390/Makefile.postlink
index 1ae5478cd6ac..c2b737500a91 100644
--- a/arch/s390/Makefile.postlink
+++ b/arch/s390/Makefile.postlink
@@ -11,7 +11,6 @@ __archpost:
-include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
-include $(srctree)/scripts/Makefile.lib
CMD_RELOCS=arch/s390/tools/relocs
OUT_RELOCS = arch/s390/boot
@@ -20,9 +19,8 @@ quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/relocs.S
mkdir -p $(OUT_RELOCS); \
$(CMD_RELOCS) $@ > $(OUT_RELOCS)/relocs.S
-vmlinux: FORCE
+vmlinux.unstripped: FORCE
$(call cmd,relocs)
- $(call cmd,strip_relocs)
clean:
@rm -f $(OUT_RELOCS)/relocs.S
diff --git a/arch/x86/Makefile.postlink b/arch/x86/Makefile.postlink
index 8b8a68162c94..445fce66630f 100644
--- a/arch/x86/Makefile.postlink
+++ b/arch/x86/Makefile.postlink
@@ -11,23 +11,21 @@ __archpost:
-include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
-include $(srctree)/scripts/Makefile.lib
CMD_RELOCS = arch/x86/tools/relocs
OUT_RELOCS = arch/x86/boot/compressed
-quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/$@.relocs
+quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/vmlinux.relocs
cmd_relocs = \
mkdir -p $(OUT_RELOCS); \
- $(CMD_RELOCS) $@ > $(OUT_RELOCS)/$@.relocs; \
+ $(CMD_RELOCS) $@ > $(OUT_RELOCS)/vmlinux.relocs; \
$(CMD_RELOCS) --abs-relocs $@
# `@true` prevents complaint when there is nothing to be done
-vmlinux: FORCE
+vmlinux vmlinux.unstripped: FORCE
@true
ifeq ($(CONFIG_X86_NEED_RELOCS),y)
$(call cmd,relocs)
- $(call cmd,strip_relocs)
endif
clean:
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cad20f0e66ee..6abfefd1bd31 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -376,9 +376,6 @@ quiet_cmd_ar = AR $@
quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
-quiet_cmd_strip_relocs = RSTRIP $@
-cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' $@
-
# Gzip
# ---------------------------------------------------------------------------
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index 3523ce3ce3dc..dd744551a896 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -9,6 +9,20 @@ include $(srctree)/scripts/Makefile.lib
targets :=
+ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS
+vmlinux-final := vmlinux.unstripped
+
+quiet_cmd_strip_relocs = RSTRIP $@
+ cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' $< $@
+
+vmlinux: $(vmlinux-final) FORCE
+ $(call if_changed,strip_relocs)
+
+targets += vmlinux
+else
+vmlinux-final := vmlinux
+endif
+
%.o: %.c FORCE
$(call if_changed_rule,cc_o_c)
@@ -47,7 +61,7 @@ targets += .builtin-dtbs-list
ifdef CONFIG_GENERIC_BUILTIN_DTB
targets += .builtin-dtbs.S .builtin-dtbs.o
-vmlinux: .builtin-dtbs.o
+$(vmlinux-final): .builtin-dtbs.o
endif
# vmlinux
@@ -55,11 +69,11 @@ endif
ifdef CONFIG_MODULES
targets += .vmlinux.export.o
-vmlinux: .vmlinux.export.o
+$(vmlinux-final): .vmlinux.export.o
endif
ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX
-vmlinux: arch/$(SRCARCH)/tools/vmlinux.arch.o
+$(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o
arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE
$(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@
@@ -72,11 +86,11 @@ cmd_link_vmlinux = \
$< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
-targets += vmlinux
-vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
+targets += $(vmlinux-final)
+$(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
+$(call if_changed_dep,link_vmlinux)
ifdef CONFIG_DEBUG_INFO_BTF
-vmlinux: $(RESOLVE_BTFIDS)
+$(vmlinux-final): $(RESOLVE_BTFIDS)
endif
# module.builtin.ranges
@@ -92,7 +106,7 @@ modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \
modules.builtin vmlinux.map vmlinux.o.map FORCE
$(call if_changed,modules_builtin_ranges)
-vmlinux.map: vmlinux
+vmlinux.map: $(vmlinux-final)
@:
endif
--
2.49.0.rc0.332.g42c0ae87b1-goog
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 4/4] x86: Get rid of Makefile.postlink
2025-03-11 11:06 [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Ard Biesheuvel
` (2 preceding siblings ...)
2025-03-11 11:06 ` [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved Ard Biesheuvel
@ 2025-03-11 11:06 ` Ard Biesheuvel
2025-03-11 11:17 ` Borislav Petkov
2025-03-13 2:08 ` Masahiro Yamada
2025-03-15 7:09 ` [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Masahiro Yamada
4 siblings, 2 replies; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-11 11:06 UTC (permalink / raw)
To: linux-kernel
Cc: linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada, Ingo Molnar
From: Ard Biesheuvel <ardb@kernel.org>
Instead of generating the vmlinux.relocs file (needed by the
decompressor build to construct the KASLR relocation tables) as a
vmlinux postlink step, which is dubious because it depends on data that
is stripped from vmlinux before the build completes, generate it from
vmlinux.unstripped, which has been introduced specifically for this
purpose.
This ensures that each artifact is rebuilt as needed, rather than as a
side effect of another build rule.
This effectively reverts commit
9d9173e9ceb6 ("x86/build: Avoid relocation information in final vmlinux")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/Makefile.postlink | 38 --------------------
arch/x86/boot/compressed/Makefile | 9 +++--
2 files changed, 6 insertions(+), 41 deletions(-)
diff --git a/arch/x86/Makefile.postlink b/arch/x86/Makefile.postlink
deleted file mode 100644
index 445fce66630f..000000000000
--- a/arch/x86/Makefile.postlink
+++ /dev/null
@@ -1,38 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# ===========================================================================
-# Post-link x86 pass
-# ===========================================================================
-#
-# 1. Separate relocations from vmlinux into vmlinux.relocs.
-# 2. Strip relocations from vmlinux.
-
-PHONY := __archpost
-__archpost:
-
--include include/config/auto.conf
-include $(srctree)/scripts/Kbuild.include
-
-CMD_RELOCS = arch/x86/tools/relocs
-OUT_RELOCS = arch/x86/boot/compressed
-quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/vmlinux.relocs
- cmd_relocs = \
- mkdir -p $(OUT_RELOCS); \
- $(CMD_RELOCS) $@ > $(OUT_RELOCS)/vmlinux.relocs; \
- $(CMD_RELOCS) --abs-relocs $@
-
-# `@true` prevents complaint when there is nothing to be done
-
-vmlinux vmlinux.unstripped: FORCE
- @true
-ifeq ($(CONFIG_X86_NEED_RELOCS),y)
- $(call cmd,relocs)
-endif
-
-clean:
- @rm -f $(OUT_RELOCS)/vmlinux.relocs
-
-PHONY += FORCE clean
-
-FORCE:
-
-.PHONY: $(PHONY)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 606c74f27459..5edee7a9786c 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -117,9 +117,12 @@ $(obj)/vmlinux.bin: vmlinux FORCE
targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
-# vmlinux.relocs is created by the vmlinux postlink step.
-$(obj)/vmlinux.relocs: vmlinux
- @true
+CMD_RELOCS = arch/x86/tools/relocs
+quiet_cmd_relocs = RELOCS $@
+ cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
+
+$(obj)/vmlinux.relocs: vmlinux.unstripped FORCE
+ $(call if_changed,relocs)
vmlinux.bin.all-y := $(obj)/vmlinux.bin
vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
--
2.49.0.rc0.332.g42c0ae87b1-goog
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 4/4] x86: Get rid of Makefile.postlink
2025-03-11 11:06 ` [PATCH v2 4/4] x86: Get rid of Makefile.postlink Ard Biesheuvel
@ 2025-03-11 11:17 ` Borislav Petkov
2025-03-12 12:35 ` Petr Pavlu
2025-03-13 2:08 ` Masahiro Yamada
1 sibling, 1 reply; 19+ messages in thread
From: Borislav Petkov @ 2025-03-11 11:17 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-kernel, linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada,
Ingo Molnar, Petr Pavlu
+ Petr for 9d9173e9ceb6
@Petr, you can find the whole thread on lore.
On Tue, Mar 11, 2025 at 12:06:21PM +0100, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Instead of generating the vmlinux.relocs file (needed by the
> decompressor build to construct the KASLR relocation tables) as a
> vmlinux postlink step, which is dubious because it depends on data that
> is stripped from vmlinux before the build completes, generate it from
> vmlinux.unstripped, which has been introduced specifically for this
> purpose.
>
> This ensures that each artifact is rebuilt as needed, rather than as a
> side effect of another build rule.
>
> This effectively reverts commit
>
> 9d9173e9ceb6 ("x86/build: Avoid relocation information in final vmlinux")
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/x86/Makefile.postlink | 38 --------------------
> arch/x86/boot/compressed/Makefile | 9 +++--
> 2 files changed, 6 insertions(+), 41 deletions(-)
>
> diff --git a/arch/x86/Makefile.postlink b/arch/x86/Makefile.postlink
> deleted file mode 100644
> index 445fce66630f..000000000000
> --- a/arch/x86/Makefile.postlink
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0
> -# ===========================================================================
> -# Post-link x86 pass
> -# ===========================================================================
> -#
> -# 1. Separate relocations from vmlinux into vmlinux.relocs.
> -# 2. Strip relocations from vmlinux.
> -
> -PHONY := __archpost
> -__archpost:
> -
> --include include/config/auto.conf
> -include $(srctree)/scripts/Kbuild.include
> -
> -CMD_RELOCS = arch/x86/tools/relocs
> -OUT_RELOCS = arch/x86/boot/compressed
> -quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/vmlinux.relocs
> - cmd_relocs = \
> - mkdir -p $(OUT_RELOCS); \
> - $(CMD_RELOCS) $@ > $(OUT_RELOCS)/vmlinux.relocs; \
> - $(CMD_RELOCS) --abs-relocs $@
> -
> -# `@true` prevents complaint when there is nothing to be done
> -
> -vmlinux vmlinux.unstripped: FORCE
> - @true
> -ifeq ($(CONFIG_X86_NEED_RELOCS),y)
> - $(call cmd,relocs)
> -endif
> -
> -clean:
> - @rm -f $(OUT_RELOCS)/vmlinux.relocs
> -
> -PHONY += FORCE clean
> -
> -FORCE:
> -
> -.PHONY: $(PHONY)
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index 606c74f27459..5edee7a9786c 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -117,9 +117,12 @@ $(obj)/vmlinux.bin: vmlinux FORCE
>
> targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
>
> -# vmlinux.relocs is created by the vmlinux postlink step.
> -$(obj)/vmlinux.relocs: vmlinux
> - @true
> +CMD_RELOCS = arch/x86/tools/relocs
> +quiet_cmd_relocs = RELOCS $@
> + cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
> +
> +$(obj)/vmlinux.relocs: vmlinux.unstripped FORCE
> + $(call if_changed,relocs)
>
> vmlinux.bin.all-y := $(obj)/vmlinux.bin
> vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
> --
> 2.49.0.rc0.332.g42c0ae87b1-goog
>
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 4/4] x86: Get rid of Makefile.postlink
2025-03-11 11:17 ` Borislav Petkov
@ 2025-03-12 12:35 ` Petr Pavlu
0 siblings, 0 replies; 19+ messages in thread
From: Petr Pavlu @ 2025-03-12 12:35 UTC (permalink / raw)
To: Borislav Petkov, Ard Biesheuvel
Cc: linux-kernel, linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada,
Ingo Molnar
On 3/11/25 12:17, Borislav Petkov wrote:
> + Petr for 9d9173e9ceb6
>
> @Petr, you can find the whole thread on lore.
>
> On Tue, Mar 11, 2025 at 12:06:21PM +0100, Ard Biesheuvel wrote:
>> From: Ard Biesheuvel <ardb@kernel.org>
>>
>> Instead of generating the vmlinux.relocs file (needed by the
>> decompressor build to construct the KASLR relocation tables) as a
>> vmlinux postlink step, which is dubious because it depends on data that
>> is stripped from vmlinux before the build completes, generate it from
>> vmlinux.unstripped, which has been introduced specifically for this
>> purpose.
>>
>> This ensures that each artifact is rebuilt as needed, rather than as a
>> side effect of another build rule.
>>
>> This effectively reverts commit
>>
>> 9d9173e9ceb6 ("x86/build: Avoid relocation information in final vmlinux")
>>
>> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
For what it's worth, the changes look to me as an improvement over the
previous implementation.
--
Thanks,
Petr
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 4/4] x86: Get rid of Makefile.postlink
2025-03-11 11:06 ` [PATCH v2 4/4] x86: Get rid of Makefile.postlink Ard Biesheuvel
2025-03-11 11:17 ` Borislav Petkov
@ 2025-03-13 2:08 ` Masahiro Yamada
2025-03-13 7:47 ` Ard Biesheuvel
1 sibling, 1 reply; 19+ messages in thread
From: Masahiro Yamada @ 2025-03-13 2:08 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-kernel, linux-kbuild, x86, Ard Biesheuvel, Ingo Molnar
On Tue, Mar 11, 2025 at 8:06 PM Ard Biesheuvel <ardb+git@google.com> wrote:
>
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Instead of generating the vmlinux.relocs file (needed by the
> decompressor build to construct the KASLR relocation tables) as a
> vmlinux postlink step, which is dubious because it depends on data that
> is stripped from vmlinux before the build completes, generate it from
> vmlinux.unstripped, which has been introduced specifically for this
> purpose.
>
> This ensures that each artifact is rebuilt as needed, rather than as a
> side effect of another build rule.
>
> This effectively reverts commit
>
> 9d9173e9ceb6 ("x86/build: Avoid relocation information in final vmlinux")
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/x86/Makefile.postlink | 38 --------------------
> arch/x86/boot/compressed/Makefile | 9 +++--
> 2 files changed, 6 insertions(+), 41 deletions(-)
>
> diff --git a/arch/x86/Makefile.postlink b/arch/x86/Makefile.postlink
> deleted file mode 100644
> index 445fce66630f..000000000000
> --- a/arch/x86/Makefile.postlink
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0
> -# ===========================================================================
> -# Post-link x86 pass
> -# ===========================================================================
> -#
> -# 1. Separate relocations from vmlinux into vmlinux.relocs.
> -# 2. Strip relocations from vmlinux.
> -
> -PHONY := __archpost
> -__archpost:
> -
> --include include/config/auto.conf
> -include $(srctree)/scripts/Kbuild.include
> -
> -CMD_RELOCS = arch/x86/tools/relocs
> -OUT_RELOCS = arch/x86/boot/compressed
> -quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/vmlinux.relocs
> - cmd_relocs = \
> - mkdir -p $(OUT_RELOCS); \
> - $(CMD_RELOCS) $@ > $(OUT_RELOCS)/vmlinux.relocs; \
> - $(CMD_RELOCS) --abs-relocs $@
> -
> -# `@true` prevents complaint when there is nothing to be done
> -
> -vmlinux vmlinux.unstripped: FORCE
> - @true
> -ifeq ($(CONFIG_X86_NEED_RELOCS),y)
> - $(call cmd,relocs)
> -endif
> -
> -clean:
> - @rm -f $(OUT_RELOCS)/vmlinux.relocs
> -
> -PHONY += FORCE clean
> -
> -FORCE:
> -
> -.PHONY: $(PHONY)
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index 606c74f27459..5edee7a9786c 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -117,9 +117,12 @@ $(obj)/vmlinux.bin: vmlinux FORCE
>
> targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
>
> -# vmlinux.relocs is created by the vmlinux postlink step.
> -$(obj)/vmlinux.relocs: vmlinux
> - @true
> +CMD_RELOCS = arch/x86/tools/relocs
> +quiet_cmd_relocs = RELOCS $@
> + cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
> +
> +$(obj)/vmlinux.relocs: vmlinux.unstripped FORCE
> + $(call if_changed,relocs)
Perhaps, it may make sense to rebuild vmlinux.relocs
when arch/x86/tools/relocs is changed, but
I do not see such dependency in the other
arch/x86/realmode/rm/Makefile.
https://github.com/torvalds/linux/blob/v6.14-rc5/arch/x86/realmode/rm/Makefile#L61
So, I decided it is ok.
If you mind, you can send v3.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 4/4] x86: Get rid of Makefile.postlink
2025-03-13 2:08 ` Masahiro Yamada
@ 2025-03-13 7:47 ` Ard Biesheuvel
0 siblings, 0 replies; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-13 7:47 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Ard Biesheuvel, linux-kernel, linux-kbuild, x86, Ingo Molnar
On Thu, 13 Mar 2025 at 03:09, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Tue, Mar 11, 2025 at 8:06 PM Ard Biesheuvel <ardb+git@google.com> wrote:
> >
> > From: Ard Biesheuvel <ardb@kernel.org>
> >
> > Instead of generating the vmlinux.relocs file (needed by the
> > decompressor build to construct the KASLR relocation tables) as a
> > vmlinux postlink step, which is dubious because it depends on data that
> > is stripped from vmlinux before the build completes, generate it from
> > vmlinux.unstripped, which has been introduced specifically for this
> > purpose.
> >
> > This ensures that each artifact is rebuilt as needed, rather than as a
> > side effect of another build rule.
> >
> > This effectively reverts commit
> >
> > 9d9173e9ceb6 ("x86/build: Avoid relocation information in final vmlinux")
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > ---
> > arch/x86/Makefile.postlink | 38 --------------------
> > arch/x86/boot/compressed/Makefile | 9 +++--
> > 2 files changed, 6 insertions(+), 41 deletions(-)
> >
> > diff --git a/arch/x86/Makefile.postlink b/arch/x86/Makefile.postlink
> > deleted file mode 100644
> > index 445fce66630f..000000000000
> > --- a/arch/x86/Makefile.postlink
> > +++ /dev/null
> > @@ -1,38 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0
> > -# ===========================================================================
> > -# Post-link x86 pass
> > -# ===========================================================================
> > -#
> > -# 1. Separate relocations from vmlinux into vmlinux.relocs.
> > -# 2. Strip relocations from vmlinux.
> > -
> > -PHONY := __archpost
> > -__archpost:
> > -
> > --include include/config/auto.conf
> > -include $(srctree)/scripts/Kbuild.include
> > -
> > -CMD_RELOCS = arch/x86/tools/relocs
> > -OUT_RELOCS = arch/x86/boot/compressed
> > -quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/vmlinux.relocs
> > - cmd_relocs = \
> > - mkdir -p $(OUT_RELOCS); \
> > - $(CMD_RELOCS) $@ > $(OUT_RELOCS)/vmlinux.relocs; \
> > - $(CMD_RELOCS) --abs-relocs $@
> > -
> > -# `@true` prevents complaint when there is nothing to be done
> > -
> > -vmlinux vmlinux.unstripped: FORCE
> > - @true
> > -ifeq ($(CONFIG_X86_NEED_RELOCS),y)
> > - $(call cmd,relocs)
> > -endif
> > -
> > -clean:
> > - @rm -f $(OUT_RELOCS)/vmlinux.relocs
> > -
> > -PHONY += FORCE clean
> > -
> > -FORCE:
> > -
> > -.PHONY: $(PHONY)
> > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> > index 606c74f27459..5edee7a9786c 100644
> > --- a/arch/x86/boot/compressed/Makefile
> > +++ b/arch/x86/boot/compressed/Makefile
> > @@ -117,9 +117,12 @@ $(obj)/vmlinux.bin: vmlinux FORCE
> >
> > targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
> >
> > -# vmlinux.relocs is created by the vmlinux postlink step.
> > -$(obj)/vmlinux.relocs: vmlinux
> > - @true
> > +CMD_RELOCS = arch/x86/tools/relocs
> > +quiet_cmd_relocs = RELOCS $@
> > + cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
> > +
> > +$(obj)/vmlinux.relocs: vmlinux.unstripped FORCE
> > + $(call if_changed,relocs)
>
> Perhaps, it may make sense to rebuild vmlinux.relocs
> when arch/x86/tools/relocs is changed, but
> I do not see such dependency in the other
> arch/x86/realmode/rm/Makefile.
>
> https://github.com/torvalds/linux/blob/v6.14-rc5/arch/x86/realmode/rm/Makefile#L61
>
>
> So, I decided it is ok.
> If you mind, you can send v3.
>
No I think that's fine: this patch reverts the changes to
arch/x86/boot/compressed/Makefile; if we need to improve it, it should
be a separate change in any case.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-11 11:06 ` [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved Ard Biesheuvel
@ 2025-03-13 9:21 ` kernel test robot
2025-03-13 9:34 ` Ard Biesheuvel
2025-04-30 16:03 ` Conor Dooley
1 sibling, 1 reply; 19+ messages in thread
From: kernel test robot @ 2025-03-13 9:21 UTC (permalink / raw)
To: Ard Biesheuvel, linux-kernel
Cc: llvm, oe-kbuild-all, linux-kbuild, x86, Ard Biesheuvel,
Masahiro Yamada, Ingo Molnar
Hi Ard,
kernel test robot noticed the following build errors:
[auto build test ERROR on masahiroy-kbuild/for-next]
[also build test ERROR on masahiroy-kbuild/fixes tip/x86/core s390/features linus/master v6.14-rc6 next-20250312]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/Kbuild-link-vmlinux-sh-Make-output-file-name-configurable/20250311-190926
base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link: https://lore.kernel.org/r/20250311110616.148682-9-ardb%2Bgit%40google.com
patch subject: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
config: x86_64-randconfig-076-20250313 (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503131715.Fb6CfjhT-lkp@intel.com/
All errors (new ones prefixed by >>):
>> gawk: scripts/generate_builtin_ranges.awk:82: fatal: cannot open file `vmlinux.map' for reading: No such file or directory
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-13 9:21 ` kernel test robot
@ 2025-03-13 9:34 ` Ard Biesheuvel
2025-03-13 10:18 ` Ard Biesheuvel
0 siblings, 1 reply; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-13 9:34 UTC (permalink / raw)
To: kernel test robot
Cc: Ard Biesheuvel, linux-kernel, llvm, oe-kbuild-all, linux-kbuild,
x86, Masahiro Yamada, Ingo Molnar
On Thu, 13 Mar 2025 at 10:21, kernel test robot <lkp@intel.com> wrote:
>
> Hi Ard,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on masahiroy-kbuild/for-next]
> [also build test ERROR on masahiroy-kbuild/fixes tip/x86/core s390/features linus/master v6.14-rc6 next-20250312]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/Kbuild-link-vmlinux-sh-Make-output-file-name-configurable/20250311-190926
> base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> patch link: https://lore.kernel.org/r/20250311110616.148682-9-ardb%2Bgit%40google.com
> patch subject: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
> config: x86_64-randconfig-076-20250313 (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202503131715.Fb6CfjhT-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> >> gawk: scripts/generate_builtin_ranges.awk:82: fatal: cannot open file `vmlinux.map' for reading: No such file or directory
>
Hmm it seems I missed some things in link-vmlinux.sh - I will take a look.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-13 9:34 ` Ard Biesheuvel
@ 2025-03-13 10:18 ` Ard Biesheuvel
2025-03-13 10:29 ` Masahiro Yamada
0 siblings, 1 reply; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-13 10:18 UTC (permalink / raw)
To: kernel test robot
Cc: Ard Biesheuvel, linux-kernel, llvm, oe-kbuild-all, linux-kbuild,
x86, Masahiro Yamada, Ingo Molnar
On Thu, 13 Mar 2025 at 10:34, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Thu, 13 Mar 2025 at 10:21, kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Ard,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on masahiroy-kbuild/for-next]
> > [also build test ERROR on masahiroy-kbuild/fixes tip/x86/core s390/features linus/master v6.14-rc6 next-20250312]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/Kbuild-link-vmlinux-sh-Make-output-file-name-configurable/20250311-190926
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> > patch link: https://lore.kernel.org/r/20250311110616.148682-9-ardb%2Bgit%40google.com
> > patch subject: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
> > config: x86_64-randconfig-076-20250313 (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/config)
> > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202503131715.Fb6CfjhT-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> > >> gawk: scripts/generate_builtin_ranges.awk:82: fatal: cannot open file `vmlinux.map' for reading: No such file or directory
> >
>
> Hmm it seems I missed some things in link-vmlinux.sh - I will take a look.
We'd need something like the below applied on top - shall I send a v3?
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -46,6 +46,7 @@
# Link of vmlinux
# ${1} - output file
+# ${2} - map file
vmlinux_link()
{
local output=${1}
@@ -99,7 +100,7 @@ vmlinux_link()
fi
if is_enabled CONFIG_VMLINUX_MAP; then
- ldflags="${ldflags} ${wl}-Map=${output}.map"
+ ldflags="${ldflags} ${wl}-Map=${2}"
fi
${ld} ${ldflags} -o ${output} \
@@ -185,7 +186,7 @@
{
rm -f .btf.*
rm -f System.map
- rm -f vmlinux
+ rm -f ${VMLINUX}
rm -f vmlinux.map
}
@@ -224,7 +225,7 @@
strip_debug=1
fi
- vmlinux_link .tmp_vmlinux1
+ vmlinux_link .tmp_vmlinux1 .tmp_vmlinux1.map
fi
if is_enabled CONFIG_DEBUG_INFO_BTF; then
@@ -267,19 +268,19 @@
sysmap_and_kallsyms .tmp_vmlinux1
size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
- vmlinux_link .tmp_vmlinux2
+ vmlinux_link .tmp_vmlinux2 .tmp_vmlinux2.map
sysmap_and_kallsyms .tmp_vmlinux2
size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
- vmlinux_link .tmp_vmlinux3
+ vmlinux_link .tmp_vmlinux3 .tmp_vmlinux3.map
sysmap_and_kallsyms .tmp_vmlinux3
fi
fi
strip_debug=
-vmlinux_link "${VMLINUX}"
+vmlinux_link "${VMLINUX}" vmlinux.map
# fill in BTF IDs
if is_enabled CONFIG_DEBUG_INFO_BTF; then
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-13 10:18 ` Ard Biesheuvel
@ 2025-03-13 10:29 ` Masahiro Yamada
2025-03-18 8:17 ` Heiko Carstens
0 siblings, 1 reply; 19+ messages in thread
From: Masahiro Yamada @ 2025-03-13 10:29 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: kernel test robot, Ard Biesheuvel, linux-kernel, llvm,
oe-kbuild-all, linux-kbuild, x86, Ingo Molnar
On Thu, Mar 13, 2025 at 7:18 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Thu, 13 Mar 2025 at 10:34, Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > On Thu, 13 Mar 2025 at 10:21, kernel test robot <lkp@intel.com> wrote:
> > >
> > > Hi Ard,
> > >
> > > kernel test robot noticed the following build errors:
> > >
> > > [auto build test ERROR on masahiroy-kbuild/for-next]
> > > [also build test ERROR on masahiroy-kbuild/fixes tip/x86/core s390/features linus/master v6.14-rc6 next-20250312]
> > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > And when submitting patch, we suggest to use '--base' as documented in
> > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > >
> > > url: https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/Kbuild-link-vmlinux-sh-Make-output-file-name-configurable/20250311-190926
> > > base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> > > patch link: https://lore.kernel.org/r/20250311110616.148682-9-ardb%2Bgit%40google.com
> > > patch subject: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
> > > config: x86_64-randconfig-076-20250313 (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/config)
> > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/reproduce)
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202503131715.Fb6CfjhT-lkp@intel.com/
> > >
> > > All errors (new ones prefixed by >>):
> > >
> > > >> gawk: scripts/generate_builtin_ranges.awk:82: fatal: cannot open file `vmlinux.map' for reading: No such file or directory
> > >
> >
> > Hmm it seems I missed some things in link-vmlinux.sh - I will take a look.
>
> We'd need something like the below applied on top - shall I send a v3?
I will insert this before you patch set.
https://lore.kernel.org/linux-kbuild/20250313102604.1491732-1-masahiroy@kernel.org/T/#u
I would have done this earlier.
That is simply because I always run out of my time
and I do not have time to fix issues before someone stumbles on them.
>
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -46,6 +46,7 @@
>
> # Link of vmlinux
> # ${1} - output file
> +# ${2} - map file
> vmlinux_link()
> {
> local output=${1}
> @@ -99,7 +100,7 @@ vmlinux_link()
> fi
>
> if is_enabled CONFIG_VMLINUX_MAP; then
> - ldflags="${ldflags} ${wl}-Map=${output}.map"
> + ldflags="${ldflags} ${wl}-Map=${2}"
> fi
>
> ${ld} ${ldflags} -o ${output} \
> @@ -185,7 +186,7 @@
> {
> rm -f .btf.*
> rm -f System.map
> - rm -f vmlinux
> + rm -f ${VMLINUX}
> rm -f vmlinux.map
> }
>
> @@ -224,7 +225,7 @@
> strip_debug=1
> fi
>
> - vmlinux_link .tmp_vmlinux1
> + vmlinux_link .tmp_vmlinux1 .tmp_vmlinux1.map
> fi
>
> if is_enabled CONFIG_DEBUG_INFO_BTF; then
> @@ -267,19 +268,19 @@
> sysmap_and_kallsyms .tmp_vmlinux1
> size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
>
> - vmlinux_link .tmp_vmlinux2
> + vmlinux_link .tmp_vmlinux2 .tmp_vmlinux2.map
> sysmap_and_kallsyms .tmp_vmlinux2
> size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
>
> if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
> - vmlinux_link .tmp_vmlinux3
> + vmlinux_link .tmp_vmlinux3 .tmp_vmlinux3.map
> sysmap_and_kallsyms .tmp_vmlinux3
> fi
> fi
>
> strip_debug=
>
> -vmlinux_link "${VMLINUX}"
> +vmlinux_link "${VMLINUX}" vmlinux.map
>
> # fill in BTF IDs
> if is_enabled CONFIG_DEBUG_INFO_BTF; then
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step
2025-03-11 11:06 [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Ard Biesheuvel
` (3 preceding siblings ...)
2025-03-11 11:06 ` [PATCH v2 4/4] x86: Get rid of Makefile.postlink Ard Biesheuvel
@ 2025-03-15 7:09 ` Masahiro Yamada
4 siblings, 0 replies; 19+ messages in thread
From: Masahiro Yamada @ 2025-03-15 7:09 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-kernel, linux-kbuild, x86, Ard Biesheuvel, Ingo Molnar
On Tue, Mar 11, 2025 at 8:06 PM Ard Biesheuvel <ardb+git@google.com> wrote:
>
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Kbuild supports an architecture specific Makefile.postlink file that is
> invoked for the vmlinux target after it has been built. This Makefile
> takes 'vmlinux' (which has just been built) as the target, and mangles
> the file and/or constructs other intermediate artifacts from it.
>
> This violates the general philosophy of Make, which is based on rules
> and dependencies, and artifacts that are rebuilt only when any of their
> dependencies have been updated.
>
> Instead, the different incarnations of vmlinux that are consumed by
> different stages of the build should be emitted as distinct files, where
> rules and dependencies are used to define one in terms of the other.
>
> This also works around an error observed here [0], where vmlinux is
> deleted by Make because a subsequent step that consumes it as input
> throws an error.
>
> So refactor the vmlinux shell scripts and build rules so that
> architectures that rely on --emit-relocs to construct vmlinux with
> static relocations preserved will get a separate vmlinux.unstripped file
> carrying those relocations. This removes the need for an imperative
> postlink step, given that any rules that depend on the unstripped
> vmlinux can now simply depend on vmlinux.unstripped, rather than inject
> a build step into Makefile.postlink
>
> S390 should be able to do the same. MIPS and RISC-V perform some
> post-build checks on vmlinux, which is reasonable in principle for a
> postlink step, although deleting vmlinux when the check fails is equally
> unhelpful.
>
> Changes since v1:
> - add vmlinux.unstripped to .gitignore and to the 'clean' target
> - move cmd_strip_relocs into Makefile.vmlinux
Applied to linux-kbuild.
Thanks!
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-13 10:29 ` Masahiro Yamada
@ 2025-03-18 8:17 ` Heiko Carstens
2025-03-18 8:27 ` Ard Biesheuvel
0 siblings, 1 reply; 19+ messages in thread
From: Heiko Carstens @ 2025-03-18 8:17 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Ard Biesheuvel, kernel test robot, Ard Biesheuvel, linux-kernel,
llvm, oe-kbuild-all, linux-kbuild, x86, Ingo Molnar,
Alexander Gordeev, Vasily Gorbik, linux-s390, linux-next,
Stephen Rothwell
On Thu, Mar 13, 2025 at 07:29:41PM +0900, Masahiro Yamada wrote:
> On Thu, Mar 13, 2025 at 7:18 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> > On Thu, 13 Mar 2025 at 10:34, Ard Biesheuvel <ardb@kernel.org> wrote:
> > > On Thu, 13 Mar 2025 at 10:21, kernel test robot <lkp@intel.com> wrote:
> > > > kernel test robot noticed the following build errors:
> > > >
> > > > [auto build test ERROR on masahiroy-kbuild/for-next]
> > > > [also build test ERROR on masahiroy-kbuild/fixes tip/x86/core s390/features linus/master v6.14-rc6 next-20250312]
> > > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > > And when submitting patch, we suggest to use '--base' as documented in
> > > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > > >
> > > > url: https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/Kbuild-link-vmlinux-sh-Make-output-file-name-configurable/20250311-190926
> > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> > > > patch link: https://lore.kernel.org/r/20250311110616.148682-9-ardb%2Bgit%40google.com
> > > > patch subject: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
> > > > config: x86_64-randconfig-076-20250313 (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/config)
> > > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/reproduce)
> > > >
> > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > > the same patch/commit), kindly add following tags
> > > > | Reported-by: kernel test robot <lkp@intel.com>
> > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202503131715.Fb6CfjhT-lkp@intel.com/
> > > >
> > > > All errors (new ones prefixed by >>):
> > > >
> > > > >> gawk: scripts/generate_builtin_ranges.awk:82: fatal: cannot open file `vmlinux.map' for reading: No such file or directory
> > > >
> > >
> > > Hmm it seems I missed some things in link-vmlinux.sh - I will take a look.
> >
> > We'd need something like the below applied on top - shall I send a v3?
>
> I will insert this before you patch set.
> https://lore.kernel.org/linux-kbuild/20250313102604.1491732-1-masahiroy@kernel.org/T/#u
...
> > --- a/scripts/link-vmlinux.sh
> > +++ b/scripts/link-vmlinux.sh
...
> > -vmlinux_link "${VMLINUX}"
> > +vmlinux_link "${VMLINUX}" vmlinux.map
> >
> > # fill in BTF IDs
> > if is_enabled CONFIG_DEBUG_INFO_BTF; then
Building linux-next breaks on s390 with DEBUG_INFO_BTF enabled because
of this; just where your addon patch ends:
LD vmlinux.unstripped
BTFIDS vmlinux
FAILED cannot open vmlinux: No such file or directory
make[2]: *** [scripts/Makefile.vmlinux:91: vmlinux.unstripped] Error 255
make[2]: *** Deleting file 'vmlinux.unstripped'
make[1]: *** [/home/builder/linux-next/Makefile:1239: vmlinux] Error 2
make: *** [Makefile:248: __sub-make] Error 2
I guess _something_ like below is needed to fix this (works for
me(tm)):
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 4949d0c8c267..51367c2bfc21 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -286,12 +286,12 @@ vmlinux_link "${VMLINUX}"
# fill in BTF IDs
if is_enabled CONFIG_DEBUG_INFO_BTF; then
- info BTFIDS vmlinux
+ info BTFIDS "${VMLINUX}"
RESOLVE_BTFIDS_ARGS=""
if is_enabled CONFIG_WERROR; then
RESOLVE_BTFIDS_ARGS=" --fatal_warnings "
fi
- ${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} vmlinux
+ ${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} "${VMLINUX}"
fi
mksysmap "${VMLINUX}" System.map
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-18 8:17 ` Heiko Carstens
@ 2025-03-18 8:27 ` Ard Biesheuvel
2025-03-18 16:26 ` Masahiro Yamada
0 siblings, 1 reply; 19+ messages in thread
From: Ard Biesheuvel @ 2025-03-18 8:27 UTC (permalink / raw)
To: Heiko Carstens
Cc: Masahiro Yamada, kernel test robot, Ard Biesheuvel, linux-kernel,
llvm, oe-kbuild-all, linux-kbuild, x86, Ingo Molnar,
Alexander Gordeev, Vasily Gorbik, linux-s390, linux-next,
Stephen Rothwell
On Tue, 18 Mar 2025 at 09:18, Heiko Carstens <hca@linux.ibm.com> wrote:
>
> On Thu, Mar 13, 2025 at 07:29:41PM +0900, Masahiro Yamada wrote:
> > On Thu, Mar 13, 2025 at 7:18 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> > > On Thu, 13 Mar 2025 at 10:34, Ard Biesheuvel <ardb@kernel.org> wrote:
> > > > On Thu, 13 Mar 2025 at 10:21, kernel test robot <lkp@intel.com> wrote:
> > > > > kernel test robot noticed the following build errors:
> > > > >
> > > > > [auto build test ERROR on masahiroy-kbuild/for-next]
> > > > > [also build test ERROR on masahiroy-kbuild/fixes tip/x86/core s390/features linus/master v6.14-rc6 next-20250312]
> > > > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > > > And when submitting patch, we suggest to use '--base' as documented in
> > > > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > > > >
> > > > > url: https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/Kbuild-link-vmlinux-sh-Make-output-file-name-configurable/20250311-190926
> > > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> > > > > patch link: https://lore.kernel.org/r/20250311110616.148682-9-ardb%2Bgit%40google.com
> > > > > patch subject: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
> > > > > config: x86_64-randconfig-076-20250313 (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/config)
> > > > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/reproduce)
> > > > >
> > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > > > the same patch/commit), kindly add following tags
> > > > > | Reported-by: kernel test robot <lkp@intel.com>
> > > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202503131715.Fb6CfjhT-lkp@intel.com/
> > > > >
> > > > > All errors (new ones prefixed by >>):
> > > > >
> > > > > >> gawk: scripts/generate_builtin_ranges.awk:82: fatal: cannot open file `vmlinux.map' for reading: No such file or directory
> > > > >
> > > >
> > > > Hmm it seems I missed some things in link-vmlinux.sh - I will take a look.
> > >
> > > We'd need something like the below applied on top - shall I send a v3?
> >
> > I will insert this before you patch set.
> > https://lore.kernel.org/linux-kbuild/20250313102604.1491732-1-masahiroy@kernel.org/T/#u
> ...
> > > --- a/scripts/link-vmlinux.sh
> > > +++ b/scripts/link-vmlinux.sh
> ...
> > > -vmlinux_link "${VMLINUX}"
> > > +vmlinux_link "${VMLINUX}" vmlinux.map
> > >
> > > # fill in BTF IDs
> > > if is_enabled CONFIG_DEBUG_INFO_BTF; then
>
> Building linux-next breaks on s390 with DEBUG_INFO_BTF enabled because
> of this; just where your addon patch ends:
>
Apologies for the breakage - this should already have been fixed in
the kbuild tree [0] but the fix does not appear to have landed yet.
[0] https://lore.kernel.org/all/202503161833.ytx1ivfu-lkp@intel.com
Masahiro?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-18 8:27 ` Ard Biesheuvel
@ 2025-03-18 16:26 ` Masahiro Yamada
0 siblings, 0 replies; 19+ messages in thread
From: Masahiro Yamada @ 2025-03-18 16:26 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Heiko Carstens, kernel test robot, Ard Biesheuvel, linux-kernel,
llvm, oe-kbuild-all, linux-kbuild, x86, Ingo Molnar,
Alexander Gordeev, Vasily Gorbik, linux-s390, linux-next,
Stephen Rothwell
On Tue, Mar 18, 2025 at 5:27 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Tue, 18 Mar 2025 at 09:18, Heiko Carstens <hca@linux.ibm.com> wrote:
> >
> > On Thu, Mar 13, 2025 at 07:29:41PM +0900, Masahiro Yamada wrote:
> > > On Thu, Mar 13, 2025 at 7:18 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> > > > On Thu, 13 Mar 2025 at 10:34, Ard Biesheuvel <ardb@kernel.org> wrote:
> > > > > On Thu, 13 Mar 2025 at 10:21, kernel test robot <lkp@intel.com> wrote:
> > > > > > kernel test robot noticed the following build errors:
> > > > > >
> > > > > > [auto build test ERROR on masahiroy-kbuild/for-next]
> > > > > > [also build test ERROR on masahiroy-kbuild/fixes tip/x86/core s390/features linus/master v6.14-rc6 next-20250312]
> > > > > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > > > > And when submitting patch, we suggest to use '--base' as documented in
> > > > > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > > > > >
> > > > > > url: https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/Kbuild-link-vmlinux-sh-Make-output-file-name-configurable/20250311-190926
> > > > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> > > > > > patch link: https://lore.kernel.org/r/20250311110616.148682-9-ardb%2Bgit%40google.com
> > > > > > patch subject: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
> > > > > > config: x86_64-randconfig-076-20250313 (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/config)
> > > > > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > > > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250313/202503131715.Fb6CfjhT-lkp@intel.com/reproduce)
> > > > > >
> > > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > > > > the same patch/commit), kindly add following tags
> > > > > > | Reported-by: kernel test robot <lkp@intel.com>
> > > > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202503131715.Fb6CfjhT-lkp@intel.com/
> > > > > >
> > > > > > All errors (new ones prefixed by >>):
> > > > > >
> > > > > > >> gawk: scripts/generate_builtin_ranges.awk:82: fatal: cannot open file `vmlinux.map' for reading: No such file or directory
> > > > > >
> > > > >
> > > > > Hmm it seems I missed some things in link-vmlinux.sh - I will take a look.
> > > >
> > > > We'd need something like the below applied on top - shall I send a v3?
> > >
> > > I will insert this before you patch set.
> > > https://lore.kernel.org/linux-kbuild/20250313102604.1491732-1-masahiroy@kernel.org/T/#u
> > ...
> > > > --- a/scripts/link-vmlinux.sh
> > > > +++ b/scripts/link-vmlinux.sh
> > ...
> > > > -vmlinux_link "${VMLINUX}"
> > > > +vmlinux_link "${VMLINUX}" vmlinux.map
> > > >
> > > > # fill in BTF IDs
> > > > if is_enabled CONFIG_DEBUG_INFO_BTF; then
> >
> > Building linux-next breaks on s390 with DEBUG_INFO_BTF enabled because
> > of this; just where your addon patch ends:
> >
>
> Apologies for the breakage - this should already have been fixed in
> the kbuild tree [0] but the fix does not appear to have landed yet.
>
> [0] https://lore.kernel.org/all/202503161833.ytx1ivfu-lkp@intel.com
>
>
> Masahiro?
Sorry, I had applied the fix-up locally, but
forgot to do "git push".
The correct one is now available, and I hope
tomorrow's linux-next will be OK.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-03-11 11:06 ` [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved Ard Biesheuvel
2025-03-13 9:21 ` kernel test robot
@ 2025-04-30 16:03 ` Conor Dooley
2025-04-30 16:29 ` Palmer Dabbelt
1 sibling, 1 reply; 19+ messages in thread
From: Conor Dooley @ 2025-04-30 16:03 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-kernel, linux-kbuild, x86, Ard Biesheuvel, Masahiro Yamada,
Ingo Molnar, palmer
[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]
+CC Palmer
On Tue, Mar 11, 2025 at 12:06:20PM +0100, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> The imperative paradigm used to build vmlinux, extract some info from it
> or perform some checks on it, and subsequently modify it again goes
> against the declarative paradigm that is usually employed for defining
> make rules.
>
> In particular, the Makefile.postlink files that consume their input via
> an output rule result in some dodgy logic in the decompressor makefiles
> for RISC-V and x86, given that the vmlinux.relocs input file needed to
> generate the arch-specific relocation tables may not exist or be out of
> date, but cannot be constructed using the ordinary Make dependency based
> rules, because the info needs to be extracted while vmlinux is in its
> ephemeral, non-stripped form.
>
> So instead, for architectures that require the static relocations that
> are emitted into vmlinux when passing --emit-relocs to the linker, and
> are subsequently stripped out again, introduce an intermediate vmlinux
> target called vmlinux.unstripped, and organize the reset of the build
> logic accordingly:
>
> - vmlinux.unstripped is created only once, and not updated again
> - build rules under arch/*/boot can depend on vmlinux.unstripped without
> running the risk of the data disappearing or being out of date
> - the final vmlinux generated by the build is not bloated with static
> relocations that are never needed again after the build completes.
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Delayed report since I have been slacking on my testing, but looks like
this has broken boot for me on riscv (mpfs-icicle-kit), no output after
"Starting kernel", defconfig should be:
https://raw.githubusercontent.com/ConchuOD/riscv-env/refs/heads/dev/conf/defconfig
Toolchain is llvm 16. LMK if there's some salient info missing.
Cheers,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved
2025-04-30 16:03 ` Conor Dooley
@ 2025-04-30 16:29 ` Palmer Dabbelt
0 siblings, 0 replies; 19+ messages in thread
From: Palmer Dabbelt @ 2025-04-30 16:29 UTC (permalink / raw)
To: Conor Dooley
Cc: ardb+git, linux-kernel, linux-kbuild, x86, Ard Biesheuvel,
masahiroy, mingo
On Wed, 30 Apr 2025 09:03:56 PDT (-0700), Conor Dooley wrote:
> +CC Palmer
>
> On Tue, Mar 11, 2025 at 12:06:20PM +0100, Ard Biesheuvel wrote:
>> From: Ard Biesheuvel <ardb@kernel.org>
>>
>> The imperative paradigm used to build vmlinux, extract some info from it
>> or perform some checks on it, and subsequently modify it again goes
>> against the declarative paradigm that is usually employed for defining
>> make rules.
>>
>> In particular, the Makefile.postlink files that consume their input via
>> an output rule result in some dodgy logic in the decompressor makefiles
>> for RISC-V and x86, given that the vmlinux.relocs input file needed to
>> generate the arch-specific relocation tables may not exist or be out of
>> date, but cannot be constructed using the ordinary Make dependency based
>> rules, because the info needs to be extracted while vmlinux is in its
>> ephemeral, non-stripped form.
>>
>> So instead, for architectures that require the static relocations that
>> are emitted into vmlinux when passing --emit-relocs to the linker, and
>> are subsequently stripped out again, introduce an intermediate vmlinux
>> target called vmlinux.unstripped, and organize the reset of the build
>> logic accordingly:
>>
>> - vmlinux.unstripped is created only once, and not updated again
>> - build rules under arch/*/boot can depend on vmlinux.unstripped without
>> running the risk of the data disappearing or being out of date
>> - the final vmlinux generated by the build is not bloated with static
>> relocations that are never needed again after the build completes.
>>
>> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> Delayed report since I have been slacking on my testing, but looks like
> this has broken boot for me on riscv (mpfs-icicle-kit), no output after
> "Starting kernel", defconfig should be:
> https://raw.githubusercontent.com/ConchuOD/riscv-env/refs/heads/dev/conf/defconfig
> Toolchain is llvm 16. LMK if there's some salient info missing.
Thanks for tracking this down. It's not manifesting on my end, but we
talked this morning about this maybe being some config-specific issue.
I'm also on LLVM 18.
I'm going to start poking around with the configs...
>
> Cheers,
> Conor.
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-04-30 16:29 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 11:06 [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 1/4] Kbuild/link-vmlinux.sh: Make output file name configurable Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 2/4] Kbuild: Introduce Kconfig symbol for linking vmlinux with relocations Ard Biesheuvel
2025-03-11 11:06 ` [PATCH v2 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved Ard Biesheuvel
2025-03-13 9:21 ` kernel test robot
2025-03-13 9:34 ` Ard Biesheuvel
2025-03-13 10:18 ` Ard Biesheuvel
2025-03-13 10:29 ` Masahiro Yamada
2025-03-18 8:17 ` Heiko Carstens
2025-03-18 8:27 ` Ard Biesheuvel
2025-03-18 16:26 ` Masahiro Yamada
2025-04-30 16:03 ` Conor Dooley
2025-04-30 16:29 ` Palmer Dabbelt
2025-03-11 11:06 ` [PATCH v2 4/4] x86: Get rid of Makefile.postlink Ard Biesheuvel
2025-03-11 11:17 ` Borislav Petkov
2025-03-12 12:35 ` Petr Pavlu
2025-03-13 2:08 ` Masahiro Yamada
2025-03-13 7:47 ` Ard Biesheuvel
2025-03-15 7:09 ` [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox