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})
-// 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
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',
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@)
defines += [ "NDEBUG" ]
}
- cflags = target_flags + target_cflags
+ cflags = target_flags
ldflags = target_flags + target_ldflags
if (host_os == "mac" && clang_base_path != "") {
# 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 = ""
}
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++" ]
}
"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",
]
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 += " "
}