public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] x86/build: Get rid of vmlinux postlink step
@ 2025-02-24 13:21 Ard Biesheuvel
  2025-02-24 13:21 ` [RFC PATCH 1/4] Kbuild/link-vmlinux.sh: Make output file name configurable Ard Biesheuvel
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2025-02-24 13:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, linux-kbuild, 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.

[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

 Makefile                          |  4 ++
 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 |  8 ++--
 scripts/Makefile.lib              |  2 +-
 scripts/Makefile.vmlinux          | 27 +++++++++----
 scripts/link-vmlinux.sh           | 11 +++---
 19 files changed, 52 insertions(+), 87 deletions(-)
 delete mode 100644 arch/x86/Makefile.postlink

-- 
2.48.1.601.g30ceb7b040-goog


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-03-13 10:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 13:21 [RFC PATCH 0/4] x86/build: Get rid of vmlinux postlink step Ard Biesheuvel
2025-02-24 13:21 ` [RFC PATCH 1/4] Kbuild/link-vmlinux.sh: Make output file name configurable Ard Biesheuvel
2025-02-24 13:21 ` [RFC PATCH 2/4] Kbuild: Introduce Kconfig symbol for linking vmlinux with relocations Ard Biesheuvel
2025-03-07 18:58   ` Masahiro Yamada
2025-02-24 13:21 ` [RFC PATCH 3/4] Kbuild: Create intermediate vmlinux build with relocations preserved Ard Biesheuvel
2025-03-07 19:04   ` Masahiro Yamada
2025-02-24 13:21 ` [RFC PATCH 4/4] x86: Get rid of Makefile.postlink Ard Biesheuvel
2025-02-24 18:51 ` [RFC PATCH 0/4] x86/build: Get rid of vmlinux postlink step Ingo Molnar
2025-02-24 19:59   ` Linus Torvalds
2025-02-24 21:25     ` Ard Biesheuvel
2025-02-24 21:28   ` Ard Biesheuvel
2025-03-06 16:47 ` Ard Biesheuvel
2025-03-07 18:54   ` Masahiro Yamada
2025-03-08 10:49     ` Ard Biesheuvel
2025-03-08 16:17       ` Masahiro Yamada
2025-03-08 22:42         ` Ard Biesheuvel
2025-03-09  9:48           ` Ingo Molnar
2025-03-11  2:38             ` Masahiro Yamada
2025-03-11  6:40               ` Ard Biesheuvel
2025-03-11  9:52                 ` Masahiro Yamada
2025-03-11 16:00                 ` Petr Pavlu
2025-03-13 10:31                 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox