`configured_alias` and configuration modifiers
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
I have a question about the interaction between configuration modifiers and `configured_alias`.
At present, you can use `configured_alias` to build a target for a specific platform, irrespective of the current target platform.
Ideally, the API should be changed to fit with the upcoming configuration modifiers (e.g. passing a list of configurations instead of a target platform).
Therefore, `configured_alias` targets should be treated as if they are top-level targets.
Maybe the new configuration modifiers API would be able to reduce the need for `configured_alias`.
However, there may also be a need to specify exactly which configuration modifiers apply – or in other words, to not inherit any configuration modifiers from PACKAGE or elsewhere – when building certain targets.
For example, let's say you want to create an Apple fat binary. You would need to build the target application for two different configurations and then invoke a host tool to combine them into one fat binary. This can currently be represented with a (macro) rule by creating `configured_alias` rules for `macos-x86_64` and `macos-arm64`, with a `genrule` for linking them with `lipo`:
```starlark
cxx_binary(
name = "app",
srcs = ["main.cpp"],
link_style = "static",
)
configured_alias(
name = "app-x86_64",
actual = ":app",
platform = "@platforms//:macos-x86_64",
)
configured_alias(
name = "app-arm64",
actual = ":app",
platform = "@platforms//:macos-arm64",
)
genrule(
name = "app-universal",
bash = 'lipo -create -output "$OUT/app" "$(location :app-x86_64)" "$(location :app-arm64)"',
outs = {
"output": ["app"],
},
default_outs = ["app"],
visibility = ["PUBLIC"],
)
```
This can then be built using `buck2 build :app-universal`.
Are there any plans for updating or replacing `configured_alias`?
Contributor guide
Assessment
This issue has not been assessed yet.