Fix MacOS shared library build (#447)

* try removing the --version-script

* remove --no-undefined flag

* remove the -rpath linker flag

* remove the -rpath linker flag, including the -Wl

* remove the --whole-archive flags

* added -all_load -noall_load flags in place of --whole-archive and --no-whole-archive

* spell correct all-load

* set the MacOS specific cmake configs with if(APPLE) condition

* added --build_shared_lib to mac CI
This commit is contained in:
shahasad 2019-02-06 15:27:37 -08:00 committed by GitHub
parent f14b258a5c
commit 8a8d1b0cea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -32,15 +32,24 @@ target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT})
onnxruntime_add_include_to_target(onnxruntime gsl)
if(UNIX)
set(BEGIN_WHOLE_ARCHIVE -Xlinker --whole-archive)
set(END_WHOLE_ARCHIVE -Xlinker --no-whole-archive)
set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker --version-script=${SYMBOL_FILE} -Xlinker --no-undefined")
if (APPLE)
set(BEGIN_WHOLE_ARCHIVE -Xlinker -all_load)
set(END_WHOLE_ARCHIVE -Xlinker -noall_load)
else()
set(BEGIN_WHOLE_ARCHIVE -Xlinker --whole-archive)
set(END_WHOLE_ARCHIVE -Xlinker --no-whole-archive)
set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker --version-script=${SYMBOL_FILE} -Xlinker --no-undefined")
endif()
else()
set(ONNXRUNTIME_SO_LINK_FLAG "-DEF:${SYMBOL_FILE}")
endif()
if (NOT WIN32)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
if (APPLE)
set_target_properties(onnxruntime PROPERTIES INSTALL_RPATH "@loader_path")
else()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
endif()
endif()
#The BEGIN_WHOLE_ARCHIVE/END_WHOLE_ARCHIVE part should contain the implementations of all the C API functions

View file

@ -5,7 +5,7 @@ jobs:
steps:
- script: |
sudo xcode-select --switch /Applications/Xcode_10.app/Contents/Developer
./build.sh --skip_submodule_sync --parallel
./build.sh --skip_submodule_sync --parallel --build_shared_lib
displayName: 'Command Line Script'
- template: templates/clean-agent-build-directory-step.yml