Skip to content

Commit e194237

Browse files
author
JiaYan Lin
committed
Fix mac-incompatible linker flags in native_deps
1 parent fd673c2 commit e194237

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

rules/android_binary_internal/attrs.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ ATTRS = _attrs.replace(
128128
default = "native",
129129
values = ["native", "legacy", "manual_main_dex"],
130130
),
131+
user_link_flags = attr.string(
132+
default = "-Wl,-soname",
133+
),
131134
_java_toolchain = attr.label(
132135
default = Label("//tools/jdk:toolchain_android_only"),
133136
),

rules/android_binary_internal/rule.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,11 @@ def android_binary_internal_macro(**attrs):
9797
Args:
9898
**attrs: Rule attributes
9999
"""
100+
user_link_flags = select({
101+
"@bazel_tools//src/conditions:darwin_x86_64": "-Wl,-install_name",
102+
"@bazel_tools//src/conditions:darwin_arm64": "-Wl,-install_name",
103+
"//conditions:default": "-Wl,-soname",
104+
})
105+
if 'user_link_flags' not in attrs:
106+
attrs["user_link_flags"] = user_link_flags
100107
android_binary_internal(**sanitize_attrs(attrs))

rules/native_deps.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def process(ctx, filename, merged_native_libs = {}):
8484
)
8585
linker_input = cc_common.create_linker_input(
8686
owner = ctx.label,
87-
user_link_flags = ["-Wl,-soname=lib" + actual_target_name],
87+
user_link_flags = [ "{link_flags}=lib{target_name}".format(link_flags = ctx.attr.user_link_flags, target_name = actual_target_name) ]
8888
)
8989
cc_info = cc_common.merge_cc_infos(
9090
cc_infos = _concat(

0 commit comments

Comments
 (0)