Skip to content

Unsupported Architecture Issue while cross-compiling on linux #1308

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

Open
aarifzafar1 opened this issue Mar 7, 2025 · 3 comments
Open

Unsupported Architecture Issue while cross-compiling on linux #1308

aarifzafar1 opened this issue Mar 7, 2025 · 3 comments

Comments

@aarifzafar1
Copy link

aarifzafar1 commented Mar 7, 2025

Describe the bug
I am trying to build onnx-genai library(shared object) by cross compiling for a linux based custom architecture. I have made the same for onnxruntime and I am able to build, while facing below issue while building onnx-genai:

-- Fetch json
-- Tokenizer needed.
-- math lib 'libm' not found; floating point support disabled
CMake Error at cmake/global_variables.cmake:153 (message):
Unsupported architecture. CMAKE_SYSTEM_PROCESSOR:
Call Stack (most recent call first):
CMakeLists.txt:37 (include)

-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
File "/home/test/onnxruntime/onnxruntime-genai/build.py", line 656, in
update(arguments, environment)
File "/home/test/onnxruntime/onnxruntime-genai/build.py", line 574, in update
util.run(command, env=env)
File "/home/test/onnxruntime/onnxruntime-genai/tools/python/util/run.py", line 56, in run
completed_process = subprocess.run(
File "/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/bin/cmake', '-G', 'Unix Makefiles', '-DCMAKE_BUILD_TYPE=MinSizeRel', '-S', '/home/test/onnxruntime/onnxruntime-genai', '-B', '/home/test/onnxruntime/onnxruntime-genai/build/basic/MinSizeRel', '-DCMAKE_POSITION_INDEPENDENT_CODE=ON', '-DUSE_CUDA=OFF', '-DUSE_ROCM=OFF', '-DUSE_DML=OFF', '-DENABLE_JAVA=OFF', '-DBUILD_WHEEL=ON', '-DCMAKE_TOOLCHAIN_FILE=/home/test/custom-toolchains/toolchains/aarch64-custom-linux-musl/tools.cmake', '-DCMAKE_POSITION_INDEPENDENT_CODE=ON']' returned non-zero exit status 1.

The command used to build is below:

./build.sh --build_dir build/basic --config MinSizeRel --parallel --cmake_extra_defines CMAKE_TOOLCHAIN_FILE="/test/custom-toolchains/toolchains/aarch64-custom-linux-musl/tools.cmake" CMAKE_POSITION_INDEPENDENT_CODE=ON --skip_tests

The debugging suggest the below line in build.py causing the error:
build.py", line 574, in update
util.run(command, env=env)

Is the linux environment not supported for cross compiling or is it some other issue?

@snnn
Copy link
Member

snnn commented Mar 7, 2025

Please set CMAKE_SYSTEM_PROCESSOR in the toolchain cmake file

@aarifzafar1
Copy link
Author

aarifzafar1 commented Mar 8, 2025

Dear @snnn
Thank you for replying the primary fix for the issue.
I have set the CMAKE_SYSTEM_PROCESSOR in toolchain but it is not reflecting while building. Although I fixed the issue with some hardcoding in global_variables.cmake file.
But I have ran into some other issue.
The issue is as below:

[ 89%] Building CXX object CMakeFiles/onnxruntime-genai.dir/src/webgpu/interface.cpp.o
In file included from /home/test/onnxruntime-genai/onnxruntime-genai/src/models/captured_graph_pool.cpp:1:
In file included from /home/test/onnxruntime-genai/onnxruntime-genai/src/models/captured_graph_pool.h:7:
In file included from /home/test/onnxruntime-genai/onnxruntime-genai/src/models/static_buffer.h:6:
/home/test/onnxruntime-genai/onnxruntime-genai/src/models/onnxruntime_api.h:156:35: error: use of undeclared identifier 'RTLD_DI_ORIGIN'
156 | dlinfo((void*)ort_lib_handle, RTLD_DI_ORIGIN, &pathname);

On debugging, I have found that RTLD_DI_ORIGIN is undefined incase we are compiling the source code for Android or Apple. But I am buildng right now with custom toolchain and build command used is below, so not sure the cause of the error:

Build Command:
./build.sh --build_dir build/basic --config MinSizeRel --parallel --cmake_extra_defines CMAKE_TOOLCHAIN_FILE="/test/custom-toolchains/toolchains/aarch64-custom-linux-musl/tools.cmake" CMAKE_POSITION_INDEPENDENT_CODE=ON --skip_tests

@snnn
Copy link
Member

snnn commented Mar 10, 2025

You are building it for musl? We never tested the config. I believe the error was because the libc doesn't have the RTLD_DI_ORIGIN symbol. I think we should add a check to this project's top level CMakeLists.txt to check if the symbol exists, then add #ifdef to the code that caused the error. Then the build will pass, but, certainly the functionalities that rely on the code path wouldn't work. It's not big deal I think, if you only use the default CPU execution provider.

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

2 participants