New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 796187 link

Starred by 3 users

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Provide a way for link steps to depend on additional files, such as an exported symbols file

Project Member Reported by mark@chromium.org, Dec 19 2017

Issue description

In order to specify a build correctly, all input to each step needs to be considered in determining whether the step’s output is up to date. For linker input other than object files and libraries, there doesn’t appear to be any way to make GN aware that a dependency exists.

This happens when the linker uses additional input in the form of an exported symbols file, for example. https://chromium-review.googlesource.com/c/crashpad/crashpad/+/833408/3/snapshot/BUILD.gn#249 is an instance of this. elf/elf_image_reader_test.cc in the snapshot_test target requires an exported symbols list, which is presented to the linker via -Wl,--dynamic-list,elf/test_exported_symbols.sym. There’s no way to tell the linker that elf/test_exported_symbols.sym is relevant to the link step. If only elf/test_exported_symbols.sym changes, the library will not be relinked.

As a workaround, it’s possible to specify elf/test_exported_symbols.sym in “inputs”. Unfortunately, this isn’t quite as targeted as appropriate. With this, the entire target depends on the input, so not only will it be relinked if elf/test_exported_symbols.sym changes, each source file in the target will also be recompiled. This is not necessary, because there’s no true dependency relationship between compilation and this file, it’s strictly relevant to the link step. Furthermore, because of  bug 781858 , “inputs” have no effect in a “config”, so in this example, elf/test_exported_symbols.sym can change and nothing will be rebuilt. The build is incorrectly specified, and I can’t see a way to fix it.

https://chromium-review.googlesource.com/c/crashpad/crashpad/+/833408/3/tools/BUILD.gn#72 is another example. Here, the linker needs “-sectcreate __TEXT __info_plist mac/sectaskaccess_info.plist. The “inputs” do have an effect here because they’re written directly into the target, not into a config, so now, when mac/sectaskaccess_info.plist changes, not only is generate_dump relinked, but generate_dump.cc is also recompiled. The same thing happens in the exception_port_tool target. (In fact, it’d be better if the two shared a config, but  bug 781858  disallows “inputs” from working properly.)
 
Components: Build
Not that GN shouldn't have a feature for this, but in the ELF linker case you can wrap the list in VERSION { { global: ...; local: *; } } to make it a linker script, and then the linker will accept this file on its inputs list just as if it were an object file or whatever rather than needing a special command-line switch to introduce it.  Then you can list the file in libs to make GN put it in the link and generate a ninja dependency for it.

Comment 3 by mark@chromium.org, Dec 21 2017

I’ve been thinking about this some more yesterday and today, and I think that the thing I really want to do is make linkers support something like the compilers’ -MD.

This is also a “not that GN shouldn’t have a feature for this”, but if the linker could write its own list of dependencies, that should plug into GN pretty nicely.
I thought of that too.  I think it would need to be both the compiler driver (that runs the linker) and the linker supporting it together to be sure you really got everything.  We can certainly look into doing that for LLD/Clang.

Sign in to add a comment