Erik Nouroyan
Erik Nouroyan

Reputation: 161

Linker gives undefined symbols error when cross compiling Halide

Hey I'm trying to build Halide into static library for arm64-v8a Android architecture on the host OSX system. When I run the following commands I get the linking errors below. Which part am I doing wrong?

Command run

$ cmake -S .-B build \
        -DCMAKE_CROSSCOMPILING=True \
        -DHalide_TARGET=arm-64-android \
        -DHalide_SHARED_LLVM=ON \
        -DBUILD_SHARED_LIBS=OFF \
        -DLLVM_DIR=/usr/local/Cellar/llvm/12.0.1/lib/cmake/llvm \
        -DClang_DIR=/usr/local/Cellar/llvm/12.0.1/lib/cmake/clang \
        -DLLD_DIR=/usr/local/Cellar/llvm/12.0.1/lib/cmake/lld \
        -DLLVM_TABLEGEN=/usr/local/Cellar/llvm/12.0.1/bin/llvm-tblgen \
        -DCLANG_TABLEGEN=/usr/local/Cellar/llvm/12.0.1/bin/ \
        -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-android \
        -DLLVM_TARGET_ARCH=aarch64 \
        -DLLVM_TARGETS_TO_BUILD=aarch64 \
        -DCMAKE_BUILD_TYPE=Debug
$ cmake --build ./build

Linking Errors

ld: warning: ignoring file variable_num_threads.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file variable_num_threads.runtime.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture x86_64:
  "_halide_join_thread", referenced from:
      _main in variable_num_threads_aottest.cpp.o
  "_halide_set_num_threads", referenced from:
      mess_with_num_threads(void*) in variable_num_threads_aottest.cpp.o
      _main in variable_num_threads_aottest.cpp.o
  "_halide_spawn_thread", referenced from:
      _main in variable_num_threads_aottest.cpp.o
  "_variable_num_threads", referenced from:
      _main in variable_num_threads_aottest.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Upvotes: 0

Views: 386

Answers (1)

Alex Reinking
Alex Reinking

Reputation: 20056

We do not currently support cross-compiling libHalide. If you want to build pipelines for arm64-v8a, you should use the Halide::Generator infrastructure to run the generator on a build machine and produce libraries for your target architecture there.

However, I am personally working on it... https://github.com/halide/Halide/pull/6071

Check back in a few weeks!

Upvotes: 1

Related Questions