Skip to content

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

@UebelAndre

Description

@UebelAndre

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 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)team-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions