Rename whitelist to allowlist in tflite_ios_static_framework
PiperOrigin-RevId: 319926991 Change-Id: I18a4eb0f23c7b80cc1ccbefa16f6ce75e15a378b
This commit is contained in:
parent
3bd8e00d55
commit
dfd69610fa
@ -12,9 +12,9 @@ package(
|
|||||||
)
|
)
|
||||||
|
|
||||||
sh_binary(
|
sh_binary(
|
||||||
name = "hide_symbols_with_whitelist",
|
name = "hide_symbols_with_allowlist",
|
||||||
srcs = [
|
srcs = [
|
||||||
"hide_symbols_with_whitelist.sh",
|
"hide_symbols_with_allowlist.sh",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,9 +53,9 @@ tflite_ios_static_framework(
|
|||||||
":xnnpack_delegate.h",
|
":xnnpack_delegate.h",
|
||||||
"//tensorflow/lite/c:common.h",
|
"//tensorflow/lite/c:common.h",
|
||||||
],
|
],
|
||||||
|
allowlist_symbols_file = ":allowlist_TensorFlowLiteC.txt",
|
||||||
bundle_name = "TensorFlowLiteC",
|
bundle_name = "TensorFlowLiteC",
|
||||||
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
||||||
whitelist_symbols_file = ":whitelist_TensorFlowLiteC.txt",
|
|
||||||
deps = [
|
deps = [
|
||||||
":tensorflow_lite_c",
|
":tensorflow_lite_c",
|
||||||
],
|
],
|
||||||
@ -101,9 +101,9 @@ tflite_ios_static_framework(
|
|||||||
hdrs = [
|
hdrs = [
|
||||||
":coreml_delegate.h",
|
":coreml_delegate.h",
|
||||||
],
|
],
|
||||||
|
allowlist_symbols_file = ":allowlist_TensorFlowLiteCCoreML.txt",
|
||||||
bundle_name = "TensorFlowLiteCCoreML",
|
bundle_name = "TensorFlowLiteCCoreML",
|
||||||
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
||||||
whitelist_symbols_file = ":whitelist_TensorFlowLiteCCoreML.txt",
|
|
||||||
deps = [
|
deps = [
|
||||||
"//tensorflow/lite/experimental/delegates/coreml:coreml_delegate",
|
"//tensorflow/lite/experimental/delegates/coreml:coreml_delegate",
|
||||||
],
|
],
|
||||||
@ -120,9 +120,9 @@ tflite_ios_static_framework(
|
|||||||
hdrs = [
|
hdrs = [
|
||||||
"//tensorflow/lite/delegates/gpu:metal_delegate.h",
|
"//tensorflow/lite/delegates/gpu:metal_delegate.h",
|
||||||
],
|
],
|
||||||
|
allowlist_symbols_file = ":allowlist_TensorFlowLiteCMetal.txt",
|
||||||
bundle_name = "TensorFlowLiteCMetal",
|
bundle_name = "TensorFlowLiteCMetal",
|
||||||
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
||||||
whitelist_symbols_file = ":whitelist_TensorFlowLiteCMetal.txt",
|
|
||||||
deps = [
|
deps = [
|
||||||
"//tensorflow/lite/delegates/gpu:metal_delegate",
|
"//tensorflow/lite/delegates/gpu:metal_delegate",
|
||||||
],
|
],
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
#
|
#
|
||||||
# A script to merge Mach-O object files into a single object file and hide
|
# A script to merge Mach-O object files into a single object file and hide
|
||||||
# their internal symbols. Only whitelisted symbols will be visible in the
|
# their internal symbols. Only allowed symbols will be visible in the
|
||||||
# symbol table after this script.
|
# symbol table after this script.
|
||||||
|
|
||||||
# To run this script, you must set several variables:
|
# To run this script, you must set several variables:
|
||||||
# INPUT_FRAMEWORK: a zip file containing the iOS static framework.
|
# INPUT_FRAMEWORK: a zip file containing the iOS static framework.
|
||||||
# BUNDLE_NAME: the pod/bundle name of the iOS static framework.
|
# BUNDLE_NAME: the pod/bundle name of the iOS static framework.
|
||||||
# WHITELIST_FILE_PATH: contains the whitelisted symbols.
|
# ALLOWLIST_FILE_PATH: contains the allowed symbols.
|
||||||
# OUTPUT: the output zip file.
|
# OUTPUT: the output zip file.
|
||||||
|
|
||||||
# Halt on any error or any unknown variable.
|
# Halt on any error or any unknown variable.
|
||||||
@ -32,15 +32,15 @@ LD_DEBUGGABLE_FLAGS="-x"
|
|||||||
# library at a time.
|
# library at a time.
|
||||||
# LD_DEBUGGABLE_FLAGS="-d"
|
# LD_DEBUGGABLE_FLAGS="-d"
|
||||||
|
|
||||||
# Exits if C++ symbols are found in the whitelist list.
|
# Exits if C++ symbols are found in the allowlist.
|
||||||
if grep -q "^__Z" "${WHITELIST_FILE_PATH}"
|
if grep -q "^__Z" "${ALLOWLIST_FILE_PATH}"
|
||||||
then
|
then
|
||||||
echo "ERROR: Failed in symbol hiding. This rule does not permit hiding of" \
|
echo "ERROR: Failed in symbol hiding. This rule does not permit hiding of" \
|
||||||
"C++ symbols due to possible serious problems mixing symbol hiding," \
|
"C++ symbols due to possible serious problems mixing symbol hiding," \
|
||||||
"shared libraries and the C++ runtime." \
|
"shared libraries and the C++ runtime." \
|
||||||
"More info can be found in go/ios-symbols-hiding." \
|
"More info can be found in go/ios-symbols-hiding." \
|
||||||
"Please recheck the whitelist list and remove C++ symbols:"
|
"Please recheck the allowlist and remove C++ symbols:"
|
||||||
echo "$(grep "^__Z" "${WHITELIST_FILE_PATH}")"
|
echo "$(grep "^__Z" "${ALLOWLIST_FILE_PATH}")"
|
||||||
exit 1 # terminate and indicate error
|
exit 1 # terminate and indicate error
|
||||||
fi
|
fi
|
||||||
# Unzips the framework zip file into a temp workspace.
|
# Unzips the framework zip file into a temp workspace.
|
||||||
@ -87,7 +87,7 @@ do
|
|||||||
mv *.o "${archdir}"/
|
mv *.o "${archdir}"/
|
||||||
|
|
||||||
objects_file_list=$(mktemp)
|
objects_file_list=$(mktemp)
|
||||||
# Hides the symbols except the whitelisted ones.
|
# Hides the symbols except the allowed ones.
|
||||||
find "${archdir}" -name "*.o" >> "${objects_file_list}"
|
find "${archdir}" -name "*.o" >> "${objects_file_list}"
|
||||||
|
|
||||||
# Checks whether bitcode is enabled in the framework.
|
# Checks whether bitcode is enabled in the framework.
|
||||||
@ -104,13 +104,13 @@ do
|
|||||||
if [[ "$all_objects_have_bitcode" = "true" ]]; then
|
if [[ "$all_objects_have_bitcode" = "true" ]]; then
|
||||||
echo "The ${arch} in ${executable_file} is fully bitcode-enabled."
|
echo "The ${arch} in ${executable_file} is fully bitcode-enabled."
|
||||||
xcrun ld -r -bitcode_bundle -exported_symbols_list \
|
xcrun ld -r -bitcode_bundle -exported_symbols_list \
|
||||||
"${WHITELIST_FILE_PATH}" \
|
"${ALLOWLIST_FILE_PATH}" \
|
||||||
$LD_DEBUGGABLE_FLAGS \
|
$LD_DEBUGGABLE_FLAGS \
|
||||||
-filelist "${objects_file_list}" -o "${arch_file}_processed.o"
|
-filelist "${objects_file_list}" -o "${arch_file}_processed.o"
|
||||||
else
|
else
|
||||||
echo "The ${arch} in ${executable_file} is NOT fully bitcode-enabled."
|
echo "The ${arch} in ${executable_file} is NOT fully bitcode-enabled."
|
||||||
xcrun ld -r -exported_symbols_list \
|
xcrun ld -r -exported_symbols_list \
|
||||||
"${WHITELIST_FILE_PATH}" \
|
"${ALLOWLIST_FILE_PATH}" \
|
||||||
$LD_DEBUGGABLE_FLAGS \
|
$LD_DEBUGGABLE_FLAGS \
|
||||||
-filelist "${objects_file_list}" -o "${arch_file}_processed.o"
|
-filelist "${objects_file_list}" -o "${arch_file}_processed.o"
|
||||||
fi
|
fi
|
@ -17,14 +17,14 @@ TFL_DISABLED_SANITIZER_TAGS = [
|
|||||||
"notsan",
|
"notsan",
|
||||||
]
|
]
|
||||||
|
|
||||||
# iOS static framework with symbol whitelist. Exported C++ symbbols might cause
|
# iOS static framework with symbol allowlist. Exported C++ symbbols might cause
|
||||||
# symbol collision with other libraries. List of symbols to whitelist can be
|
# symbol collision with other libraries. List of symbols to allowlist can be
|
||||||
# generated by running `nm -m -g FRAMEWORK_LIBRARY | grep _TfLite` for framework
|
# generated by running `nm -m -g FRAMEWORK_LIBRARY | grep _TfLite` for framework
|
||||||
# built with `ios_static_framework` rule.
|
# built with `ios_static_framework` rule.
|
||||||
def tflite_ios_static_framework(
|
def tflite_ios_static_framework(
|
||||||
name,
|
name,
|
||||||
bundle_name,
|
bundle_name,
|
||||||
whitelist_symbols_file,
|
allowlist_symbols_file,
|
||||||
exclude_resources = True,
|
exclude_resources = True,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""TFLite variant of ios_static_framework with symbol hiding.
|
"""TFLite variant of ios_static_framework with symbol hiding.
|
||||||
@ -33,7 +33,7 @@ def tflite_ios_static_framework(
|
|||||||
name: The name of the target.
|
name: The name of the target.
|
||||||
bundle_name: The name to give to the framework bundle, without the
|
bundle_name: The name to give to the framework bundle, without the
|
||||||
".framework" extension. If omitted, the target's name will be used.
|
".framework" extension. If omitted, the target's name will be used.
|
||||||
whitelist_symbols_file: a file including a list of whitelisted symbols,
|
allowlist_symbols_file: a file including a list of allowed symbols,
|
||||||
one symbol per line.
|
one symbol per line.
|
||||||
exclude_resources: Indicates whether resources should be excluded from the
|
exclude_resources: Indicates whether resources should be excluded from the
|
||||||
bundle. This can be used to avoid unnecessarily bundling resources if
|
bundle. This can be used to avoid unnecessarily bundling resources if
|
||||||
@ -54,13 +54,13 @@ def tflite_ios_static_framework(
|
|||||||
|
|
||||||
srcs = [
|
srcs = [
|
||||||
framework_target,
|
framework_target,
|
||||||
whitelist_symbols_file,
|
allowlist_symbols_file,
|
||||||
]
|
]
|
||||||
cmd = ("INPUT_FRAMEWORK=\"$(location " + framework_target + ")\" " +
|
cmd = ("INPUT_FRAMEWORK=\"$(location " + framework_target + ")\" " +
|
||||||
"BUNDLE_NAME=\"" + bundle_name + "\" " +
|
"BUNDLE_NAME=\"" + bundle_name + "\" " +
|
||||||
"WHITELIST_FILE_PATH=\"$(location " + whitelist_symbols_file + ")\" " +
|
"ALLOWLIST_FILE_PATH=\"$(location " + allowlist_symbols_file + ")\" " +
|
||||||
"OUTPUT=\"$(OUTS)\" " +
|
"OUTPUT=\"$(OUTS)\" " +
|
||||||
"\"$(location //tensorflow/lite/experimental/ios:hide_symbols_with_whitelist)\"")
|
"\"$(location //tensorflow/lite/experimental/ios:hide_symbols_with_allowlist)\"")
|
||||||
|
|
||||||
native.genrule(
|
native.genrule(
|
||||||
name = name,
|
name = name,
|
||||||
@ -68,6 +68,6 @@ def tflite_ios_static_framework(
|
|||||||
outs = [name + ".zip"],
|
outs = [name + ".zip"],
|
||||||
cmd = cmd,
|
cmd = cmd,
|
||||||
tools = [
|
tools = [
|
||||||
"//tensorflow/lite/experimental/ios:hide_symbols_with_whitelist",
|
"//tensorflow/lite/experimental/ios:hide_symbols_with_allowlist",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user