Skip to content

Support cross-compiling Halide #5040

Open
@shoaibkamil

Description

@shoaibkamil

We should support cross-compiling Halide for a different architecture. Concretely, I'm trying to build Halide for arm64-windows. After more wrangling than I'd like, I've managed to get a cross-compiled LLVM for arm64-windows, following these steps:

  1. Install the appropriate toolchain from the VC installer
  2. Build LLVM from source using directions on the Halide webpage, but don't install. Here, I'm using LLVM 10.
  3. vcpkg env --triplet arm64-windows
  4. cmake -G Ninja -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=<install-dir> -DLLVM_TABLEGEN=d:/llvm-x64-build/bin/llvm-tblgen -DCLANG_TABLEGEN=d:/llvm-x64-build/clang-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-pc-windows-mscvc -DLLVM_TARGET=aarch64 -DENABLE_DIA_SDK=off <rest of options from halide webpage>
    Note here that enabling the DIA SDK will cause the build to fail.
  5. cmake --build . --config release --target install --parallel %NUMBER_OF_PROCESSORS%
  6. Build fails because it attempts to use the newly-built llvm-nm.exe for arm64. Manually edit build.ninja, search for --nm, and point it to the x64 one built earlier instead
  7. cmake --build . --config release --target install --parallel %NUMBER_OF_PROCESSORS%

The build should succeed then. However, trying to build Halide:

  1. cmake -G Ninja -DCMAKE_CROSSCOMPILING=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=d:/halide/vcpkg/scripts/buildsystems/vcpkg.cmake -DLLVM_DIR=d:/halide/llvm-arm-install/lib/cmake/llvm -DClang_DIR=d:/halide/llvm-arm-install/lib/cmake/clang -DWITH_PYTHON_BINDINGS=off ..\halide
  2. cmake.exe --build . --config release --parallel 5 fails with:
[9/3549] Generating _initmod_HalidePyTorchCudaHelpers_h.cpp
FAILED: src/runtime/_initmod_HalidePyTorchCudaHelpers_h.cpp
cmd.exe /C "cd /D D:\halide\halide-arm-build\src\runtime && D:\halide\halide-arm-build\bin\binary2cpp.exe halide_internal_runtime_header_HalidePyTorchCudaHelpers_h < D:/halide/halide/src/runtime/HalidePyTorchCudaHelpers.h > _initmod_HalidePyTorchCudaHelpers_h.cpp"
This version of D:\halide\halide-arm-build\bin\binary2cpp.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
[13/3549] Building CXX object apps\autoscheduler\CMakeFiles\weightsdir_to_weightsfile.dir\Weights.cpp.obj
ninja: build stopped: subcommand failed.

Metadata

Metadata

Assignees

Labels

buildIssues related to building Halide and with CI

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions