Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rules_cc runfiles library does not provide BAZEL_CURRENT_REPOSITORY #285

Open
flurie opened this issue Dec 1, 2024 · 4 comments
Open

rules_cc runfiles library does not provide BAZEL_CURRENT_REPOSITORY #285

flurie opened this issue Dec 1, 2024 · 4 comments
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.

Comments

@flurie
Copy link

flurie commented Dec 1, 2024

Description of the problem / feature request:

The runfiles library has been deprecated in bazel-tools and now points to the library in rules_cc, but the instructions ported over refer to BAZEL_CURRENT_REPOSITORY, which is not present in the rules_cc runfiles library.

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

I made a branch off something I was working on. You should be able to run touch data/inputs/01.txt && bazel build //src/day/01 using //https://github.com/flurie/aoc-2024/tree/demo-rules-cc-runfiles if you install the prereqs (nix and devenv) and it should work on macOS and Linux.

What operating system are you running Bazel on?

macOS 14.5

What's the output of bazel info release?

release 7.4.1- (@non-git)

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

It is built from nixpkgs 24.11.

What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?

http_archive(
    name = "rules_cc",
    urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
    sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
    strip_prefix = "rules_cc-0.0.17",
)

What Bazel options do you use to trigger the issue? What C++ toolchain do you use?

.bazelrc:

build --host_platform=@rules_nixpkgs_core//platforms:host
build --crosstool_top=@nixpkgs_config_cc//:toolchain

for completeness, the output when the repro command is run with --announce_rc:

INFO: Reading 'startup' options from /nix/store/zsyc077bgm4g3xq3h0a2qfzw4g4jzjfi-bazel-rc: --server_javabase=/nix/store/dd8l9acgfnax38j7wvz0lh96c2vkxyg3-zulu-ca-jdk-21.0.4
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=104
INFO: Reading rc options for 'run' from /nix/store/zsyc077bgm4g3xq3h0a2qfzw4g4jzjfi-bazel-rc:
  Inherited 'build' options: --extra_toolchains=@bazel_tools//tools/jdk:all --tool_java_runtime_version=local_jdk --java_runtime_version=local_jdk
INFO: Reading rc options for 'run' from /Users/flurie/Repos/github.com/flurie/aoc-2024/.bazelrc:
  Inherited 'build' options: --host_platform=@rules_nixpkgs_core//platforms:host --crosstool_top=@nixpkgs_config_cc//:toolchain

toolchain:

nixpkgs_git_repository(
    name = "nixpkgs",
    revision = "release-24.11",
)

nixpkgs_cc_configure(
    name = "nixpkgs_config_cc",
    repository = "@nixpkgs",
)

Have you found anything relevant by searching the web?

No

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

No

@flurie
Copy link
Author

flurie commented Dec 3, 2024

After some additional digging, I see what is going on here.

the cc_* rules all end up calling the native rules under the hood, but the native rules in 7.4.1 and even 8.0.0rcs don't recognize the new runfiles library label, only master does. So that check likely needs to move over to rules_cc.

@jwnimmer-tri
Copy link

FYI my current work-around is to add a redundant entry in deps just so that bazel adds the correct definition:

    deps = [
        "@rules_cc//cc/runfiles",
        # The next line is a hack to get BAZEL_CURRENT_REPOSITORY working.
        "@bazel_tools//tools/cpp/runfiles",
    ],

@keith
Copy link
Member

keith commented Dec 12, 2024

looks like this is still being fixed in bazel itself, not rules_cc, and looks like it'll be in 8.1.0 bazelbuild/bazel#24465

@fmeum
Copy link
Contributor

fmeum commented Dec 13, 2024

@jwnimmer-tri's workaround or just using @bazel_tools//tools/cpp/runfiles for now is recommended until 8.1.0 lands. @bazel_tools//tools/cpp/runfiles will keep working, so there is no rush to migrate.

@pzembrod pzembrod added the P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.
Projects
None yet
Development

No branches or pull requests

5 participants