Repository navigation
Fix iOS runtime symbol-loader exports - #9736
Open
derek-gerstmann wants to merge 2 commits into
Open
derek-gerstmann wants to merge 2 commits into
derek-gerstmann wants to merge 2 commits into
Conversation
Include the Darwin symbol loader in iOS runtimes and cover Host and Metal archives across device and Simulator targets. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Halide's runtime API (
HalideRuntime.h) declares nine symbol-loading entry points (halide_default_get_symbol,halide_default_load_library,halide_default_get_library_symbol,halide_get_symbol,halide_load_library,halide_get_library_symbol, and the threehalide_set_custom_*setters). Whileget_initial_module_for_targetinsrc/LLVM_Runtime_Linker.cppincludesosx_get_symbolforTarget::MacOS, theTarget::IOSbranch omitted a symbol-lookup module altogether. Consequently, standalone iOS Host and Metal runtime archives (across ARM64 device, ARM64 Simulator, and x86-64 Simulator targets, including symbol-prefixed multi-backend distributions) omitted definitions for this entire function family, causing downstream executables that populate runtime dispatch tables or take addresses of these functions to fail at link time even when no kernel performs dynamic symbol lookup.Summary of changes
src/LLVM_Runtime_Linker.cpp): Addget_initmod_osx_get_symbolto theTarget::IOSbranch so iOS Host and Metal runtimes reuse the existing Darwindlopen/dlsymsymbol-loader implementation.src/runtime/HalideRuntime.h,src/runtime/metal.cpp): Document the macOS and iOS default loader behavior (RTLD_DEFAULTglobal lookup,dlopen(name, RTLD_LAZY | RTLD_LOCAL),RTLD_DEFAULTfallback for null library handles, null return on missing libraries/symbols, and adherence to iOS code-signing/dynamic-loading restrictions without implying JIT support), and remove the obsolete comment inmetal.cppnotinghalide_get_symbolwas absent on iOS.test/correctness/ios_runtime_symbols.cpp,test/correctness/CMakeLists.txt): Compile standalone runtimes to LLVM IR forarm-64-ios,arm-64-ios-simulator, andx86-64-ios-simulator(with and without-metal) and verify externally visible weak definitions for all nine symbol-loader functions.test/integration/ios_runtime_symbols/,.github/workflows/testing-macos.yml): Build standalone Host and Metal.aarchives viaadd_halide_runtimeacross all six iOS target/backend combinations, verify all nine defined exports per slice withxcrun nm -gU, link standalone consumer executables against theiphoneosandiphonesimulatorSDKs (FoundationandMetalsupplied explicitly), and run the native ARM64 Simulator Host and Metal consumers viasimctlintesting-macos.ymlto exercise default lookup,load_library(nullptr), null-handle lookup, missing symbol/library failure returns, custom handler dispatch, and handler restoration.Validation
ctest --test-dir build\ios-loader-validation --output-on-failure -R '^correctness_(ios_runtime_symbols|cross_compilation)$' -j 2— passed (and verifiedcorrectness_ios_runtime_symbolsfails withoutosx_get_symbol).LC_SYMTABsymbol tables across all six generated standalone.aarchives (arm-64-ios,arm-64-ios-simulator,x86-64-ios-simulator× Host/Metal) — passed (all nine public loader exports defined in each archive).ruff check test/integration/ios_runtime_symbols/run.pyandclang-format --dry-run --Werror test/correctness/ios_runtime_symbols.cpp test/integration/ios_runtime_symbols/consumer.cpp— passed.python3 test/integration/ios_runtime_symbols/run.py --halide-root "$PWD/install" --build-dir "$PWD/build-ios-runtime-symbols"— wired intotesting-macos.yml(arm-64); not run locally on Windows because macOS/Xcode SDKs and Simulator runtimes are required.Fixes: N/A
Breaking changes
None.
Checklist
Generated with GitHub Copilot