Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow commands with implicit outputs in the depslog #1236

Closed
wants to merge 1 commit into from

Conversation

danw
Copy link
Contributor

@danw danw commented Feb 7, 2017

Compilers such as GCC and Clang can output auxiliary files when certain
arguments are passed. In order to add these to the build graph today, we
must turn off the depslog for these commands (deps = gcc -> deps = )

One example is '--coverage', which will output the standard .o/.d files,
but also writes a .gcno file. Then we'd like to distribute a bundle of
these files for the test systems to create the full coverage
information, so they need to be in the build graph.

This is no worse than using depfiles today, since the current depfile
code only cares about the first output. And the depslog code also only
looks at the first output. For auxiliary (implicit) outputs, this is
completely fine. For commands with multiple output that don't have a
"primary" output, the current depslog code that uses the first output
may not be correct, so I'm leaving the check in for that case.

Compilers such as GCC and Clang can output auxiliary files when certain
arguments are passed. In order to add these to the build graph today, we
must turn off the depslog for these commands (deps = gcc -> deps = )

One example is '--coverage', which will output the standard .o/.d files,
but also writes a .gcno file. Then we'd like to distribute a bundle of
these files for the test systems to create the full coverage
information, so they need to be in the build graph.

This is no worse than using depfiles today, since the current depfile
code only cares about the first output. And the depslog code also only
looks at the first output. For auxiliary (implicit) outputs, this is
completely fine. For commands with multiple output that don't have a
"primary" output, the current depslog code that uses the first output
may not be correct, so I'm leaving the check in for that case.
@jgunthorpe
Copy link

I think you should revise the warning as well:

"When using deps only a single file can be in $out, use implicit outputs for other files"

I also tested this patch and it works for my use cases too which is a bit different, more like

rule foo
 command = foo -o a -o b -o c --deps a.d
 deps = gcc
 depfile = ${out}.d
build a | b c : foo

However, unlike your case, 'foo' emits something like this for the deps file:

b : inp1 inp2

Ie it does not emit $out in the makefile. It looks like the ninja dep parse ignores the output filename when parsing the makefile so this is OK.

I tried various situations with this patch and all worked as I would expect after modifying the generator script to use this syntax, including restat rules and edges that flow through the implicit outputs. Looks good to me, and certainly solves my problem.

@melak47
Copy link

melak47 commented Mar 5, 2017

I'm using this so I can have .pdbs as implicit outputs, and ninja -t clean deletes them.

@plinss
Copy link

plinss commented Jun 13, 2017

I have a project using a custom transpiler that generates multiple outputs and needs a depfile. While multiple output support for depfiles would be ideal, this change allows me work around the lack of multiple output support by making one of the outputs implicit.

@jhasse jhasse added this to the 1.10.0 milestone Nov 14, 2018
@jhasse
Copy link
Collaborator

jhasse commented Nov 16, 2018

Superseded by #1364.

@jhasse jhasse closed this Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants