Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 14 additions & 27 deletions cmake/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ if(UNIX)
set(SYMBOL_FILE ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime.lds)
if(APPLE)
set(OUTPUT_STYLE xcode)
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX")
set(OUTPUT_STYLE aix)
else()
set(OUTPUT_STYLE gcc)
endif()
Expand Down Expand Up @@ -66,7 +68,6 @@ if(onnxruntime_BUILD_SHARED_LIB)
list(APPEND SYMBOL_FILES "${ONNXRUNTIME_ROOT}/core/providers/${f}/symbols.txt")
endforeach()

if(NOT CMAKE_SYSTEM_NAME MATCHES "AIX")
add_custom_command(OUTPUT ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c
COMMAND ${Python_EXECUTABLE} "${REPO_ROOT}/tools/ci_build/gen_def.py"
--version_file "${ONNXRUNTIME_ROOT}/../VERSION_NUMBER" --src_root "${ONNXRUNTIME_ROOT}"
Expand All @@ -76,7 +77,6 @@ if(onnxruntime_BUILD_SHARED_LIB)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

add_custom_target(onnxruntime_generate_def ALL DEPENDS ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c)
endif()
if(WIN32)
onnxruntime_add_shared_library(onnxruntime
${SYMBOL_FILE}
Expand Down Expand Up @@ -122,11 +122,7 @@ if(onnxruntime_BUILD_SHARED_LIB)
# Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file.
)
else()
if(CMAKE_SYSTEM_NAME MATCHES "AIX")
onnxruntime_add_shared_library(onnxruntime ${ONNXRUNTIME_ROOT}/core/session/onnxruntime_c_api.cc)
else()
onnxruntime_add_shared_library(onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c )
endif()
onnxruntime_add_shared_library(onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c)
if(NOT APPLE)
include(CheckLinkerFlag)
check_linker_flag(CXX "LINKER:-rpath=\$ORIGIN" LINKER_SUPPORT_RPATH)
Expand All @@ -136,11 +132,7 @@ if(onnxruntime_BUILD_SHARED_LIB)
endif()
endif()

if(CMAKE_SYSTEM_NAME MATCHES "AIX")
add_dependencies(onnxruntime ${onnxruntime_EXTERNAL_DEPENDENCIES})
else()
add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES})
endif()
add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime>")


Expand All @@ -149,7 +141,10 @@ if(onnxruntime_BUILD_SHARED_LIB)
if(UNIX)
if (APPLE)
target_link_options(onnxruntime PRIVATE "LINKER:-dead_strip")
elseif(NOT CMAKE_SYSTEM_NAME MATCHES "AIX")
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX")
set_property(TARGET onnxruntime PROPERTY AIX_EXPORT_ALL_SYMBOLS OFF)
target_link_options(onnxruntime PRIVATE "LINKER:-bE:${SYMBOL_FILE}")
else()
target_link_options(onnxruntime PRIVATE "LINKER:--version-script=${SYMBOL_FILE}" "LINKER:--no-undefined" "LINKER:--gc-sections" "LINKER:-z,noexecstack")
endif()
else()
Expand Down Expand Up @@ -287,20 +282,12 @@ if(WIN32)
endif()
#See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html
if(NOT APPLE AND NOT WIN32)
if(CMAKE_SYSTEM_NAME MATCHES "AIX")
set_target_properties(onnxruntime PROPERTIES
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
VERSION ${ORT_VERSION}
SOVERSION 1
FOLDER "ONNXRuntime")
else()
set_target_properties(onnxruntime PROPERTIES
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
LINK_DEPENDS ${SYMBOL_FILE}
VERSION ${ORT_VERSION}
SOVERSION 1
FOLDER "ONNXRuntime")
endif()
set_target_properties(onnxruntime PROPERTIES
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
LINK_DEPENDS ${SYMBOL_FILE}
VERSION ${ORT_VERSION}
SOVERSION 1
FOLDER "ONNXRuntime")
else()
# Omit the SOVERSION setting in Windows/macOS/iOS/.. build
set_target_properties(onnxruntime PROPERTIES
Expand Down
8 changes: 5 additions & 3 deletions tools/ci_build/gen_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def parse_arguments():
parser.add_argument("--output", required=True, help="output file")
parser.add_argument("--output_source", required=True, help="output file")
parser.add_argument("--version_file", required=True, help="VERSION_NUMBER file")
parser.add_argument("--style", required=True, choices=["gcc", "vc", "xcode"])
parser.add_argument("--style", required=True, choices=["gcc", "vc", "xcode", "aix"])
parser.add_argument("--config", required=True, nargs="+")
return parser.parse_args()

Expand Down Expand Up @@ -38,8 +38,8 @@ def parse_arguments():
if args.style == "vc":
file.write("LIBRARY\n")
file.write("EXPORTS\n")
elif args.style == "xcode":
pass # xcode compile don't has any header.
elif args.style in ["xcode", "aix"]:
pass # Both xcode and AIX export files don't need a specific header.
else:
file.write(f"VERS_{VERSION_STRING} {{\n")
file.write(" global:\n")
Expand All @@ -49,6 +49,8 @@ def parse_arguments():
file.write(f" {symbol} @{symbol_index}\n")
elif args.style == "xcode":
file.write(f"_{symbol}\n")
elif args.style == "aix":
file.write(f"{symbol}\n") # AIX just needs the name
else:
file.write(f" {symbol};\n")
symbol_index += 1
Expand Down