fix: 修复 macOS release 二进制因 brew onnxruntime 依赖链无法在其他 Mac 运行 - #7
Merged
Conversation
改用 Microsoft 官方自包含 onnxruntime 发布包替代 brew 安装, 将 libonnxruntime.dylib/.so 与二进制捆绑分发,通过 @loader_path / $ORIGIN 实现可移植的动态库加载。 同时添加 ad-hoc 签名避免 macOS Gatekeeper 阻止运行。
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.
Background
brew install onnxruntime安装 onnxruntime,但 brew 版本的libonnxruntime.dylib不是自包含的,它依赖了 50+ 个 brew 安装的其他库(protobuf、abseil、onnx 等),路径全部硬编码为/opt/homebrew/opt/...LC_LOAD_DYLIB,用户下载后在其他 Mac 上运行时,dyld 找不到这些 brew 库就会崩溃(KILL)Changes
onnxruntime-osx-arm64-1.21.0.tgz替代brew install onnxruntime,dylib 仅依赖系统框架libonnxruntime.dylib/.so与二进制一起上传到 Releaseinstall_name_tool -id @loader_path/实现同目录查找-Wl,-rpath,\$ORIGIN实现同样效果codesign --force --sign -,避免 Gatekeeper 阻止Fixup macOS binary步骤,用otool -L检查库引用路径Behavior Impact
libonnxruntime.dylib/.so与二进制放在同一目录即可运行,无需安装 brew 或其他依赖ci.yml)不变,仍使用 brewRisks and Rollback
git revert回滚此 commitVerification
otool -L确认二进制引用@loader_path/libonnxruntime.dylibNotes