@@ -23,10 +23,8 @@ executables and scripts will differ.
23
23
24
24
The NDK uses the [ LLVM] family of tools for building C/C++ code. These include
25
25
[ Clang] for compilation, [ LLD] for linking, and other [ LLVM tools] for other
26
- tasks. Historically [ Binutils] was used and remains available during the
27
- transition but is deprecated and will soon be removed from the NDK.
26
+ tasks.
28
27
29
- [ Binutils ] : https://www.gnu.org/software/binutils
30
28
[ Clang ] : https://clang.llvm.org/
31
29
[ LLD ] : https://lld.llvm.org/
32
30
[ LLVM tools ] : https://llvm.org/docs/CommandGuide/
@@ -168,6 +166,11 @@ the binary being linked contains no C++ code (i.e. none of the object files
168
166
being linked were generated from C++ files) and ` clang++ ` should be used
169
167
otherwise. Using ` clang++ ` ensures that the C++ standard library is linked.
170
168
169
+ When linking a shared library, the ` -Wl,-soname,$NAME_OF_LIBRARY ` argument is
170
+ required. This is necessary to avoid the problems described in [ this stack
171
+ overflow post] ( https://stackoverflow.com/a/48291044/632035 ) . For example, when
172
+ building ` libapp.so ` , ` -Wl,-soname,libapp.so ` must be used.
173
+
171
174
### Target Selection
172
175
173
176
[ Cross-compilation] targets can be selected in one of two ways: by using
@@ -203,35 +206,15 @@ Versions] sections.
203
206
204
207
## Linkers
205
208
206
- LLD is the default linker.
207
-
208
- Gold is the fallback linker for most architectures, but BFD is used for AArch64
209
- as Gold previously emitted broken debug information for that architecture (see
210
- [ Issue 70838247] for more details).
211
-
212
- The linker used by Clang can be selected with the ` -fuse-ld=<linker> ` argument,
213
- passed during linking. For example, to use gold instead of LLD, pass
214
- ` -fuse-ld=gold ` when linking. No argument is required to use LLD.
215
-
216
- The default linkers are installed to
217
- ` <NDK>/toolchains/llvm/prebuilt/<host-tag>/bin/<triple>-ld ` and
218
- ` <NDK>/toolchains/llvm/prebuilt/<host-tag>/<triple>/bin/ld ` . BFD and gold are
219
- installed as ` ld.bfd ` or ` ld.gold ` in the same locations. The triple-prefixed
220
- executables in the common bin directory should be preferred to the
221
- triple-specific bin directory because the triple-specific directory will be
222
- removed when binutils is removed from the NDK.
209
+ The NDK uses LLD for linking. The linker is installed to
210
+ ` <NDK>/toolchains/llvm/prebuilt/<host-tag>/bin/<triple>-ld ` .
223
211
224
212
Note: It is usually not necessary to invoke the linkers directly since Clang
225
213
will do so automatically. Clang will also automatically link CRT objects and
226
214
default libraries and set up other target-specific options, so it is generally
227
215
better to use Clang for linking.
228
216
229
- Warning: Using LLD with GNU ` strip ` or ` objcopy ` breaks RelRO. LLVM ` strip ` and
230
- ` objcopy ` must be used with LLD. See [ Issue 843] and the [ Binutils] section of
231
- this document for more information.
232
-
233
217
[ Issue 70838247 ] : https://issuetracker.google.com/70838247
234
- [ Issue 843 ] : https://github.com/android-ndk/ndk/issues/843
235
218
236
219
## Binutils
237
220
@@ -250,14 +233,6 @@ assembling LLVM IR. If you are currently using `as` directly, you will need to
250
233
migrate to using ` clang ` as a driver for building assembly. See [ Clang
251
234
Migration Notes] for advice on fixing assembly to be LLVM compatible.
252
235
253
- GNU Binutils remains available up to and including r22. All binutils tools with
254
- the exception of the assembler (GAS) were removed in r23. GAS was removed in
255
- r24.
256
-
257
- In r22 or earlier, GNU binutils tools are installed to
258
- ` <NDK>/toolchains/llvm/prebuilt/<host-tag>/bin/<triple>-<tool> ` and
259
- ` <NDK>/toolchains/llvm/prebuilt/<host-tag>/<triple>/bin/<tool> ` .
260
-
261
236
Note that by default ` /usr/bin/as ` is used by Clang if the
262
237
` -fno-integrated-as ` argument is used, which is almost certainly not
263
238
what you want!
0 commit comments