Skip to content

Commit 012af3b

Browse files
thomasUebelAndre
thomas
andauthored
Fix #2402: use get_lib_name_default(lib) instead of lib.owner.name. (#2405)
This commit fixes #2402 by using [`get_lib_name_default`] to pass libraries names to `rustc` through `-lstatic` instead of relying on the owner's name of the `File` object. [`get_lib_name_default`]: https://github.com/bazelbuild/rules_rust/blob/a1e9f9600cd22ecfdd08fc4a7572ccbdeba97395/rust/private/utils.bzl#L101 Co-authored-by: UebelAndre <github@uebelandre.com>
1 parent 0972574 commit 012af3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bindgen/private/bindgen.bzl

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ load("//rust:rust_common.bzl", "BuildInfo")
2626
load("//rust/private:rustc.bzl", "get_linker_and_args")
2727

2828
# buildifier: disable=bzl-visibility
29-
load("//rust/private:utils.bzl", "find_cc_toolchain", "get_preferred_artifact")
29+
load("//rust/private:utils.bzl", "find_cc_toolchain", "get_lib_name_default", "get_preferred_artifact")
3030

3131
# TODO(hlopko): use the more robust logic from rustc.bzl also here, through a reasonable API.
3232
def _get_libs_for_static_executable(dep):
@@ -116,11 +116,11 @@ def _generate_cc_link_build_info(ctx, cc_lib):
116116
for linker_input in cc_lib[CcInfo].linking_context.linker_inputs.to_list():
117117
for lib in linker_input.libraries:
118118
if lib.static_library:
119-
linker_flags.append("-lstatic={}".format(lib.static_library.owner.name))
119+
linker_flags.append("-lstatic={}".format(get_lib_name_default(lib.static_library)))
120120
linker_search_paths.append(lib.static_library.dirname)
121121
compile_data.append(lib.static_library)
122122
elif lib.pic_static_library:
123-
linker_flags.append("-lstatic={}".format(lib.pic_static_library.owner.name))
123+
linker_flags.append("-lstatic={}".format(get_lib_name_default(lib.pic_static_library)))
124124
linker_search_paths.append(lib.pic_static_library.dirname)
125125
compile_data.append(lib.pic_static_library)
126126

0 commit comments

Comments
 (0)