uber / hermetic_cc_toolchain

Bazel C/C++ toolchain for cross-compiling C/C++ programs
MIT License
269 stars 43 forks source link

bzlmod: hermetic_cc_toolchain>2.2.0 registers toolchains by default #181

Open TvdW opened 1 month ago

TvdW commented 1 month ago

As of 8a1ca917888f32c4c3106a275d3611d2b3f1bbf6 / #135, the root MODULE.bazel contains a call to register_toolchains that causes every zig-cc toolchain to be registered if the module is loaded. This means that when loading hermetic_cc_toolchain using bzlmod, it's not possible to only build a single target using this toolchain, as they will be registered by default and picked up by bazel for all compilation.

I believe this to be a bug, as the README specifically lists this as an option.

This could well be a Bazel bug in visibility: I don't think that just loading a module should ever create side-effects like this. Sadly, it still makes it problematic to load hermetic_cc_toolchain via bzlmod.

motiejus commented 4 weeks ago

Certainly not intended. @linzhp can you have a look?

zaucy commented 2 weeks ago

adding dev_dependency=True to the register_toolchains should prevent the toolchains from being registered by consumers of this module.

xuzhenglun commented 2 weeks ago

it seam like --incompatible_enable_cc_toolchain_resolution default to be true in bazel 7.0. I set this flag to false, and host default toolchains works again.