Skip to content

Commit

Permalink
Reland "Update Android NDK to r16"
Browse files Browse the repository at this point in the history
This is a reland of 2c1e006
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/834609
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Ryan Sturm <ryansturm@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#527029}
  • Loading branch information
bsheedy authored and Commit Bot committed Jan 4, 2018
1 parent bf124ca commit 2a59f25
Show file tree
Hide file tree
Showing 30 changed files with 122 additions and 101 deletions.
8 changes: 4 additions & 4 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ 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',
},

'src/third_party/angle':
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',
},

Expand All @@ -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'),
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions base/android/linker/legacy_linker_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion base/files/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion base/files/file_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions base/files/file_util_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions base/os_compat_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <math.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <unistd.h>

#if !defined(__LP64__)
#include <time64.h>
Expand Down
11 changes: 0 additions & 11 deletions base/os_compat_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
33 changes: 30 additions & 3 deletions build/config/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build/config/android/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 4 additions & 2 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
29 changes: 27 additions & 2 deletions build/config/posix/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
18 changes: 3 additions & 15 deletions build/config/sysroot.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions chrome/android/static_initializers.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions device/usb/usb_device_handle_usbfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
22 changes: 0 additions & 22 deletions media/audio/android/opensles_output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 0 additions & 19 deletions media/audio/android/opensles_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions media/audio/android/opensles_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading

0 comments on commit 2a59f25

Please sign in to comment.