[llvm-dev] Cross compiling C++ program
Goran Mekić via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 4 15:29:59 PDT 2017
On Fri, Aug 04, 2017 at 04:03:35PM -0600, Jonathan Roelofs wrote:
> > > 1) Pick a directory as your sysroot
> > ~/arm-sysroot
> >
> > > 2) Install the libc headers there (without having built it)
> > What I did was mv musl-*/include ~/arm-sysroot/usr/include.
>
> I think you need to copy them, not move them.
On a new directories and fresh untar of musl, I don't think there's a difference
> > > 3) Build clang w/ baremetal cache, pointing it at the partially built
> > > sysroot.
> > cmake -G 'Unix Makefiles' -DBAREMETAL_ARMV7EM_SYSROOT=~/arm-sysroot -C ../../code/clang/cmake/caches/BaremetalARM.cmake ../../code/clang
>
> Sorry, I wasn't explicit enough. You need to define all of the variables
> that the cache is looking for.
>
> > loading initial cache file ../../code/clang/cmake/caches/BaremetalARM.cmake
> > -- Found LLVM_CONFIG as /usr/local/bin/llvm-config
> > -- Building with -fPIC
> > -- Could NOT find Z3 (missing: Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at least version "4.5")
> > -- Clang version: 4.0.1
> > CMake Error at /usr/local/llvm40/lib/cmake/llvm/LLVM-Config.cmake:203 (message):
> > Library `BinaryFormat' not found in list of llvm libraries.
> > Call Stack (most recent call first):
> > /usr/local/llvm40/lib/cmake/llvm/AddLLVM.cmake:508 (llvm_map_components_to_libnames)
> > cmake/modules/AddClang.cmake:86 (llvm_add_library)
> > lib/AST/CMakeLists.txt:6 (add_clang_library)
> >
> > -- Configuring incomplete, errors occurred!
> > See also "/usr/home/meka/repos/clang/build/clang/CMakeFiles/CMakeOutput.log".
>
> I think it found an installed llvm, and is trying to use that to build clang
> against. First, the clang and llvm's versions have to match. Second, when I
> mentioned building clang, I really meant building llvm+clang... sorry.
>
> $ cmake -G 'Unix Makefiles' -DBAREMETAL_ARMV7EM_SYSROOT=~/arm-sysroot -C
> path/to/copy/of/edited/BaremetalARM.cmake path/to/llvm
>
> Where your path/to/llvm has the symlinks:
>
> * path/to/llvm/tools/clang -> path/to/clang
ln -s `which clang40` path/to/llvm/tools/clang
> * path/to/llvm/runtimes/compiler_rt path/to/compiler_rt
ln -s path/to/llvm/projects/compiler-rt path/to/llvm/runtimes/compiler_rt
Is that right?
>
> And by "edited BaremetalARM.cmake" I mean you can strip out the other
> targets in there that you don't need.
So I have copied BaremetalARM.cmake into llvm/cmake/caches/BaremetalARM.cmake to be able to alter it, I've put all other repos in llvm/projects and the command is:
# cmake -G 'Unix Makefiles' -DBAREMETAL_ARMV7EM_SYSROOT=~/arm-sysroot -DBAREMETAL_ARMV6M_SYSROOT=~/arm-sysroot -DBAREMETAL_ARMV7M_SYSROOT=~/arm-sysroot -C ../../code/llvm/cmake/caches/BaremetalARM.cmake ../../code/llvm
Before adding all repos into llvm/projects, it complained about 'Specified distribution component 'clang' doesn't have a target' (just an example). Now I have 'Specified distribution component 'builtins-armv6m-none-eabi' doesn't have a target' as error.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170805/52db4043/attachment.sig>
More information about the llvm-dev
mailing list