On Tue, Mar 11, 2025 at 8:06 PM Ard Biesheuvel <ardb+git@xxxxxxxxxx> wrote: > > From: Ard Biesheuvel <ardb@xxxxxxxxxx> > > 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