diff options
author | Nicholas Chin <nic.c3.14@gmail.com> | 2024-09-15 11:35:28 -0600 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2024-09-28 20:46:07 +0000 |
commit | a0dc215c9b8786f54a2a86d83368348ab3006ec1 (patch) | |
tree | 9fe4f54581ffd7264464f772cfa9fde16e4e9f14 /src/cpu/Makefile.mk | |
parent | 86517315376011afa864c30571091e4789ca26c3 (diff) |
Makefile: Fix no-op incremental build
If make is ran a second time after an initial clean compile, the entire
rom will be rebuilt. Subsequent calls to make will not rebuild the rom.
This initial rebuild was due to build/util/kconfig/conf being newer than
config.h, and the subsequent rebuild of the header marked everything
else as out of date. The reason conf was newer than config.h is because
it was being treated as an intermediate file [1]. In the rule for
config.h, conf is a prerequisite, but since it is treated as an
intermediate, its rule will not be run if config.h exists and all the
prerequisites of conf (i.e. its source files) are also up to date.
On a clean build after a make menuconfig, config.h exists, satisfying
these conditions. In this case, config.h is treated as being up to date
even though conf does not exist. However, if another target does not
exist and also has conf as a prerequisite, conf will then be built so
that the target can be built. This caused conf to be newer than
config.h, but by default GNU Make deletes intermediate files after a
build which would prevent conf from affecting config.h on subsequent
rebuilds.
However, commit dd6efce934fb ("Makefile: Add .SECONDARY") adds the
.SECONDARY special target, which prevents intermediate files from being
deleted after the build [2]. Thus, conf persists to the first no-op
build, making config.h out of date. Since config.h is updated during
this first rebuild, conf is no longer newer than it, and thus subsequent
no-op builds behave as expected.
Fix this by preventing conf from being treated as an intermediate file
by adding it as a prerequisite of the .NOTINTERMEDIATE special target,
which causes conf to always be rebuilt if it does not exist. Thus, on
the initial clean compile, config.h will be updated after building conf
as a prerequisite, preventing config.h from being marked out of date on
a subsequent rebuild.
[1] https://www.gnu.org/software/make/manual/html_node/Chained-Rules.html
[2] https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
Change-Id: I98c49d47f811e5cceebce7b7d54b282c773734e3
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84385
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/cpu/Makefile.mk')
0 files changed, 0 insertions, 0 deletions