[PATCH users/roland/ld-depfile] ld, gold: Add --dependency-file option.

Roland McGrath mcgrathr@google.com
Mon Jun 15 21:13:07 GMT 2020


On Sat, Jun 13, 2020 at 9:44 AM Fangrui Song <i@maskray.me> wrote:
> Sorry, but I am not convinced this option provides additional features.

You are mistaken.

> You'd want to link https://sourceware.org/bugzilla/show_bug.cgi?id=22843

I hadn't noticed it had been filed.  I've updated the ChangeLog items
to mention it and updated the bug.
Thanks for the pointer!

> tl;dr -t satisfies your needs: { echo -n 'a: '; clang a.o -o a -Wl,-t | sed 's/(.*//' | sort -u | sed '$!s/$/ \\/';} > a.d

This is frankly ludicrous on its face, even if it were technically
accurate (which it's not).

The possibility of a ridiculous kludge is not a reason to avoid adding
a sensible feature that is straightforward to use and fits existing
models.

A kludge like that is hopelessly impractical to integration into build
systems, which is where this feature is useful.

Moreover, it's not semantically equivalent.  While it's true that ld
does print -t output on stdout (gold is incompatible in putting it on
stderr), it's not true that -t output has equivalent information.

The criterion for -t output is "input object file was included in the
link".  The criterion for dependency files is "input file was read by
the linker".
The -t output omits archives from which no members were taken, input
linker scripts, -T linker scripts, version scripts, etc.  All of these
are important in dependency file output.


More information about the Binutils mailing list