Skip to content

Commit 90e4505

Browse files
author
thomas
authored
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
1 parent 012af3b commit 90e4505

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bindgen/private/bindgen.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def _generate_cc_link_build_info(ctx, cc_lib):
124124
linker_search_paths.append(lib.pic_static_library.dirname)
125125
compile_data.append(lib.pic_static_library)
126126

127-
linker_flags.extend(linker_input.user_link_flags)
127+
if linker_input.user_link_flags:
128+
linker_flags.append("-C")
129+
linker_flags.append("link-args={}".format(" ".join(linker_input.user_link_flags)))
128130

129131
if not compile_data:
130132
fail("No static libraries found in {}".format(

0 commit comments

Comments
 (0)