Skip to content

Commit

Permalink
Build 32- and 64-bit Android mojo_core for Chrome OS distribution
Browse files Browse the repository at this point in the history
Causes Chrome builds for Chrome OS to emit additional 32-bit and
64-bit copies of the mojo_core shared library built against the
Android toolchain, for use from within the ARC++ container.

In order to support building these library targets, this also
modifies DEPS to include a minimal set of required Android support
tools and libraries in chromeos checkouts.

Bug: 822034
Change-Id: I219837de3076490cdea8315e6cc98c5432871ea0
Reviewed-on: https://chromium-review.googlesource.com/1026203
Commit-Queue: Ken Rockot <rockot@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554617}
  • Loading branch information
krockot authored and Commit Bot committed Apr 28, 2018
1 parent 78ac2b9 commit 58eabf0
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 29 deletions.
11 changes: 8 additions & 3 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
gclient_gn_args_file = 'src/build/config/gclient_args.gni'
gclient_gn_args = [
'checkout_android',
'checkout_android_native_support',
'checkout_libaom',
'checkout_nacl',
'checkout_oculus_sdk',
Expand All @@ -42,6 +43,10 @@ vars = {
# purposes.
'checkout_configuration': 'default',

# Pull in Android native toolchain dependencies for Chrome OS too, so we can
# build ARC++ support libraries.
'checkout_android_native_support': 'checkout_android or checkout_chromeos',

# By default, do not check out android sdk sources. This can be overridden
# e.g. with custom_vars.
'checkout_android_sdk_sources': False,
Expand Down Expand Up @@ -338,7 +343,7 @@ deps = {

'src/third_party/android_ndk': {
'url': Var('chromium_git') + '/android_ndk.git' + '@' + '635bc380968a76f6948fee65f80a0b28db53ae81',
'condition': 'checkout_android',
'condition': 'checkout_android_native_support',
},

'src/third_party/android_support_test_runner': {
Expand All @@ -365,7 +370,7 @@ deps = {

'src/third_party/android_tools': {
'url': Var('chromium_git') + '/android_tools.git' + '@' + 'c22a664c39af72dd8f89200220713dcad811300a',
'condition': 'checkout_android',
'condition': 'checkout_android_native_support',
},

'src/third_party/android_sdk/public': {
Expand Down Expand Up @@ -524,7 +529,7 @@ deps = {

'src/third_party/elfutils/src': {
'url': Var('chromium_git') + '/external/elfutils.git' + '@' + '249673729a7e5dbd5de4f3760bdcaa3d23d154d7',
'condition': 'checkout_android',
'condition': 'checkout_android_native_support',
},

'src/third_party/errorprone/lib': {
Expand Down
8 changes: 7 additions & 1 deletion build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ config("feature_flags") {
if (use_nss_certs) {
defines += [ "USE_NSS_CERTS=1" ]
}
if (use_ozone) {
if (use_ozone && !is_android) {
# Note that some Chrome OS builds unconditionally set |use_ozone| to true,
# but they also build some targets with the Android toolchain. This ensures
# that Android targets still build with USE_OZONE=0 in such cases.
#
# TODO(crbug.com/837032): Maybe this can be cleaned up if we can avoid
# setting use_ozone globally.
defines += [ "USE_OZONE=1" ]
}
if (use_x11) {
Expand Down
5 changes: 4 additions & 1 deletion build/config/android/abi.gni
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
# Logic separated out from config.gni so that it can be used by compiler.gni
# without introducing a circular dependency.

assert(is_android)
# NOTE: Because Chrome OS builds may depend on targets built with the Android
# toolchain, this GNI file may be read and processed from within Chrome OS
# toolchains. Checking |is_android| here would therefore be too restrictive.
assert(is_android || is_chromeos)

declare_args() {
# Adds intrumentation to each function. Writes a file with the order that
Expand Down
13 changes: 9 additions & 4 deletions build/config/android/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

# This file contains common system config stuff for the Android build.

if (is_android) {
# NOTE: Because Chrome OS builds may depend on targets built with the Android
# toolchain, this GNI file may be read and processed from within Chrome OS
# toolchains. Checking |is_android| here would therefore be too restrictive.
if (is_android || is_chromeos) {
import("//build_overrides/build.gni")
import("abi.gni")

Expand All @@ -13,9 +16,11 @@ if (is_android) {
# heavily but don't write gclient args files.

import("//build/config/gclient_args.gni")
if (defined(checkout_android)) {
assert(checkout_android,
"target_os in your .gclient configuration must include android.")
if (defined(checkout_android_native_support)) {
assert(checkout_android_native_support,
"Missing native Android toolchain support. |target_os| in your " +
".gclient configuration must include \"android\" and/or " +
"\"chromeos\".")
}
}

Expand Down
17 changes: 15 additions & 2 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,14 @@ config("compiler") {
ldflags += [ "--gcc-toolchain=$_rebased_android_toolchain_root" ]
}

if ((is_posix || is_fuchsia) && use_lld && !is_nacl) {
if (((is_posix || is_fuchsia) && use_lld && !is_nacl) ||
(target_os == "chromeos" && is_android)) {
# NOTE: Some Chrome OS builds globally disable LLD, but they also build some
# targets against Android toolchains which should use LLD. Therefore we
# explicitly select LLD in these cases.
#
# TODO(https://crbug.com/837095): This should be cleaned up if/when LLD can
# work properly for Chrome OS builds.
ldflags += [ "-fuse-ld=lld" ]
if (current_cpu == "arm64") {
# Reduce the page size from 65536 in order to reduce binary size slightly
Expand Down Expand Up @@ -2116,7 +2123,13 @@ config("symbols") {
}
cflags += [ "-g2" ]
}
if (use_debug_fission && !is_nacl) {
if (use_debug_fission && !is_nacl && !is_android) {
# NOTE: Some Chrome OS builds globally set |use_debug_fission| to true,
# but they also build some targets against Android toolchains which aren't
# compatible with it.
#
# TODO(https://crbug.com/837032): See if we can clean this up by e.g. not
# setting use_debug_fission globally.
cflags += [ "-gsplit-dwarf" ]
}
asmflags = cflags
Expand Down
4 changes: 3 additions & 1 deletion build/config/compiler/compiler.gni
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ if (symbol_level == -1) {
}

# Assert that the configuration isn't going to hit https://crbug.com/648948.
assert(ignore_elf32_limitations || !is_android ||
# An exception is made when target_os == "chromeos" as we only use the Android
# toolchain there to build relatively small binaries.
assert(ignore_elf32_limitations || !is_android || target_os == "chromeos" ||
(android_64bit_target_cpu && !build_apk_secondary_abi) ||
is_component_build || symbol_level < 2,
"Android 32-bit non-component builds cannot have symbol_level=2 " +
Expand Down
2 changes: 1 addition & 1 deletion build/toolchain/toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (generate_linker_map) {
assert(
is_official_build,
"Linker map files should only be generated when is_official_build = true")
assert(target_os == "android" || target_os == "linux",
assert(current_os == "android" || current_os == "linux",
"Linker map files should only be generated for Android and Linux")
}

Expand Down
5 changes: 4 additions & 1 deletion chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ if (!is_android && !is_mac) {
}

if (is_chromeos) {
data_deps += [ "//mojo/edk:mojo_core" ]
data_deps += [
"//mojo/edk:mojo_core",
"//mojo/edk:mojo_core_for_arc",
]
}

# These files are used by the installer so we need a public dep.
Expand Down
73 changes: 58 additions & 15 deletions mojo/edk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ core_impl_source_set("impl_for_edk") {
for_mojo_core = false
}

if (is_chromeos || is_linux) {
if (is_chromeos || is_linux || is_android) {
core_impl_source_set("impl_for_mojo_core") {
for_mojo_core = true
}
Expand All @@ -223,26 +223,69 @@ if (is_chromeos || is_linux) {
configs += [ ":export_only_thunks_api" ]
}

if (is_chromeos) {
if (target_cpu == "arm" || target_cpu == "arm64") {
android32_toolchain = "android_clang_arm"
android64_toolchain = "android_clang_arm64"
} else {
android32_toolchain = "android_clang_x86"
android64_toolchain = "android_clang_x64"
}

group("mojo_core_for_arc") {
deps = [
":mojo_core_arc32",
":mojo_core_arc64",
]
}

copy("mojo_core_arc32") {
sources = [
"${root_out_dir}/${android32_toolchain}/libmojo_core.so",
]
outputs = [
"${root_out_dir}/libmojo_core_arc32.so",
]
deps = [
":mojo_core(//build/toolchain/android:${android32_toolchain})",
]
}

copy("mojo_core_arc64") {
sources = [
"${root_out_dir}/${android64_toolchain}/libmojo_core.so",
]
outputs = [
"${root_out_dir}/libmojo_core_arc64.so",
]
deps = [
":mojo_core(//build/toolchain/android:${android64_toolchain})",
]
}
}

config("export_only_thunks_api") {
ldflags = [ "-Wl,--version-script=" +
rebase_path("//mojo/edk/export_only_thunks_api.lst") ]
}

test("mojo_core_unittests") {
sources = [
"mojo_core_unittest.cc",
"run_all_core_unittests.cc",
]
if (is_chromeos || is_linux) {
test("mojo_core_unittests") {
sources = [
"mojo_core_unittest.cc",
"run_all_core_unittests.cc",
]

deps = [
"//base",
"//base/test:test_support",
"//mojo/public/c/system",
"//testing/gtest",
]
deps = [
"//base",
"//base/test:test_support",
"//mojo/public/c/system",
"//testing/gtest",
]

data_deps = [
":mojo_core",
]
data_deps = [
":mojo_core",
]
}
}
}

0 comments on commit 58eabf0

Please sign in to comment.