Repository navigation
Rebuild outputs when their commands change - #8
Merged
Merged
Conversation
LazyMake rebuilt an output only when a prerequisite file was newer, so a changed compiler or linker flag, a changed tool, or a source dropped from a target left stale objects, archives, and links. Each output now records the command of its last successful build, and an output whose command no longer matches gains a phony prerequisite. The comparison runs during secondary expansion, so make -n, -q, and -B keep their meaning. That expansion has no $<, so the compile command names its source. It also cannot see a variable inherited from another target's target-specific assignment. The record holds the text the expansion saw, so such a variable goes uncompared instead of rebuilding on every run. Existing build trees have no records, so the first build after upgrading rebuilds every output once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Templates now declare only each output's command and file prerequisites. Two rules supply the comparison and recipe for every object and every link or archive output, so a new output kind cannot miss either piece. Objects append their record to the dependency file the compiler rewrites on each compile, which drops an included makefile per object and most of the no-op cost it added. The record write is now the only escaping step, and binaries and tests share one link command. The shared recipe makes the archive's rm -f part of its echoed command. The header-edit check now restores the default command first, so only the header edit can rebuild the binary it checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR rebuilds an object, archive, or link output when its command changes, not only when a prerequisite file is newer. Changed flags, tools, and source lists used to leave stale outputs; for example, a linker flag added in a project's
Build.mknever relinked existing shared libraries.build/.make -n,-q, and-Bstay accurate. Templates now declare only each command and its file prerequisites.rm -fnow appears in its echoed command.Validated with
make -C tests host(GNU Make 3.81) andmake -C tests docker(Ubuntu arm64 and amd64, GNU Make 4.3); reverting any of the six new mechanisms fails the suite. In Whirlwind a no-op build goes from 0.29 s to 0.34 s, and a linker flag added inBuild.mkrelinks all 17 shared libraries without compiling; on a synthetic component of similar size, peak Make memory rises from 22 MB to 49 MB.