google / glog

C++ implementation of the Google logging module
http://google.github.io/glog/
BSD 3-Clause "New" or "Revised" License
7.03k stars 2.06k forks source link

[Bazel CI]cc_configure.bzl does not export a module extension called cc_configure_extension. #1135

Open sgowroji opened 3 days ago

sgowroji commented 3 days ago

CI: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/4200#01928e5d-1434-461c-a9de-dd55737653e3

Platform: Windows

Logs:

(04:10:21) WARNING: Couldn't auto load rules or symbols, because no dependency on module/repository 'rules_android' found. This will result in a failure if there's a reference to those rules or symbols.
Target //:shared_headers failed to build
(04:10:25) ERROR: Analysis of target '//bazel/example:main' failed; build aborted: @@bazel_tools//tools/cpp:cc_configure.bzl does not export a module extension called cc_configure_extension, yet its use is requested at C:/b/bk-windows-5k1s/bazel-org-repo-root/glog/MODULE.bazel:11:29
(04:10:25) INFO: Elapsed time: 4.544s, Critical Path: 0.05s
(04:10:25) INFO: 1 process: 1 internal.
(04:10:25) ERROR: Build did NOT complete successfully
(04:10:25) FAILED:

Culprit: https://github.com/bazelbuild/bazel/commit/1c4e78a9ceab9794140324d64833c628e382a3da

Steps:

 git clone https://github.com/google/glog
git reset de309c08c05382fee0792380de7df1bd65332da2  --hard
export USE_BAZEL_VERSION=18e3dc07876536b98d93aca1997478700b9c8d9e
bazel build --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl --compiler=clang-cl --features=layering_check //... 

CC Greenteam @meteorcloudy

drigz commented 2 days ago

Thanks for the report! Esp thanks for the repro steps with USE_BAZEL_VERSION, super helpful.

I found the migration guide linked from the culprit a lacking here. It just says _"If you are depending on anything in @bazel_tools//tools/cpp, you should use the version from @rulescc instead." - IIUC this dependency came from the PR that migrated glog to bzlmod, but I figured I'd take a shot at migrating it.

  1. Try s/bazel_tools/rules_cc/ which failed with: no repo visible as '@rules_cc' here
  2. Copy bazel_dep(name = "rules_cc", version = "0.0.12") from https://github.com/bazelbuild/bazel/commit/1c4e78a9ceab9794140324d64833c628e382a3da, fails with no such package '@@rules_cc+//tools/cpp'
  3. Copy "@rules_cc//cc/private/toolchain:clang-cl" and "@rules_cc//cc:extensions.bzl" from the above commit, fails with ERROR: /usr/local/google/home/rodrigoq/git/glog/BUILD.bazel:7:13: While resolving toolchains for target //:strip_include_prefix_hack (77ef3ef): invalid registered toolchain '@local_config_cc//:cc-toolchain-x64_windows-clang-cl': no such target '@@rules_cc++cc_configure_extension+local_config_cc//:cc-toolchain-x64_windows-clang-cl': target 'cc-toolchain-x64_windows-clang-cl' not declared in package '' defined by /usr/local/google/home/rodrigoq/.cache/bazel/_bazel_rodrigoq/dd880f2ce084c0dadd188a0a46eacfcd/external/rules_cc++cc_configure_extension+local_config_cc/BUILD.
  4. Realize this is because the repro instructions are for a Windows build and I'm on a Linux dev machine, maybe this will work in CI, but the repro instructions only work for local execution...

Created https://github.com/google/glog/pull/1136 and hoping I'm on the right track given that I don't have a way to actually test the fix.