Skip to content

x86/build: Get rid of vmlinux postlink step

Ard Biesheuvel linux-kbuild linux-next linux-s390 lkml llvm oe-kbuild-all 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 13 repliesIn review
  2. v1 RFC4 patches 17 repliesSuperseded

Changes in v2 from the cover letter

- add vmlinux.unstripped to .gitignore and to the 'clean' target
- move cmd_strip_relocs into Makefile.vmlinux

[0] https://lore.kernel.org/all/[email protected]/T/#m731ed0206949fc3f39fcc8a7b82fe348a8fc80c4

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4Kbuild/link-vmlinux.sh: Make output file name configurablescripts/Makefile.vmlinux scripts/link-vmlinux.sh+7 -60 replies
2/4Kbuild: Introduce Kconfig symbol for linking vmlinux with relocationsMakefile arch/Kconfig arch/mips/Kconfig +7 more+17 -120 replies
3/4Kbuild: Create intermediate vmlinux build with relocations preserved.gitignore Makefile arch/mips/Makefile.postlink +6 more+30 -348 replies
4/4x86: Get rid of Makefile.postlinkarch/x86/Makefile.postlink arch/x86/boot/compressed/Makefile+6 -414 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] x86/build: Get rid of vmlinux postlink step

From: Ard Biesheuvel <[email protected]>

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/[email protected]/T/#m731ed0206949fc3f39fcc8a7b82fe348a8fc80c4

Cc Masahiro Yamada <[email protected]>
Cc Ingo Molnar <[email protected]>

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
Signature · 1 line
2.49.0.rc0.332.g42c0ae87b1-goog