diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -425,6 +425,7 @@ # Set common link flags. append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS) append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS) +append_list_if(ANDROID -fuse-ld=lld SANITIZER_COMMON_LINK_FLAGS) if (COMPILER_RT_USE_BUILTINS_LIBRARY) string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -91,6 +91,7 @@ endif() if(ANDROID) list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS -pie) + list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS -fuse-ld=lld) endif() set(ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS diff --git a/compiler-rt/test/asan/TestCases/Linux/globals-gc-sections-lld.cpp b/compiler-rt/test/asan/TestCases/Linux/globals-gc-sections-lld.cpp --- a/compiler-rt/test/asan/TestCases/Linux/globals-gc-sections-lld.cpp +++ b/compiler-rt/test/asan/TestCases/Linux/globals-gc-sections-lld.cpp @@ -3,7 +3,8 @@ // https://code.google.com/p/address-sanitizer/issues/detail?id=260 // REQUIRES: lld - +// FIXME: This may pass on Android, with non-emulated-tls. +// XFAIL: android int undefined(); // On i386 clang adds --export-dynamic when linking with ASan, which adds all diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -64,7 +64,7 @@ # is a transitive shared library dependency (via asan runtime). if config.android: # Prepend the flag so that it can be overridden. - config.target_cflags = "-pie -fuse-ld=gold " + config.target_cflags + config.target_cflags = "-pie -fuse-ld=lld " + config.target_cflags if config.android_ndk_version < 19: # With a new compiler and NDK < r19 this flag ends up meaning "link against # libc++", but NDK r19 makes this mean "link against the stub libstdc++ that diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in --- a/compiler-rt/test/lit.common.configured.in +++ b/compiler-rt/test/lit.common.configured.in @@ -35,7 +35,7 @@ set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@) set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@) set_default("can_symbolize", @CAN_SYMBOLIZE@) -set_default("use_lld", False) +set_default("use_lld", @ANDROID_PYBOOL@) set_default("use_thinlto", False) set_default("use_lto", config.use_thinlto) set_default("use_newpm", False)