Commit 2a59f25d authored by bsheedy's avatar bsheedy Committed by Commit Bot

Reland "Update Android NDK to r16"

This is a reland of 2c1e0069
Original change's description:
> Update Android NDK to r16
>
> This contains all the src/ changes necessary to make
> Chromium compile with Android NDK r16. Most changes
> are to make the code compatible with the unified
> headers that are used now.
>
> The libwebm revision is updated to a newer version in
> order to get a fix for using unified headers that was
> added a while back, but never rolled into Chromium.
>
> Sister CLs:
> src/third_party/skia/: https://skia-review.googlesource.com/c/skia/+/75422
> src/third_party/android_tools/ndk/: https://chromium-review.googlesource.com/c/android_ndk/+/784230
>
> Bug: 771171
> Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
> Change-Id: I643f9f7bd75d111e540778d2fdf8c20851485a5a
> Reviewed-on: https://chromium-review.googlesource.com/777822
> Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
> Reviewed-by: Scott Graham <scottmg@chromium.org>
> Reviewed-by: Zhongyi Shi <zhongyi@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Ryan Sturm <ryansturm@chromium.org>
> Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
> Reviewed-by: agrieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#525076}

TBR=rsesek@chromium.org,pfeldman@chromium.org,scottmg@chromium.org,zhongyi@chromium.org,dcheng@chromium.org,dalecurtis@chromium.org

Bug: 771171
Change-Id: I5e2288bf3f94359a0afe6c16293bcdecd0f02514
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Reviewed-on: https://chromium-review.googlesource.com/834609Reviewed-by: default avataragrieve <agrieve@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#527029}
parent bf124ca1
......@@ -263,7 +263,7 @@ deps = {
},
'src/third_party/android_tools': {
'url': Var('chromium_git') + '/android_tools.git' + '@' + 'a2e9bc7c1b41d983577907df51d339fb1e0fd02f',
'url': Var('chromium_git') + '/android_tools.git' + '@' + '7d781b3544ef67dfa8c7c0c1a347b818c49c42bc',
'condition': 'checkout_android',
},
......@@ -271,7 +271,7 @@ deps = {
Var('chromium_git') + '/angle/angle.git' + '@' + Var('angle_revision'),
'src/third_party/apache-portable-runtime/src': {
'url': Var('chromium_git') + '/external/apache-portable-runtime.git' + '@' + 'c76a8c4277e09a82eaa229e35246edea1ee0a6a1',
'url': Var('chromium_git') + '/external/apache-portable-runtime.git' + '@' + 'c3f11fcd86b42922834cae91103cf068246c6bb6',
'condition': 'checkout_android',
},
......@@ -292,7 +292,7 @@ deps = {
Var('boringssl_git') + '/boringssl.git' + '@' + Var('boringssl_revision'),
'src/third_party/breakpad/breakpad':
Var('chromium_git') + '/breakpad/breakpad.git' + '@' + '4af3e83b10b17bbd31099d55c2e272d56fb0ef13',
Var('chromium_git') + '/breakpad/breakpad.git' + '@' + '4a02ec03038d9d6f870f42d5070591512f488db0',
'src/third_party/catapult':
Var('chromium_git') + '/catapult.git' + '@' + Var('catapult_revision'),
......@@ -478,7 +478,7 @@ deps = {
Var('chromium_git') + '/webm/libvpx.git' + '@' + 'a2127236ae4742f329e5571d76b84de08cd3b8ea',
'src/third_party/libwebm/source':
Var('chromium_git') + '/webm/libwebm.git' + '@' + '4956b2dec65352af32dc71bab553acb631c64177',
Var('chromium_git') + '/webm/libwebm.git' + '@' + 'b03c65468b06d097f27235d93d76bfc45f490ede',
'src/third_party/libyuv':
Var('chromium_git') + '/libyuv/libyuv.git' + '@' + 'c67db6053495a2744511a43ba7b6ba3fa49b26a5', # from r1685
......
......@@ -9,6 +9,9 @@
#if defined(OS_ANDROID) && __ANDROID_API__ < 17
#include <dlfcn.h>
// This is defined in malloc.h on other platforms. We just need the definition
// for the decltype(malloc_usable_size)* call to work.
size_t malloc_usable_size(const void*);
#endif
// This translation unit defines a default dispatch for the allocator shim which
......
......@@ -93,7 +93,8 @@ bool GenericLoadLibrary(JNIEnv* env,
crazy_context_t* context = GetCrazyContext();
if (!IsValidAddress(load_address)) {
LOG_ERROR("Invalid address 0x%llx", load_address);
LOG_ERROR("Invalid address 0x%llx",
static_cast<unsigned long long>(load_address));
return false;
}
......@@ -328,7 +329,8 @@ jboolean CreateSharedRelro(JNIEnv* env,
LOG_INFO("Called for %s", lib_name.c_str());
if (!IsValidAddress(load_address)) {
LOG_ERROR("Invalid address 0x%llx", load_address);
LOG_ERROR("Invalid address 0x%llx",
static_cast<unsigned long long>(load_address));
return false;
}
......
......@@ -24,7 +24,8 @@
namespace base {
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) || \
defined(OS_ANDROID) && __ANDROID_API__ < 21
typedef struct stat stat_wrapper_t;
#elif defined(OS_POSIX)
typedef struct stat64 stat_wrapper_t;
......
......@@ -30,7 +30,8 @@ static_assert(File::FROM_BEGIN == SEEK_SET && File::FROM_CURRENT == SEEK_CUR &&
namespace {
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) || \
defined(OS_ANDROID) && __ANDROID_API__ < 21
int CallFstat(int fd, stat_wrapper_t *sb) {
AssertBlockingAllowed();
return fstat(fd, sb);
......
......@@ -68,7 +68,8 @@ namespace base {
namespace {
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) || \
defined(OS_ANDROID) && __ANDROID_API__ < 21
static int CallStat(const char *path, stat_wrapper_t *sb) {
AssertBlockingAllowed();
return stat(path, sb);
......@@ -77,7 +78,8 @@ static int CallLstat(const char *path, stat_wrapper_t *sb) {
AssertBlockingAllowed();
return lstat(path, sb);
}
#else // defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
#else // defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) ||
// defined(OS_ANDROID) && __ANDROID_API__ < 21
static int CallStat(const char *path, stat_wrapper_t *sb) {
AssertBlockingAllowed();
return stat64(path, sb);
......
......@@ -10,6 +10,7 @@
#include <math.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <unistd.h>
#if !defined(__LP64__)
#include <time64.h>
......
......@@ -18,15 +18,4 @@ extern "C" char* mkdtemp(char* path);
// Android has no timegm().
extern "C" time_t timegm(struct tm* const t);
// The lockf() function is not available on Android; we translate to flock().
#define F_LOCK LOCK_EX
#define F_ULOCK LOCK_UN
inline int lockf(int fd, int cmd, off_t ignored_len) {
return flock(fd, cmd);
}
// In case __USE_FILE_OFFSET64 is not used, we need to call pwrite64() instead
// of pwrite()
#define pwrite(fd, buf, count, offset) pwrite64(fd, buf, count, offset)
#endif // BASE_OS_COMPAT_ANDROID_H_
......@@ -48,27 +48,54 @@ config("compiler") {
"-Wl,--exclude-libs=libvpx_assembly_arm.a",
]
# $compile_api_level corresponds to the API level used for the sysroot path
# calculation in //build/config/android/config.gni
if (current_cpu == "arm") {
abi_target = "arm-linux-androideabi"
compile_api_level = 16
} else if (current_cpu == "x86") {
abi_target = "i686-linux-androideabi"
abi_target = "i686-linux-android"
compile_api_level = 16
} else if (current_cpu == "arm64") {
abi_target = "aarch64-linux-android"
compile_api_level = 21
} else if (current_cpu == "x64") {
# Place holder for x64 support, not tested.
# TODO: Enable clang support for Android x64. http://crbug.com/539781
abi_target = "x86_64-linux-androideabi"
abi_target = "x86_64-linux-android"
compile_api_level = 21
} else if (current_cpu == "mipsel") {
abi_target = "mipsel-linux-android"
compile_api_level = 16
} else if (current_cpu == "mips64el") {
# Place holder for mips64 support, not tested.
abi_target = "mips64el-linux-androideabi"
compile_api_level = 21
} else {
assert(false, "Architecture not supported")
}
cflags += [ "--target=$abi_target" ]
cflags += [
"--target=$abi_target",
"-isystem" +
rebase_path("$android_ndk_root/sysroot/usr/include/$abi_target",
root_build_dir),
"-D__ANDROID_API__=$compile_api_level",
# Temporary workaround for third party dependencies requiring this to be
# defined.
# TODO(crbug.com/771171): Remove this once the third party deps have been
# fixed to be compatible with newer NDK versions
"-D__NDK_FPABI__=",
]
ldflags += [ "--target=$abi_target" ]
# TODO(crbug.com/771171): Remove this define once code that uses it has been
# updated to no longer need it. This is leftover from older Android NDK
# versions.
if (compile_api_level < 20) {
cflags += [ "-DHAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC=1" ]
}
# Assign any flags set for the C compiler to asmflags so that they are sent
# to the assembler.
asmflags = cflags
......
......@@ -44,8 +44,8 @@ if (is_android) {
if (!defined(default_android_ndk_root)) {
default_android_ndk_root = "//third_party/android_tools/ndk"
default_android_ndk_version = "r12b"
default_android_ndk_major_version = 12
default_android_ndk_version = "r16"
default_android_ndk_major_version = 16
} else {
assert(defined(default_android_ndk_version))
assert(defined(default_android_ndk_major_version))
......
......@@ -324,10 +324,12 @@ config("compiler") {
ldflags += [ "-Wl,--build-id=sha1" ]
}
defines += [ "_FILE_OFFSET_BITS=64" ]
if (!is_android) {
defines += [
# _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain
# the behavior of the Android NDK from earlier versions.
# See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
"_FILE_OFFSET_BITS=64",
"_LARGEFILE_SOURCE",
"_LARGEFILE64_SOURCE",
]
......
......@@ -92,8 +92,33 @@ config("runtime_library") {
if (!is_mac && !is_ios && sysroot != "") {
# Pass the sysroot to all C compiler variants, the assembler, and linker.
sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
# Android uses unified headers in NDK r16 and later, meaning that the
# compile time sysroot and link time sysroot are different
link_sysroot = sysroot
if (is_android) {
if (current_cpu == "arm") {
link_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir"
} else if (current_cpu == "arm64") {
link_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir"
} else if (current_cpu == "x86") {
link_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir"
} else if (current_cpu == "x64") {
link_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir"
} else if (current_cpu == "mipsel") {
link_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir"
} else if (current_cpu == "mips64el") {
link_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir"
} else {
assert(false, "No android link sysroot for cpu: $target_cpu")
}
}
asmflags += sysroot_flags
ldflags += sysroot_flags
link_sysroot_flags =
[ "--sysroot=" + rebase_path(link_sysroot, root_build_dir) ]
ldflags += link_sysroot_flags
# When use_custom_libcxx=true, some -isystem flags get passed to
# cflags_cc to set up libc++ include paths. We want to make sure
......@@ -113,7 +138,7 @@ config("runtime_library") {
[
rebase_path("//build/linux/sysroot_ld_path.sh",
root_build_dir),
rebase_path(sysroot),
rebase_path(link_sysroot),
],
"list lines")
foreach(ld_path, ld_paths) {
......
......@@ -25,21 +25,9 @@ if (current_os == target_os && current_cpu == target_cpu &&
sysroot = target_sysroot
} else if (is_android) {
import("//build/config/android/config.gni")
if (current_cpu == "x86") {
sysroot = "$android_ndk_root/$x86_android_sysroot_subdir"
} else if (current_cpu == "arm") {
sysroot = "$android_ndk_root/$arm_android_sysroot_subdir"
} else if (current_cpu == "mipsel") {
sysroot = "$android_ndk_root/$mips_android_sysroot_subdir"
} else if (current_cpu == "x64") {
sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir"
} else if (current_cpu == "arm64") {
sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir"
} else if (current_cpu == "mips64el") {
sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir"
} else {
assert(false, "No android sysroot for cpu: $target_cpu")
}
# Android uses unified headers, and thus a single compile time sysroot
sysroot = "$android_ndk_root/sysroot"
} else if (is_linux && use_sysroot) {
# By default build against a sysroot image downloaded from Cloud Storage
# during gclient runhooks.
......
......@@ -13,8 +13,8 @@ if (current_toolchain == default_toolchain &&
(!is_debug && !using_sanitizer && proprietary_codecs)) {
# Define expectations only for target_cpu covered by trybots.
if (target_cpu == "arm") {
expected_static_initializer_count = 7
expected_static_initializer_count = 8
} else if (target_cpu == "arm64") {
expected_static_initializer_count = 3
expected_static_initializer_count = 4
}
}
......@@ -216,7 +216,9 @@ DataReductionProxySettingsAndroid::GetDailyContentLengths(
if (!lengths.empty()) {
DCHECK_EQ(lengths.size(), data_reduction_proxy::kNumDaysInHistory);
env->SetLongArrayRegion(result, 0, lengths.size(), &lengths[0]);
std::vector<jlong> lengths_jlong(lengths.begin(), lengths.end());
env->SetLongArrayRegion(result, 0, lengths_jlong.size(),
lengths_jlong.data());
return ScopedJavaLocalRef<jlongArray>(env, result);
}
......
......@@ -41,7 +41,7 @@
#include "third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h"
#if defined(OS_ANDROID) && !defined(__LP64__)
#include <sys/linux-syscalls.h>
#include <sys/syscall.h>
#define SYS_read __NR_read
#endif
......
......@@ -4,11 +4,7 @@
#include "device/usb/usb_device_handle_usbfs.h"
#if defined(OS_ANDROID) && __ANDROID_API__ < 21
#include <linux/usb_ch9.h>
#else
#include <linux/usb/ch9.h>
#endif
#include <linux/usbdevice_fs.h>
#include <sys/ioctl.h>
......
......@@ -23,28 +23,6 @@
} \
} while (0)
// On N MR1+ we want to use high buffer sizes for power saving. Per Android
// audio team, this should be in N MR1+ SDK, but it's not, so use a defined()
// check instead of __API_LEVEL__ check.
#if !defined(SL_ANDROID_KEY_PERFORMANCE_MODE)
#define SL_ANDROID_KEY_PERFORMANCE_MODE \
((const SLchar*)"androidPerformanceMode")
// No specific performance requirement. Allows HW and SW pre/post processing.
#define SL_ANDROID_PERFORMANCE_NONE ((SLuint32)0x00000000)
// Priority given to latency. No HW or software pre/post processing. This is the
// default if no performance mode is specified.
#define SL_ANDROID_PERFORMANCE_LATENCY ((SLuint32)0x00000001)
// Priority given to latency while still allowing HW pre and post processing.
#define SL_ANDROID_PERFORMANCE_LATENCY_EFFECTS ((SLuint32)0x00000002)
// Priority given to power saving if latency is not a concern. Allows HW and SW
// pre/post processing.
#define SL_ANDROID_PERFORMANCE_POWER_SAVING ((SLuint32)0x00000003)
#endif
namespace media {
OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager,
......
......@@ -21,25 +21,6 @@
#include "media/base/audio_parameters.h"
#include "media/base/audio_timestamp_helper.h"
// On L+, we want to use floating point output for better fidelity.
#if __ANDROID_API__ < 21
#define SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT ((SLuint32)0x00000001)
#define SL_ANDROID_PCM_REPRESENTATION_UNSIGNED_INT ((SLuint32)0x00000002)
#define SL_ANDROID_PCM_REPRESENTATION_FLOAT ((SLuint32)0x00000003)
#define SL_ANDROID_DATAFORMAT_PCM_EX ((SLuint32)0x00000004)
typedef struct SLAndroidDataFormat_PCM_EX_ {
SLuint32 formatType;
SLuint32 numChannels;
SLuint32 sampleRate;
SLuint32 bitsPerSample;
SLuint32 containerSize;
SLuint32 channelMask;
SLuint32 endianness;
SLuint32 representation;
} SLAndroidDataFormat_PCM_EX;
#endif
namespace media {
class AudioManagerAndroid;
......
......@@ -9,6 +9,16 @@
// proxies for those constants and redefine those when the library is first
// loaded. For this, it need to be able to change their content and so import
// the headers without const. This is correct because OpenSLES.h is a C API.
// We include stdint.h here as a workaround for an issue caused by the
// #define const below. The inclusion of OpenSLES headers on newer Android NDK
// versions causes stdint.h to be included, which in turn includes __config.
// This causes the declaration of __sanitizer_annotate_contiguous_container to
// not use const parameters, which causes compile issues when building with
// asan. Including here forces __config to be included while const is still
// untouched.
#include <stdint.h>
#define const
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
......
......@@ -41,8 +41,6 @@
#if defined(OS_ANDROID)
#include <dlfcn.h>
// This was added in Lollipop to dlfcn.h
#define RTLD_NOLOAD 4
#include "base/android/build_info.h"
#include "base/native_library.h"
#include "base/strings/utf_string_conversions.h"
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <unistd.h>
#include "sandbox/linux/syscall_broker/broker_command.h"
#include "sandbox/linux/syscall_broker/broker_permission_list.h"
......
......@@ -7,6 +7,7 @@
#include <fcntl.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <string>
......
......@@ -197,6 +197,12 @@ void StatFileForIPC(const BrokerCommandSet& allowed_command_set,
write_pickle->WriteData(reinterpret_cast<char*>(&sb), sizeof(sb));
} else {
DCHECK(command_type == COMMAND_STAT64);
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
// stat64 is not defined for older Android API versions in newer NDK
// versions.
write_pickle->WriteInt(-ENOSYS);
return;
#else
struct stat64 sb;
if (stat64(file_to_access, &sb) < 0) {
write_pickle->WriteInt(-errno);
......@@ -204,6 +210,7 @@ void StatFileForIPC(const BrokerCommandSet& allowed_command_set,
}
write_pickle->WriteInt(0);
write_pickle->WriteData(reinterpret_cast<char*>(&sb), sizeof(sb));
#endif // defined(__ANDROID_API__) && __ANDROID_API__ < 21
}
}
......
......@@ -241,7 +241,7 @@ _Unwind_Ptr LibraryList::FindArmExIdx(void* pc, int* count) {
}
}
*count = 0;
return NULL;
return static_cast<_Unwind_Ptr>(NULL);
}
#else // !__arm__
int LibraryList::IteratePhdr(PhdrIterationCallback callback, void* data) {
......
......@@ -7,6 +7,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
namespace {
......
......@@ -9,6 +9,8 @@
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <cstdlib>
#include <cstring>
namespace crazy {
......
......@@ -234,7 +234,8 @@ _Unwind_Ptr WrapDl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
{
ScopedGlobalLock lock;
LibraryList* list = Globals::GetLibraries();
_Unwind_Ptr result = list->FindArmExIdx(pc, pcount);
_Unwind_Ptr result =
list->FindArmExIdx(reinterpret_cast<void*>(pc), pcount);
if (result)
return result;
}
......
......@@ -6,6 +6,7 @@
#include <jni.h>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
extern "C" {
JNIEXPORT void JNICALL
......@@ -40,10 +41,9 @@ JNIEXPORT void JNICALL
}
g_memory = static_cast<uint32_t*>(malloc(memory));
if (!g_memory) {
__android_log_print(ANDROID_LOG_WARN,
"MemConsumer",
__android_log_print(ANDROID_LOG_WARN, "MemConsumer",
"Unable to allocate %lld bytes",
memory);
static_cast<long long>(memory));
}
// If memory allocation failed, try to allocate as much as possible.
while (!g_memory) {
......
......@@ -17,6 +17,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
/*
* This is a helper daemon for Android which makes memtrack graphics information
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment