Skip to content

Commit

Permalink
Add -Lnative flags for C++ runtime library
Browse files Browse the repository at this point in the history
  • Loading branch information
hlopko committed Feb 25, 2021
1 parent 094b5bd commit 9ee759a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ def establish_cc_info(ctx, crate_info, toolchain, cc_toolchain, feature_configur
# by creating a symlink to the .rlib with a .a extension.
dot_a = ctx.actions.declare_file(crate_info.name + ".a", sibling = crate_info.output)
ctx.actions.symlink(output = dot_a, target_file = crate_info.output)

# TODO(hlopko): handle PIC/NOPIC correctly
library_to_link = cc_common.create_library_to_link(
actions = ctx.actions,
feature_configuration = feature_configuration,
Expand Down Expand Up @@ -842,6 +844,11 @@ def _add_native_link_flags(args, dep_info, crate_type, cc_toolchain, feature_con
if crate_type in ["dylib", "cdylib"]:
# For shared libraries we want to link C++ runtime library dynamically
# (for example libstdc++.so or libc++.so).
args.add_all(
cc_toolchain.dynamic_runtime_lib(feature_configuration = feature_configuration),
map_each = _get_dirname,
format_each = "-Lnative=%s",
)
args.add_all(
cc_toolchain.dynamic_runtime_lib(feature_configuration = feature_configuration),
map_each = get_lib_name,
Expand All @@ -850,6 +857,11 @@ def _add_native_link_flags(args, dep_info, crate_type, cc_toolchain, feature_con
else:
# For all other crate types we want to link C++ runtime library statically
# (for example libstdc++.a or libc++.a).
args.add_all(
cc_toolchain.static_runtime_lib(feature_configuration = feature_configuration),
map_each = _get_dirname,
format_each = "-Lnative=%s",
)
args.add_all(
cc_toolchain.static_runtime_lib(feature_configuration = feature_configuration),
map_each = get_lib_name,
Expand Down

0 comments on commit 9ee759a

Please sign in to comment.