Skip to content

[Build] Issue when cross-compiling for ARM64 #25201

Open
@john-dance

Description

@john-dance

Describe the issue

We are using linux-x86 to build for linux-arm64. There is an issue in how cpuinfo is included and built.

See

The onnxruntime_target_platform is set up to be aarch64, but this is not checked before running clang -dumpmachine ...which of course doesn't help when running on an x86 machine but targeting an aarch64 machine. ARM64 or ARM need to be defined for the proper inclusion and build of cpuinfo. (See lines 213-221)

One easy way to fix this is to add

if (onnxruntime_target_platform STREQUAL "aarch64")
    set(ARM64 TRUE)

before testing the dumpmachine_output.

As an aside, the parameter --arm64 is only checked when building on Windows.

Urgency

No response

Target platform

linux-aarch64

Build script

        python3 tools/ci_build/build.py \
            --cmake_extra_defines CMAKE_TOOLCHAIN_FILE="<toolchain-targeting-linux-aarch64" \
            --build_dir "$build_dir" \
            --config $build_type \
            --compile_no_warning_as_error \
            --build_shared_lib \
            --target onnxruntime_perf_test \
            --parallel \
            --use_cache \
            --use_qnn static_lib \
            --qnn_home="$QNN_SDK" \
            --skip_tests
            $@

Note: We have worked around the issue by adding ARM64=TRUE to the cmake_extra_defines.

Error / output

cpuinfo_initialize (and friends) are not found when linking.

Visual Studio Version

No response

GCC / Compiler Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildbuild issues; typically submitted using templatecontributions welcomeexternal contributions welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions