[compiler-rt] 707d69f - Use LLD for Android compiler-rt

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 00:51:26 PST 2020


Author: Vy Nguyen
Date: 2020-11-04T00:51:18-08:00
New Revision: 707d69ff32309bf244552c1a8e7335bb7bbc951e

URL: https://github.com/llvm/llvm-project/commit/707d69ff32309bf244552c1a8e7335bb7bbc951e
DIFF: https://github.com/llvm/llvm-project/commit/707d69ff32309bf244552c1a8e7335bb7bbc951e.diff

LOG: Use LLD for Android compiler-rt

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D90720

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt
    compiler-rt/test/asan/TestCases/Linux/globals-gc-sections-lld.cpp
    compiler-rt/test/lit.common.cfg.py
    compiler-rt/test/lit.common.configured.in

Removed: 
    


################################################################################
diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 1705a005caef..bb8b81e2d51f 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -597,7 +597,18 @@ else()
     set(COMPILER_RT_HAS_LLD TRUE)
   endif()
 endif()
+
+if(ANDROID)
+  set(COMPILER_RT_HAS_LLD TRUE)
+  set(COMPILER_RT_TEST_USE_LLD TRUE)
+  append_list_if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG -fuse-ld=lld SANITIZER_COMMON_LINK_FLAGS)
+  append_list_if(COMPILER_RT_HAS_LLD -fuse-ld=lld COMPILER_RT_UNITTEST_LINK_FLAGS)
+  if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
+    set(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT FALSE)
+  endif()
+endif()
 pythonize_bool(COMPILER_RT_HAS_LLD)
+pythonize_bool(COMPILER_RT_TEST_USE_LLD)
 
 add_subdirectory(lib)
 

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
index 0d8bcdd1cb17..f6edc7032018 100644
--- 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
index 742da04fe059..dc616f914c6d 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -60,18 +60,6 @@
 if config.memprof_shadow_scale != '':
   config.target_cflags += " -mllvm -memprof-mapping-scale=" + config.memprof_shadow_scale
 
-# BFD linker in 64-bit android toolchains fails to find libc++_shared.so, which
-# 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
-  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
-    # just contains a handful of ABI functions", which makes most C++ code fail
-    # to link. In r19 and later we just use the default which is libc++.
-    config.cxx_mode_flags.append('-stdlib=libstdc++')
-
 config.environment = dict(os.environ)
 
 # Clear some environment variables that might affect Clang.

diff  --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in
index 92eb8c58ca6b..626c847f25ba 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -35,7 +35,7 @@ set_default("apple_platform_min_deployment_target_flag", "-mmacosx-version-min")
 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", @COMPILER_RT_TEST_USE_LLD_PYBOOL@)
 set_default("use_thinlto", False)
 set_default("use_lto", config.use_thinlto)
 set_default("use_newpm", False)


        


More information about the llvm-commits mailing list