-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Stop adding .d files to outputs when dependency_file is disabled #7771
Conversation
Previously if you disabled the dependency_file feature, your build would fail because the .d file was still added to the outputs of the action but would not be generated.
@hlopko can you review this? |
Hi Keith, I'll need to investigate this deeper, but my worry is that C++ compile actions are not correct without .d file (meaning we will not recompile on changed header). One quick workaround is to use a compiler wrapper, and postprocess .d file to remove absolute path prefix. To make C++ rules work correctly without .d file we have to stop creating middleman artifact in compilation context and instead use nested set of headers for action inputs. @scentini can tell you more if you're interested. |
@hlopko I think you're right about system level headers, but in the common case those shouldn't be mutated right? If this is required regardless, should we remove the ability to disable this feature? |
Actually without a |
@hlopko any other thoughts? |
So imagine a simple workspace: BUILD:
foo.cc:
foo.h:
And you build it by
and run Bazel, you'll see the library was not recompiled. This is what I mean by 'not correct', Bazel doesn't correctly identify which actions need to be reexecuted. So I see 2 ways forward:
|
Forgive the uninformed question, but why does bazel not track |
@kastiglione It does, but :) There is an optimization in Bazel based on the hypothesis that substantial number of headers that are passed to compilation are actually unused. We see ~50% of transitive headers in compilation actions are not included by source file internally at Google. Now if any of the unused headers would change, we would reexecute the compilation action and discover that nothing changed. Plus backwards dependency edges consume a lot of memory at scale. So we pass all the headers to the first compilation action, get the .d file, and only declare dependency edges on the pruned set of headers. Subsequent action executions work as you expect. All works fine if there is a .d file. If there is not, Bazel crashes. This PR tries to fix that, but the fix is a little bit more involved, but still doable. |
If it is important to keep bazel work correctly, why doens't just remove this feature? It's really confusing that it's said this is a feature, which implies it could be switch on/off. But actually it's not. Bazel just fail when this feature is off. |
Previously if you disabled the dependency_file feature, your build would
fail because the .d file was still added to the outputs of the action
but would not be generated.
Fixes #7769