bazel: Unexpected builtin dependencies being loaded
Description of the bug:
I noticed on https://github.com/bazelbuild/rules_rust/pull/3077 that one of the extensions fails with references to rules_foreign_cc which rules_rust does not use (to my knowledge) for any dependencies.
https://buildkite.com/bazel/rules-rust-rustlang/builds/13675#0194496d-7d43-4239-a8b9-bf9b265ad98d
(04:58:40) ERROR: Traceback (most recent call last):
File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/c6c4a40d41fee053967cb47ffd3a0778/external/rules_foreign_cc+/toolchains/BUILD.bazel", line 317, column 15, in <toplevel>
pkgconfig_tool(
File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/c6c4a40d41fee053967cb47ffd3a0778/external/rules_foreign_cc+/foreign_cc/built_tools/pkgconfig_build.bzl", line 104, column 20, in pkgconfig_tool
runnable_binary(
File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/c6c4a40d41fee053967cb47ffd3a0778/external/rules_foreign_cc+/foreign_cc/utils.bzl", line 61, column 11, in runnable_binary
native.sh_binary(
Error: no native function or rule 'sh_binary'
Available attributes: action_listener, alias, available_xcodes, cc_binary, cc_import, cc_libc_top_alias, cc_library, cc_shared_library, cc_static_library, cc_test, cc_toolchain, cc_toolchain_alias, cc_toolchain_suite, config_feature_flag, config_setting, constraint_setting, constraint_value, environment, existing_rule, existing_rules, exports_files, extra_action, fdo_prefetch_hints, fdo_profile, filegroup, genquery, genrule, glob, java_binary, java_import, java_library, java_package_configuration, java_plugin, java_plugins_flag_alias, java_runtime, java_test, java_toolchain, label_flag, label_setting, legacy_globals, memprof_profile, module_name, module_version, objc_import, objc_library, package, package_group, package_name, package_relative_label, platform, propeller_optimize, repo_name, repository_name, starlark_doc_extract, subpackages, test_suite, toolchain, toolchain_type, xcode_config, xcode_config_alias, xcode_version
(04:58:40) ERROR: /workdir/extensions/prost/private/tests/package_imports/BUILD.bazel:31:19: While resolving toolchains for target //private/tests/package_imports:package_importer_rs_proto (208597c): invalid registered toolchain '@rules_foreign_cc//toolchains:preinstalled_automake_toolchain': Error evaluating '@rules_foreign_cc//toolchains:preinstalled_automake_toolchain': error loading package '@@rules_foreign_cc+//toolchains': Package 'toolchains' contains errors
Note that rules_rust uses --incompatible_autoload_externally=
I ran bazel build --experimental_repository_resolved_file=resolved.json //... and found the following entry:
{
"original_rule_class": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"definition_information": "Repository rules_foreign_cc~ instantiated at:\n <builtin>: in <toplevel>\nRepository rule http_archive defined at:\n /private/var/tmp/_bazel_user/ee718586e70ecc7cc89f275b4f545d0b/external/bazel_tools/tools/build_defs/repo/http.bzl:387:31: in <toplevel>\n",
"original_attributes": {
"name": "rules_foreign_cc~",
"urls": [
"https://github.com/bazelbuild/rules_foreign_cc/releases/download/0.10.1/rules_foreign_cc-0.10.1.tar.gz"
],
"integrity": "sha256-R2MDvQ8bBMwxH8JY8XCKX274LTCR5T/Rl3+iA4NCWmo=",
"strip_prefix": "rules_foreign_cc-0.10.1",
"remote_file_urls": {},
"remote_file_integrity": {},
"remote_patches": {
"https://bcr.bazel.build/modules/rules_foreign_cc/0.10.1/patches/module_dot_bazel.patch": "sha256-hDvLi+Nx91lvhEd2qRrPfPu0RjiG5w3a/c4N4AiJb3U="
},
"remote_patch_strip": 0
},
"repositories": [
{
"rule_class": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"url": "",
"urls": [
"https://github.com/bazelbuild/rules_foreign_cc/releases/download/0.10.1/rules_foreign_cc-0.10.1.tar.gz"
],
"sha256": "",
"integrity": "sha256-R2MDvQ8bBMwxH8JY8XCKX274LTCR5T/Rl3+iA4NCWmo=",
"netrc": "",
"auth_patterns": {},
"canonical_id": "",
"strip_prefix": "rules_foreign_cc-0.10.1",
"add_prefix": "",
"type": "",
"patches": [],
"remote_file_urls": {},
"remote_file_integrity": {},
"remote_patches": {
"https://bcr.bazel.build/modules/rules_foreign_cc/0.10.1/patches/module_dot_bazel.patch": "sha256-hDvLi+Nx91lvhEd2qRrPfPu0RjiG5w3a/c4N4AiJb3U="
},
"remote_patch_strip": 0,
"patch_tool": "",
"patch_args": [
"-p0"
],
"patch_cmds": [],
"patch_cmds_win": [],
"build_file_content": "",
"workspace_file_content": "",
"name": "rules_foreign_cc~"
},
"output_tree_hash": "066e589cb8a8722e5f06ca827d3a85fa31e659034f83eccd7ad4c1400a06aa37"
}
]
},
Why would this be showing up at all?
Which category does this issue belong to?
No response
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
- Checkout https://github.com/bazelbuild/rules_rust/pull/3077
- Navigate to
extensions/prost - Run
bazel test //...
Which operating system are you running Bazel on?
Linux, Macos, Windows
What is the output of bazel info release?
8.0.0
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 HEAD ?
No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 33 (30 by maintainers)
Commits related to this issue
- Disable `--incompatible_autoload_externally=` as it's unusable in Bazel8 (#3214) https://github.com/bazelbuild/bazel/issues/24871 will need to be addressed somehow where unnecessary "built-ins" are e... — committed to bazelbuild/rules_rust by UebelAndre 2 years ago
- libpfm@4.11.0.bcr.1 - Build using rules_cc vs rules_foreign_cc (#3764) This has been tested against [googlebench:`9d8201efd4cbbe6271d0579ec2047dbfc396d22d`](https://github.com/google/benchmark/tree/9... — committed to bazelbuild/bazel-central-registry by UebelAndre 2 years ago
That flag (and the entire
bazel synccommand) will be gone in Bazel 9, FWIW. Since it’s an experimental flag, I don’t want to devote too much work time to it – happy to take a PR for backporting into Bazel 8.x, though.https://github.com/bazelbuild/bazel-central-registry/pull/3472 may help cut the dependency on grpc.
Looks like what actually needs rules_foriegn_cc is only
libpfmand its Makefile doesn’t look too complicated. Maybe we should just create a proper BUILD file for it.