55 set (SYMBOL_FILE ${CMAKE_CURRENT_BINARY_DIR } /onnxruntime.lds)
66 if (APPLE )
77 set (OUTPUT_STYLE xcode)
8+ elseif (CMAKE_SYSTEM_NAME MATCHES "AIX" )
9+ set (OUTPUT_STYLE aix)
810 else ()
911 set (OUTPUT_STYLE gcc)
1012 endif ()
@@ -66,7 +68,6 @@ if(onnxruntime_BUILD_SHARED_LIB)
6668 list (APPEND SYMBOL_FILES "${ONNXRUNTIME_ROOT} /core/providers/${f} /symbols.txt" )
6769 endforeach ()
6870
69- if (NOT CMAKE_SYSTEM_NAME MATCHES "AIX" )
7071 add_custom_command (OUTPUT ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR } /generated_source.c
7172 COMMAND ${Python_EXECUTABLE} "${REPO_ROOT} /tools/ci_build/gen_def.py"
7273 --version_file "${ONNXRUNTIME_ROOT} /../VERSION_NUMBER" --src_root "${ONNXRUNTIME_ROOT} "
@@ -76,7 +77,6 @@ if(onnxruntime_BUILD_SHARED_LIB)
7677 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR } )
7778
7879 add_custom_target (onnxruntime_generate_def ALL DEPENDS ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR } /generated_source.c )
79- endif ()
8080 if (WIN32 )
8181 onnxruntime_add_shared_library (onnxruntime
8282 ${SYMBOL_FILE}
@@ -122,11 +122,7 @@ if(onnxruntime_BUILD_SHARED_LIB)
122122 # Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file.
123123 )
124124 else ()
125- if (CMAKE_SYSTEM_NAME MATCHES "AIX" )
126- onnxruntime_add_shared_library (onnxruntime ${ONNXRUNTIME_ROOT} /core/session/onnxruntime_c_api.cc )
127- else ()
128- onnxruntime_add_shared_library (onnxruntime ${CMAKE_CURRENT_BINARY_DIR } /generated_source.c )
129- endif ()
125+ onnxruntime_add_shared_library (onnxruntime ${CMAKE_CURRENT_BINARY_DIR } /generated_source.c )
130126 if (NOT APPLE )
131127 include (CheckLinkerFlag )
132128 check_linker_flag (CXX "LINKER:-rpath=\$ ORIGIN" LINKER_SUPPORT_RPATH )
@@ -136,11 +132,7 @@ if(onnxruntime_BUILD_SHARED_LIB)
136132 endif ()
137133 endif ()
138134
139- if (CMAKE_SYSTEM_NAME MATCHES "AIX" )
140- add_dependencies (onnxruntime ${onnxruntime_EXTERNAL_DEPENDENCIES} )
141- else ()
142- add_dependencies (onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES} )
143- endif ()
135+ add_dependencies (onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES} )
144136 target_include_directories (onnxruntime PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "$<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} /onnxruntime >" )
145137
146138
@@ -149,7 +141,10 @@ if(onnxruntime_BUILD_SHARED_LIB)
149141 if(UNIX)
150142 if (APPLE)
151143 target_link_options(onnxruntime PRIVATE " LINKER:-dead_strip ")
152- elseif(NOT CMAKE_SYSTEM_NAME MATCHES " AIX ")
144+ elseif(CMAKE_SYSTEM_NAME MATCHES " AIX ")
145+ set_property(TARGET onnxruntime PROPERTY AIX_EXPORT_ALL_SYMBOLS OFF)
146+ target_link_options(onnxruntime PRIVATE " LINKER:-bE:${SYMBOL_FILE} ")
147+ else()
153148 target_link_options(onnxruntime PRIVATE " LINKER:--version-script=${SYMBOL_FILE} " " LINKER:--no-undefined " " LINKER:--gc-sections " " LINKER:-z,noexecstack ")
154149 endif()
155150 else()
@@ -286,21 +281,13 @@ if(WIN32)
286281 target_link_options(onnxruntime PRIVATE ${onnxruntime_DELAYLOAD_FLAGS} )
287282endif()
288283#See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html
289- if(NOT WIN32)
290- if(CMAKE_SYSTEM_NAME MATCHES " AIX ")
291- set_target_properties(onnxruntime PROPERTIES
292- PUBLIC_HEADER " ${ONNXRUNTIME_PUBLIC_HEADERS} "
293- VERSION ${ORT_VERSION}
294- SOVERSION 1
295- FOLDER " ONNXRuntime ")
296- else()
297- set_target_properties(onnxruntime PROPERTIES
298- PUBLIC_HEADER " ${ONNXRUNTIME_PUBLIC_HEADERS} "
299- LINK_DEPENDS ${SYMBOL_FILE}
300- VERSION ${ORT_VERSION}
301- SOVERSION 1
302- FOLDER " ONNXRuntime ")
303- endif()
284+ if(NOT WIN32)
285+ set_target_properties(onnxruntime PROPERTIES
286+ PUBLIC_HEADER " ${ONNXRUNTIME_PUBLIC_HEADERS} "
287+ LINK_DEPENDS ${SYMBOL_FILE}
288+ VERSION ${ORT_VERSION}
289+ SOVERSION 1
290+ FOLDER " ONNXRuntime ")
304291else()
305292 # Omit the SOVERSION setting in Windows build
306293 set_target_properties(onnxruntime PROPERTIES
0 commit comments