You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[llvm][docs] Refresh Arm builtins cross compile guide (#150966)
Someone asked about this on Discord and it was a bit hard to follow. I
found them a config that worked, but the doc was not as much help as it
should have been.
It probably needs some updates for the runtime build era, but for now,
I'm just making it easier to read. I know the basic build can work at
least.
Some aspects of it may be literally wrong now, but I'll check that
later.
* Remove contractions.
* Remove references to the old separate llvm repo layout.
* Remove mentions of cmake versions older than what llvm requires now.
* Make a bunch of things plain text.
* Make a bunch of things code blocks so they are easier to copy and
paste from.
The ``/path/to/armhf/sysroot`` should be the same as the one passed to
121
-
``--sysroot`` in the "build-c-flags".
117
+
``--sysroot`` in the ``build-c-flags``.
122
118
123
-
The "test-c-flags" need to include the target, architecture, gcc-toolchain,
124
-
sysroot and arm/thumb state. The additional cmake defines such as
119
+
The ``test-c-flags`` need to include the target, architecture, gcc-toolchain,
120
+
sysroot and Arm/Thumb state. The additional cmake defines such as
125
121
``CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN`` do not apply when building the tests. If
126
-
you have put all of these in "build-c-flags" then these can be repeated. If you
127
-
wish to use lld to link the tests then add ``"-fuse-ld=lld``.
122
+
you have put all of these in ``build-c-flags`` then these can be repeated. If you
123
+
wish to use lld to link the tests then add ``-fuse-ld=lld``.
128
124
129
125
Once cmake has completed the tests can be built and run using
130
126
``ninja check-builtins``
@@ -142,19 +138,21 @@ This stage can often fail at link time if the ``--sysroot=`` and
142
138
``CMAKE_C_FLAGS`` and ``CMAKE_C_COMPILER_TARGET`` flags.
143
139
144
140
It can be useful to build a simple example outside of cmake with your toolchain
145
-
to make sure it is working. For example: ``clang --target=arm-linux-gnueabi -march=armv7a --gcc-toolchain=/path/to/gcc-toolchain --sysroot=/path/to/gcc-toolchain/arm-linux-gnueabihf/libc helloworld.c``
On debian based systems it is possible to install multiarch support for
150
-
arm-linux-gnueabi and arm-linux-gnueabihf. In many cases clang can successfully
148
+
``arm-linux-gnueabi`` and ``arm-linux-gnueabihf``. In many cases clang can successfully
151
149
use this multiarch support when ``--gcc-toolchain=`` and ``--sysroot=`` are not supplied.
152
150
Unfortunately clang adds ``/usr/local/include`` before
153
151
``/usr/include/arm-linux-gnueabihf`` leading to errors when compiling the hosts
154
152
header files.
155
153
156
154
The multiarch support is not sufficient to build the builtins you will need to
157
-
use a separate arm-linux-gnueabihf toolchain.
155
+
use a separate ``arm-linux-gnueabihf`` toolchain.
158
156
159
157
No target passed to clang
160
158
-------------------------
@@ -164,12 +162,13 @@ as ``error: unknown directive .syntax unified``.
164
162
165
163
You can check the clang invocation in the error message to see if there is no
166
164
``--target`` or if it is set incorrectly. The cause is usually
167
-
``CMAKE_ASM_FLAGS`` not containing ``--target`` or ``CMAKE_ASM_COMPILER_TARGET`` not being present.
165
+
``CMAKE_ASM_FLAGS`` not containing ``--target`` or ``CMAKE_ASM_COMPILER_TARGET``
166
+
not being present.
168
167
169
168
Arm architecture not given
170
169
--------------------------
171
-
The ``--target=arm-linux-gnueabihf`` will default to arm architecture v4t which
172
-
cannot assemble the barrier instructions used in the synch_and_fetch source
170
+
The ``--target=arm-linux-gnueabihf`` will default to Arm architecture v4t which
171
+
cannot assemble the barrier instructions used in the ``synch_and_fetch`` source
173
172
files.
174
173
175
174
The cause is usually a missing ``-march=armv7a`` from the ``CMAKE_ASM_FLAGS``.
@@ -202,7 +201,7 @@ may need extra c-flags such as ``-mfloat-abi=softfp`` for use of floating-point
202
201
instructions, and ``-mfloat-abi=soft -mfpu=none`` for software floating-point
203
202
emulation.
204
203
205
-
You will need to use an arm-linux-gnueabi GNU toolchain for soft-float.
204
+
You will need to use an ``arm-linux-gnueabi`` GNU toolchain for soft-float.
206
205
207
206
AArch64 Target
208
207
--------------
@@ -220,8 +219,12 @@ Armv6-m, Armv7-m and Armv7E-M targets
220
219
To build and test the libraries using a similar method to Armv7-A is possible
221
220
but more difficult. The main problems are:
222
221
223
-
* There isn't a ``qemu-arm`` user-mode emulator for bare-metal systems. The ``qemu-system-arm`` can be used but this is significantly more difficult to setup.
224
-
* The targets to compile compiler-rt have the suffix -none-eabi. This uses the BareMetal driver in clang and by default won't find the libraries needed to pass the cmake compiler check.
222
+
* There is not a ``qemu-arm`` user-mode emulator for bare-metal systems.
223
+
``qemu-system-arm`` can be used but this is significantly more difficult
224
+
to setup.
225
+
* The targets to compile compiler-rt have the suffix ``-none-eabi``. This uses
226
+
the BareMetal driver in clang and by default will not find the libraries
227
+
needed to pass the cmake compiler check.
225
228
226
229
As the Armv6-M, Armv7-M and Armv7E-M builds of compiler-rt only use instructions
227
230
that are supported on Armv7-A we can still get most of the value of running the
@@ -233,32 +236,30 @@ builtins use instructions that are supported on Armv7-A but not Armv6-M,
233
236
Armv7-M and Armv7E-M.
234
237
235
238
To get the cmake compile test to pass you will need to pass the libraries
236
-
needed to successfully link the cmake test via ``CMAKE_CFLAGS``. It is
237
-
strongly recommended that you use version 3.6 or above of cmake so you can use
238
-
``CMAKE_TRY_COMPILE_TARGET=STATIC_LIBRARY`` to skip the link step.
0 commit comments