-
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
virtual includes and headers only cc_library #18913
Comments
The virtual headers directory isn't created since Not creating the virtual includes in this situation appears to be an optimization, but since default include paths use |
I see! Thanks for clarifying. Indeed for my use case would have been nice to have a -I instead of a -iquote.. But I guess there must be, as you said, some internal reason for this choice. I wonder if there's any way to get around this or is it the only way to make a custom rule? |
The behavior you are looking for can be achieved via In your And add needs to be |
Hi @buildbreaker2021 , thank you for the heads up, I have now fixed the example.
This makes the usage of the third party library less maintainable. What would be your recommended approach? I've seen people copying public headers on a separate "generated" folder and use it as exported system headers. |
Also, it is still very surprising for me that adding https://github.com/lromor/bazel_cc_prefix/blob/main/dir/BUILD#L16 adds a virtual include parameter to the compiler, but doesn't generate the actual folder. Is this behavior wanted or documented? |
My answer to both is no. Probably it is because of this check: bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java Line 908 in e93dc18
And my assumption is that we do not do similar check when we construct command line. However that should only effect cases when package directory is the same as include prefix.
Would you still have problem if you used other directory name instead of As a side note, you can try and use includes attribute. However then you probably need to do |
Thank you for your answer. The problem is for me during the porting of some thirdy party library which has these system imports all over the codebase. It would either mean to patch the whole library and change the dir prefix or find another way. By looking around in other projects I noticed that people tend to make a copy into a "generated" folder to get around it, for instance: https://github.com/hdl/bazel_rules_hdl/blob/main/dependency_support/org_sourceware_libffi/bundled.BUILD.bazel#L89-L92 This is the cleanest method I found so far and sounds an extension of what you suggested. |
Right, that's what I thought might create problems. To answer your question considering everything above, I think generated folder approach looks fine, I don't see anything better ATM. |
These links may explain why the actual folders are not being generated. |
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. |
Description of the bug:
I'm trying to port into bazel a cc library. The library uses system includes (say
#include <dir/foo.h>
) internally.The headers are included both using double quotes and angle brackets. Externally is used mostly via angle brackets.
I made a simple repository that mocks the situation:
When I try to compile
bazel build //dir:foo
I get:By inspecting the sandbox with and adding more verbosity, the command is the following:
As you can see,
bazel-out/k8-fastbuild/bin/dir/_virtual_includes/dir_headers
is included, but there's no such directory or path in the sandbox environment. My expectation reading the commandline would be:What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Example
Which operating system are you running Bazel on?
Debian
What is the output of
bazel info release
?release 6.2.1
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.N/A
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
N/A
Have you found anything relevant by searching the web?
N/A
Any other information, logs, or outputs that you want to share?
N/A
The text was updated successfully, but these errors were encountered: