Ensure TFLite shared libs have resolved symbols
Ensure all TFLite binary targets have fully resolved symbols at link time. Also enabling building of .dylib targets for iOS. PiperOrigin-RevId: 307902313 Change-Id: I6ec48fbd7e8f51b8b786eba9d13118cb51638fde
This commit is contained in:
parent
f9d6dd6269
commit
eaca795c24
@ -132,6 +132,7 @@ def tflite_jni_binary(
|
||||
"//conditions:default": [
|
||||
"-Wl,--version-script,$(location {})".format(linkscript),
|
||||
"-Wl,-soname," + name,
|
||||
"-z defs", # Prevent unresolved symbols.
|
||||
],
|
||||
})
|
||||
native.cc_binary(
|
||||
@ -156,6 +157,14 @@ def tflite_cc_shared_object(
|
||||
per_os_targets = False,
|
||||
tags = None):
|
||||
"""Builds a shared object for TFLite."""
|
||||
linkopts = linkopts + select({
|
||||
clean_dep("//tensorflow:ios"): [],
|
||||
clean_dep("//tensorflow:macos"): [],
|
||||
clean_dep("//tensorflow:windows"): [],
|
||||
"//conditions:default": [
|
||||
"-z defs", # Prevent unresolved symbols.
|
||||
],
|
||||
})
|
||||
tf_cc_shared_object(
|
||||
name = name,
|
||||
copts = copts,
|
||||
|
@ -22,12 +22,14 @@ package(
|
||||
tflite_cc_shared_object(
|
||||
name = "tensorflowlite_c",
|
||||
linkopts = select({
|
||||
"//tensorflow:ios": [
|
||||
"-Wl,-exported_symbols_list,$(location //tensorflow/lite/c:exported_symbols.lds)",
|
||||
],
|
||||
"//tensorflow:macos": [
|
||||
"-Wl,-exported_symbols_list,$(location //tensorflow/lite/c:exported_symbols.lds)",
|
||||
],
|
||||
"//tensorflow:windows": [],
|
||||
"//conditions:default": [
|
||||
"-z defs",
|
||||
"-Wl,--version-script,$(location //tensorflow/lite/c:version_script.lds)",
|
||||
],
|
||||
}),
|
||||
|
@ -91,9 +91,15 @@ android_library(
|
||||
proguard_specs = ["proguard.flags"],
|
||||
deps = [
|
||||
":tensorflowlite_java",
|
||||
":tensorflowlite_native_gpu",
|
||||
"@org_checkerframework_qual",
|
||||
],
|
||||
] + select({
|
||||
# For non-Android builds (e.g., Robolectric), it can be useful to build
|
||||
# the Java library but not actually use/link the full native impl.
|
||||
"//tensorflow:android": [
|
||||
":tensorflowlite_native_gpu",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
android_library(
|
||||
|
@ -615,6 +615,9 @@ def tf_cc_shared_object(
|
||||
linkshared = 1,
|
||||
data = data + data_extra,
|
||||
linkopts = linkopts + _rpath_linkopts(name_os_full) + select({
|
||||
clean_dep("//tensorflow:ios"): [
|
||||
"-Wl,-install_name,@rpath/" + soname,
|
||||
],
|
||||
clean_dep("//tensorflow:macos"): [
|
||||
"-Wl,-install_name,@rpath/" + soname,
|
||||
],
|
||||
@ -632,6 +635,7 @@ def tf_cc_shared_object(
|
||||
native.filegroup(
|
||||
name = name,
|
||||
srcs = select({
|
||||
"//tensorflow:ios": [":lib%s%s.dylib" % (name, longsuffix)],
|
||||
"//tensorflow:windows": [":%s.dll" % (name)],
|
||||
"//tensorflow:macos": [":lib%s%s.dylib" % (name, longsuffix)],
|
||||
"//conditions:default": [":lib%s.so%s" % (name, longsuffix)],
|
||||
|
Loading…
Reference in New Issue
Block a user