[llvm-dev] Cross compiling C++ program

Richard Pennington via llvm-dev llvm-dev at lists.llvm.org
Sat Aug 5 07:19:57 PDT 2017


On 08/05/2017 08:41 AM, Goran Mekić via llvm-dev wrote:

>
> So I tried to use it, and clang/llvm build, but compiler-rt fails:
>
> # cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release -DBAREMETAL_ARMV7EM_SYSROOT=/tmp/barearm-sysroot -DCMAKE_INSTALL_PREFIX=/tmp/barearm-sysroot -C ../../source/llvm/cmake/caches/BaremetalARM.cmake ../../source/llvm
> # make -j4
> https://gist.github.com/anonymous/85cd5081a6d46a63731d970ee95b20b4
>
> This is the BaremetalARM.cmake:
> https://gist.github.com/anonymous/ff3248f08ddc99361dcc009e9f4c1020
It is slightly tricky to compile compile musl and compiler-rt. The bits
directory is populated when you install musl, but musl needs compiler-rt
built if you want to build libc.so.
The solution that works is to first do a "make install-headers" on musl,
then build compiler-rt, then build musl. If you look at the ELLCC
make-libraries and build-musl scripts, you'll see how ELLCC does it. Or
you can disable building the musl shared library.

The other problem you'll run into is that musl is nowhere near bare
metal. It's whole purpose in life is to turn the C standard library
calls into Linux system calls. While a baremetal version of musl would
be very nice to have, it is a non-trivial project.  Baremetal is what
something like NuttX's C library provides.

-Rich






More information about the llvm-dev mailing list