bazelbuild / bazelbuild/bazel-toolchains
Can we generate a toolchain config without a hardcoded toolchain target?
- Dominant language
- Go
- Stars
- 202
- Forks
- 100
- PR merge metrics
- No merged PRs in 30d
Description
`bazel-toolchains` generates a hard coded toolchain identifier: https://github.com/bazelbuild/bazel-toolchains/blob/e45491b49fdf48091915df04ca25540b22590b59/configs/ubuntu16_04_clang/11.0.0/bazel_3.4.1/config/BUILD#L32
This works for Linux toolchains as when the toolchain config `BUILD` file is always generated (from here: https://github.com/bazelbuild/bazel/blob/e4e06c0293bda20ad8c2b8db131ce821316b8d12/tools/cpp/BUILD.tpl#L47-L55) with an appropriate cpu and compiler combination only the target compiler: https://github.com/bazelbuild/bazel-toolchains/blob/e45491b49fdf48091915df04ca25540b22590b59/configs/ubuntu16_04_clang/11.0.0/bazel_3.4.1/cc/BUILD#L56
On Windows however, the `BUILD` file that is generated (from here: https://github.com/bazelbuild/bazel/blob/e4e06c0293bda20ad8c2b8db131ce821316b8d12/tools/cpp/BUILD.windows.tpl#L47-L59) is not structured specifically for the target compiler, rather it has a toolchain suite for all supported toolchain configs: https://github.com/envoyproxy/envoy-build-tools/blob/c4d2fe1a46a1e173c3dad245b4bbc772a75b5db7/toolchains/configs/windows/msvc-cl/bazel_3.4.1/cc/BUILD#L47-L59
It seems like this might just an issue of Bazel fixing the structure of the `BUILD` file template and how it is generated on Windows to match Linux, but is there anything we can do in bazel-toolchains in the mean time/instead? If we could take in the cpu and target compiler and use that to determine the toolchain config target that would help. Currently we are using the Bazel hack to set `USE_CLANG_CL=1` in the environment to make the `msvc-cl` toolchain use `clang-cl` tools but we would rather use a properly named toolchain config etc.
Just looking for ideas/thoughts, and if you think we should focus on getting Bazel to structure its builtin C++ toolchain `BUILD` files differently
Also see:
https://github.com/bazelbuild/bazel-toolchains/blob/e45491b49fdf48091915df04ca25540b22590b59/rules/rbe_repo/build_gen.bzl#L101-L127
https://github.com/bazelbuild/bazel-toolchains/blob/e45491b49fdf48091915df04ca25540b22590b59/rules/rbe_repo/build_gen.bzl#L25-L28
Contributor guide
Assessment
This issue has not been assessed yet.