commit | 1cd0788d2ab461c71b2815214fb0596d6dc1f906 | [log] [tgz] |
---|---|---|
author | scentini <rosica@google.com> | Tue Aug 09 16:29:09 2022 +0200 |
committer | GitHub <noreply@github.com> | Tue Aug 09 16:29:09 2022 +0200 |
tree | 6f96fd37bb5621d78ad8a0476b7832e0b8fb0170 | |
parent | 90808f0dc47e289bc149561ffcc8451b64b5a8bd [diff] |
Apply get_lib_name correctly to the C++ runtime libraries (#1508) https://github.com/bazelbuild/rules_rust/pull/1500 added an additional `for_windows` parameter to `get_lib_name`. I missed the fact that we also pass that function to `map_each` here: https://github.com/bazelbuild/rules_rust/blob/main/rust/private/rustc.bzl#L1671 and as such, this code does not always work correctly (we don't get to pass the `for_windows` parameter, and internally at Google it ended up evaluating to `True` on Linux builds). I tried to avoid flattening the `cc_toolchain.dynamic_runtime_lib` and `cc_toolchain.static_runtime_lib` depsets by using a lambda: ``` args.add_all( cc_toolchain.dynamic_runtime_lib(feature_configuration = feature_configuration), map_each = lambda x: get_lib_name(x, for_windows = toolchain.os.startswith("windows)), format_each = "-ldylib=%s", ) ``` However it looks like such usage of lambdas is not allowed: ``` Error in add_all: to avoid unintended retention of analysis data structures, the map_each function (declared at ...) must be declared by a top-level def statement ``` So instead of `get_lib_name` we now have `get_lib_name_default` and `get_lib_name_for_windows`.
This repository provides rules for building Rust projects with Bazel.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust
.
Please refer to the full documentation.