aboutsummaryrefslogtreecommitdiff
path: root/ndk/checkbuild.py
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2020-03-18 16:14:52 -0700
committerDan Albert <danalbert@google.com>2020-03-18 16:14:52 -0700
commitaf99a45fe6e8a004122fb1d37f120fea47b43dc4 (patch)
tree3df4f0b2bd8ab01f5b42c3fe62cf9a585bd72457 /ndk/checkbuild.py
parentf50670481a3de2330647d910d390a48d701e2286 (diff)
downloadndk-af99a45fe6e8a004122fb1d37f120fea47b43dc4.tar.gz
Revert "Switch to LLD as the default linker."
This reverts commit 393761d2e07461366ea456cea7f67fade95e3b4b. This broke Darwin. It seems that LLD assumes the target based on the name of the executable, so it can't be reliably used from the target-specific directory as I tried to do here. Trying to use this with Darwin results in the following: ``` ld: warning: ignoring unknown argument: -z ld: warning: ignoring unknown argument: --warn-shared-textrel ld: warning: ignoring unknown argument: -z ld: warning: ignoring unknown argument: -z ld: warning: ignoring unknown argument: --hash-style=both ld: warning: ignoring unknown argument: --enable-new-dtags ld: warning: ignoring unknown argument: --eh-frame-hdr ld: warning: ignoring unknown argument: -m ld: warning: ignoring unknown argument: -dynamic-linker ld: warning: ignoring unknown argument: -plugin ld: warning: ignoring unknown argument: -plugin-opt=mcpu=x86-64 ld: warning: ignoring unknown argument: --gc-sections ld: warning: ignoring unknown argument: -rpath-link=/Volumes/Android/danalbert/ndk/out/darwin/android-ndk-r22-canary/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/x86_64-linux-android/21 ld: warning: ignoring unknown argument: -rpath-link=./obj/local/x86_64 ld: warning: ignoring unknown argument: --exclude-libs ld: warning: ignoring unknown argument: --exclude-libs ld: warning: ignoring unknown argument: --exclude-libs ld: warning: ignoring unknown argument: --build-id ld: warning: ignoring unknown argument: --no-undefined ld: warning: ignoring unknown argument: --fatal-warnings ld: error: -arch not specified and could not be inferred clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` It's trivially fixed with `-fuse-ld=lld`, which causes Clang to pick LLD from a different directory and passes the target explicitly. We could do that in ndk-build and in the CMake toolchain to change the default for those systems, but we really need to upstream a patch to change the default in the Clang driver to affect other build systems. Bug: None Test: treehugger
Diffstat (limited to 'ndk/checkbuild.py')
-rwxr-xr-xndk/checkbuild.py46
1 files changed, 0 insertions, 46 deletions
diff --git a/ndk/checkbuild.py b/ndk/checkbuild.py
index eaf7f1c80..6a1e82830 100755
--- a/ndk/checkbuild.py
+++ b/ndk/checkbuild.py
@@ -1956,52 +1956,6 @@ class BaseToolchain(ndk.builds.Module):
binutils_dir = self.get_dep('binutils').get_install_path(arch=arch)
copy_tree(binutils_dir, install_dir)
- # Replace the default ld executable with lld.
- triple = ndk.abis.arch_to_triple(arch)
- bin_dir = Path(install_dir) / 'bin'
- arch_bin_dir = Path(install_dir) / triple / 'bin'
-
- bin_ld = bin_dir / f'{triple}-ld{exe}'
- arch_ld = arch_bin_dir / f'ld{exe}'
- lld = bin_dir / f'ld.lld{exe}'
-
- bin_ld.unlink()
- shutil.copyfile(lld, bin_ld)
- shutil.copystat(lld, bin_ld)
-
- arch_ld.unlink()
- shutil.copyfile(lld, arch_ld)
- shutil.copystat(lld, arch_ld)
-
- # LLD isn't really meant to be moved, so it doesn't have an RPATH
- # for the arch-specific directory. Ideally we wouldn't copy to this
- # directory at all, but Clang only searches the arch-specific
- # directory, so if we don't have this it'll wrongly fall back to
- # /usr/bin/ld.
- #
- # We'll fix Clang before we remove the directory entirely when we
- # remove binutils, but for now just copy the dependent libraries
- # with it.
- if not self.host.is_windows:
- src_lib64 = bin_dir.parent / 'lib64'
- dst_lib64 = arch_bin_dir.parent / 'lib64'
- # The directory already exists for LP64 ABIs, but not for LP32
- # ABIs.
- dst_lib64.mkdir(exist_ok=True)
-
- libcxx = versioned_so(self.host, 'libc++', '1')
- shutil.copyfile(src_lib64 / libcxx, dst_lib64 / libcxx)
- shutil.copystat(src_lib64 / libcxx, dst_lib64 / libcxx)
-
- libcxxabi = versioned_so(self.host, 'libc++', '1')
- shutil.copyfile(src_lib64 / libcxxabi, dst_lib64 / libcxxabi)
- shutil.copystat(src_lib64 / libcxxabi, dst_lib64 / libcxxabi)
- else:
- src = bin_dir / 'libwinpthread-1.dll'
- dest = arch_bin_dir / 'libwinpthread-1.dll'
- shutil.copyfile(src, dest)
- shutil.copystat(src, dest)
-
platforms = self.get_dep('platforms')
assert isinstance(platforms, Platforms)
for api in platforms.get_apis():