bazelbuild / bazelbuild/bazel

per_file_copt doesn't work with remote repository labels

Open
#19,665 10 comments 1 reaction 1 assignee Claimed by @Wyverald View on GitHub
P2 team-OSS 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 options I want to apply just in an external repository. I can do so by setting `--per_file_copt=external/repo_name/file@blah`, but I can't use the label form: `--per_file_copt=@repo_name//:target@blah`.

This means I need to hard-code my knowledge of how repository names map to paths (i.e. the `external/` prefix), and I believe these are things we're not mean to rely on (e.g. bzlmod may change them).

It would be great to instead support labels (i.e. look to see if the pattern starts with `@`, and maybe if it was followed by a `//` before the next `@` or somthing)

### Which category does this issue belong to?

C++/Objective-C Rules

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

Create an external repository building C++, and need to set a compile flag for it.

Try to build with `bazel build --per_file_copt=@repo_name//external:target //some/target`.

Expect the option to be applied, but it's not.

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

macOS

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

release 6.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_

### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

_No response_

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

_No response_

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

This is the relevant code: https://github.com/bazelbuild/bazel/blob/778a6f35ccd9058910a0529b2325a6de8d409762/src/main/java/com/google/devtools/build/lib/analysis/config/PerLabelOptions.java#L49-L65

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.