Template variables for `cxx_genrule` do not work with `system_cxx_toolchain`
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
The [documentation for `cxx_genrule`](https://buck2.build/docs/api/rules/#cxx_genrule) lists a bunch of macros that are available in the context of the command such as `$(cxx)` or `$(cxxflags)`. These unkeyed `TemplatePlaceholderInfo()` variables are expected to come from `toolchains//:cxx` which is a dependency of `cxx_genrule`. These macros are very useful, obviously, for commands like `bindgen` that need access to the compiler flags.
However, it doesn't work OOTB with `system_cxx_toolchain`, because `system_cxx_toolchain` doesn't call `cxx_toolchain_infos` which sets up the appropriate `TemplatePlaceholderInfo()`. After some spelunking I found `cxx_toolchain`, a very handy rule, that does do that, and is a bit more appropriate for my use case where I download a toolchain and then point something to it.
Currently on Windows I use `system_cxx_toolchain` with a hack to avoid these template variables in that case, and though I'll probably migrate to `cxx_toolchain` on all platforms including Windows to mitigate this and make things more consistent, this should still probably be fixed OOTB for users.
Contributor guide
Assessment
This issue has not been assessed yet.