2018-11-20 00:48:22 +00:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
|
set(SYMBOL_FILE ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime.lds)
|
2021-10-27 10:07:07 +00:00
|
|
|
if(APPLE)
|
|
|
|
|
set(OUTPUT_STYLE xcode)
|
|
|
|
|
else()
|
|
|
|
|
set(OUTPUT_STYLE gcc)
|
2022-02-11 03:17:08 +00:00
|
|
|
endif()
|
2018-11-20 00:48:22 +00:00
|
|
|
else()
|
|
|
|
|
set(SYMBOL_FILE ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime_dll.def)
|
|
|
|
|
set(OUTPUT_STYLE vc)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-09-14 17:32:39 +00:00
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
|
|
|
|
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
|
2020-09-15 06:59:41 +00:00
|
|
|
set(OUTPUT_STYLE xcode)
|
2020-09-14 17:32:39 +00:00
|
|
|
endif()
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2023-10-04 15:55:08 +00:00
|
|
|
# Gets the public C/C++ API header files
|
|
|
|
|
function(get_c_cxx_api_headers HEADERS_VAR)
|
|
|
|
|
set(_headers
|
2021-05-28 00:07:48 +00:00
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_c_api.h"
|
|
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_cxx_api.h"
|
|
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_cxx_inline.h"
|
2023-10-04 15:55:08 +00:00
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_float16.h"
|
|
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_run_options_config_keys.h"
|
|
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h"
|
2024-07-24 17:02:00 +00:00
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_lite_custom_op.h"
|
2021-05-28 00:07:48 +00:00
|
|
|
)
|
2023-05-01 19:59:56 +00:00
|
|
|
|
|
|
|
|
if (onnxruntime_ENABLE_TRAINING_APIS)
|
2023-10-04 15:55:08 +00:00
|
|
|
list(APPEND _headers "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_c_api.h")
|
|
|
|
|
list(APPEND _headers "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_api.h")
|
|
|
|
|
list(APPEND _headers "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_inline.h")
|
2023-05-01 19:59:56 +00:00
|
|
|
endif()
|
2021-05-28 00:07:48 +00:00
|
|
|
|
|
|
|
|
# need to add header files for enabled EPs
|
|
|
|
|
foreach(f ${ONNXRUNTIME_PROVIDER_NAMES})
|
2024-10-08 23:10:46 +00:00
|
|
|
# The header files in include/onnxruntime/core/providers/cuda directory cannot be flattened to the same directory
|
2024-08-01 11:23:02 +00:00
|
|
|
# with onnxruntime_c_api.h . Most other EPs probably also do not work in this way.
|
|
|
|
|
if((NOT f STREQUAL cuda) AND (NOT f STREQUAL rocm))
|
|
|
|
|
file(GLOB _provider_headers CONFIGURE_DEPENDS
|
|
|
|
|
"${REPO_ROOT}/include/onnxruntime/core/providers/${f}/*.h"
|
|
|
|
|
)
|
|
|
|
|
list(APPEND _headers ${_provider_headers})
|
|
|
|
|
endif()
|
2021-05-28 00:07:48 +00:00
|
|
|
endforeach()
|
2023-10-04 15:55:08 +00:00
|
|
|
|
|
|
|
|
set(${HEADERS_VAR} ${_headers} PARENT_SCOPE)
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
get_c_cxx_api_headers(ONNXRUNTIME_PUBLIC_HEADERS)
|
2021-05-28 00:07:48 +00:00
|
|
|
|
2018-11-23 04:56:43 +00:00
|
|
|
#If you want to verify if there is any extra line in symbols.txt, run
|
|
|
|
|
# nm -C -g --defined libonnxruntime.so |grep -v '\sA\s' | cut -f 3 -d ' ' | sort
|
|
|
|
|
# after build
|
|
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
list(APPEND SYMBOL_FILES "${REPO_ROOT}/tools/ci_build/gen_def.py")
|
|
|
|
|
foreach(f ${ONNXRUNTIME_PROVIDER_NAMES})
|
|
|
|
|
list(APPEND SYMBOL_FILES "${ONNXRUNTIME_ROOT}/core/providers/${f}/symbols.txt")
|
|
|
|
|
endforeach()
|
|
|
|
|
|
Enablement of onnxruntime for AIX and fixing issues related to big-endian platform. (#21133)
### Description
Enablement of onnxruntime for AIX and fixing issues related to
big-endian platform.
### Motivation and Context
changes in this PR contains:
1. Enablement code for building onnxruntime on AIX operating system.
2. while testing the build on AIX, we found issues related to big endian
platform . More details about few of those issues can be found in [Big
endian issue: Graph Transformation Attention Fusion tests are failing
#12921](https://github.com/microsoft/onnxruntime/issues/12921)
Below are list of files and the description about the change.
1. cmake/CMakeLists.txt
[BUILDING on AIX issue] check for "IBMClang" is added for handling
-Wno-unused-parameter
2. cmake/external/onnxruntime_external_deps.cmake
[BUILDING on AIX issue]Enabling gtest_disable_pthreads for AIX
3. cmake/onnxruntime.cmake
[BUILDING on AIX issue]
o Blocking codes for AIX which generates generated_source.c and further
requires some symbol files.
o Putting NO AIX check for non-supported linker flags like --Xlinker
o iconv linking
4. cmake/onnxruntime_framework.cmake
[BUILDING on AIX issue]Putting NO AIX check for -Wl,-rpath='$ORIGIN'
5. cmake/onnxruntime_mlas.cmake
[BUILDING on AIX issue]POWER10 releated macro/function definition .
6. cmake/onnxruntime_providers_cpu.cmake
[BUILDING on AIX issue]Putting NO AIX check for non-supported linker
flags like --Xlinker
7. cmake/onnxruntime_unittests.cmake
[BUILDING on AIX issue]
o Putting NO AIX check for non-supported linker flags like --Xlinker
o Adding required libraries for AIX linker under applicatiion like
onnxruntime_shared_lib_test ,onnxruntime_logging_apis etc
8. cmake/patches/flatbuffers/flatbuffers.patch
[BUILDING on AIX issue] Handling of TypeCode in
include/flatbuffers/flatbuffers.h under AIX + clang
9. onnxruntime/contrib_ops/cpu/murmur_hash3.cc
[Big endian issue] Byte-Conversion handlling in compute() and getblock()
routines
10. onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc
[Big endian issue] Handling of test failures . Byte swapping for
quant_value.
11. onnxruntime/core/framework/tensorprotoutils.cc
[Big endian issue]
Implementation of SetRawDataInTensorProto , ConvertRawDataInTensorProto
.
o SetRawDataInTensorProto : Wrapper for set_raw_data(). Calling
ConvertRawDataInTensorProto() in big-endian system
o ConvertRawDataInTensorProto : function used mainly on big-endian
system for byte-swapping of tensor raw_data
12. onnxruntime/core/framework/tensorprotoutils.h
[Big endian issue]
Declaration of SetRawDataInTensorProto, ConvertRawDataInTensorProto
13. onnxruntime/core/graph/graph.cc
[Big endian issue]
o Call ConvertRawDataInTensorProto for SPARSE_TENSOR type
o Call ConvertRawDataInTensorProto for SaveToOrtFormat
14. onnxruntime/core/mlas/lib/platform.cpp
[BUILDING on AIX issue] POWER10 released enablement for AIX
15. onnxruntime/core/mlas/lib/power/qgemm_kernel_power10.cpp
[BUILDING on AIX issue]Handling of __vector under AIX+clang
16. onnxruntime/core/mlas/lib/qgemm.h
[BUILDING on AIX issue] Adding _AIX flag
17. onnxruntime/core/mlas/lib/qlmul.cpp
[BUILDING on AIX issue] Handling of __vector under AIX+clang
18. onnxruntime/core/optimizer/attention_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
19. onnxruntime/core/optimizer/compute_optimizer/shared_utils.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
20. onnxruntime/core/optimizer/constant_folding.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
21. onnxruntime/core/optimizer/embed_layer_norm_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
22. onnxruntime/core/optimizer/nchwc_transformer.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
23. onnxruntime/core/optimizer/qdq_transformer/avx2_weight_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
24. onnxruntime/core/optimizer/qdq_transformer/qdq_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
25. onnxruntime/core/optimizer/qdq_transformer/s8_to_u8.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
26.
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
27. onnxruntime/core/optimizer/reshape_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
28. onnxruntime/core/optimizer/stft_decomposition.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
29.
onnxruntime/core/optimizer/transpose_optimization/ort_optimizer_api_impl.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
30. onnxruntime/core/platform/path_lib.h
[BUILDING on AIX issue] Moving to normal function call, instead of
template
31. onnxruntime/core/platform/posix/env.cc
[BUILDING on AIX issue]Blocking syscall.h in AIX
32. onnxruntime/core/session/inference_session.cc
[Big endian issue] Removing ORT_RETURN_IF_NOT, FLATBUFFERS_LITTLEENDIAN
33. onnxruntime/test/flatbuffers/flatbuffer_utils_test.cc
[Big endian issue] Call ConvertRawDataInTensorProto in CreateInitializer
and ExternalWriteReadWithLoadInitializers
34. onnxruntime/test/framework/sparse_kernels_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
35. onnxruntime/test/framework/tensorutils_test.cc
[Big endian issue] Helper method ConvertEndianessForVector and call this
from required place.
36. onnxruntime/test/framework/test_tensor_loader.cc
o. [BUILDING on AIX issue] Handling of getcwd for AIX
o. [Big endian issue] Bytes Swapping in run_external_data_test
37. onnxruntime/test/onnx/main.cc
[Big endian issue] including <thread> for AIX
38. onnxruntime/test/onnx/tensorprotoutils.cc
[Big endian issue] Bytes swapping in UnpackTensorWithRawData
39. onnxruntime/test/optimizer/graph_transform_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
40. onnxruntime/test/optimizer/graph_transform_test_builder.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
41. onnxruntime/test/optimizer/graph_transform_test_builder.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
42. onnxruntime/test/optimizer/initializer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
43. onnxruntime/test/optimizer/nchwc_optimizer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
44. onnxruntime/test/providers/base_tester.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
45. onnxruntime/test/providers/cpu/generator/random_test.cc
[BUILDING on AIX issue] Adding AIX check in MultinomialGoodCase
---------
Co-authored-by: Vamshikrishna Thatikonda <vamshikrishna@in.ibm.com>
2024-07-17 19:37:06 +00:00
|
|
|
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
2019-08-20 19:04:10 +00:00
|
|
|
add_custom_command(OUTPUT ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c
|
2021-06-03 06:36:49 +00:00
|
|
|
COMMAND ${Python_EXECUTABLE} "${REPO_ROOT}/tools/ci_build/gen_def.py"
|
2020-09-29 20:53:11 +00:00
|
|
|
--version_file "${ONNXRUNTIME_ROOT}/../VERSION_NUMBER" --src_root "${ONNXRUNTIME_ROOT}"
|
|
|
|
|
--config ${ONNXRUNTIME_PROVIDER_NAMES} --style=${OUTPUT_STYLE} --output ${SYMBOL_FILE}
|
|
|
|
|
--output_source ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c
|
2018-11-20 00:48:22 +00:00
|
|
|
DEPENDS ${SYMBOL_FILES}
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
2019-08-20 19:04:10 +00:00
|
|
|
add_custom_target(onnxruntime_generate_def ALL DEPENDS ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c)
|
Enablement of onnxruntime for AIX and fixing issues related to big-endian platform. (#21133)
### Description
Enablement of onnxruntime for AIX and fixing issues related to
big-endian platform.
### Motivation and Context
changes in this PR contains:
1. Enablement code for building onnxruntime on AIX operating system.
2. while testing the build on AIX, we found issues related to big endian
platform . More details about few of those issues can be found in [Big
endian issue: Graph Transformation Attention Fusion tests are failing
#12921](https://github.com/microsoft/onnxruntime/issues/12921)
Below are list of files and the description about the change.
1. cmake/CMakeLists.txt
[BUILDING on AIX issue] check for "IBMClang" is added for handling
-Wno-unused-parameter
2. cmake/external/onnxruntime_external_deps.cmake
[BUILDING on AIX issue]Enabling gtest_disable_pthreads for AIX
3. cmake/onnxruntime.cmake
[BUILDING on AIX issue]
o Blocking codes for AIX which generates generated_source.c and further
requires some symbol files.
o Putting NO AIX check for non-supported linker flags like --Xlinker
o iconv linking
4. cmake/onnxruntime_framework.cmake
[BUILDING on AIX issue]Putting NO AIX check for -Wl,-rpath='$ORIGIN'
5. cmake/onnxruntime_mlas.cmake
[BUILDING on AIX issue]POWER10 releated macro/function definition .
6. cmake/onnxruntime_providers_cpu.cmake
[BUILDING on AIX issue]Putting NO AIX check for non-supported linker
flags like --Xlinker
7. cmake/onnxruntime_unittests.cmake
[BUILDING on AIX issue]
o Putting NO AIX check for non-supported linker flags like --Xlinker
o Adding required libraries for AIX linker under applicatiion like
onnxruntime_shared_lib_test ,onnxruntime_logging_apis etc
8. cmake/patches/flatbuffers/flatbuffers.patch
[BUILDING on AIX issue] Handling of TypeCode in
include/flatbuffers/flatbuffers.h under AIX + clang
9. onnxruntime/contrib_ops/cpu/murmur_hash3.cc
[Big endian issue] Byte-Conversion handlling in compute() and getblock()
routines
10. onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc
[Big endian issue] Handling of test failures . Byte swapping for
quant_value.
11. onnxruntime/core/framework/tensorprotoutils.cc
[Big endian issue]
Implementation of SetRawDataInTensorProto , ConvertRawDataInTensorProto
.
o SetRawDataInTensorProto : Wrapper for set_raw_data(). Calling
ConvertRawDataInTensorProto() in big-endian system
o ConvertRawDataInTensorProto : function used mainly on big-endian
system for byte-swapping of tensor raw_data
12. onnxruntime/core/framework/tensorprotoutils.h
[Big endian issue]
Declaration of SetRawDataInTensorProto, ConvertRawDataInTensorProto
13. onnxruntime/core/graph/graph.cc
[Big endian issue]
o Call ConvertRawDataInTensorProto for SPARSE_TENSOR type
o Call ConvertRawDataInTensorProto for SaveToOrtFormat
14. onnxruntime/core/mlas/lib/platform.cpp
[BUILDING on AIX issue] POWER10 released enablement for AIX
15. onnxruntime/core/mlas/lib/power/qgemm_kernel_power10.cpp
[BUILDING on AIX issue]Handling of __vector under AIX+clang
16. onnxruntime/core/mlas/lib/qgemm.h
[BUILDING on AIX issue] Adding _AIX flag
17. onnxruntime/core/mlas/lib/qlmul.cpp
[BUILDING on AIX issue] Handling of __vector under AIX+clang
18. onnxruntime/core/optimizer/attention_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
19. onnxruntime/core/optimizer/compute_optimizer/shared_utils.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
20. onnxruntime/core/optimizer/constant_folding.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
21. onnxruntime/core/optimizer/embed_layer_norm_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
22. onnxruntime/core/optimizer/nchwc_transformer.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
23. onnxruntime/core/optimizer/qdq_transformer/avx2_weight_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
24. onnxruntime/core/optimizer/qdq_transformer/qdq_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
25. onnxruntime/core/optimizer/qdq_transformer/s8_to_u8.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
26.
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
27. onnxruntime/core/optimizer/reshape_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
28. onnxruntime/core/optimizer/stft_decomposition.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
29.
onnxruntime/core/optimizer/transpose_optimization/ort_optimizer_api_impl.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
30. onnxruntime/core/platform/path_lib.h
[BUILDING on AIX issue] Moving to normal function call, instead of
template
31. onnxruntime/core/platform/posix/env.cc
[BUILDING on AIX issue]Blocking syscall.h in AIX
32. onnxruntime/core/session/inference_session.cc
[Big endian issue] Removing ORT_RETURN_IF_NOT, FLATBUFFERS_LITTLEENDIAN
33. onnxruntime/test/flatbuffers/flatbuffer_utils_test.cc
[Big endian issue] Call ConvertRawDataInTensorProto in CreateInitializer
and ExternalWriteReadWithLoadInitializers
34. onnxruntime/test/framework/sparse_kernels_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
35. onnxruntime/test/framework/tensorutils_test.cc
[Big endian issue] Helper method ConvertEndianessForVector and call this
from required place.
36. onnxruntime/test/framework/test_tensor_loader.cc
o. [BUILDING on AIX issue] Handling of getcwd for AIX
o. [Big endian issue] Bytes Swapping in run_external_data_test
37. onnxruntime/test/onnx/main.cc
[Big endian issue] including <thread> for AIX
38. onnxruntime/test/onnx/tensorprotoutils.cc
[Big endian issue] Bytes swapping in UnpackTensorWithRawData
39. onnxruntime/test/optimizer/graph_transform_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
40. onnxruntime/test/optimizer/graph_transform_test_builder.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
41. onnxruntime/test/optimizer/graph_transform_test_builder.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
42. onnxruntime/test/optimizer/initializer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
43. onnxruntime/test/optimizer/nchwc_optimizer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
44. onnxruntime/test/providers/base_tester.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
45. onnxruntime/test/providers/cpu/generator/random_test.cc
[BUILDING on AIX issue] Adding AIX check in MultinomialGoodCase
---------
Co-authored-by: Vamshikrishna Thatikonda <vamshikrishna@in.ibm.com>
2024-07-17 19:37:06 +00:00
|
|
|
endif()
|
2020-02-04 03:33:14 +00:00
|
|
|
if(WIN32)
|
2021-04-15 23:47:53 +00:00
|
|
|
onnxruntime_add_shared_library(onnxruntime
|
|
|
|
|
${SYMBOL_FILE}
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/dll/dllmain.cc"
|
Fix delay load for WebGPU EP and DML EP (#23111)
### Description
This change fixes the DLL delay load problem for the WebGPU EP and
DirectML EP. See detailed explanation below.
### Problem
When onnxruntime.dll uses delay loading for its dependencies, the
dependencies are loaded using `LoadLibraryEx()`, which search the
directory of process (.exe) instead of this library (onnxruntime.dll).
This is a problem for usages of Node.js binding and python binding,
because Windows will try to find the dependencies in the directory of
node.exe or python.exe, which is not the directory of onnxruntime.dll.
There was previous attempt to fix this by loading DirectML.dll in the
initialization of onnxruntime nodejs binding, which works for DML EP but
is not a good solution because it does not really "delay" the load.
For WebGPU, the situation became worse because webgpu_dawn.dll depends
on dxil.dll and dxcompiler.dll, which are explicitly dynamically loaded
in the code using `LoadLibraryA()`. This has the same problem of the DLL
search.
### Solutions
For onnxruntime.dll loading its direct dependencies, it can be resolved
by set the [`__pfnDliNotifyHook2`
hook](https://learn.microsoft.com/en-us/cpp/build/reference/understanding-the-helper-function?view=msvc-170#structure-and-constant-definitions)
to load from an absolute path that constructed from the onnxruntime.dll
folder and the DLL name.
For webgpu_dawn.dll loading dxil.dll and dxcompiler.dll, since they are
explicitly loaded in the code, the hook does not work. Instead, it can
be resolved by ~~using WIN32 API `SetDllDirectory()` to add the
onnxruntime.dll folder to the search path.~~ preloading the 2 DLLs from
the onnxruntime.dll folder .
2024-12-19 18:23:48 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/dll/delay_load_hook.cc"
|
2021-04-15 23:47:53 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/dll/onnxruntime.rc"
|
|
|
|
|
)
|
|
|
|
|
elseif(onnxruntime_BUILD_APPLE_FRAMEWORK)
|
|
|
|
|
# apple framework requires the header file be part of the library
|
|
|
|
|
onnxruntime_add_shared_library(onnxruntime
|
2023-10-04 15:55:08 +00:00
|
|
|
${ONNXRUNTIME_PUBLIC_HEADERS}
|
2021-04-15 23:47:53 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/generated_source.c"
|
|
|
|
|
)
|
|
|
|
|
|
2021-06-02 18:30:05 +00:00
|
|
|
# create Info.plist for the framework and podspec for CocoaPods (optional)
|
2021-04-15 23:47:53 +00:00
|
|
|
set(MACOSX_FRAMEWORK_NAME "onnxruntime")
|
|
|
|
|
set(MACOSX_FRAMEWORK_IDENTIFIER "com.microsoft.onnxruntime")
|
2024-10-08 23:10:46 +00:00
|
|
|
|
|
|
|
|
# Setup weak frameworks for macOS/iOS. 'weak' as the CoreML or WebGPU EPs are optionally enabled.
|
2021-07-14 23:39:17 +00:00
|
|
|
if(onnxruntime_USE_COREML)
|
2024-10-08 23:10:46 +00:00
|
|
|
list(APPEND _weak_frameworks "\\\"CoreML\\\"")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(onnxruntime_USE_WEBGPU)
|
|
|
|
|
list(APPEND _weak_frameworks "\\\"QuartzCore\\\"")
|
|
|
|
|
list(APPEND _weak_frameworks "\\\"IOSurface\\\"")
|
|
|
|
|
list(APPEND _weak_frameworks "\\\"Metal\\\"")
|
2021-07-14 23:39:17 +00:00
|
|
|
endif()
|
2024-10-08 23:10:46 +00:00
|
|
|
|
|
|
|
|
if (_weak_frameworks)
|
|
|
|
|
string(JOIN ", " APPLE_WEAK_FRAMEWORK ${_weak_frameworks})
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-07-14 23:39:17 +00:00
|
|
|
set(INFO_PLIST_PATH "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
|
|
|
|
|
configure_file(${REPO_ROOT}/cmake/Info.plist.in ${INFO_PLIST_PATH})
|
2021-06-02 18:30:05 +00:00
|
|
|
configure_file(
|
2021-07-02 13:21:59 +00:00
|
|
|
${REPO_ROOT}/tools/ci_build/github/apple/framework_info.json.template
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/framework_info.json)
|
2021-04-15 23:47:53 +00:00
|
|
|
set_target_properties(onnxruntime PROPERTIES
|
|
|
|
|
FRAMEWORK TRUE
|
|
|
|
|
FRAMEWORK_VERSION A
|
2023-10-04 15:55:08 +00:00
|
|
|
MACOSX_FRAMEWORK_INFO_PLIST ${INFO_PLIST_PATH}
|
|
|
|
|
# Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file.
|
2021-04-15 23:47:53 +00:00
|
|
|
)
|
2020-02-04 03:33:14 +00:00
|
|
|
else()
|
Enablement of onnxruntime for AIX and fixing issues related to big-endian platform. (#21133)
### Description
Enablement of onnxruntime for AIX and fixing issues related to
big-endian platform.
### Motivation and Context
changes in this PR contains:
1. Enablement code for building onnxruntime on AIX operating system.
2. while testing the build on AIX, we found issues related to big endian
platform . More details about few of those issues can be found in [Big
endian issue: Graph Transformation Attention Fusion tests are failing
#12921](https://github.com/microsoft/onnxruntime/issues/12921)
Below are list of files and the description about the change.
1. cmake/CMakeLists.txt
[BUILDING on AIX issue] check for "IBMClang" is added for handling
-Wno-unused-parameter
2. cmake/external/onnxruntime_external_deps.cmake
[BUILDING on AIX issue]Enabling gtest_disable_pthreads for AIX
3. cmake/onnxruntime.cmake
[BUILDING on AIX issue]
o Blocking codes for AIX which generates generated_source.c and further
requires some symbol files.
o Putting NO AIX check for non-supported linker flags like --Xlinker
o iconv linking
4. cmake/onnxruntime_framework.cmake
[BUILDING on AIX issue]Putting NO AIX check for -Wl,-rpath='$ORIGIN'
5. cmake/onnxruntime_mlas.cmake
[BUILDING on AIX issue]POWER10 releated macro/function definition .
6. cmake/onnxruntime_providers_cpu.cmake
[BUILDING on AIX issue]Putting NO AIX check for non-supported linker
flags like --Xlinker
7. cmake/onnxruntime_unittests.cmake
[BUILDING on AIX issue]
o Putting NO AIX check for non-supported linker flags like --Xlinker
o Adding required libraries for AIX linker under applicatiion like
onnxruntime_shared_lib_test ,onnxruntime_logging_apis etc
8. cmake/patches/flatbuffers/flatbuffers.patch
[BUILDING on AIX issue] Handling of TypeCode in
include/flatbuffers/flatbuffers.h under AIX + clang
9. onnxruntime/contrib_ops/cpu/murmur_hash3.cc
[Big endian issue] Byte-Conversion handlling in compute() and getblock()
routines
10. onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc
[Big endian issue] Handling of test failures . Byte swapping for
quant_value.
11. onnxruntime/core/framework/tensorprotoutils.cc
[Big endian issue]
Implementation of SetRawDataInTensorProto , ConvertRawDataInTensorProto
.
o SetRawDataInTensorProto : Wrapper for set_raw_data(). Calling
ConvertRawDataInTensorProto() in big-endian system
o ConvertRawDataInTensorProto : function used mainly on big-endian
system for byte-swapping of tensor raw_data
12. onnxruntime/core/framework/tensorprotoutils.h
[Big endian issue]
Declaration of SetRawDataInTensorProto, ConvertRawDataInTensorProto
13. onnxruntime/core/graph/graph.cc
[Big endian issue]
o Call ConvertRawDataInTensorProto for SPARSE_TENSOR type
o Call ConvertRawDataInTensorProto for SaveToOrtFormat
14. onnxruntime/core/mlas/lib/platform.cpp
[BUILDING on AIX issue] POWER10 released enablement for AIX
15. onnxruntime/core/mlas/lib/power/qgemm_kernel_power10.cpp
[BUILDING on AIX issue]Handling of __vector under AIX+clang
16. onnxruntime/core/mlas/lib/qgemm.h
[BUILDING on AIX issue] Adding _AIX flag
17. onnxruntime/core/mlas/lib/qlmul.cpp
[BUILDING on AIX issue] Handling of __vector under AIX+clang
18. onnxruntime/core/optimizer/attention_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
19. onnxruntime/core/optimizer/compute_optimizer/shared_utils.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
20. onnxruntime/core/optimizer/constant_folding.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
21. onnxruntime/core/optimizer/embed_layer_norm_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
22. onnxruntime/core/optimizer/nchwc_transformer.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
23. onnxruntime/core/optimizer/qdq_transformer/avx2_weight_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
24. onnxruntime/core/optimizer/qdq_transformer/qdq_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
25. onnxruntime/core/optimizer/qdq_transformer/s8_to_u8.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
26.
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
27. onnxruntime/core/optimizer/reshape_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
28. onnxruntime/core/optimizer/stft_decomposition.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
29.
onnxruntime/core/optimizer/transpose_optimization/ort_optimizer_api_impl.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
30. onnxruntime/core/platform/path_lib.h
[BUILDING on AIX issue] Moving to normal function call, instead of
template
31. onnxruntime/core/platform/posix/env.cc
[BUILDING on AIX issue]Blocking syscall.h in AIX
32. onnxruntime/core/session/inference_session.cc
[Big endian issue] Removing ORT_RETURN_IF_NOT, FLATBUFFERS_LITTLEENDIAN
33. onnxruntime/test/flatbuffers/flatbuffer_utils_test.cc
[Big endian issue] Call ConvertRawDataInTensorProto in CreateInitializer
and ExternalWriteReadWithLoadInitializers
34. onnxruntime/test/framework/sparse_kernels_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
35. onnxruntime/test/framework/tensorutils_test.cc
[Big endian issue] Helper method ConvertEndianessForVector and call this
from required place.
36. onnxruntime/test/framework/test_tensor_loader.cc
o. [BUILDING on AIX issue] Handling of getcwd for AIX
o. [Big endian issue] Bytes Swapping in run_external_data_test
37. onnxruntime/test/onnx/main.cc
[Big endian issue] including <thread> for AIX
38. onnxruntime/test/onnx/tensorprotoutils.cc
[Big endian issue] Bytes swapping in UnpackTensorWithRawData
39. onnxruntime/test/optimizer/graph_transform_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
40. onnxruntime/test/optimizer/graph_transform_test_builder.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
41. onnxruntime/test/optimizer/graph_transform_test_builder.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
42. onnxruntime/test/optimizer/initializer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
43. onnxruntime/test/optimizer/nchwc_optimizer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
44. onnxruntime/test/providers/base_tester.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
45. onnxruntime/test/providers/cpu/generator/random_test.cc
[BUILDING on AIX issue] Adding AIX check in MultinomialGoodCase
---------
Co-authored-by: Vamshikrishna Thatikonda <vamshikrishna@in.ibm.com>
2024-07-17 19:37:06 +00:00
|
|
|
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()
|
2024-11-05 00:30:50 +00:00
|
|
|
if(NOT APPLE)
|
2024-11-07 21:22:22 +00:00
|
|
|
include(CheckLinkerFlag)
|
|
|
|
|
check_linker_flag(CXX "LINKER:-rpath=\$ORIGIN" LINKER_SUPPORT_RPATH)
|
|
|
|
|
if(LINKER_SUPPORT_RPATH)
|
|
|
|
|
target_link_options(onnxruntime PRIVATE "LINKER:-rpath=\$ORIGIN")
|
|
|
|
|
endif()
|
2021-05-26 00:36:15 +00:00
|
|
|
endif()
|
2020-02-04 03:33:14 +00:00
|
|
|
endif()
|
|
|
|
|
|
Enablement of onnxruntime for AIX and fixing issues related to big-endian platform. (#21133)
### Description
Enablement of onnxruntime for AIX and fixing issues related to
big-endian platform.
### Motivation and Context
changes in this PR contains:
1. Enablement code for building onnxruntime on AIX operating system.
2. while testing the build on AIX, we found issues related to big endian
platform . More details about few of those issues can be found in [Big
endian issue: Graph Transformation Attention Fusion tests are failing
#12921](https://github.com/microsoft/onnxruntime/issues/12921)
Below are list of files and the description about the change.
1. cmake/CMakeLists.txt
[BUILDING on AIX issue] check for "IBMClang" is added for handling
-Wno-unused-parameter
2. cmake/external/onnxruntime_external_deps.cmake
[BUILDING on AIX issue]Enabling gtest_disable_pthreads for AIX
3. cmake/onnxruntime.cmake
[BUILDING on AIX issue]
o Blocking codes for AIX which generates generated_source.c and further
requires some symbol files.
o Putting NO AIX check for non-supported linker flags like --Xlinker
o iconv linking
4. cmake/onnxruntime_framework.cmake
[BUILDING on AIX issue]Putting NO AIX check for -Wl,-rpath='$ORIGIN'
5. cmake/onnxruntime_mlas.cmake
[BUILDING on AIX issue]POWER10 releated macro/function definition .
6. cmake/onnxruntime_providers_cpu.cmake
[BUILDING on AIX issue]Putting NO AIX check for non-supported linker
flags like --Xlinker
7. cmake/onnxruntime_unittests.cmake
[BUILDING on AIX issue]
o Putting NO AIX check for non-supported linker flags like --Xlinker
o Adding required libraries for AIX linker under applicatiion like
onnxruntime_shared_lib_test ,onnxruntime_logging_apis etc
8. cmake/patches/flatbuffers/flatbuffers.patch
[BUILDING on AIX issue] Handling of TypeCode in
include/flatbuffers/flatbuffers.h under AIX + clang
9. onnxruntime/contrib_ops/cpu/murmur_hash3.cc
[Big endian issue] Byte-Conversion handlling in compute() and getblock()
routines
10. onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc
[Big endian issue] Handling of test failures . Byte swapping for
quant_value.
11. onnxruntime/core/framework/tensorprotoutils.cc
[Big endian issue]
Implementation of SetRawDataInTensorProto , ConvertRawDataInTensorProto
.
o SetRawDataInTensorProto : Wrapper for set_raw_data(). Calling
ConvertRawDataInTensorProto() in big-endian system
o ConvertRawDataInTensorProto : function used mainly on big-endian
system for byte-swapping of tensor raw_data
12. onnxruntime/core/framework/tensorprotoutils.h
[Big endian issue]
Declaration of SetRawDataInTensorProto, ConvertRawDataInTensorProto
13. onnxruntime/core/graph/graph.cc
[Big endian issue]
o Call ConvertRawDataInTensorProto for SPARSE_TENSOR type
o Call ConvertRawDataInTensorProto for SaveToOrtFormat
14. onnxruntime/core/mlas/lib/platform.cpp
[BUILDING on AIX issue] POWER10 released enablement for AIX
15. onnxruntime/core/mlas/lib/power/qgemm_kernel_power10.cpp
[BUILDING on AIX issue]Handling of __vector under AIX+clang
16. onnxruntime/core/mlas/lib/qgemm.h
[BUILDING on AIX issue] Adding _AIX flag
17. onnxruntime/core/mlas/lib/qlmul.cpp
[BUILDING on AIX issue] Handling of __vector under AIX+clang
18. onnxruntime/core/optimizer/attention_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
19. onnxruntime/core/optimizer/compute_optimizer/shared_utils.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
20. onnxruntime/core/optimizer/constant_folding.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
21. onnxruntime/core/optimizer/embed_layer_norm_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
22. onnxruntime/core/optimizer/nchwc_transformer.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
23. onnxruntime/core/optimizer/qdq_transformer/avx2_weight_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
24. onnxruntime/core/optimizer/qdq_transformer/qdq_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
25. onnxruntime/core/optimizer/qdq_transformer/s8_to_u8.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
26.
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
27. onnxruntime/core/optimizer/reshape_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
28. onnxruntime/core/optimizer/stft_decomposition.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
29.
onnxruntime/core/optimizer/transpose_optimization/ort_optimizer_api_impl.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
30. onnxruntime/core/platform/path_lib.h
[BUILDING on AIX issue] Moving to normal function call, instead of
template
31. onnxruntime/core/platform/posix/env.cc
[BUILDING on AIX issue]Blocking syscall.h in AIX
32. onnxruntime/core/session/inference_session.cc
[Big endian issue] Removing ORT_RETURN_IF_NOT, FLATBUFFERS_LITTLEENDIAN
33. onnxruntime/test/flatbuffers/flatbuffer_utils_test.cc
[Big endian issue] Call ConvertRawDataInTensorProto in CreateInitializer
and ExternalWriteReadWithLoadInitializers
34. onnxruntime/test/framework/sparse_kernels_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
35. onnxruntime/test/framework/tensorutils_test.cc
[Big endian issue] Helper method ConvertEndianessForVector and call this
from required place.
36. onnxruntime/test/framework/test_tensor_loader.cc
o. [BUILDING on AIX issue] Handling of getcwd for AIX
o. [Big endian issue] Bytes Swapping in run_external_data_test
37. onnxruntime/test/onnx/main.cc
[Big endian issue] including <thread> for AIX
38. onnxruntime/test/onnx/tensorprotoutils.cc
[Big endian issue] Bytes swapping in UnpackTensorWithRawData
39. onnxruntime/test/optimizer/graph_transform_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
40. onnxruntime/test/optimizer/graph_transform_test_builder.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
41. onnxruntime/test/optimizer/graph_transform_test_builder.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
42. onnxruntime/test/optimizer/initializer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
43. onnxruntime/test/optimizer/nchwc_optimizer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
44. onnxruntime/test/providers/base_tester.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
45. onnxruntime/test/providers/cpu/generator/random_test.cc
[BUILDING on AIX issue] Adding AIX check in MultinomialGoodCase
---------
Co-authored-by: Vamshikrishna Thatikonda <vamshikrishna@in.ibm.com>
2024-07-17 19:37:06 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
|
|
|
|
add_dependencies(onnxruntime ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
|
|
|
|
else()
|
|
|
|
|
add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
|
|
|
|
endif()
|
2023-06-20 05:20:31 +00:00
|
|
|
target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime>")
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2024-07-15 21:21:34 +00:00
|
|
|
|
2022-06-17 21:49:04 +00:00
|
|
|
target_compile_definitions(onnxruntime PRIVATE FILE_NAME=\"onnxruntime.dll\")
|
2020-02-07 19:00:28 +00:00
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
if(UNIX)
|
2019-02-06 23:27:37 +00:00
|
|
|
if (APPLE)
|
2024-11-05 00:30:50 +00:00
|
|
|
target_link_options(onnxruntime PRIVATE "LINKER:-dead_strip")
|
Enablement of onnxruntime for AIX and fixing issues related to big-endian platform. (#21133)
### Description
Enablement of onnxruntime for AIX and fixing issues related to
big-endian platform.
### Motivation and Context
changes in this PR contains:
1. Enablement code for building onnxruntime on AIX operating system.
2. while testing the build on AIX, we found issues related to big endian
platform . More details about few of those issues can be found in [Big
endian issue: Graph Transformation Attention Fusion tests are failing
#12921](https://github.com/microsoft/onnxruntime/issues/12921)
Below are list of files and the description about the change.
1. cmake/CMakeLists.txt
[BUILDING on AIX issue] check for "IBMClang" is added for handling
-Wno-unused-parameter
2. cmake/external/onnxruntime_external_deps.cmake
[BUILDING on AIX issue]Enabling gtest_disable_pthreads for AIX
3. cmake/onnxruntime.cmake
[BUILDING on AIX issue]
o Blocking codes for AIX which generates generated_source.c and further
requires some symbol files.
o Putting NO AIX check for non-supported linker flags like --Xlinker
o iconv linking
4. cmake/onnxruntime_framework.cmake
[BUILDING on AIX issue]Putting NO AIX check for -Wl,-rpath='$ORIGIN'
5. cmake/onnxruntime_mlas.cmake
[BUILDING on AIX issue]POWER10 releated macro/function definition .
6. cmake/onnxruntime_providers_cpu.cmake
[BUILDING on AIX issue]Putting NO AIX check for non-supported linker
flags like --Xlinker
7. cmake/onnxruntime_unittests.cmake
[BUILDING on AIX issue]
o Putting NO AIX check for non-supported linker flags like --Xlinker
o Adding required libraries for AIX linker under applicatiion like
onnxruntime_shared_lib_test ,onnxruntime_logging_apis etc
8. cmake/patches/flatbuffers/flatbuffers.patch
[BUILDING on AIX issue] Handling of TypeCode in
include/flatbuffers/flatbuffers.h under AIX + clang
9. onnxruntime/contrib_ops/cpu/murmur_hash3.cc
[Big endian issue] Byte-Conversion handlling in compute() and getblock()
routines
10. onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc
[Big endian issue] Handling of test failures . Byte swapping for
quant_value.
11. onnxruntime/core/framework/tensorprotoutils.cc
[Big endian issue]
Implementation of SetRawDataInTensorProto , ConvertRawDataInTensorProto
.
o SetRawDataInTensorProto : Wrapper for set_raw_data(). Calling
ConvertRawDataInTensorProto() in big-endian system
o ConvertRawDataInTensorProto : function used mainly on big-endian
system for byte-swapping of tensor raw_data
12. onnxruntime/core/framework/tensorprotoutils.h
[Big endian issue]
Declaration of SetRawDataInTensorProto, ConvertRawDataInTensorProto
13. onnxruntime/core/graph/graph.cc
[Big endian issue]
o Call ConvertRawDataInTensorProto for SPARSE_TENSOR type
o Call ConvertRawDataInTensorProto for SaveToOrtFormat
14. onnxruntime/core/mlas/lib/platform.cpp
[BUILDING on AIX issue] POWER10 released enablement for AIX
15. onnxruntime/core/mlas/lib/power/qgemm_kernel_power10.cpp
[BUILDING on AIX issue]Handling of __vector under AIX+clang
16. onnxruntime/core/mlas/lib/qgemm.h
[BUILDING on AIX issue] Adding _AIX flag
17. onnxruntime/core/mlas/lib/qlmul.cpp
[BUILDING on AIX issue] Handling of __vector under AIX+clang
18. onnxruntime/core/optimizer/attention_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
19. onnxruntime/core/optimizer/compute_optimizer/shared_utils.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
20. onnxruntime/core/optimizer/constant_folding.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
21. onnxruntime/core/optimizer/embed_layer_norm_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
22. onnxruntime/core/optimizer/nchwc_transformer.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
23. onnxruntime/core/optimizer/qdq_transformer/avx2_weight_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
24. onnxruntime/core/optimizer/qdq_transformer/qdq_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
25. onnxruntime/core/optimizer/qdq_transformer/s8_to_u8.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
26.
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
27. onnxruntime/core/optimizer/reshape_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
28. onnxruntime/core/optimizer/stft_decomposition.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
29.
onnxruntime/core/optimizer/transpose_optimization/ort_optimizer_api_impl.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
30. onnxruntime/core/platform/path_lib.h
[BUILDING on AIX issue] Moving to normal function call, instead of
template
31. onnxruntime/core/platform/posix/env.cc
[BUILDING on AIX issue]Blocking syscall.h in AIX
32. onnxruntime/core/session/inference_session.cc
[Big endian issue] Removing ORT_RETURN_IF_NOT, FLATBUFFERS_LITTLEENDIAN
33. onnxruntime/test/flatbuffers/flatbuffer_utils_test.cc
[Big endian issue] Call ConvertRawDataInTensorProto in CreateInitializer
and ExternalWriteReadWithLoadInitializers
34. onnxruntime/test/framework/sparse_kernels_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
35. onnxruntime/test/framework/tensorutils_test.cc
[Big endian issue] Helper method ConvertEndianessForVector and call this
from required place.
36. onnxruntime/test/framework/test_tensor_loader.cc
o. [BUILDING on AIX issue] Handling of getcwd for AIX
o. [Big endian issue] Bytes Swapping in run_external_data_test
37. onnxruntime/test/onnx/main.cc
[Big endian issue] including <thread> for AIX
38. onnxruntime/test/onnx/tensorprotoutils.cc
[Big endian issue] Bytes swapping in UnpackTensorWithRawData
39. onnxruntime/test/optimizer/graph_transform_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
40. onnxruntime/test/optimizer/graph_transform_test_builder.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
41. onnxruntime/test/optimizer/graph_transform_test_builder.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
42. onnxruntime/test/optimizer/initializer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
43. onnxruntime/test/optimizer/nchwc_optimizer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
44. onnxruntime/test/providers/base_tester.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
45. onnxruntime/test/providers/cpu/generator/random_test.cc
[BUILDING on AIX issue] Adding AIX check in MultinomialGoodCase
---------
Co-authored-by: Vamshikrishna Thatikonda <vamshikrishna@in.ibm.com>
2024-07-17 19:37:06 +00:00
|
|
|
elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
2024-11-05 00:30:50 +00:00
|
|
|
target_link_options(onnxruntime PRIVATE "LINKER:--version-script=${SYMBOL_FILE}" "LINKER:--no-undefined" "LINKER:--gc-sections")
|
2019-02-06 23:27:37 +00:00
|
|
|
endif()
|
2018-11-20 00:48:22 +00:00
|
|
|
else()
|
2024-11-05 00:30:50 +00:00
|
|
|
target_link_options(onnxruntime PRIVATE "-DEF:${SYMBOL_FILE}")
|
2018-11-20 00:48:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
2024-11-05 00:30:50 +00:00
|
|
|
|
|
|
|
|
if (APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "^iOS")
|
|
|
|
|
target_link_options(onnxruntime PRIVATE "LINKER:-exported_symbols_list,${SYMBOL_FILE}")
|
2020-09-14 17:32:39 +00:00
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
|
|
|
|
set_target_properties(onnxruntime PROPERTIES
|
|
|
|
|
MACOSX_RPATH TRUE
|
|
|
|
|
INSTALL_RPATH_USE_LINK_PATH FALSE
|
|
|
|
|
BUILD_WITH_INSTALL_NAME_DIR TRUE
|
|
|
|
|
INSTALL_NAME_DIR @rpath)
|
|
|
|
|
else()
|
|
|
|
|
set_target_properties(onnxruntime PROPERTIES INSTALL_RPATH "@loader_path")
|
|
|
|
|
endif()
|
2019-01-25 18:45:39 +00:00
|
|
|
endif()
|
|
|
|
|
|
2020-09-09 11:38:34 +00:00
|
|
|
|
2024-11-05 00:30:50 +00:00
|
|
|
|
2022-04-20 16:11:10 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_MINIMAL_BUILD)
|
|
|
|
|
# target onnxruntime is a shared library, the dummy __cxa_demangle is only attach to it to avoid
|
2024-07-22 20:37:32 +00:00
|
|
|
# affecting downstream ort library users with the behavior of dummy __cxa_demangle. So the dummy
|
2022-04-20 16:11:10 +00:00
|
|
|
# __cxa_demangle must not expose to libonnxruntime_common.a. It works as when the linker is
|
|
|
|
|
# creating the DSO, our dummy __cxa_demangle always comes before libc++abi.a so the
|
|
|
|
|
# __cxa_demangle in libc++abi.a is discarded, thus, huge binary size reduction.
|
|
|
|
|
target_sources(onnxruntime PRIVATE "${ONNXRUNTIME_ROOT}/core/platform/android/cxa_demangle.cc")
|
|
|
|
|
target_compile_definitions(onnxruntime PRIVATE USE_DUMMY_EXA_DEMANGLE=1)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-09-09 11:38:34 +00:00
|
|
|
# strip binary on Android, or for a minimal build on Unix
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android" OR (onnxruntime_MINIMAL_BUILD AND UNIX))
|
2020-09-10 20:50:28 +00:00
|
|
|
if (onnxruntime_MINIMAL_BUILD AND ADD_DEBUG_INFO_TO_MINIMAL_BUILD)
|
|
|
|
|
# don't strip
|
|
|
|
|
else()
|
|
|
|
|
set_target_properties(onnxruntime PROPERTIES LINK_FLAGS_RELEASE -s)
|
|
|
|
|
set_target_properties(onnxruntime PROPERTIES LINK_FLAGS_MINSIZEREL -s)
|
|
|
|
|
endif()
|
2020-05-19 02:20:23 +00:00
|
|
|
endif()
|
|
|
|
|
|
2021-05-28 00:07:48 +00:00
|
|
|
# we need to copy C/C++ API headers to be packed into Android AAR package
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_BUILD_JAVA)
|
|
|
|
|
set(ANDROID_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/android/headers)
|
|
|
|
|
file(MAKE_DIRECTORY ${ANDROID_HEADERS_DIR})
|
|
|
|
|
# copy the header files one by one
|
2023-10-04 15:55:08 +00:00
|
|
|
foreach(h_ ${ONNXRUNTIME_PUBLIC_HEADERS})
|
2021-05-28 00:07:48 +00:00
|
|
|
get_filename_component(HEADER_NAME_ ${h_} NAME)
|
2021-07-14 23:39:17 +00:00
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${h_} ${ANDROID_HEADERS_DIR}/${HEADER_NAME_})
|
2021-05-28 00:07:48 +00:00
|
|
|
endforeach()
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-01-22 20:11:00 +00:00
|
|
|
set(onnxruntime_INTERNAL_PROVIDER_LIBRARIES
|
2021-07-14 23:39:17 +00:00
|
|
|
${PROVIDERS_ACL}
|
|
|
|
|
${PROVIDERS_ARMNN}
|
|
|
|
|
${PROVIDERS_COREML}
|
|
|
|
|
${PROVIDERS_DML}
|
|
|
|
|
${PROVIDERS_NNAPI}
|
2022-06-03 21:10:02 +00:00
|
|
|
${PROVIDERS_SNPE}
|
2021-07-14 23:39:17 +00:00
|
|
|
${PROVIDERS_RKNPU}
|
2024-06-29 04:48:34 +00:00
|
|
|
${PROVIDERS_VSINPU}
|
2022-06-03 10:22:34 +00:00
|
|
|
${PROVIDERS_XNNPACK}
|
2024-10-08 23:10:46 +00:00
|
|
|
${PROVIDERS_WEBGPU}
|
2023-05-09 04:25:10 +00:00
|
|
|
${PROVIDERS_WEBNN}
|
2023-01-11 20:25:04 +00:00
|
|
|
${PROVIDERS_AZURE}
|
2021-07-14 23:39:17 +00:00
|
|
|
${PROVIDERS_INTERNAL_TESTING}
|
2025-01-22 20:11:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (onnxruntime_BUILD_QNN_EP_STATIC_LIB)
|
|
|
|
|
list(APPEND onnxruntime_INTERNAL_PROVIDER_LIBRARIES onnxruntime_providers_qnn)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# This list is a reversed topological ordering of library dependencies.
|
|
|
|
|
# Earlier entries may depend on later ones. Later ones should not depend on earlier ones.
|
|
|
|
|
set(onnxruntime_INTERNAL_LIBRARIES
|
|
|
|
|
onnxruntime_session
|
|
|
|
|
${onnxruntime_libs}
|
|
|
|
|
${onnxruntime_INTERNAL_PROVIDER_LIBRARIES}
|
2021-07-14 23:39:17 +00:00
|
|
|
${onnxruntime_winml}
|
|
|
|
|
onnxruntime_optimizer
|
|
|
|
|
onnxruntime_providers
|
2024-09-30 22:59:07 +00:00
|
|
|
onnxruntime_lora
|
2021-07-14 23:39:17 +00:00
|
|
|
onnxruntime_framework
|
|
|
|
|
onnxruntime_graph
|
2022-02-11 03:17:08 +00:00
|
|
|
onnxruntime_util
|
2021-09-04 20:30:33 +00:00
|
|
|
${ONNXRUNTIME_MLAS_LIBS}
|
2021-07-14 23:39:17 +00:00
|
|
|
onnxruntime_common
|
|
|
|
|
onnxruntime_flatbuffers
|
|
|
|
|
)
|
2018-11-20 00:48:22 +00:00
|
|
|
|
Enablement of onnxruntime for AIX and fixing issues related to big-endian platform. (#21133)
### Description
Enablement of onnxruntime for AIX and fixing issues related to
big-endian platform.
### Motivation and Context
changes in this PR contains:
1. Enablement code for building onnxruntime on AIX operating system.
2. while testing the build on AIX, we found issues related to big endian
platform . More details about few of those issues can be found in [Big
endian issue: Graph Transformation Attention Fusion tests are failing
#12921](https://github.com/microsoft/onnxruntime/issues/12921)
Below are list of files and the description about the change.
1. cmake/CMakeLists.txt
[BUILDING on AIX issue] check for "IBMClang" is added for handling
-Wno-unused-parameter
2. cmake/external/onnxruntime_external_deps.cmake
[BUILDING on AIX issue]Enabling gtest_disable_pthreads for AIX
3. cmake/onnxruntime.cmake
[BUILDING on AIX issue]
o Blocking codes for AIX which generates generated_source.c and further
requires some symbol files.
o Putting NO AIX check for non-supported linker flags like --Xlinker
o iconv linking
4. cmake/onnxruntime_framework.cmake
[BUILDING on AIX issue]Putting NO AIX check for -Wl,-rpath='$ORIGIN'
5. cmake/onnxruntime_mlas.cmake
[BUILDING on AIX issue]POWER10 releated macro/function definition .
6. cmake/onnxruntime_providers_cpu.cmake
[BUILDING on AIX issue]Putting NO AIX check for non-supported linker
flags like --Xlinker
7. cmake/onnxruntime_unittests.cmake
[BUILDING on AIX issue]
o Putting NO AIX check for non-supported linker flags like --Xlinker
o Adding required libraries for AIX linker under applicatiion like
onnxruntime_shared_lib_test ,onnxruntime_logging_apis etc
8. cmake/patches/flatbuffers/flatbuffers.patch
[BUILDING on AIX issue] Handling of TypeCode in
include/flatbuffers/flatbuffers.h under AIX + clang
9. onnxruntime/contrib_ops/cpu/murmur_hash3.cc
[Big endian issue] Byte-Conversion handlling in compute() and getblock()
routines
10. onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc
[Big endian issue] Handling of test failures . Byte swapping for
quant_value.
11. onnxruntime/core/framework/tensorprotoutils.cc
[Big endian issue]
Implementation of SetRawDataInTensorProto , ConvertRawDataInTensorProto
.
o SetRawDataInTensorProto : Wrapper for set_raw_data(). Calling
ConvertRawDataInTensorProto() in big-endian system
o ConvertRawDataInTensorProto : function used mainly on big-endian
system for byte-swapping of tensor raw_data
12. onnxruntime/core/framework/tensorprotoutils.h
[Big endian issue]
Declaration of SetRawDataInTensorProto, ConvertRawDataInTensorProto
13. onnxruntime/core/graph/graph.cc
[Big endian issue]
o Call ConvertRawDataInTensorProto for SPARSE_TENSOR type
o Call ConvertRawDataInTensorProto for SaveToOrtFormat
14. onnxruntime/core/mlas/lib/platform.cpp
[BUILDING on AIX issue] POWER10 released enablement for AIX
15. onnxruntime/core/mlas/lib/power/qgemm_kernel_power10.cpp
[BUILDING on AIX issue]Handling of __vector under AIX+clang
16. onnxruntime/core/mlas/lib/qgemm.h
[BUILDING on AIX issue] Adding _AIX flag
17. onnxruntime/core/mlas/lib/qlmul.cpp
[BUILDING on AIX issue] Handling of __vector under AIX+clang
18. onnxruntime/core/optimizer/attention_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
19. onnxruntime/core/optimizer/compute_optimizer/shared_utils.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
20. onnxruntime/core/optimizer/constant_folding.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
21. onnxruntime/core/optimizer/embed_layer_norm_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
22. onnxruntime/core/optimizer/nchwc_transformer.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
23. onnxruntime/core/optimizer/qdq_transformer/avx2_weight_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
24. onnxruntime/core/optimizer/qdq_transformer/qdq_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
25. onnxruntime/core/optimizer/qdq_transformer/s8_to_u8.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
26.
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
27. onnxruntime/core/optimizer/reshape_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
28. onnxruntime/core/optimizer/stft_decomposition.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
29.
onnxruntime/core/optimizer/transpose_optimization/ort_optimizer_api_impl.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
30. onnxruntime/core/platform/path_lib.h
[BUILDING on AIX issue] Moving to normal function call, instead of
template
31. onnxruntime/core/platform/posix/env.cc
[BUILDING on AIX issue]Blocking syscall.h in AIX
32. onnxruntime/core/session/inference_session.cc
[Big endian issue] Removing ORT_RETURN_IF_NOT, FLATBUFFERS_LITTLEENDIAN
33. onnxruntime/test/flatbuffers/flatbuffer_utils_test.cc
[Big endian issue] Call ConvertRawDataInTensorProto in CreateInitializer
and ExternalWriteReadWithLoadInitializers
34. onnxruntime/test/framework/sparse_kernels_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
35. onnxruntime/test/framework/tensorutils_test.cc
[Big endian issue] Helper method ConvertEndianessForVector and call this
from required place.
36. onnxruntime/test/framework/test_tensor_loader.cc
o. [BUILDING on AIX issue] Handling of getcwd for AIX
o. [Big endian issue] Bytes Swapping in run_external_data_test
37. onnxruntime/test/onnx/main.cc
[Big endian issue] including <thread> for AIX
38. onnxruntime/test/onnx/tensorprotoutils.cc
[Big endian issue] Bytes swapping in UnpackTensorWithRawData
39. onnxruntime/test/optimizer/graph_transform_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
40. onnxruntime/test/optimizer/graph_transform_test_builder.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
41. onnxruntime/test/optimizer/graph_transform_test_builder.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
42. onnxruntime/test/optimizer/initializer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
43. onnxruntime/test/optimizer/nchwc_optimizer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
44. onnxruntime/test/providers/base_tester.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
45. onnxruntime/test/providers/cpu/generator/random_test.cc
[BUILDING on AIX issue] Adding AIX check in MultinomialGoodCase
---------
Co-authored-by: Vamshikrishna Thatikonda <vamshikrishna@in.ibm.com>
2024-07-17 19:37:06 +00:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
|
|
|
|
list(APPEND onnxruntime_INTERNAL_LIBRARIES iconv)
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-07-14 22:37:16 +00:00
|
|
|
if (onnxruntime_USE_EXTENSIONS)
|
|
|
|
|
list(APPEND onnxruntime_INTERNAL_LIBRARIES
|
|
|
|
|
onnxruntime_extensions
|
|
|
|
|
ocos_operators
|
2023-10-09 23:29:41 +00:00
|
|
|
noexcep_operators
|
2023-07-14 22:37:16 +00:00
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-07-14 23:39:17 +00:00
|
|
|
# If you are linking a new library, please add it to the list onnxruntime_INTERNAL_LIBRARIES or onnxruntime_EXTERNAL_LIBRARIES,
|
|
|
|
|
# Please do not add a library directly to the target_link_libraries command
|
|
|
|
|
target_link_libraries(onnxruntime PRIVATE
|
|
|
|
|
${onnxruntime_INTERNAL_LIBRARIES}
|
|
|
|
|
${onnxruntime_EXTERNAL_LIBRARIES}
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-05 00:30:50 +00:00
|
|
|
if(WIN32)
|
|
|
|
|
target_link_options(onnxruntime PRIVATE ${onnxruntime_DELAYLOAD_FLAGS})
|
|
|
|
|
endif()
|
2024-07-15 21:21:34 +00:00
|
|
|
#See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html
|
|
|
|
|
if(NOT APPLE AND NOT WIN32)
|
Enablement of onnxruntime for AIX and fixing issues related to big-endian platform. (#21133)
### Description
Enablement of onnxruntime for AIX and fixing issues related to
big-endian platform.
### Motivation and Context
changes in this PR contains:
1. Enablement code for building onnxruntime on AIX operating system.
2. while testing the build on AIX, we found issues related to big endian
platform . More details about few of those issues can be found in [Big
endian issue: Graph Transformation Attention Fusion tests are failing
#12921](https://github.com/microsoft/onnxruntime/issues/12921)
Below are list of files and the description about the change.
1. cmake/CMakeLists.txt
[BUILDING on AIX issue] check for "IBMClang" is added for handling
-Wno-unused-parameter
2. cmake/external/onnxruntime_external_deps.cmake
[BUILDING on AIX issue]Enabling gtest_disable_pthreads for AIX
3. cmake/onnxruntime.cmake
[BUILDING on AIX issue]
o Blocking codes for AIX which generates generated_source.c and further
requires some symbol files.
o Putting NO AIX check for non-supported linker flags like --Xlinker
o iconv linking
4. cmake/onnxruntime_framework.cmake
[BUILDING on AIX issue]Putting NO AIX check for -Wl,-rpath='$ORIGIN'
5. cmake/onnxruntime_mlas.cmake
[BUILDING on AIX issue]POWER10 releated macro/function definition .
6. cmake/onnxruntime_providers_cpu.cmake
[BUILDING on AIX issue]Putting NO AIX check for non-supported linker
flags like --Xlinker
7. cmake/onnxruntime_unittests.cmake
[BUILDING on AIX issue]
o Putting NO AIX check for non-supported linker flags like --Xlinker
o Adding required libraries for AIX linker under applicatiion like
onnxruntime_shared_lib_test ,onnxruntime_logging_apis etc
8. cmake/patches/flatbuffers/flatbuffers.patch
[BUILDING on AIX issue] Handling of TypeCode in
include/flatbuffers/flatbuffers.h under AIX + clang
9. onnxruntime/contrib_ops/cpu/murmur_hash3.cc
[Big endian issue] Byte-Conversion handlling in compute() and getblock()
routines
10. onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc
[Big endian issue] Handling of test failures . Byte swapping for
quant_value.
11. onnxruntime/core/framework/tensorprotoutils.cc
[Big endian issue]
Implementation of SetRawDataInTensorProto , ConvertRawDataInTensorProto
.
o SetRawDataInTensorProto : Wrapper for set_raw_data(). Calling
ConvertRawDataInTensorProto() in big-endian system
o ConvertRawDataInTensorProto : function used mainly on big-endian
system for byte-swapping of tensor raw_data
12. onnxruntime/core/framework/tensorprotoutils.h
[Big endian issue]
Declaration of SetRawDataInTensorProto, ConvertRawDataInTensorProto
13. onnxruntime/core/graph/graph.cc
[Big endian issue]
o Call ConvertRawDataInTensorProto for SPARSE_TENSOR type
o Call ConvertRawDataInTensorProto for SaveToOrtFormat
14. onnxruntime/core/mlas/lib/platform.cpp
[BUILDING on AIX issue] POWER10 released enablement for AIX
15. onnxruntime/core/mlas/lib/power/qgemm_kernel_power10.cpp
[BUILDING on AIX issue]Handling of __vector under AIX+clang
16. onnxruntime/core/mlas/lib/qgemm.h
[BUILDING on AIX issue] Adding _AIX flag
17. onnxruntime/core/mlas/lib/qlmul.cpp
[BUILDING on AIX issue] Handling of __vector under AIX+clang
18. onnxruntime/core/optimizer/attention_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
19. onnxruntime/core/optimizer/compute_optimizer/shared_utils.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
20. onnxruntime/core/optimizer/constant_folding.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
21. onnxruntime/core/optimizer/embed_layer_norm_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
22. onnxruntime/core/optimizer/nchwc_transformer.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
23. onnxruntime/core/optimizer/qdq_transformer/avx2_weight_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
24. onnxruntime/core/optimizer/qdq_transformer/qdq_s8_to_u8.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
25. onnxruntime/core/optimizer/qdq_transformer/s8_to_u8.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
26.
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
27. onnxruntime/core/optimizer/reshape_fusion.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
28. onnxruntime/core/optimizer/stft_decomposition.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
29.
onnxruntime/core/optimizer/transpose_optimization/ort_optimizer_api_impl.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
30. onnxruntime/core/platform/path_lib.h
[BUILDING on AIX issue] Moving to normal function call, instead of
template
31. onnxruntime/core/platform/posix/env.cc
[BUILDING on AIX issue]Blocking syscall.h in AIX
32. onnxruntime/core/session/inference_session.cc
[Big endian issue] Removing ORT_RETURN_IF_NOT, FLATBUFFERS_LITTLEENDIAN
33. onnxruntime/test/flatbuffers/flatbuffer_utils_test.cc
[Big endian issue] Call ConvertRawDataInTensorProto in CreateInitializer
and ExternalWriteReadWithLoadInitializers
34. onnxruntime/test/framework/sparse_kernels_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
35. onnxruntime/test/framework/tensorutils_test.cc
[Big endian issue] Helper method ConvertEndianessForVector and call this
from required place.
36. onnxruntime/test/framework/test_tensor_loader.cc
o. [BUILDING on AIX issue] Handling of getcwd for AIX
o. [Big endian issue] Bytes Swapping in run_external_data_test
37. onnxruntime/test/onnx/main.cc
[Big endian issue] including <thread> for AIX
38. onnxruntime/test/onnx/tensorprotoutils.cc
[Big endian issue] Bytes swapping in UnpackTensorWithRawData
39. onnxruntime/test/optimizer/graph_transform_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
40. onnxruntime/test/optimizer/graph_transform_test_builder.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
41. onnxruntime/test/optimizer/graph_transform_test_builder.h
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
42. onnxruntime/test/optimizer/initializer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
43. onnxruntime/test/optimizer/nchwc_optimizer_test.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
44. onnxruntime/test/providers/base_tester.cc
[Big endian issue] Use util function SetRawDataInTensorProto, instead of
set_raw_data
45. onnxruntime/test/providers/cpu/generator/random_test.cc
[BUILDING on AIX issue] Adding AIX check in MultinomialGoodCase
---------
Co-authored-by: Vamshikrishna Thatikonda <vamshikrishna@in.ibm.com>
2024-07-17 19:37:06 +00:00
|
|
|
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()
|
2024-07-15 21:21:34 +00:00
|
|
|
else()
|
|
|
|
|
# Omit the SOVERSION setting in Windows/macOS/iOS/.. build
|
|
|
|
|
set_target_properties(onnxruntime PROPERTIES
|
|
|
|
|
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
|
|
|
|
|
LINK_DEPENDS ${SYMBOL_FILE}
|
|
|
|
|
VERSION ${ORT_VERSION}
|
|
|
|
|
FOLDER "ONNXRuntime")
|
|
|
|
|
endif()
|
2018-11-20 00:48:22 +00:00
|
|
|
install(TARGETS onnxruntime
|
2023-06-20 05:20:31 +00:00
|
|
|
EXPORT ${PROJECT_NAME}Targets
|
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime
|
2021-04-15 23:47:53 +00:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2023-10-07 18:50:02 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2021-04-15 23:47:53 +00:00
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2020-02-26 01:47:02 +00:00
|
|
|
|
2021-09-17 00:45:29 +00:00
|
|
|
if (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
|
|
|
|
|
# Workaround STL bug https://github.com/microsoft/STL/issues/434#issuecomment-921321254
|
|
|
|
|
# Note that the workaround makes std::system_error crash before Windows 10
|
|
|
|
|
|
|
|
|
|
# The linker warns "LNK4199: /DELAYLOAD:api-ms-win-core-heapl2-1-0.dll ignored; no imports found from api-ms-win-core-heapl2-1-0.dll"
|
|
|
|
|
# when you're not using imports directly, even though the import exists in the STL and the DLL would have been linked without DELAYLOAD
|
|
|
|
|
target_link_options(onnxruntime PRIVATE /DELAYLOAD:api-ms-win-core-heapl2-1-0.dll /ignore:4199)
|
|
|
|
|
endif()
|
2021-07-14 23:39:17 +00:00
|
|
|
|
2021-12-07 20:39:46 +00:00
|
|
|
if (winml_is_inbox)
|
|
|
|
|
# Apply linking flags required by inbox static analysis tools
|
|
|
|
|
target_link_options(onnxruntime PRIVATE ${os_component_link_flags_list})
|
|
|
|
|
# Link *_x64/*_arm64 DLLs for the ARM64X forwarder
|
|
|
|
|
function(duplicate_shared_library target new_target)
|
|
|
|
|
get_target_property(sources ${target} SOURCES)
|
|
|
|
|
get_target_property(compile_definitions ${target} COMPILE_DEFINITIONS)
|
|
|
|
|
get_target_property(compile_options ${target} COMPILE_OPTIONS)
|
|
|
|
|
get_target_property(include_directories ${target} INCLUDE_DIRECTORIES)
|
|
|
|
|
get_target_property(link_libraries ${target} LINK_LIBRARIES)
|
|
|
|
|
get_target_property(link_flags ${target} LINK_FLAGS)
|
|
|
|
|
get_target_property(link_options ${target} LINK_OPTIONS)
|
|
|
|
|
add_library(${new_target} SHARED ${sources})
|
|
|
|
|
add_dependencies(${target} ${new_target})
|
|
|
|
|
target_compile_definitions(${new_target} PRIVATE ${compile_definitions})
|
|
|
|
|
target_compile_options(${new_target} PRIVATE ${compile_options})
|
|
|
|
|
target_include_directories(${new_target} PRIVATE ${include_directories})
|
|
|
|
|
target_link_libraries(${new_target} PRIVATE ${link_libraries})
|
|
|
|
|
set_property(TARGET ${new_target} PROPERTY LINK_FLAGS "${link_flags}")
|
|
|
|
|
target_link_options(${new_target} PRIVATE ${link_options})
|
|
|
|
|
endfunction()
|
|
|
|
|
if (WAI_ARCH STREQUAL x64 OR WAI_ARCH STREQUAL arm64)
|
|
|
|
|
duplicate_shared_library(onnxruntime onnxruntime_${WAI_ARCH})
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-07-14 23:39:17 +00:00
|
|
|
# Assemble the Apple static framework (iOS and macOS)
|
|
|
|
|
if(onnxruntime_BUILD_APPLE_FRAMEWORK)
|
2024-03-20 17:55:19 +00:00
|
|
|
# when building for mac catalyst, the CMAKE_OSX_SYSROOT is set to MacOSX as well, to avoid duplication,
|
|
|
|
|
# we specify as `-macabi` in the name of the output static apple framework directory.
|
|
|
|
|
if (PLATFORM_NAME STREQUAL "macabi")
|
|
|
|
|
set(STATIC_FRAMEWORK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}-macabi)
|
|
|
|
|
else()
|
|
|
|
|
set(STATIC_FRAMEWORK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}-${CMAKE_OSX_SYSROOT})
|
|
|
|
|
endif()
|
2023-11-03 13:38:29 +00:00
|
|
|
|
|
|
|
|
# Setup the various directories required. Remove any existing ones so we start with a clean directory.
|
2021-07-14 23:39:17 +00:00
|
|
|
set(STATIC_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/static_libraries)
|
2023-11-03 13:38:29 +00:00
|
|
|
set(STATIC_LIB_TEMP_DIR ${STATIC_LIB_DIR}/temp)
|
|
|
|
|
add_custom_command(TARGET onnxruntime PRE_BUILD COMMAND ${CMAKE_COMMAND} -E rm -rf ${STATIC_LIB_DIR})
|
|
|
|
|
add_custom_command(TARGET onnxruntime PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${STATIC_LIB_DIR})
|
|
|
|
|
add_custom_command(TARGET onnxruntime PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${STATIC_LIB_TEMP_DIR})
|
2021-07-14 23:39:17 +00:00
|
|
|
|
2023-11-03 13:38:29 +00:00
|
|
|
set(STATIC_FRAMEWORK_DIR ${STATIC_FRAMEWORK_OUTPUT_DIR}/static_framework/onnxruntime.framework)
|
|
|
|
|
add_custom_command(TARGET onnxruntime PRE_BUILD COMMAND ${CMAKE_COMMAND} -E rm -rf ${STATIC_FRAMEWORK_DIR})
|
|
|
|
|
add_custom_command(TARGET onnxruntime PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${STATIC_FRAMEWORK_DIR})
|
|
|
|
|
|
|
|
|
|
# replicate XCode's Single Object Pre-Link
|
|
|
|
|
# link the internal onnxruntime .o files with the external .a files into a single relocatable object
|
|
|
|
|
# to enforce symbol visibility. doing it this way limits the symbols included from the .a files to symbols used
|
|
|
|
|
# by the ORT .o files.
|
2021-07-14 23:39:17 +00:00
|
|
|
|
2024-03-20 17:55:19 +00:00
|
|
|
# If it's an onnxruntime library, extract .o files from the original cmake build path to a separate directory for
|
|
|
|
|
# each library to avoid any clashes with filenames (e.g. utils.o)
|
2023-11-03 13:38:29 +00:00
|
|
|
foreach(_LIB ${onnxruntime_INTERNAL_LIBRARIES} )
|
2024-09-10 23:39:27 +00:00
|
|
|
if(NOT TARGET ${_LIB}) # if we didn't build from source. it may not a target
|
|
|
|
|
continue()
|
|
|
|
|
endif()
|
2021-07-14 23:39:17 +00:00
|
|
|
GET_TARGET_PROPERTY(_LIB_TYPE ${_LIB} TYPE)
|
|
|
|
|
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
|
2023-11-03 13:38:29 +00:00
|
|
|
set(CUR_STATIC_LIB_OBJ_DIR ${STATIC_LIB_TEMP_DIR}/$<TARGET_LINKER_FILE_BASE_NAME:${_LIB}>)
|
|
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CUR_STATIC_LIB_OBJ_DIR})
|
2024-03-20 17:55:19 +00:00
|
|
|
if (PLATFORM_NAME STREQUAL "macabi")
|
|
|
|
|
# There exists several duplicate names for source files under different subdirectories within
|
|
|
|
|
# each onnxruntime library. (e.g. onnxruntime/contrib_ops/cpu/element_wise_ops.o
|
|
|
|
|
# vs. onnxruntime/providers/core/cpu/math/element_wise_ops.o)
|
|
|
|
|
# In that case, using 'ar ARGS -x' to extract the .o files from .a lib would possibly cause duplicate naming files being overwritten
|
|
|
|
|
# and lead to missing undefined symbol error in the generated binary.
|
|
|
|
|
# So we use the below python script as a sanity check to do a recursive find of all .o files in ${CUR_TARGET_CMAKE_SOURCE_LIB_DIR}
|
|
|
|
|
# and verifies that matches the content of the .a, and then copy from the source dir.
|
|
|
|
|
# TODO: The copying action here isn't really necessary. For future fix, consider using the script extracts from the ar with the rename to potentially
|
|
|
|
|
# make both maccatalyst and other builds do the same thing.
|
|
|
|
|
set(CUR_TARGET_CMAKE_SOURCE_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_LIB}.dir)
|
|
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
2024-09-23 09:19:30 +00:00
|
|
|
COMMAND /usr/bin/ar -t $<TARGET_FILE:${_LIB}> | grep "\.o$" > ${_LIB}.object_file_list.txt
|
2024-03-20 17:55:19 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env python3 ${CMAKE_CURRENT_SOURCE_DIR}/maccatalyst_prepare_objects_for_prelink.py ${CUR_TARGET_CMAKE_SOURCE_LIB_DIR} ${CUR_STATIC_LIB_OBJ_DIR} ${CUR_STATIC_LIB_OBJ_DIR}/${_LIB}.object_file_list.txt
|
|
|
|
|
WORKING_DIRECTORY ${CUR_STATIC_LIB_OBJ_DIR})
|
|
|
|
|
else()
|
|
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
2024-09-23 09:19:30 +00:00
|
|
|
COMMAND /usr/bin/ar ARGS -x $<TARGET_FILE:${_LIB}>
|
2024-03-20 17:55:19 +00:00
|
|
|
WORKING_DIRECTORY ${CUR_STATIC_LIB_OBJ_DIR})
|
|
|
|
|
endif()
|
2021-07-14 23:39:17 +00:00
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
2024-10-08 23:10:46 +00:00
|
|
|
# helper function that recurses to also handle static library dependencies of the ORT external libraries
|
|
|
|
|
set(_processed_libs) # keep track of processed libraries to skip any duplicate dependencies
|
|
|
|
|
function(add_symlink_for_static_lib_and_dependencies lib)
|
|
|
|
|
function(process cur_target)
|
|
|
|
|
# de-alias if applicable so a consistent target name is used
|
|
|
|
|
get_target_property(alias ${cur_target} ALIASED_TARGET)
|
|
|
|
|
if(TARGET ${alias})
|
|
|
|
|
set(cur_target ${alias})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(${cur_target} IN_LIST _processed_libs OR ${cur_target} IN_LIST lib_and_dependencies)
|
|
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
list(APPEND lib_and_dependencies ${cur_target})
|
|
|
|
|
|
2024-10-14 16:24:38 +00:00
|
|
|
set(all_link_libraries)
|
|
|
|
|
|
|
|
|
|
get_property(link_libraries_set TARGET ${cur_target} PROPERTY LINK_LIBRARIES SET)
|
|
|
|
|
if(link_libraries_set)
|
|
|
|
|
get_target_property(link_libraries ${cur_target} LINK_LIBRARIES)
|
|
|
|
|
list(APPEND all_link_libraries ${link_libraries})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
get_property(interface_link_libraries_set TARGET ${cur_target} PROPERTY INTERFACE_LINK_LIBRARIES SET)
|
|
|
|
|
if(interface_link_libraries_set)
|
|
|
|
|
get_target_property(interface_link_libraries ${cur_target} INTERFACE_LINK_LIBRARIES)
|
|
|
|
|
list(APPEND all_link_libraries ${interface_link_libraries})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
list(REMOVE_DUPLICATES all_link_libraries)
|
|
|
|
|
|
|
|
|
|
foreach(dependency ${all_link_libraries})
|
2024-10-08 23:10:46 +00:00
|
|
|
if(TARGET ${dependency})
|
|
|
|
|
process(${dependency})
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
set(lib_and_dependencies ${lib_and_dependencies} PARENT_SCOPE)
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
set(lib_and_dependencies)
|
|
|
|
|
process(${lib})
|
|
|
|
|
|
|
|
|
|
foreach(_target ${lib_and_dependencies})
|
|
|
|
|
get_target_property(type ${_target} TYPE)
|
|
|
|
|
if(${type} STREQUAL "STATIC_LIBRARY")
|
|
|
|
|
# message(STATUS "Adding symlink for ${_target}")
|
|
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
|
|
|
$<TARGET_FILE:${_target}> ${STATIC_LIB_DIR}/$<TARGET_LINKER_FILE_NAME:${_target}>)
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
list(APPEND _processed_libs ${lib_and_dependencies})
|
|
|
|
|
set(_processed_libs ${_processed_libs} PARENT_SCOPE)
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2023-11-03 13:38:29 +00:00
|
|
|
# for external libraries we create a symlink to the .a file
|
|
|
|
|
foreach(_LIB ${onnxruntime_EXTERNAL_LIBRARIES})
|
2024-10-08 23:10:46 +00:00
|
|
|
if(NOT TARGET ${_LIB}) # if we didn't build from source it may not be a target
|
2024-09-10 23:39:27 +00:00
|
|
|
continue()
|
|
|
|
|
endif()
|
2024-10-08 23:10:46 +00:00
|
|
|
|
2023-11-03 13:38:29 +00:00
|
|
|
GET_TARGET_PROPERTY(_LIB_TYPE ${_LIB} TYPE)
|
|
|
|
|
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
|
2024-10-08 23:10:46 +00:00
|
|
|
add_symlink_for_static_lib_and_dependencies(${_LIB})
|
2023-11-03 13:38:29 +00:00
|
|
|
endif()
|
|
|
|
|
endforeach()
|
2021-07-14 23:39:17 +00:00
|
|
|
|
2023-11-03 13:38:29 +00:00
|
|
|
# do the pre-link with `ld -r` to create a single relocatable object with correct symbol visibility
|
|
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
2024-09-23 09:19:30 +00:00
|
|
|
COMMAND /usr/bin/ld ARGS -r -o ${STATIC_LIB_DIR}/prelinked_objects.o */*.o ../*.a
|
2023-11-03 13:38:29 +00:00
|
|
|
WORKING_DIRECTORY ${STATIC_LIB_TEMP_DIR})
|
|
|
|
|
|
|
|
|
|
# create the static library
|
|
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
2024-09-23 09:19:30 +00:00
|
|
|
COMMAND /usr/bin/libtool -static -o ${STATIC_FRAMEWORK_DIR}/onnxruntime prelinked_objects.o
|
2023-11-03 13:38:29 +00:00
|
|
|
WORKING_DIRECTORY ${STATIC_LIB_DIR})
|
2021-07-14 23:39:17 +00:00
|
|
|
|
2023-11-03 13:38:29 +00:00
|
|
|
# Assemble the other pieces of the static framework
|
|
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E
|
|
|
|
|
copy_if_different ${INFO_PLIST_PATH} ${STATIC_FRAMEWORK_DIR}/Info.plist)
|
|
|
|
|
|
|
|
|
|
# add the framework header files
|
|
|
|
|
set(STATIC_FRAMEWORK_HEADER_DIR ${STATIC_FRAMEWORK_DIR}/Headers)
|
2021-07-14 23:39:17 +00:00
|
|
|
file(MAKE_DIRECTORY ${STATIC_FRAMEWORK_HEADER_DIR})
|
|
|
|
|
|
2023-10-04 15:55:08 +00:00
|
|
|
foreach(h_ ${ONNXRUNTIME_PUBLIC_HEADERS})
|
2021-07-14 23:39:17 +00:00
|
|
|
get_filename_component(HEADER_NAME_ ${h_} NAME)
|
2023-11-03 13:38:29 +00:00
|
|
|
add_custom_command(TARGET onnxruntime POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E
|
|
|
|
|
copy_if_different ${h_} ${STATIC_FRAMEWORK_HEADER_DIR}/${HEADER_NAME_})
|
2021-07-14 23:39:17 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
endif()
|