[llvm-dev] Cross compiling for ARMv7-m

Arslan Khan via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 26 08:57:22 PST 2020


Hi,
I am trying to use LLVM/clang to build a binary for ARM Cortex M platforms.
When I build my binary the linker fails to find these libraries.

./bin/clang++ -target arm-none-eabi -mcpu=cortex-m4 ./temp.cpp -L
./lib/ -L ./libexec/ -L ../build3_v7m/lib/
ld.lld: error: unable to find library -lunwind
ld.lld: error: unable to find library -lc
ld.lld: error: unable to find library -lm
ld.lld: error: unable to find library -lclang_rt.builtins-arm.a

I am guessing I can borrow libraries such as lc and lm from GCC
arm-none-eabi*, but for clang_rt.builtins-arm.a (which I thought
should've been built with LLVM build but I couldn't find that library
in my build directory) I tried building it from LLVM source.


To generate the library, I tried generating builtins by following the guide at:
https://llvm.org/docs/HowToCrossCompileBuiltinsOnArm.html
I tried with different configurations, but each one ends up in some
error which left me wondering that this document might be obsolete.

Anyhow googling things led me to this thread.

http://llvm.1065342.n5.nabble.com/llvm-dev-Compiling-for-baremetal-ARMv4-on-Ubuntu-Linux-td124226.html

After going through this I figured my best bet would be using GCC
sysroot. After which my cmake command looks like this.

cmake -G "Unix Makefiles"
-DBAREMETAL_ARMV6M_SYSROOT=../../gcc-arm-none-eabi-9-2019-q4-major/arm-none-eabi/
-DBAREMETAL_ARMV7M_SYSROOT=../../gcc-arm-none-eabi-9-2019-q4-major/arm-none-eabi/
-DBAREMETAL_ARMV7EM_SYSROOT=../../gcc-arm-none-eabi-9-2019-q4-major/arm-none-eabi/
-DCMAKE_BUILD_TYPE=Release -C ../clang/cmake/caches/BaremetalARM.cmake
../llvm

But with this, I am getting this error attached to the email. Is there
something I am missing here? Is there any update to the
cross-compilation guide? My end goal is cross-compiling C++ programs
for ARM on x86. Any pointers for this would be helpful.

Thanks,
Arslan
-------------- next part --------------
CMake Error at cmake/modules/LLVMDistributionSupport.cmake:18 (message):
  Specified distribution component 'clang' doesn't have a target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:24 (message):
  Specified distribution component 'clang' doesn't have an install target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:30 (message):
  Specified distribution component 'clang' doesn't have an install-stripped
  target.  Its installation target creation should be changed to use
  add_llvm_install_targets, or you should manually create the
  'install-clang-stripped' target.
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:18 (message):
  Specified distribution component 'lld' doesn't have a target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:24 (message):
  Specified distribution component 'lld' doesn't have an install target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:30 (message):
  Specified distribution component 'lld' doesn't have an install-stripped
  target.  Its installation target creation should be changed to use
  add_llvm_install_targets, or you should manually create the
  'install-lld-stripped' target.
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:18 (message):
  Specified distribution component 'clang-resource-headers' doesn't have a
  target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:24 (message):
  Specified distribution component 'clang-resource-headers' doesn't have an
  install target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:30 (message):
  Specified distribution component 'clang-resource-headers' doesn't have an
  install-stripped target.  Its installation target creation should be
  changed to use add_llvm_install_targets, or you should manually create the
  'install-clang-resource-headers-stripped' target.
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:18 (message):
  Specified distribution component 'builtins-armv6m-none-eabi' doesn't have a
  target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:24 (message):
  Specified distribution component 'builtins-armv6m-none-eabi' doesn't have
  an install target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:30 (message):
  Specified distribution component 'builtins-armv6m-none-eabi' doesn't have
  an install-stripped target.  Its installation target creation should be
  changed to use add_llvm_install_targets, or you should manually create the
  'install-builtins-armv6m-none-eabi-stripped' target.
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:18 (message):
  Specified distribution component 'builtins-armv7m-none-eabi' doesn't have a
  target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:24 (message):
  Specified distribution component 'builtins-armv7m-none-eabi' doesn't have
  an install target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:30 (message):
  Specified distribution component 'builtins-armv7m-none-eabi' doesn't have
  an install-stripped target.  Its installation target creation should be
  changed to use add_llvm_install_targets, or you should manually create the
  'install-builtins-armv7m-none-eabi-stripped' target.
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:18 (message):
  Specified distribution component 'builtins-armv7em-none-eabi' doesn't have
  a target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:24 (message):
  Specified distribution component 'builtins-armv7em-none-eabi' doesn't have
  an install target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:30 (message):
  Specified distribution component 'builtins-armv7em-none-eabi' doesn't have
  an install-stripped target.  Its installation target creation should be
  changed to use add_llvm_install_targets, or you should manually create the
  'install-builtins-armv7em-none-eabi-stripped' target.
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:18 (message):
  Specified distribution component 'runtimes' doesn't have a target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:24 (message):
  Specified distribution component 'runtimes' doesn't have an install target
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


CMake Error at cmake/modules/LLVMDistributionSupport.cmake:30 (message):
  Specified distribution component 'runtimes' doesn't have an
  install-stripped target.  Its installation target creation should be
  changed to use add_llvm_install_targets, or you should manually create the
  'install-runtimes-stripped' target.
Call Stack (most recent call first):
  CMakeLists.txt:1080 (llvm_distribution_add_targets)


More information about the llvm-dev mailing list