You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: feature request
As we know, C++ headers have quadratic stat() multiplied by all the -isystem flags Bazel passes to gcc. But if all include paths are vendored to the Bazel execroot, it's only quadratic, and compiling goes way faster. But rewriting include lines breaks people who want to compile the sources for a particular project outside of Bazel. It also creates headaches for people packaging libraries for Linux distros.
If that is the optimal approach, then maybe it would make sense to make that a standard define, so -D__BAZEL__ doesn't need to be manually passed copts.
Does the performance matter in practice? I was under the impression that the look-for-every-include-under-every-include-path-entry algorithm isn't a concern for Bazel, because there aren't that many include path entries.
Should this not perhaps be rather solved at Compiler invocation level? I would rather have a map which you feed the compiler so it no longer searches for <zlib.h> but is taught where it is. Especially since a lot of that information is already available in Bazel.
I ran strace on GCC invocations for TensorFlow and determined those stat() system calls were >50% of wall time. So yes, but with a grain of salt.
Part of the problem is that TensorFlow's build configuration is not optimal. It basically globs everything into one big cc_library. This means every single one of our dependencies (nearly all of which specify the includes attribute) are part of the compilation for nearly every .cc file. If TensorFlow broke up that cc_library into more finely grained targets, it would make TensorFlow builds faster. But it would not make builds faster for downstream targets referencing TensorFlow as a single label.
Should this not perhaps be rather solved at Compiler invocation level? I would rather have a map which you feed the compiler [...]
That would be the optimal solution. I spent an hour digging through the GCC docs looking for exactly that a month ago. Couldn't find anything that would let me do that. If we know any GCC experts it would be a good idea to consult them though.
I think Bazel should not put the remote packages under external, but just under the name of the remote repository. So for zlib, the files would be under zlib/. That way, you can make it #include <zlib/zlib.h>
or #include "zlib/zlib.h"
Ideally, upstream would install the files under /usr/lib/include/zlib/ instead of mashing everything into a single directory, which seems very non-ideal if you ask me. If they don't want to do that (backwards compat?), maybe they can at least provide an optional mechanism?
Yes but when are modules actually going to happen?
Depending on when the different directions of Microsoft and Clang are resolved. Soonest seems C++20. And when I look at the pace that XCode ships Clang variants it way well take until 2022 on Mac.
That is actually the reason why I thought a persistent gcc compiler may exist. Because modules will not be a solution for cross platform for a LONG time.
And will they require existing codebases to be rewritten in order to reap the benifits?
To a certain extend yes. Seems more rewrite for Microsoft (<- am prefering) than Clang approach.
Aren't header maps solving this problem? We have an external contribution at #3712. Could you take a look at it and comment if it will help your use case?
With Bazel 6, all Bazel cc_* rules define BAZEL_CURRENT_REPOSITORY to the name of the repository containing the target, which can be used for #2160 (comment). Relying on it for #2160 (comment) would seem a bit hacky though.
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!
P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: feature request
Activity
abergmeier commentedon Dec 2, 2016
Why then not take the more general approach and have a
VEND_HDR_PREFIXdefined, which can be used like so:This way you have at least a slim chance to upstream that.
IIRC, defines with two underscores and then uppercase are reserved for the standard (implementor).
jart commentedon Dec 2, 2016
Well there would be a different prefix for every third party library, because they're all in their own bazel repositories.
lberki commentedon Dec 2, 2016
Does the performance matter in practice? I was under the impression that the look-for-every-include-under-every-include-path-entry algorithm isn't a concern for Bazel, because there aren't that many include path entries.
abergmeier-dsfishlabs commentedon Dec 2, 2016
Should this not perhaps be rather solved at Compiler invocation level? I would rather have a map which you feed the compiler so it no longer searches for
<zlib.h>but is taught where it is. Especially since a lot of that information is already available in Bazel.lberki commentedon Dec 2, 2016
Does any compiler at the moment provide that functionality?
abergmeier-dsfishlabs commentedon Dec 2, 2016
Not that I know of. Would be awesome, though 🤓
jart commentedon Dec 3, 2016
I ran strace on GCC invocations for TensorFlow and determined those stat() system calls were >50% of wall time. So yes, but with a grain of salt.
Part of the problem is that TensorFlow's build configuration is not optimal. It basically globs everything into one big cc_library. This means every single one of our dependencies (nearly all of which specify the
includesattribute) are part of the compilation for nearly every .cc file. If TensorFlow broke up that cc_library into more finely grained targets, it would make TensorFlow builds faster. But it would not make builds faster for downstream targets referencing TensorFlow as a single label.That would be the optimal solution. I spent an hour digging through the GCC docs looking for exactly that a month ago. Couldn't find anything that would let me do that. If we know any GCC experts it would be a good idea to consult them though.
abergmeier-dsfishlabs commentedon Dec 5, 2016
@jart For Tensorflow then, I would expect a persistent compiler (e.g. GCC) process to be another (better) option. This one could cache include file locations on previous
statcalls.That being said - do not know whether there is a variant like that.
A quick Google found this however (at least interesting): http://clang.llvm.org/doxygen/classclang_1_1FileSystemStatCache.html
abergmeier-dsfishlabs commentedon Dec 5, 2016
Perhaps cc @DanAlbert?
DanAlbert commentedon Dec 6, 2016
Not sure what I can offer here.
1 remaining item
ulfjack commentedon Dec 8, 2016
I think Bazel should not put the remote packages under external, but just under the name of the remote repository. So for zlib, the files would be under zlib/. That way, you can make it
#include <zlib/zlib.h>or
#include "zlib/zlib.h"Ideally, upstream would install the files under /usr/lib/include/zlib/ instead of mashing everything into a single directory, which seems very non-ideal if you ask me. If they don't want to do that (backwards compat?), maybe they can at least provide an optional mechanism?
DanAlbert commentedon Dec 13, 2016
I certainly haven't heard of anything like it. Aren't modules supposed to be the solution for this?
jart commentedon Dec 13, 2016
Yes but when are modules actually going to happen? And will they require existing codebases to be rewritten in order to reap the benifits? https://youtu.be/ND-TuW0KIgg
abergmeier-dsfishlabs commentedon Dec 14, 2016
Depending on when the different directions of Microsoft and Clang are resolved. Soonest seems C++20. And when I look at the pace that XCode ships Clang variants it way well take until 2022 on Mac.
That is actually the reason why I thought a persistent gcc compiler may exist. Because modules will not be a solution for cross platform for a LONG time.
To a certain extend yes. Seems more rewrite for Microsoft (<- am prefering) than Clang approach.
hlopko commentedon Oct 25, 2017
Aren't header maps solving this problem? We have an external contribution at #3712. Could you take a look at it and comment if it will help your use case?
fmeum commentedon Dec 12, 2022
With Bazel 6, all Bazel
cc_*rules defineBAZEL_CURRENT_REPOSITORYto the name of the repository containing the target, which can be used for #2160 (comment). Relying on it for #2160 (comment) would seem a bit hacky though.github-actions commentedon Feb 16, 2024
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.
github-actions commentedon May 16, 2024
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post
@bazelbuild/triagein a comment here and we'll take a look. Thanks!