Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build fails at linking stage, CXX option -fPIC not handed through #503

Open
grexe opened this issue Dec 11, 2024 · 0 comments
Open

build fails at linking stage, CXX option -fPIC not handed through #503

grexe opened this issue Dec 11, 2024 · 0 comments

Comments

@grexe
Copy link

grexe commented Dec 11, 2024

I need to compile on Haiku (for this scenario, much like BSD).
The build runs fine until it tries to link the flatc submodule, where it fails with this error message, indicating the setting for position independent code is not respected:

[ 16%] Linking CXX executable flatc
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: CMakeFiles/flatc.dir/src/idl_parser.cpp.o: relocation R_X86_64_PC32 against symbol `_ZTVN11flatbuffers9AllocatorE' can not be used when making a shared object; recompile with -fPIC
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
_deps/flatbuffers-build/CMakeFiles/flatc.dir/build.make:656: recipe for target '_deps/flatbuffers-build/flatc' failed
make[2]: *** [_deps/flatbuffers-build/flatc] Error 1
CMakeFiles/Makefile2:7110: recipe for target '_deps/flatbuffers-build/CMakeFiles/flatc.dir/all' failed
make[1]: *** [_deps/flatbuffers-build/CMakeFiles/flatc.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2
...
subprocess.CalledProcessError: Command '['/bin/cmake', '--build', '/boot/home/Develop/SEN/NER/onnxruntime/build/Linux/Debug', '--config', 'Debug']' returned non-zero exit status 2.

Here's the config output from the start of the build:

-- ******** Summary ********
--   CMake version                     : 3.30.5
--   CMake command                     : /boot/system/bin/cmake
--   System                            : Haiku
--   C++ compiler                      : /bin/c++
--   C++ compiler version              : 13.3.0
--   CXX flags                         :  -fPIC -ffunction-sections -fdata-sections -Wno-restrict  -DCPUINFO_SUPPORTED -Wnon-virtual-dtor
--   Build type                        : Debug
--   Compile definitions               : ORT_ENABLE_STREAM;EIGEN_MPL2_ONLY;__STDC_FORMAT_MACROS
--   CMAKE_PREFIX_PATH                 : /boot/home/Develop/SEN/NER/onnxruntime/build/Linux/Debug/installed
--   CMAKE_INSTALL_PREFIX              : /boot/system
--   CMAKE_MODULE_PATH                 : /boot/home/Develop/SEN/NER/onnxruntime/cmake/external
-- 
--   ONNX version                      : 1.16.1
--   ONNX NAMESPACE                    : onnx
--   ONNX_USE_LITE_PROTO               : ON
--   USE_PROTOBUF_SHARED_LIBS          : OFF
--   Protobuf_USE_STATIC_LIBS          : ON
--   ONNX_DISABLE_EXCEPTIONS           : OFF
--   ONNX_DISABLE_STATIC_REGISTRATION  : OFF
--   ONNX_WERROR                       : OFF
--   ONNX_BUILD_TESTS                  : OFF
--   ONNX_BUILD_BENCHMARKS             : OFF
--   ONNX_BUILD_SHARED_LIBS            : 
--   BUILD_SHARED_LIBS                 : OFF
-- 
--   Protobuf compiler                 : 
--   Protobuf includes                 : 
--   Protobuf libraries                : 
--   BUILD_ONNX_PYTHON                 : OFF
-- Could NOT find Eigen3 (missing: Eigen3_DIR)

PIC is set correctly in cmake/CMakeLists.txt and I even added the explicit -fPIC flag manually below (without that, the option does not show up in the compiler config output above):

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# seems not to be enough, so directly set -fPIC option
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

I also added these 2 settings to cmake/onnxruntime_common.cmake and to onnxruntime_flatbuffers.cmake just for testing, but to no avail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant