Skip to content

Linking CXX executable onnxruntime_test_all fails when cross-compiling onnxruntime for arm #8427

@drux007

Description

@drux007

Describe the bug
When I try to build onnxruntime for arm by cross compiling on Linux using arm-linux-gnueabihf-gcc-7 toolchain, Linking CXX executable onnxruntime_test_all fails.

Urgency
We use onnxruntime for deploying our models on various different platforms and also we need to add ARM platform as soon as possible.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
  • ONNX Runtime installed from (source or binary): source
  • ONNX Runtime version: 1.8.0
  • Python version: 3.6.9
  • GCC/Compiler version (if compiling from source):7.5.0

I tried to build it using docker image conanio/gcc7-armv7:

  • OS Platform: Linux
  • ONNX Runtime installed from (source or binary): source
  • ONNX Runtime version: 1.8.0
  • GCC/Compiler: arm-linux-gnueabihf-gcc-7
  • GCC/Compiler version (if compiling from source):7.2.0

To Reproduce
The easiest is to simply run it inside the following docker container:

docker run -it conanio/gcc7-armv7 /bin/bash

Download the source code:

git clone --single-branch --branch v1.8.0 --recursive https://github.com/Microsoft/onnxruntime

Download pre-compiled protoc version 3.16.0 inside docker container from here, as described in the official instructions and unzip it after downloading.. The version must match the one onnxruntime is using. Currently that is 3.16.0 (see here).

Start build process with:

./build.sh --path_to_protoc_exe=/home/conan/protoc-3.16.0-linux-x86_64/bin/protoc --cmake_extra_defines="CMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc-7" --cmake_extra_defines="CMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++-7" --parallel --config Release --build_dir build --skip_tests

Note: Adapt the path to pre-compiled-protoc.

Expected behavior
Expected would be that it builds successfully, but it fails at Linking CXX executable onnxruntime_test_all with:

Linking CXX executable onnxruntime_test_all
CMakeFiles/onnxruntime_test_all.dir/home/conan/onnxruntime/onnxruntime/test/providers/cpu/controlflow/loop_test.cc.o: In function `std::__atomic_futex_unsigned<2147483648u>::_M_store_notify_all(unsigned int, std::memory_order)':
/usr/arm-linux-gnueabihf/include/c++/7/bits/atomic_futex.h:208: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)'
/usr/arm-linux-gnueabihf/include/c++/7/bits/atomic_futex.h:208: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)'
CMakeFiles/onnxruntime_test_all.dir/home/conan/onnxruntime/onnxruntime/test/providers/cpu/controlflow/loop_test.cc.o: In function `std::__atomic_futex_unsigned<2147483648u>::_M_load_and_test_until(unsigned int, unsigned int, bool, std::memory_order, bool, std::chrono::duration<long long, std::ratio<1ll, 1ll> >, std::chrono::duration<long long, std::ratio<1ll, 1000000000ll> >)':
/usr/arm-linux-gnueabihf/include/c++/7/bits/atomic_futex.h:102: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_wait_until(unsigned int*, unsigned int, bool, std::chrono::duration<long long, std::ratio<1ll, 1ll> >, std::chrono::duration<long long, std::ratio<1ll, 1000000000ll> >)'
collect2: error: ld returned 1 exit status
CMakeFiles/onnxruntime_test_all.dir/build.make:3589: recipe for target 'onnxruntime_test_all' failed
make[2]: *** [onnxruntime_test_all] Error 1
CMakeFiles/Makefile2:1072: recipe for target 'CMakeFiles/onnxruntime_test_all.dir/all' failed
make[1]: *** [CMakeFiles/onnxruntime_test_all.dir/all] Error 2
Makefile:181: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
  File "/home/conan/onnxruntime/tools/ci_build/build.py", line 2152, in <module>
    sys.exit(main())
  File "/home/conan/onnxruntime/tools/ci_build/build.py", line 2076, in main
    build_targets(args, cmake_path, build_dir, configs, num_parallel_jobs, args.target)
  File "/home/conan/onnxruntime/tools/ci_build/build.py", line 1067, in build_targets
    run_subprocess(cmd_args, env=env)
  File "/home/conan/onnxruntime/tools/ci_build/build.py", line 581, in run_subprocess
    return run(*args, cwd=cwd, capture_stdout=capture_stdout, shell=shell, env=my_env)
  File "/home/conan/onnxruntime/tools/python/util/run.py", line 44, in run
    env=env, shell=shell)
  File "/opt/pyenv/versions/3.7.5/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/cmake', '--build', 'build/Debug', '--config', 'Debug', '--', '-j8']' returned non-zero exit status 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions