bazel-contrib / rules_foreign_cc

Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja, Meson)
https://bazel-contrib.github.io/rules_foreign_cc
Apache License 2.0
662 stars 243 forks source link

`cmake_variant` preinstalled make toolchain broken on 0.10.1 #1154

Open criemen opened 9 months ago

criemen commented 9 months ago

Hi,

when upgrading from 0.9.0 to 0.10.1, our invocation of cmake_variant with toolchain = "@rules_foreign_cc//toolchains:preinstalled_make_toolchain" is broken on Linux (Ubuntu 20.04) and MacOS.

We're getting

ERROR: /private/var/tmp/_bazel_criemen/1ae7e8b72656956ce63cda3a3c55ef29/external/rules_foreign_cc/toolchains/BUILD.bazel:317:15: in pkgconfig_tool_unix rule @rules_foreign_cc//toolchains:pkgconfig_tool_default: Traceback (most recent call last): File "/private/var/tmp/_bazel_criemen/1ae7e8b72656956ce63cda3a3c55ef29/external/rules_foreign_cc/foreign_cc/built_tools/pkgconfig_build.bzl", line 21, column 61, in _pkgconfig_tool_impl additional_tools = depset(transitive = [make_data.target.files]) Error: 'NoneType' value has no field or method 'files' ERROR: /private/var/tmp/_bazel_criemen/1ae7e8b72656956ce63cda3a3c55ef29/external/rules_foreign_cc/toolchains/BUILD.bazel:317:15: Analysis of target '@rules_foreign_cc//toolchains:pkgconfig_tool_default' failed ERROR: Analysis of target '@mimalloc//:mimalloc_variant' failed; build aborted:

A simple reproduction workspace can be found at https://github.com/criemen/bazel-rules-foreig-cc-bug-repro, the bug reproduces with bazelisk build @mimalloc//:mimalloc_variant.

The same code compiles with 0.9.0.

Let me know if I can do anything to help investigating this bug!

criemen commented 7 months ago

I bisected this, and the cause is https://github.com/bazelbuild/rules_foreign_cc/pull/1104. Therefore, setting rules_foreign_cc_dependencies(register_built_pkgconfig_toolchain = False) is a workaround for this issue.

criemen commented 7 months ago

Now, of course that PR didn't introduce the problem, so I bisected again with register_built_pkgconfig_toolchain = True (which was a bit harder as not all variants have that flag), and that points at https://github.com/bazelbuild/rules_foreign_cc/pull/987 as the culprit.