bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/22843] Provide dependency information from the linker similar to


From: maskray at google dot com
Subject: [Bug ld/22843] Provide dependency information from the linker similar to the compiler
Date: Sun, 01 Sep 2019 02:30:45 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=22843

Fangrui Song <maskray at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maskray at google dot com

--- Comment #6 from Fangrui Song <maskray at google dot com> ---
Besides -M, -t (--trace) can also be used.
There is no LOAD command in gold's and lld's -M formats.
The linkers' -t formats have more similarities, so it is easier for a script to
adapt the three linkers.

Assume there is a linker option, say --write-dependencies=final_exe.link.d,
that writes dependency information:

  final_exe: source.o /path/to/my/place/liba.a /path/to/somewhere/else/libb.so

The Makefile contains `-include final_exe.link.d`.

If /path/to/my/place/liba.a is deleted, there will be a GNU make error:

  make: *** No rule to make target '/path/to/my/place/liba.a', needed by
'final_exe'.  Stop.

To prevent this, the linker needs another option that is similar to gcc -MP,
which creates force targets:

  /path/to/my/place/liba.a:
  /path/to/somewhere/else/libb.so:

An example Makefile:

  CFLAGS = -MD -MP -MF $@.d  # note -MP is not required in build.ninja
  LDFLAGS = -fuse-ld=bfd -Wl,--write-dependencies=$@.link.d -Wl,-MP
  final_exe_deps = source.o -la -lb

  final_exe: $(final_exe_deps)
          $(LINK.c) $(final_exe_deps) $(LDLIBS) -o $@

  -include a.o.d
  -include final_exe.link.d

The build system (may be the generator of the Makefile) still has to analyze
force targets to extract information. Then, why can't it obtain dependency
information from -M or -t in the first place?

There is a similar feature request to lld:
https://bugs.llvm.org/show_bug.cgi?id=42806 and my reaction is the same that
this is probably not necessary https://reviews.llvm.org/D65430#1616208

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]