Bug 84351 - Provide dependency information also when linking
Summary: Provide dependency information also when linking
Status: RESOLVED MOVED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 7.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-12 22:52 UTC by jpakkane
Modified: 2018-02-13 11:09 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jpakkane 2018-02-12 22:52:10 UTC
The -M flag and its like is very useful for reliable dependencies. It would be great if the same would work also when linking.

The use case is the following. Suppose you build a project with a dependency that comes in via pkg-config. The eventual link line looks like this:

gcc -o final_exe source.o -L/path/to/my/place -L/path/to/somewhere/else -lmydep

It is very difficult to tell where the dependency library will be picked up from. If the user updates any library by doing a "make/ninja install" from the dependency file, then it is hard to know that the dependency libraries have changed and thus require a rebuild. (usually doing an install updates headers, which _do_ trigger a rebuild but some systems only overwrite installed files if they have changed so looking only at header files is not reliable).

If linking supported generating dependency files like -M does for source compilations, this would not be a problem and
Comment 1 Jonathan Wakely 2018-02-12 22:57:08 UTC
(In reply to jpakkane from comment #0)
> If linking supported generating dependency files like -M does for source
> compilations, this would not be a problem and

... and?

The main problem is that GCC doesn't do the linking, it just calls the linker. GCC is not involved in resolving -lmydep to a file on disk, that's the linker.

So the feature would have to be added to the linker, not to GCC.
Comment 2 Richard Biener 2018-02-13 11:09:27 UTC
Please file on sourceware.org/bugzilla