On 9/13/21 3:54 AM, Michael S wrote:
> On Monday, September 13, 2021 at 6:10:17 AM UTC+3,
james...@alumni.caltech.edu wrote:
>> On 9/11/21 4:16 PM, Michael S wrote:
...
>>> You forgot system headers and other non-user headers.
>>> I just tested a file that I was working with few days ago.
>>> a single #include <immintrin.h> caused 76 lines in .d
>> In what sense do you think I forgot them?
>
> In a sense that after you take into account long lists of system headers in the .d files it becomes perfectly possible
> that manually written 29-line makefile is fully sufficient.
I knew full well that those headers were going to be included, and in
fact, wanted them to be included, so it's not a matter of me forgetting
something. Without all of those files being included in the dependencies
lists, it is not fully sufficient.
>> One of the strengths of this
>> approach is gcc -MD tracks down all dependencies, direct and indirect,
>> including dependencies on system headers and non-user headers.
>> And if, for some bizarre reason, you don't want your code that rebuilt
>> when system headers are changed, even though building of your code might
>> be affected by those changes, you can also instruct gcc to leave them out.
>
> You have a right to dislike it, but makefiles that don't take into account a possibility of such unlikely event
> as meaningful change of system headers are *very* common in industry practice.
I can understand that, if you had to rely upon manually generated
dependency lists. However, it's trivial to use gcc -MD to generate a
list of header dependencies that's not merely accurate, but also
comprehensive, complete, and always up-to-date, which is almost never
the case for manually created lists. The amount of time and effort you
spent while manually recording just the header dependencies listed in
that 29-line makefile would be far greater than the amount of time and
effort needed when using gcc -MD. That would be true even if you only
included a single such dependency.
Why in the world should you NOT include a real dependency just because
it will rarely ever be relevant, given how cheaply it can be included?
The only legitimate reason I can think of is if you need to be able to
build your project on a platform where you can't use gcc - and I fully
agree that this is a reasonable issue to consider.