cxx_builtin_include_directory doesn't work with non-absolute path
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the problem / feature request:
I'm trying to use gcc cross-compiler as external dependency, when I'm specifying cxx_builtin_include_directory as ```external/cross_toolchain/...``` or ``` %package(@cross_toolchain//...)``` I'm getting error:
```
'/private/var/tmp/_bazel_ilya/d86e0e7cfe53385dc3edff3c0d9662b6/external/cross_toolchain/lib/gcc/x86_64-unknown-linux-gnu/7.3.0/include/stddef.h'
'/private/var/tmp/_bazel_ilya/d86e0e7cfe53385dc3edff3c0d9662b6/external/cross_toolchain/lib/gcc/x86_64-unknown-linux-gnu/7.3.0/include/stdarg.h'
```
It works only if you specify absolute path to include directory.
### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
You can find minimal example here: https://github.com/ipolyakovskiy/bazel-crosscompile-example
To build:
```
bazel build --config=docker //:hello
INFO: Analysed target //:hello (0 packages loaded).
INFO: Found 1 target...
ERROR: /Users/ilya/hello-bazel-docker/BUILD:1:1: undeclared inclusion(s) in rule '//:hello':
this rule is missing dependency declarations for the following files included by 'hello.c':
'/private/var/tmp/_bazel_ilya/d86e0e7cfe53385dc3edff3c0d9662b6/external/cross_toolchain/lib/gcc/x86_64-unknown-linux-gnu/7.3.0/include/stddef.h'
'/private/var/tmp/_bazel_ilya/d86e0e7cfe53385dc3edff3c0d9662b6/external/cross_toolchain/lib/gcc/x86_64-unknown-linux-gnu/7.3.0/include/stdarg.h'
Target //:hello failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.723s, Critical Path: 0.58s
FAILED: Build did NOT complete successfully
```
### What operating system are you running Bazel on?
macOS 10.12.6
### What's the output of `bazel info release`?
Tried with ```release 0.10.0-homebrew``` and ```development version``` also
### If `bazel info release` returns "development version" or "(@non-git)", tell us how you built Bazel.
development version was build form sources by ```bazel build //src:bazel```
### What's the output of `git remote get-url origin ; git rev-parse master ; git rev-parse HEAD` ?
```
https://bazel.googlesource.com/bazel
e7541262293977598ad96d9eb7a83b439eedd634
e7541262293977598ad96d9eb7a83b439eedd634
```
### Have you found anything relevant by searching the web?
Nothing
### Any other information, logs, or outputs that you want to share?
AFAIU problem is here: https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java#L1233
Paths which are not absolute just discarded. So is it a bug or intentional behavior? If it is intentional, how I should specify include path in such example?
If it is a bug I can create pull-request with merging execRoot and includePath, which is absolute path to include directory in such case.
Contributor guide
Research direction
Start with src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java at the line identified in the report, then reproduce the failure using the linked bazel-crosscompile-example and its bazel build --config=docker //:hello command. Done means a non-absolute cxx_builtin_include_directory is handled correctly and the build no longer reports the generated stddef.h and stdarg.h paths as undeclared inclusions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, java
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100