Skip to content

Conversation

dan-stowell
Copy link
Contributor

To get bazel build //:main --config=remote-linux working for examples/bzlmod, I had to add the --extra_toolchains flag. I am on OS X building remotely on Linux.

(I would like to test builds with the toolchain in preparation for a release pipeline.)

@sluongng
Copy link
Contributor

I think we should add this in the commented-out form, not as-is.

The reason is that BzlMod automatically registers the toolchain for you based on the content of the bazel_dep's MODULE.bazel file. That makes the flag --extra_toolchains= redundant.

For example, let's say I have a module toolchains_foo with @@toolchains_foo//:MODULE.bazel file calling register_toolchains(...). Those toolchains will then be available automatically for selection when the user declares bazel_dep(name = "toolchains_foo") in their project's MODULE.bazel file.

However, there are cases where a user can have multiple toolchains of the same type automatically registered. In those cases, the --extra_toolchains flag does come in handy as it manually selects the exact toolchain, avoiding any error in the automatic selection process.

@dan-stowell
Copy link
Contributor Author

I think we should add this in the commented-out form, not as-is.

The reason is that BzlMod automatically registers the toolchain for you based on the content of the bazel_dep's MODULE.bazel file. That makes the flag --extra_toolchains= redundant.

I'm on a MacBook Pro trying to get the bzlmod example to build using RBE. If I do not pass --extra_toolchains, the build does not succeed.

dan@dan-bb-mbp bzlmod % bazel --nohome_rc build --config=remote-linux //:main
INFO: Invocation ID: 8690133f-4de6-4bad-9fc5-51e7928569df
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/8690133f-4de6-4bad-9fc5-51e7928569df
ERROR: /private/var/tmp/_bazel_dan/b759800e61deba813376bced2cb79625/external/rules_cc+/cc/BUILD:103:19: in cc_toolchain_alias rule @@rules_cc+//cc:current_cc_toolchain:
Traceback (most recent call last):
        File "/virtual_builtins_bzl/common/cc/cc_toolchain_alias.bzl", line 26, column 48, in _impl
        File "/virtual_builtins_bzl/common/cc/cc_helper.bzl", line 165, column 13, in _find_cpp_toolchain
Error in fail: Unable to find a CC toolchain using toolchain resolution. Target: @@rules_cc+//cc:current_cc_toolchain, Platform: @@toolchains_buildbuddy+//platforms:linux_x86_64, Exec platform: @@bazel_tools//tools:host_platform
ERROR: /private/var/tmp/_bazel_dan/b759800e61deba813376bced2cb79625/external/rules_cc+/cc/BUILD:103:19: Analysis of target '@@rules_cc+//cc:current_cc_toolchain' (config: e09d445) failed
ERROR: Analysis of target '//:main' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.442s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/8690133f-4de6-4bad-9fc5-51e7928569df
dan@dan-bb-mbp bzlmod % bazel --nohome_rc build --config=remote-linux //:main --extra_toolchains=@toolchains_buildbuddy//toolchains/cc:ubuntu_gcc_x86_64
INFO: Invocation ID: f32d267e-19dd-4d9e-a090-d3d7125aa705
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/f32d267e-19dd-4d9e-a090-d3d7125aa705
WARNING: Build option --extra_toolchains has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target //:main (4 packages loaded, 458 targets configured).
INFO: Found 1 target...
Target //:main up-to-date:
  bazel-bin/main
INFO: Elapsed time: 0.288s, Critical Path: 0.08s
INFO: 2 processes: 5 action cache hit, 1 remote cache hit, 1 internal.
INFO: Build completed successfully, 2 total actions
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/f32d267e-19dd-4d9e-a090-d3d7125aa705

@dan-stowell
Copy link
Contributor Author

We're tinkering with #53 instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants