cc_binary dep on cc_library#linkstamp doesn't set up include paths correctly for non-root module deps

Open
#415 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the failure using the linked linkstamp_issue_rules_cc example with Bazel 8.2.1 and rules_cc 0.1.1, comparing ersatz_foo and ersatz_main in module B. Start from the cc_binary target with the linkstamp and the reported build_embed.cc include failure. Done means the non-root-module binary compiles with the required include path, while the existing reproduction case remains covered.

Written by the indexing model from the issue text.

Description

P3

Suppose you have two bazel modules, A and B. B depends upon A.

A has a cc_library called "src/foo:foo". This library has linkstamp = build_embed.cc", where build_embed.cc has a local include path: #include "src/foo/build_embed.h"`.

A's "src/foo:foo" library is a dep of a binary called "src/foo:main", also within A.

B has two targets that just copy from A: "ersatz_main" and "ersatz_foo". Both of these targets just copy the output files of @A//src/foo:{foo,main} into B's repository.

Within B, it is possible to compile ersatz_foo correctly. However, it is not possible to compile ersatz_main. This error occurs:

external/foo+/src/foo/build_embed.cc:1:10: fatal error: src/foo/build_embed.h: No such file or directory
    1 | #include "src/foo/build_embed.h"

It seems that the compilation action for cc_binary targets with linkstamp set does not properly add all required include paths.

See https://github.com/ted-xie/linkstamp_issue_rules_cc for full repro.

Bazel version: 8.2.1 (also repros at 7.4.1)
rules_cc version: 0.1.1 (also repros at 0.0.10)

Dominant language
Starlark
Stars
247
Forks
196
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_cc

All issues in bazelbuild/rules_cc

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.