Skip to content

Commit 1db7c25

Browse files
Copilottianleiwu
andauthored
Set SOVERSION 1 for Apple builds to match Linux library versioning (#28101)
### Description Include Apple in the existing `SOVERSION 1` block by changing the CMake condition from `if(NOT APPLE AND NOT WIN32)` to `if(NOT WIN32)`. **Before:** macOS install name is `@rpath/libonnxruntime.1.20.0.dylib` — dependents pinned to exact version. **After:** macOS install name is `@rpath/libonnxruntime.1.dylib` — dependents only require major version, matching Linux `libonnxruntime.so.1`. The actual library file remains `libonnxruntime.<VERSION>.dylib`, so existing packaging scripts (`copy_strip_binary.sh`, `mac-cpu-packaging-steps.yml`, `js/node/CMakeLists.txt`) are unaffected. CMake creates the intermediate `libonnxruntime.1.dylib` symlink automatically. ### Motivation and Context On macOS, linking against onnxruntime embeds the full-versioned install name, causing `dlopen` failures when a different patch version is installed: ``` dlopen(dependent.dylib, 0x0001): Library not loaded: @rpath/libonnxruntime.1.20.0.dylib ``` Linux already avoids this via `SOVERSION 1`. The exclusion of Apple from that code path appears unintentional. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
1 parent 7fdc60e commit 1db7c25

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cmake/onnxruntime.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ if(WIN32)
286286
target_link_options(onnxruntime PRIVATE ${onnxruntime_DELAYLOAD_FLAGS})
287287
endif()
288288
#See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html
289-
if(NOT APPLE AND NOT WIN32)
289+
if(NOT WIN32)
290290
if(CMAKE_SYSTEM_NAME MATCHES "AIX")
291291
set_target_properties(onnxruntime PROPERTIES
292292
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
@@ -302,7 +302,7 @@ if(NOT APPLE AND NOT WIN32)
302302
FOLDER "ONNXRuntime")
303303
endif()
304304
else()
305-
# Omit the SOVERSION setting in Windows/macOS/iOS/.. build
305+
# Omit the SOVERSION setting in Windows build
306306
set_target_properties(onnxruntime PROPERTIES
307307
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
308308
LINK_DEPENDS ${SYMBOL_FILE}

0 commit comments

Comments
 (0)