@@ -46,20 +46,38 @@ The CMake options you need to add are:
46
46
* ``-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf ``
47
47
* ``-DLLVM_TARGET_ARCH=ARM ``
48
48
* ``-DLLVM_TARGETS_TO_BUILD=ARM ``
49
- * ``-DCMAKE_CXX_FLAGS='-target armv7a-linux-gnueabihf -mcpu=cortex-a9 -I/usr/arm-linux-gnueabihf/include/c++/4.7.2/arm-linux-gnueabihf/ -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc' ``
49
+
50
+ If you're compiling with GCC, you can use architecture options for your target,
51
+ and the compiler driver will detect everything that it needs:
52
+ * ``-DCMAKE_CXX_FLAGS='-march=armv7-a -mcpu=cortex-a9 -mfloat-abi=hard' ``
53
+
54
+ However, if you're using Clang, the driver might not be up-to-date with your
55
+ specific Linux distribution, version or GCC layout, so you'll need to fudge.
56
+
57
+ In addition to the ones above, you'll also need:
58
+ * ``'-target arm-linux-gnueabihf' `` or whatever is the triple of your cross GCC.
59
+ * ``'--sysroot=/usr/arm-linux-gnueabihf' ``, ``'--sysroot=/opt/gcc/arm-linux-gnueabihf' ``
60
+ or whatever is the location of your GCC's sysroot (where /lib, /bin etc are).
61
+ * Appropriate use of ``-I `` and ``-L ``, depending on how the cross GCC is installed,
62
+ and where are the libraries and headers.
50
63
51
64
The TableGen options are required to compile it with the host compiler,
52
65
so you'll need to compile LLVM (or at least ``llvm-tblgen ``) to your host
53
- platform before you start. The CXX flags define the target, cpu (which
66
+ platform before you start. The CXX flags define the target, cpu (which in this case
54
67
defaults to ``fpu=VFP3 `` with NEON), and forcing the hard-float ABI. If you're
55
- using Clang as a cross-compiler, you will *also * have to set ``-ccc-gcc-name ``,
68
+ using Clang as a cross-compiler, you will *also * have to set ``--sysroot ``
56
69
to make sure it picks the correct linker.
57
70
71
+ When using Clang, it's important that you choose the triple to be *identical *
72
+ to the GCC triple and the sysroot. This will make it easier for Clang to
73
+ find the correct tools and include headers. But that won't mean all headers and
74
+ libraries will be found. You'll still need to use ``-I `` and ``-L `` to locate
75
+ those extra ones, depending on your distribution.
76
+
58
77
Most of the time, what you want is to have a native compiler to the
59
- platform itself, but not others. It might not even be feasible to
60
- produce x86 binaries from ARM targets, so there's no point in compiling
78
+ platform itself, but not others. So there's rarely a point in compiling
61
79
all back-ends. For that reason, you should also set the
62
- ``TARGETS_TO_BUILD `` to only build the ARM back-end.
80
+ ``TARGETS_TO_BUILD `` to only build the back-end you're targeting to .
63
81
64
82
You must set the ``CMAKE_INSTALL_PREFIX ``, otherwise a ``ninja install ``
65
83
will copy ARM binaries to your root filesystem, which is not what you
@@ -83,14 +101,23 @@ running CMake:
83
101
This is not a problem, since Clang/LLVM libraries are statically
84
102
linked anyway, it shouldn't affect much.
85
103
86
- #. The ARM libraries won't be installed in your system, and possibly
87
- not easily installable anyway, so you'll have to build/download
88
- them separately. But the CMake prepare step, which checks for
104
+ #. The ARM libraries won't be installed in your system.
105
+ But the CMake prepare step, which checks for
89
106
dependencies, will check the *host * libraries, not the *target *
90
- ones.
107
+ ones. Below there's a list of some dependencies, but your project could
108
+ have more, or this document could be outdated. You'll see the errors
109
+ while linking as an indication of that.
110
+
111
+ Debian based distros have a way to add ``multiarch ``, which adds
112
+ a new architecture and allows you to install packages for those
113
+ systems. See https://wiki.debian.org/Multiarch/HOWTO for more info.
114
+
115
+ But not all distros will have that, and possibly not an easy way to
116
+ install them in any anyway, so you'll have to build/download
117
+ them separately.
91
118
92
119
A quick way of getting the libraries is to download them from
93
- a distribution repository, like Debian (http://packages.debian.org/wheezy /),
120
+ a distribution repository, like Debian (http://packages.debian.org/jessie /),
94
121
and download the missing libraries. Note that the ``libXXX ``
95
122
will have the shared objects (``.so ``) and the ``libXXX-dev `` will
96
123
give you the headers and the static (``.a ``) library. Just in
0 commit comments