Skip to content

Commit

Permalink
Prevent crash on import after GCC 8 builds (#6048)
Browse files Browse the repository at this point in the history
### Description
Possible fix for #6047 based on
https://stackoverflow.com/questions/33149878/experimentalfilesystem-linker-error/33159746#33159746

### Motivation and Context
I'm not a cmake expert so there may be a better way to do this. This did
allow me to build ONNX 1.16 on RHEL 8.

---------

Signed-off-by: Charles Volzka <cjvolzka@us.ibm.com>
Signed-off-by: Charles Volzka <42243335+cjvolzka@users.noreply.github.com>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
Co-authored-by: G. Ramalingam <grama@microsoft.com>
  • Loading branch information
3 people committed Apr 12, 2024
1 parent 284b124 commit 3f24ef3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -587,6 +587,11 @@ if(BUILD_ONNX_PYTHON)
target_link_libraries(onnx_cpp2py_export
PRIVATE "-Wl,--whole-archive" $<TARGET_FILE:onnx>
"-Wl,--no-whole-archive")
# Prevent "undefined symbol: _ZNSt10filesystem7__cxx114path14_M_split_cmptsEv"
# (std::filesystem::__cxx11::path::_M_split_cmpts()) on gcc 8
if (CMAKE_CXX_STANDARD EQUAL 17 AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
target_link_libraries(onnx_cpp2py_export PRIVATE "-lstdc++fs")
endif()
set_target_properties(onnx_cpp2py_export
PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL")
endif()
Expand Down

0 comments on commit 3f24ef3

Please sign in to comment.