aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2020-03-20 12:12:48 -0700
committerDan Albert <danalbert@google.com>2020-03-24 13:06:16 -0700
commitfed0a4058d786dcc73ee4d625388f9f416b719cc (patch)
tree68c801d3220dc943d1afd9ce884ddcf1bf55cd54 /docs
parent5aec38c42f1e6da17437c72066e4a59beb5a265f (diff)
downloadndk-fed0a4058d786dcc73ee4d625388f9f416b719cc.tar.gz
Default to lld again.
Rather than trying to replace `ld` in each location, this instead relies on Clang defaulting to `ld.lld`, which it invokes from the Clang bin directory. Test: treehugger Bug: None Change-Id: I32b0655c0d89522848f044f1067b53f9214c5444
Diffstat (limited to 'docs')
-rw-r--r--docs/BuildSystemMaintainers.md54
-rw-r--r--docs/changelogs/Changelog-r22.md20
2 files changed, 48 insertions, 26 deletions
diff --git a/docs/BuildSystemMaintainers.md b/docs/BuildSystemMaintainers.md
index 922d84405..383fcf864 100644
--- a/docs/BuildSystemMaintainers.md
+++ b/docs/BuildSystemMaintainers.md
@@ -21,14 +21,16 @@ executables and scripts will differ.
## Introduction
-The NDK uses [Clang] as its C/C++ compiler and [Binutils] for linking,
-archiving, and object file manipulation. Binutils provides both BFD and gold for
-linking. LLVM's [LLD] is also included for testing. AOSP uses LLD by default for
-most projects and the NDK is expected to move to it in the future.
+The NDK predominantly uses [LLVM] tools for building C/C++ code. These include
+[Clang] for compilation, [LLD] for linking, and other [LLVM tools] as well as
+some parts of [Binutils] for other tasks. Binutils will soon be entirely
+replaced by its LLVM equivalents within the NDK, but it remains available during
+the transition.
[Binutils]: https://www.gnu.org/software/binutils
[Clang]: https://clang.llvm.org/
[LLD]: https://lld.llvm.org/
+[LLVM tools]: https://llvm.org/docs/CommandGuide/
### Architectures
[Architectures]: #architectures
@@ -198,23 +200,27 @@ Versions] sections.
## Linkers
-Gold is used by default for most architectures, but BFD is used for AArch64 as
-Gold emits broken debug information for that architecture (see [Issue 70838247]
-for more details).
+LLD is the default linker.
+
+Gold is the fallback linker for most architectures, but BFD is used for AArch64
+as Gold emits broken debug information for that architecture (see [Issue
+70838247] for more details).
+
+The linker used by Clang can be selected with the `-fuse-ld=<linker>` argument,
+passed during linking. For example, to use gold instead of LLD, pass
+`-fuse-ld=gold` when linking. No argument is required to use LLD.
+
+LLD is installed to `<NDK>/toolchains/llvm/prebuilt/<host-tag>/bin/ld`. BFD and
+gold are installed as
+`<NDK>/toolchains/llvm/prebuilt/<host-tag>/bin/<triple>-ld.<suffix>` and
+`<NDK>/toolchains/llvm/prebuilt/<host-tag>/<triple>/bin/ld.<suffix>`, where
+`<suffix>` is either `gold` or `bfd`.
Note: It is usually not necessary to invoke the linkers directly since Clang
will do so automatically. Clang will also automatically link CRT objects and
default libraries and set up other target-specific options, so it is generally
better to use Clang for linking.
-The default linkers are installed to
-`<NDK>/toolchains/llvm/prebuilt/<host-tag>/bin/<triple>-ld` and
-`<NDK>/toolchains/llvm/prebuilt/<host-tag>/<triple>/bin/ld`. To use BFD or gold
-explicitly, use `ld.bfd` or `ld.gold` from the same locations. `ld.lld` is not
-installed to the triple directory and is not triple-prefixed, but rather is only
-installed as `<NDK>/toolchains/llvm/prebuilt/<host-tag>/bin/ld.lld` because the
-one binary supports all ABIs.
-
Warning: Using LLD with GNU `strip` or `objcopy` breaks RelRO. LLVM `strip` and
`objcopy` must be used with LLD. See [Issue 843] and the [Binutils] section of
this document for more information.
@@ -236,16 +242,24 @@ but are not limited to:
* readelf
* strip
-For some of these tools, LLVM equivalents are available. They typically have the
+For each of these tools, LLVM equivalents are available. They typically have the
same name but are prefixed with `llvm-`. For example, `llvm-strip` is used
instead of `<triple>-strip` or the `strip` binary from the triple-specific
directory.
+Note that binutils `as` is used by Clang if the `-fno-integrated-as` argument is
+used.
+
Android is moving away from GNU Binutils in favor of LLVM tools. This is a work
-in progress, but it is likely that a future release of the NDK will deprecate
-and eventually remove GNU Binutils. For now, ensure that your build system works
-with `llvm-strip` and `llvm-objcopy` as they are required when using LLD ([Issue
-843]).
+in progress, but it is likely that binutils will be deprecated in the next
+release of the NDK and removed in the late 2020 LTS release.
+
+At present, the only binutils tool still used by the NDK's build systems is
+`ar`. There may be some issues using `llvm-ar` as a drop in replacement for `ar`
+on Darwin that are still being investigated. See [Issue 1209] for more
+information.
+
+[Issue 1209]: https://github.com/android/ndk/issues/1209
## Sysroot
diff --git a/docs/changelogs/Changelog-r22.md b/docs/changelogs/Changelog-r22.md
index 0b102a579..bdeb8f04f 100644
--- a/docs/changelogs/Changelog-r22.md
+++ b/docs/changelogs/Changelog-r22.md
@@ -9,16 +9,14 @@ For Android Studio issues, follow the docs on the [Android Studio site].
## Announcements
-* [LLD](https://lld.llvm.org/) is now available for testing. AOSP has switched
- to using LLD by default and the NDK will follow (timeline unknown). Test LLD
- in your app by passing `-fuse-ld=lld` when linking. Note that [Issue 843]
- will affect builds using LLD with binutils strip and objcopy as opposed to
- llvm-strip and llvm-objcopy.
+* [LLD](https://lld.llvm.org/) is now the default linker. Gold and BFD will
+ likely be removed in the next LTS release (Q3-Q4 2020). See the Changes
+ section below for more information.
* [Issue 843]: Build system maintainers should begin testing with LLVM's
binutils. Android has switched to using these by default (with the exception
of llvm-ar, as we're still investigating some issues on macOS), and GNU
- binutils will be removed in a future release.
+ binutils will likely be removed in the next LTS release (Q3-Q4 2020).
## Changes
@@ -38,6 +36,16 @@ For Android Studio issues, follow the docs on the [Android Studio site].
r19, file a bug with your build system maintainer. See the [Build System
Maintainers Guide] for information on using the NDK in your own build system.
+* LLD is now used by default. If your build is not yet compatible with LLD, you
+ can continue using the deprecated linkers, set `APP_LD=deprecated` for
+ ndk-build, `ANDROID_LD=deprecated` for CMake, or use an explicit
+ `-fuse-ld=gold` or `-fuse-ld=bfd` in your custom build system. If you
+ encounter issues be sure to file a bug, because this will not be an option in
+ a subsequent release.
+
+ Note that [Issue 843] will affect builds using LLD with binutils strip and
+ objcopy as opposed to llvm-strip and llvm-objcopy.
+
[Build System Maintainers Guide]: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md
## Known Issues