Skip to content

Commit

Permalink
Merge pull request tensorflow#122 from lissyx/fix-linker2
Browse files Browse the repository at this point in the history
Fix tensorflow#3207: do not force -shared on the linkage
  • Loading branch information
lissyx committed Aug 3, 2020
2 parents 6f73d77 + d124566 commit 1c1b2b9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions tensorflow/lite/c/BUILD
Expand Up @@ -26,6 +26,7 @@ tflite_cc_shared_object(
"-Wl,-exported_symbols_list,$(location //tensorflow/lite/c:exported_symbols.lds)",
],
"//tensorflow:windows": [],
"//tensorflow:ios": [],
"//conditions:default": [
"-z defs",
"-Wl,--version-script,$(location //tensorflow/lite/c:version_script.lds)",
Expand Down
3 changes: 3 additions & 0 deletions tensorflow/tensorflow.bzl
Expand Up @@ -613,6 +613,9 @@ def tf_cc_shared_object(
"-Wl,-install_name,@rpath/" + soname,
],
clean_dep("//tensorflow:windows"): [],
clean_dep("//tensorflow:ios"): [
"-Wl,-install_name,@rpath/" + soname
],
"//conditions:default": [
"-Wl,-soname," + soname,
],
Expand Down
Expand Up @@ -150,6 +150,21 @@ def _impl(ctx):
],
)

shared_flag_feature = feature(
name = "shared_flag",
flag_sets = [
flag_set(
actions = [
ACTION_NAMES.cpp_link_dynamic_library,
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
ACTION_NAMES.lto_index_for_dynamic_library,
ACTION_NAMES.lto_index_for_nodeps_dynamic_library,
],
flag_groups = [flag_group(flags = ["-shared"])],
),
],
)

sysroot_feature = feature(
name = "sysroot",
enabled = True,
Expand Down Expand Up @@ -380,7 +395,6 @@ def _impl(ctx):
"-Lexternal/LinaroAarch64Gcc72/aarch64-linux-gnu/libc/lib",
"-Lexternal/LinaroAarch64Gcc72/aarch64-linux-gnu/libc/usr/lib",
"-Bexternal/LinaroAarch64Gcc72/aarch64-linux-gnu/bin",
"-shared",
],
),
],
Expand All @@ -407,6 +421,7 @@ def _impl(ctx):
dbg_feature,
user_compile_flags_feature,
user_link_flags_feature,
shared_flag_feature,
sysroot_feature,
unfiltered_compile_flags_feature,
]
Expand Down
Expand Up @@ -150,6 +150,21 @@ def _impl(ctx):
],
)

shared_flag_feature = feature(
name = "shared_flag",
flag_sets = [
flag_set(
actions = [
ACTION_NAMES.cpp_link_dynamic_library,
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
ACTION_NAMES.lto_index_for_dynamic_library,
ACTION_NAMES.lto_index_for_nodeps_dynamic_library,
],
flag_groups = [flag_group(flags = ["-shared"])],
),
],
)

sysroot_feature = feature(
name = "sysroot",
enabled = True,
Expand Down Expand Up @@ -380,7 +395,6 @@ def _impl(ctx):
"-Lexternal/LinaroArmGcc72/arm-linux-gnueabihf/libc/lib",
"-Lexternal/LinaroArmGcc72/arm-linux-gnueabihf/libc/usr/lib",
"-Bexternal/LinaroArmGcc72/arm-linux-gnueabihf/bin",
"-shared",
],
),
],
Expand All @@ -407,6 +421,7 @@ def _impl(ctx):
dbg_feature,
user_compile_flags_feature,
user_link_flags_feature,
shared_flag_feature,
sysroot_feature,
unfiltered_compile_flags_feature,
]
Expand Down

0 comments on commit 1c1b2b9

Please sign in to comment.