bazelbuild / bazelbuild/bazel

External targets cc targets do not add the exec root to include paths

Open
#16,690 3 comments 0 reactions 0 assignees View on GitHub
P2 team-ExternalDeps type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

I have a reproduction at https://github.com/UebelAndre/bazel_include_repro with steps to reproduce the issue.

Currently C++ targets which have a mutual external dependency fail to compile with an error similar to the following:

```
+ pushd /Users/user/Code/bazel_include_repro/repo_a
+ bazel test //...
INFO: Analyzed 2 targets (0 packages loaded, 0 targets configured).
INFO: Found 1 target and 1 test target...
ERROR: /private/var/tmp/_bazel_user/8c14b48967f1ce9aa170fa8eaa724499/external/repo_b/lib/BUILD.bazel:3:11: Compiling lib/repo_b.cc failed: (Aborted): wrapped_clang_pp failed: error executing command external/local_config_cc/wrapped_clang_pp '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 31 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/repo_b/lib/repo_b.cc:3:10: fatal error: 'external/repo_c/lib/repo_c.h' file not found
#include "external/repo_c/lib/repo_c.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
INFO: Elapsed time: 0.576s, Critical Path: 0.44s
INFO: 4 processes: 4 internal.
FAILED: Build did NOT complete successfully
//lib:repo_test NO STATUS

FAILED: Build did NOT complete successfully
```

After inspecting the subcommands it seems external dependencies do not get any flags which add the execroot to the include path. This then causes failures when building `repo_b` which depends on `repo_c`.

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Again, I have a reproduction at https://github.com/UebelAndre/bazel_include_repro with steps to reproduce the issue.

An archive can be found below.

| url | checksum |
| --- | --- |
| [bazel_include_repro-30262c2b9fa13b294cec060c02ea3e54b9b21be9.zip](https://github.com/bazelbuild/bazel/files/9956475/bazel_include_repro-30262c2b9fa13b294cec060c02ea3e54b9b21be9.zip) | 921afd3cc42d9ac2e47228635935aec40acabe4344fd2a58a432cbd905d4f04a |

### Which operating system are you running Bazel on?

Linux, MacOS

### What is the output of `bazel info release`?

release 5.3.2

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked bazel_include_repro reproduction and run `bazel test //...` using Bazel 5.3.2 on Linux or macOS. Inspect the generated subcommands and external dependency include paths around repo_b depending on repo_c. Done means the external C++ target receives the execroot include path and the reproduction builds and tests successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.