diff options
author | thomas <108470890+thb-sb@users.noreply.github.com> | 2024-01-09 17:29:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-09 08:29:18 -0800 |
commit | 90e4505c19e8276311cd5ad7d9d894aa659105dd (patch) | |
tree | 2cd10587f9f8617238df02c7dc1128a79faed159 | |
parent | 012af3ba8fda6acb91a440f8c86b5a45d2c4e64e (diff) | |
download | bazelbuild-rules_rust-90e4505c19e8276311cd5ad7d9d894aa659105dd.tar.gz |
Fix #2406: use codegen option `link-args` to forward `user_link_flags` in bindgen. (#2407)
This commit fixes issue #2406 by using the [`link-args`] codegen option
of `rustc`:
```
-C
link-args=<user_link_flags>
```
where `<user_link_flags>` are the flags from the [`user_link_flags`]
field of [`LinkerInput`].
[`user_link_flags`]:
https://bazel.build/rules/lib/builtins/LinkerInput#user_link_flags
[`LinkerInput`]: https://bazel.build/rules/lib/builtins/LinkerInput
[`link-args`]:
https://doc.rust-lang.org/rustc/codegen-options/index.html#link-args
-rw-r--r-- | bindgen/private/bindgen.bzl | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/bindgen/private/bindgen.bzl b/bindgen/private/bindgen.bzl index ba2f62b8..f32a4fc8 100644 --- a/bindgen/private/bindgen.bzl +++ b/bindgen/private/bindgen.bzl @@ -124,7 +124,9 @@ def _generate_cc_link_build_info(ctx, cc_lib): linker_search_paths.append(lib.pic_static_library.dirname) compile_data.append(lib.pic_static_library) - linker_flags.extend(linker_input.user_link_flags) + if linker_input.user_link_flags: + linker_flags.append("-C") + linker_flags.append("link-args={}".format(" ".join(linker_input.user_link_flags))) if not compile_data: fail("No static libraries found in {}".format( |