summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-02-05 05:10:19 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-02-05 05:10:19 +0000
commit6141b037a98ae641eb60f5344d244252871a21cf (patch)
tree87e40d40c87ba2f04129228aa7b24c09b81336ba
parent31259c52ff76d16d758e6234ea2ac4778a0e59f3 (diff)
downloadbcm5719-llvm-6141b037a98ae641eb60f5344d244252871a21cf.tar.gz
bcm5719-llvm-6141b037a98ae641eb60f5344d244252871a21cf.zip
gn build: Upgrade to NDK r19.
NDK r19 includes a sysroot that can be used directly by the compiler without creating a standalone toolchain, so we just need a handful of flags to point Clang there. Differential Revision: https://reviews.llvm.org/D57733 llvm-svn: 353139
-rw-r--r--compiler-rt/CMakeLists.txt3
-rw-r--r--compiler-rt/test/hwasan/TestCases/sizes.cpp4
-rw-r--r--compiler-rt/test/lit.common.cfg7
-rw-r--r--compiler-rt/test/lit.common.configured.in1
-rw-r--r--llvm/utils/gn/build/BUILD.gn2
-rw-r--r--llvm/utils/gn/build/toolchain/compiler.gni2
-rw-r--r--llvm/utils/gn/build/toolchain/target_flags.gni26
-rw-r--r--llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn1
-rw-r--r--llvm/utils/gn/secondary/compiler-rt/test/test.gni3
9 files changed, 20 insertions, 29 deletions
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index bc0233c3675..3b2b5145f9c 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -157,6 +157,9 @@ if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*android.*")
endif()
pythonize_bool(ANDROID)
+set(ANDROID_NDK_VERSION 18
+ CACHE STRING "Set this to the Android NDK version that you are using")
+
set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/compiler-rt/test/hwasan/TestCases/sizes.cpp b/compiler-rt/test/hwasan/TestCases/sizes.cpp
index 52217de746e..8effe3c5435 100644
--- a/compiler-rt/test/hwasan/TestCases/sizes.cpp
+++ b/compiler-rt/test/hwasan/TestCases/sizes.cpp
@@ -1,4 +1,6 @@
-// RUN: %clangxx_hwasan %s -lstdc++ -o %t
+// This test requires operator new to be intercepted by the hwasan runtime,
+// so we need to avoid linking against libc++.
+// RUN: %clangxx_hwasan %s -nostdlib++ -lstdc++ -o %t
// RUN: %env_hwasan_opts=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-max
// RUN: %env_hwasan_opts=allocator_may_return_null=1 %run %t malloc 2>&1
// RUN: %env_hwasan_opts=allocator_may_return_null=0 not %run %t malloc max 2>&1 | FileCheck %s --check-prefix=CHECK-max
diff --git a/compiler-rt/test/lit.common.cfg b/compiler-rt/test/lit.common.cfg
index 6688c717a02..6965fa6f418 100644
--- a/compiler-rt/test/lit.common.cfg
+++ b/compiler-rt/test/lit.common.cfg
@@ -60,7 +60,12 @@ if config.asan_shadow_scale != '':
if config.android:
# Prepend the flag so that it can be overridden.
config.target_cflags = "-pie -fuse-ld=gold " + config.target_cflags
- config.cxx_mode_flags.append('-stdlib=libstdc++')
+ 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++')
# Clear some environment variables that might affect Clang.
possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS',
diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in
index df326a6b555..e1884b409e5 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -36,6 +36,7 @@ set_default("use_thinlto", False)
set_default("use_lto", config.use_thinlto)
set_default("use_newpm", False)
set_default("android", @ANDROID_PYBOOL@)
+set_default("android_ndk_version", @ANDROID_NDK_VERSION@)
set_default("android_serial", "@ANDROID_SERIAL_FOR_TESTING@")
set_default("android_files_to_push", [])
set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@)
diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index e33cde23773..e323f99ac65 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -10,7 +10,7 @@ config("compiler_defaults") {
defines += [ "NDEBUG" ]
}
- cflags = target_flags + target_cflags
+ cflags = target_flags
ldflags = target_flags + target_ldflags
if (host_os == "mac" && clang_base_path != "") {
diff --git a/llvm/utils/gn/build/toolchain/compiler.gni b/llvm/utils/gn/build/toolchain/compiler.gni
index 3c419fb29a1..37ad1f5bc31 100644
--- a/llvm/utils/gn/build/toolchain/compiler.gni
+++ b/llvm/utils/gn/build/toolchain/compiler.gni
@@ -10,7 +10,7 @@ declare_args() {
# Example value: getenv("HOME") + "/src/llvm-build/Release+Asserts"
clang_base_path = ""
- # Set this to the path to Android NDK r18b. If set, cross compilation targeting
+ # Set this to the path to Android NDK r19. If set, cross compilation targeting
# Android will be enabled.
android_ndk_path = ""
}
diff --git a/llvm/utils/gn/build/toolchain/target_flags.gni b/llvm/utils/gn/build/toolchain/target_flags.gni
index 6b6373a0093..3ad02a969fd 100644
--- a/llvm/utils/gn/build/toolchain/target_flags.gni
+++ b/llvm/utils/gn/build/toolchain/target_flags.gni
@@ -2,33 +2,13 @@ import("//llvm/triples.gni")
import("//llvm/utils/gn/build/toolchain/compiler.gni")
target_flags = []
-target_cflags = []
target_ldflags = []
if (current_os == "android") {
- assert(current_cpu == "arm64", "current_cpu not supported")
-
- libcxx_path = "$android_ndk_path/sources/cxx-stl/llvm-libc++"
- platform_lib_path =
- "$android_ndk_path/platforms/android-21/arch-arm64/usr/lib"
- libgcc_path = "$android_ndk_path/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x"
-
target_flags += [
"--target=$llvm_current_triple",
- "--sysroot=$android_ndk_path/sysroot",
- ]
- target_cflags += [
- "-isystem",
- "$libcxx_path/include",
- ]
- target_ldflags += [
- "-B$platform_lib_path",
- "-L$platform_lib_path",
- "-L$libgcc_path",
- ]
- target_ldflags += [
- "-nostdlib++",
- "-L$libcxx_path/libs/arm64-v8a",
- "-l:libc++.a.21",
+ "--sysroot=$android_ndk_path/toolchains/llvm/prebuilt/linux-x86_64/sysroot",
+ "-B$android_ndk_path/toolchains/llvm/prebuilt/linux-x86_64",
]
+ target_ldflags += [ "-static-libstdc++" ]
}
diff --git a/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
index 90a9201681a..a5fa1a3f9fb 100644
--- a/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
@@ -47,6 +47,7 @@ write_cmake_config("lit_common_configured") {
"SANITIZER_CAN_USE_CXXABI_PYBOOL=True",
"COMPILER_RT_HAS_LLD_PYBOOL=True",
"HAVE_RPC_XDR_H=0",
+ "ANDROID_NDK_VERSION=19",
"ANDROID_SERIAL_FOR_TESTING=$android_serial_for_testing",
]
diff --git a/llvm/utils/gn/secondary/compiler-rt/test/test.gni b/llvm/utils/gn/secondary/compiler-rt/test/test.gni
index 4144482bcbd..e2335933659 100644
--- a/llvm/utils/gn/secondary/compiler-rt/test/test.gni
+++ b/llvm/utils/gn/secondary/compiler-rt/test/test.gni
@@ -7,8 +7,7 @@ declare_args() {
target_flags_string = ""
-foreach(flag,
- target_flags + target_cflags + target_ldflags + [ "-fuse-ld=lld" ]) {
+foreach(flag, target_flags + target_ldflags + [ "-fuse-ld=lld" ]) {
if (target_flags_string != "") {
target_flags_string += " "
}
OpenPOWER on IntegriCloud