Skip to content

custom_ops fails to build when cross-compiling to x64 from arm64 #6839

@zcbenz

Description

@zcbenz

🐛 Describe the bug

Run following command to build for x64 on arm64 mac:

cmake . -B out \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/opt/homebrew/Caskroom/miniconda/base/envs/executorch/lib/python3.10/site-packages/torch \
-DPYTHON_EXECUTABLE=/opt/homebrew/Caskroom/miniconda/base/envs/executorch/bin/python3 \
-DFLATC_EXECUTABLE=/opt/homebrew/Caskroom/miniconda/base/envs/executorch/bin/flatc \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DDEPLOYMENT_TARGET=10.15 \
-DEXECUTORCH_BUILD_COREML=ON \
-DEXECUTORCH_BUILD_MPS=ON \
-DCMAKE_TOOLCHAIN_FILE=third-party/ios-cmake/ios.toolchain.cmake \
-DPLATFORM=MAC
cmake --build out --config Release -j 

And compilation fails at custom_ops:

/Users/zcbenz/codes/executorch-binaries/executorch/extension/llm/custom_ops/spinquant/third-party/FFHT/fht_neon.c:28:11: error: unknown register name '%v0' in asm
        : "%v0",
          ^
/Users/zcbenz/codes/executorch-binaries/executorch/extension/llm/custom_ops/spinquant/third-party/FFHT/fht_neon.c:82:15: error: unknown register name '%v0' in asm
            : "%v0",
              ^

Which is because of fht_neon.c being compiled for x64.

The extension/llm/custom_ops/spinquant/third-party/FFHT/targets.bzl file sets the file to only build from arm64, so I suspect the build system did not handle target/host arch correctly somewhere, however I know nothing about buck2 so I can't see how to fix this, even though I suspect the fix could be simple.

Also note that while mac x64 is not a supported target, everything else works fine with EXECUTORCH_BUILD_KERNELS_CUSTOM=OFF.

Versions

I'm building with the latest ExecuTorch (5b51bb8).

cc @larryliu0820

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: build/installIssues related to the cmake and buck2 builds, and to installing ExecuTorchtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions