Re:Redo: A recursive, general-purpose build system
by sigjuice on Tuesday December 28, 2021 @08:05PM
(#29720430)
make doesn't really understand C or C dependencies, but the compilers usually do. Here is a minimal example that will take care of dependencies by passing -MD -MP to gcc or clang. The dependencies (*.d files) get generated as part of the normal gcc/clang invocations. There is no separate dependency generation step.
[ Parent
| on HN ]
Re:Redo: A recursive, general-purpose build system
by JdeBP on Wednesday December 29, 2021 @02:25AM
(#29722714)
Actually, the compilers do not and you are doing less than half of the job there. They don't emit information about the non-existent files that would change the build if they were to suddenly exist, such as an "x.h" in one of several standard search directories in that example.
* http://jdebp.uk./FGA/introduction-to-redo.html#CompilerDefic...
Re:Redo: A recursive, general-purpose build system
by glandium on Wednesday December 29, 2021 @05:12AM
(#29723475)
Also they don't add an empty rule for the source file (like they can do for headers), so if you rename from e.g. foo.c to foo.cpp, which still produces a foo.o, your incremental build fails because the dep file still has the dep on foo.c which doesn't exist anymore.
Re:Redo: A recursive, general-purpose build system
by brandmeyer on Wednesday December 29, 2021 @10:58AM
(#29725956)
The original sin here is generating the dependencies from the source files in the same step that was used to generate the object files. The only way to ensure that Make observes structural changes in the dependency DAG is if the graph is rebuilt.
Re:Redo: A recursive, general-purpose build system
by glandium on Wednesday December 29, 2021 @04:02PM
(#29729988)
Good old "make depend". If only it didn't add a significant overhead...
Re:Redo: A recursive, general-purpose build system
by brandmeyer on Thursday December 30, 2021 @01:12PM
(#29739422)
You can get make to only re-generate its rules incrementally based on what was changed.
https://www.gnu.org/software/make/manual/html_node/Remaking-...
Re:Redo: A recursive, general-purpose build system
by sigjuice on Wednesday December 29, 2021 @07:10PM
(#29731826)
Looks like gcc does not plan to do this https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28810