Fix crash on iOS due to symbol resolution. (#4162)

Fixes #2588
This commit is contained in:
Fangjun Kuang authored and GitHub committed 2026-11-06 10:37:03 +08:00
1 parent 079a6f05d0
commit ed0e4b171e
17 files changed
+91 -57

No files matched your search

+2 -3
View File
@@ -1,8 +1,9 @@
include_guard(GLOBAL)
function(download_asio)
include(FetchContent)
set(asio_URL "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-24-0.tar.gz")
set(asio_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/asio-asio-1-24-0.tar.gz")
set(asio_HASH "SHA256=cbcaaba0f66722787b1a7c33afe1befb3a012b5af3ad7da7ff0f6b8c9b7a8a5b")
# If you don't have access to the Internet,
@@ -20,7 +21,6 @@ function(download_asio)
set(asio_URL "${f}")
file(TO_CMAKE_PATH "${asio_URL}" asio_URL)
message(STATUS "Found local downloaded asio: ${asio_URL}")
set(asio_URL2)
break()
endif()
endforeach()
@@ -28,7 +28,6 @@ function(download_asio)
FetchContent_Declare(asio
URL
${asio_URL}
${asio_URL2}
URL_HASH ${asio_HASH}
)
+9 -25
View File
@@ -71,13 +71,12 @@ def get_cmake_dir():
def get_hardcoded_deps():
"""Return deps that don't have a cmake file (e.g., kaldifst).
Returns list of (name, url, url2, sha256).
Returns list of (name, url, sha256).
"""
return [
(
"kaldifst",
"https://github.com/k2-fsa/kaldifst/archive/refs/tags/v1.8.0.tar.gz",
"",
"3f247b7e5a2409071202f5e2bc6200060f66728c0a3443c03923ad2723e040b3",
),
]
@@ -86,22 +85,18 @@ def get_hardcoded_deps():
def parse_url_and_hash(filepath):
"""Parse a cmake file for URL and SHA256 hash pairs.
Returns a list of (name, url, url2, sha256) tuples.
Returns a list of (name, url, sha256) tuples.
"""
text = filepath.read_text()
deps = []
# Pattern: set(name_URL "https://...")
# set(name_URL2 "https://...") (optional)
# set(name_HASH "SHA256=...")
# Use [\w-]+ to match names with hyphens (e.g., simple-sentencepiece)
name_re = r'([\w-]+?)'
url_pattern = re.compile(
rf'set\({name_re}_URL\s+"([^"]+)"\)', re.MULTILINE
)
url2_pattern = re.compile(
rf'set\({name_re}_URL2\s+"([^"]+)"\)', re.MULTILINE
)
hash_pattern = re.compile(
rf'set\({name_re}_HASH\s+"SHA256=([^"]+)"\)', re.MULTILINE
)
@@ -113,14 +108,12 @@ def parse_url_and_hash(filepath):
if "${" not in url and name not in urls:
urls[name] = url
url2s = {m.group(1): m.group(2) for m in url2_pattern.finditer(text)}
hashes = {m.group(1): m.group(2) for m in hash_pattern.finditer(text)}
for name, url in urls.items():
sha256 = hashes.get(name, "")
url2 = url2s.get(name, "")
if sha256:
deps.append((name, url, url2, sha256))
deps.append((name, url, sha256))
return deps
@@ -170,7 +163,7 @@ def parse_windows_onnxruntime(filepath, crt, build_type):
def discover_common_deps(cmake_dir):
"""Discover platform-independent deps from cmake files.
Returns list of (name, url, url2, sha256).
Returns list of (name, url, sha256).
"""
# These cmake files contain platform-independent deps
dep_files = [
@@ -230,7 +223,7 @@ def ask_yes_no(question, default="y"):
def select_onnxruntime_deps(cmake_dir):
"""Interactively select onnxruntime deps based on platform.
Returns list of (name, url, url2, sha256).
Returns list of (name, url, sha256).
"""
os_choice = select_menu(
"Select target OS:",
@@ -389,17 +382,14 @@ def parse_aarch64_gpu_deps(path):
# Check for URL override in this block
url_m = re.search(r'set\(onnxruntime_URL\s+"(https://[^"]+)"\)', block)
url2_m = re.search(r'set\(onnxruntime_URL2\s+"(https://[^"]+)"\)', block)
if url_m:
url = url_m.group(1)
url2 = url2_m.group(1) if url2_m else ""
else:
# Use template
url = url_template.format(v=version)
url2 = ""
deps.append(("onnxruntime", url, url2, sha256))
deps.append(("onnxruntime", url, sha256))
return deps
@@ -524,7 +514,7 @@ def main():
# Discover common deps
common_deps = get_hardcoded_deps() + discover_common_deps(cmake_dir)
print(f"\nFound {len(common_deps)} common (platform-independent) dependencies:")
for name, url, url2, sha256 in common_deps:
for name, url, sha256 in common_deps:
print(f" {name}: {filename_from_url(url, name, cmake_dir)}")
# Ask about onnxruntime
@@ -533,7 +523,7 @@ def main():
ort_deps = select_onnxruntime_deps(cmake_dir)
if ort_deps:
print(f"\nSelected {len(ort_deps)} onnxruntime file(s):")
for name, url, url2, sha256 in ort_deps:
for name, url, sha256 in ort_deps:
print(f" {name}: {filename_from_url(url, name, cmake_dir)}")
else:
print("\nSkipping onnxruntime download.")
@@ -560,18 +550,12 @@ def main():
print(f"\nDownloading {len(all_deps)} file(s) to {dl_path}...")
downloaded = []
failed = []
for name, url, url2, sha256 in all_deps:
for name, url, sha256 in all_deps:
fname = filename_from_url(url, name, cmake_dir)
filepath = dl_path / fname
if download_file(url, filepath, sha256):
downloaded.append(fname)
else:
# Try mirror URL
if url2:
print(f" Trying mirror: {url2}")
if download_file(url2, filepath, sha256):
downloaded.append(fname)
continue
failed.append(fname)
# Summary
+2
View File
@@ -1,3 +1,5 @@
include_guard(GLOBAL)
function(download_eigen)
include(FetchContent)
+2 -3
View File
@@ -1,8 +1,9 @@
include_guard(GLOBAL)
function(download_googltest)
include(FetchContent)
set(googletest_URL "https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz")
set(googletest_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/googletest-1.13.0.tar.gz")
set(googletest_HASH "SHA256=ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363")
# If you don't have access to the Internet,
@@ -20,7 +21,6 @@ function(download_googltest)
set(googletest_URL "${f}")
file(TO_CMAKE_PATH "${googletest_URL}" googletest_URL)
message(STATUS "Found local downloaded googletest: ${googletest_URL}")
set(googletest_URL2)
break()
endif()
endforeach()
@@ -33,7 +33,6 @@ function(download_googltest)
FetchContent_Declare(googletest
URL
${googletest_URL}
${googletest_URL2}
URL_HASH ${googletest_HASH}
)
+2 -3
View File
@@ -1,9 +1,10 @@
include_guard(GLOBAL)
function(download_hclust_cpp)
include(FetchContent)
# The latest release as of 2026.02.25
set(hclust_cpp_URL "https://github.com/csukuangfj/hclust-cpp/archive/refs/tags/2026-02-25.tar.gz")
set(hclust_cpp_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/hclust-cpp-2026-02-25.tar.gz")
set(hclust_cpp_HASH "SHA256=8f14e024c709d73afb40ae69cb22de4b73dba67cbce40f2e518813da8139ab56")
# If you don't have access to the Internet,
@@ -21,7 +22,6 @@ function(download_hclust_cpp)
set(hclust_cpp_URL "${f}")
file(TO_CMAKE_PATH "${hclust_cpp_URL}" hclust_cpp_URL)
message(STATUS "Found local downloaded hclust_cpp: ${hclust_cpp_URL}")
set(hclust_cpp_URL2)
break()
endif()
endforeach()
@@ -29,7 +29,6 @@ function(download_hclust_cpp)
FetchContent_Declare(hclust_cpp
URL
${hclust_cpp_URL}
${hclust_cpp_URL2}
URL_HASH ${hclust_cpp_HASH}
)
+3 -3
View File
@@ -1,8 +1,9 @@
include_guard(GLOBAL)
function(download_json)
include(FetchContent)
set(json_URL "https://github.com/nlohmann/json/archive/refs/tags/v3.12.0.tar.gz")
set(json_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/json-3.12.0.tar.gz")
set(json_HASH "SHA256=4b92eb0c06d10683f7447ce9406cb97cd4b453be18d7279320f7b2f025c10187")
# If you don't have access to the Internet,
@@ -20,13 +21,12 @@ function(download_json)
set(json_URL "${f}")
file(TO_CMAKE_PATH "${json_URL}" json_URL)
message(STATUS "Found local downloaded json: ${json_URL}")
set(json_URL2)
break()
endif()
endforeach()
FetchContent_Declare(json
URL ${json_URL} ${json_URL2}
URL ${json_URL}
URL_HASH ${json_HASH}
)
+2
View File
@@ -1,3 +1,5 @@
include_guard(GLOBAL)
function(download_kaldi_decoder)
include(FetchContent)
+9 -7
View File
@@ -1,8 +1,10 @@
include_guard(GLOBAL)
function(download_kaldi_native_fbank)
include(FetchContent)
set(kaldi_native_fbank_URL "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.22.4.tar.gz")
set(kaldi_native_fbank_HASH "SHA256=257fea639585ca6ee00860493bb9d7ab32488b8a5407ffe434c1f361ea545fae")
set(kaldi_native_fbank_URL "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.23.0.tar.gz")
set(kaldi_native_fbank_HASH "SHA256=97e75ad01f486c45d6b0169a305e1e057f660fe84eb65db1aab773b732335062")
set(KALDI_NATIVE_FBANK_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(KALDI_NATIVE_FBANK_BUILD_PYTHON OFF CACHE BOOL "" FORCE)
@@ -11,11 +13,11 @@ function(download_kaldi_native_fbank)
# If you don't have access to the Internet,
# please pre-download kaldi-native-fbank
set(possible_file_locations
$ENV{HOME}/Downloads/kaldi-native-fbank-1.22.4.tar.gz
${CMAKE_SOURCE_DIR}/kaldi-native-fbank-1.22.4.tar.gz
${CMAKE_BINARY_DIR}/kaldi-native-fbank-1.22.4.tar.gz
/tmp/kaldi-native-fbank-1.22.4.tar.gz
/star-fj/fangjun/download/github/kaldi-native-fbank-1.22.4.tar.gz
$ENV{HOME}/Downloads/kaldi-native-fbank-1.23.0.tar.gz
${CMAKE_SOURCE_DIR}/kaldi-native-fbank-1.23.0.tar.gz
${CMAKE_BINARY_DIR}/kaldi-native-fbank-1.23.0.tar.gz
/tmp/kaldi-native-fbank-1.23.0.tar.gz
/star-fj/fangjun/download/github/kaldi-native-fbank-1.23.0.tar.gz
)
foreach(f IN LISTS possible_file_locations)
+2
View File
@@ -1,3 +1,5 @@
include_guard(GLOBAL)
# Copyright (c) 2022-2023 Xiaomi Corporation
function(download_onnxruntime)
include(FetchContent)
+2
View File
@@ -1,3 +1,5 @@
include_guard(GLOBAL)
# Copyright (c) 2020 Xiaomi Corporation (author: Fangjun Kuang)
function(download_openfst)
+2 -3
View File
@@ -1,8 +1,9 @@
include_guard(GLOBAL)
function(download_portaudio)
include(FetchContent)
set(portaudio_URL "http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz")
set(portaudio_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pa_stable_v190700_20210406.tgz")
set(portaudio_HASH "SHA256=47efbf42c77c19a05d22e627d42873e991ec0c1357219c0d74ce6a2948cb2def")
# If you don't have access to the Internet, please download it to your
@@ -21,7 +22,6 @@ function(download_portaudio)
set(portaudio_URL "${f}")
file(TO_CMAKE_PATH "${portaudio_URL}" portaudio_URL)
message(STATUS "Found local downloaded portaudio: ${portaudio_URL}")
set(portaudio_URL2)
break()
endif()
endforeach()
@@ -35,7 +35,6 @@ function(download_portaudio)
FetchContent_Declare(portaudio
URL
${portaudio_URL}
${portaudio_URL2}
URL_HASH ${portaudio_HASH}
)
+2 -3
View File
@@ -1,8 +1,9 @@
include_guard(GLOBAL)
function(download_pybind11)
include(FetchContent)
set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v3.0.0.tar.gz")
set(pybind11_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-3.0.0.tar.gz")
set(pybind11_HASH "SHA256=453b1a3e2b266c3ae9da872411cadb6d693ac18063bd73226d96cfb7015a200c")
# If you don't have access to the Internet,
@@ -20,7 +21,6 @@ function(download_pybind11)
set(pybind11_URL "${f}")
file(TO_CMAKE_PATH "${pybind11_URL}" pybind11_URL)
message(STATUS "Found local downloaded pybind11: ${pybind11_URL}")
set(pybind11_URL2)
break()
endif()
endforeach()
@@ -28,7 +28,6 @@ function(download_pybind11)
FetchContent_Declare(pybind11
URL
${pybind11_URL}
${pybind11_URL2}
URL_HASH ${pybind11_HASH}
)
+2 -3
View File
@@ -1,3 +1,5 @@
include_guard(GLOBAL)
# Write ${content} to ${path} only when it differs from what is on disk.
# The patches below run on every configure; a plain file(WRITE) would update
# the header's mtime each time and make/ssentencepiece (plus every dependent
@@ -18,7 +20,6 @@ function(download_simple_sentencepiece)
include(FetchContent)
set(simple-sentencepiece_URL "https://github.com/pkufool/simple-sentencepiece/archive/refs/tags/v0.7.tar.gz")
set(simple-sentencepiece_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/simple-sentencepiece-0.7.tar.gz")
set(simple-sentencepiece_HASH "SHA256=1748a822060a35baa9f6609f84efc8eb54dc0e74b9ece3d82367b7119fdc75af")
# If you don't have access to the Internet,
@@ -36,7 +37,6 @@ function(download_simple_sentencepiece)
set(simple-sentencepiece_URL "${f}")
file(TO_CMAKE_PATH "${simple-sentencepiece_URL}" simple-sentencepiece_URL)
message(STATUS "Found local downloaded simple-sentencepiece: ${simple-sentencepiece_URL}")
set(simple-sentencepiece_URL2)
break()
endif()
endforeach()
@@ -47,7 +47,6 @@ function(download_simple_sentencepiece)
FetchContent_Declare(simple-sentencepiece
URL
${simple-sentencepiece_URL}
${simple-sentencepiece_URL2}
URL_HASH
${simple-sentencepiece_HASH}
)
+44
View File
@@ -1,3 +1,5 @@
include_guard(GLOBAL)
function(download_utf8proc)
include(FetchContent)
@@ -49,6 +51,48 @@ function(download_utf8proc)
add_subdirectory(${utf8proc_SOURCE_DIR} ${utf8proc_BINARY_DIR} EXCLUDE_FROM_ALL)
# utf8proc's C symbols (utf8proc_map, utf8proc_free, ...) are generic enough
# that the host application may link its own copy of utf8proc (text libraries
# commonly bundle it). Merging two copies makes the linker bind our calls to
# the foreign one; if the two versions disagree (e.g. utf8proc_property_t
# layout), that corrupts memory at runtime — the same failure mode as the
# kissfft clash in https://github.com/k2-fsa/sherpa-onnx/issues/2588.
# Rename every public C symbol of utf8proc with a sherpa_onnx_ prefix. PUBLIC
# is required so our own sources see the renamed declarations.
target_compile_definitions(utf8proc PUBLIC
utf8proc_category=sherpa_onnx_utf8proc_category
utf8proc_category_string=sherpa_onnx_utf8proc_category_string
utf8proc_charwidth=sherpa_onnx_utf8proc_charwidth
utf8proc_charwidth_ambiguous=sherpa_onnx_utf8proc_charwidth_ambiguous
utf8proc_codepoint_valid=sherpa_onnx_utf8proc_codepoint_valid
utf8proc_decompose=sherpa_onnx_utf8proc_decompose
utf8proc_decompose_char=sherpa_onnx_utf8proc_decompose_char
utf8proc_decompose_custom=sherpa_onnx_utf8proc_decompose_custom
utf8proc_encode_char=sherpa_onnx_utf8proc_encode_char
utf8proc_errmsg=sherpa_onnx_utf8proc_errmsg
utf8proc_free=sherpa_onnx_utf8proc_free
utf8proc_get_property=sherpa_onnx_utf8proc_get_property
utf8proc_grapheme_break=sherpa_onnx_utf8proc_grapheme_break
utf8proc_grapheme_break_stateful=sherpa_onnx_utf8proc_grapheme_break_stateful
utf8proc_islower=sherpa_onnx_utf8proc_islower
utf8proc_isupper=sherpa_onnx_utf8proc_isupper
utf8proc_iterate=sherpa_onnx_utf8proc_iterate
utf8proc_map=sherpa_onnx_utf8proc_map
utf8proc_map_custom=sherpa_onnx_utf8proc_map_custom
utf8proc_NFC=sherpa_onnx_utf8proc_NFC
utf8proc_NFD=sherpa_onnx_utf8proc_NFD
utf8proc_NFKC=sherpa_onnx_utf8proc_NFKC
utf8proc_NFKC_Casefold=sherpa_onnx_utf8proc_NFKC_Casefold
utf8proc_NFKD=sherpa_onnx_utf8proc_NFKD
utf8proc_normalize_utf32=sherpa_onnx_utf8proc_normalize_utf32
utf8proc_reencode=sherpa_onnx_utf8proc_reencode
utf8proc_tolower=sherpa_onnx_utf8proc_tolower
utf8proc_totitle=sherpa_onnx_utf8proc_totitle
utf8proc_toupper=sherpa_onnx_utf8proc_toupper
utf8proc_unicode_version=sherpa_onnx_utf8proc_unicode_version
utf8proc_version=sherpa_onnx_utf8proc_version
)
# utf8proc renames the static library to utf8proc_static under MSVC, which
# would make the artifact name platform-dependent. Force it back to
# "utf8proc" everywhere so -lutf8proc / utf8proc.lib / {$linklib utf8proc}
+2 -3
View File
@@ -1,9 +1,10 @@
include_guard(GLOBAL)
function(download_websocketpp)
include(FetchContent)
# The latest commit on the develop branch os as 2022-10-22
set(websocketpp_URL "https://github.com/zaphoyd/websocketpp/archive/b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip")
set(websocketpp_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip")
set(websocketpp_HASH "SHA256=1385135ede8191a7fbef9ec8099e3c5a673d48df0c143958216cd1690567f583")
# If you don't have access to the Internet,
@@ -21,7 +22,6 @@ function(download_websocketpp)
set(websocketpp_URL "${f}")
file(TO_CMAKE_PATH "${websocketpp_URL}" websocketpp_URL)
message(STATUS "Found local downloaded websocketpp: ${websocketpp_URL}")
set(websocketpp_URL2)
break()
endif()
endforeach()
@@ -29,7 +29,6 @@ function(download_websocketpp)
FetchContent_Declare(websocketpp
URL
${websocketpp_URL}
${websocketpp_URL2}
URL_HASH ${websocketpp_HASH}
)
+2 -1
View File
@@ -75,7 +75,8 @@ function check_style() {
if [[ $1 == mfc-example* ]]; then
return
fi
python3 $cpplint_src $1 || abort $1
# Silence vendored-cpplint DeprecationWarnings (sre_compile, codecs.open ...)
python3 -W ignore::DeprecationWarning $cpplint_src $1 || abort $1
}
function check_last_commit() {
@@ -113,6 +113,7 @@ _SherpaOnnxOfflineSpeakerDiarizationResultSortByStartTime
_SherpaOnnxOfflineSpeakerDiarizationSetConfig
_SherpaOnnxOfflineSpeechDenoiserGetSampleRate
_SherpaOnnxOfflineSpeechDenoiserRun
_SherpaOnnxOfflineSpeechDenoiserSetVoiceSample
_SherpaOnnxOfflineStreamGetOption
_SherpaOnnxOfflineStreamHasOption
_SherpaOnnxOfflineStreamSetOption
@@ -133,6 +134,7 @@ _SherpaOnnxOnlineSpeechDenoiserGetFrameShiftInSamples
_SherpaOnnxOnlineSpeechDenoiserGetSampleRate
_SherpaOnnxOnlineSpeechDenoiserReset
_SherpaOnnxOnlineSpeechDenoiserRun
_SherpaOnnxOnlineSpeechDenoiserSetVoiceSample
_SherpaOnnxOnlineStreamAcceptWaveform
_SherpaOnnxOnlineStreamGetOption
_SherpaOnnxOnlineStreamHasOption