Skip to content

Commit

Permalink
Config changes to support target_os="fuchsia"
Browse files Browse the repository at this point in the history
Fuchsia support has been upstreamed into Clang, so the existing
Linux-hosted Clang toolchain binaries in third_party with the correct
--target are sufficient.  Fuchsia is POSIXy so a lot of things will just
work, but some places will require different implementations, so this CL
adds support for is_fuchsia as well as a basic implementation of the
toolchain config.

The SDK (headers, sysroot, etc.) is currently available at
go/fuchsia-sdk until a standard location for it is decided upon.

The near term goal behind this CL is to bring up base/ and net/ on an
fyi bot running Fuchsia.

BUG=706592

Review-Url: https://codereview.chromium.org/2784063002
Cr-Commit-Position: refs/heads/master@{#471360}
  • Loading branch information
sgraham authored and Commit bot committed May 12, 2017
1 parent 498c838 commit 2f97ee1
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 34 deletions.
33 changes: 19 additions & 14 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,9 @@ group("gn_all") {
":gn_visibility",
"//base:base_unittests",
"//chrome/installer",
"//components:components_unittests",
"//net:net_unittests",
"//skia:skia_unittests",
"//sql:sql_unittests",
"//tools/ipc_fuzzer:ipc_fuzzer_all",
"//tools/metrics:metrics_metadata",
"//ui/base:ui_base_unittests",
"//ui/gfx:gfx_unittests",
"//url:url_unittests",
]

Expand All @@ -87,7 +82,17 @@ group("gn_all") {
]
}

if (!is_ios && !is_android && !is_chromecast) {
if (!is_fuchsia) {
deps += [
"//components:components_unittests",
"//skia:skia_unittests",
"//tools/metrics:metrics_metadata",
"//ui/base:ui_base_unittests",
"//ui/gfx:gfx_unittests",
]
}

if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) {
deps += [
"//chrome",
"//chrome/test:browser_tests",
Expand Down Expand Up @@ -146,7 +151,7 @@ group("gn_all") {
]
}

if (!is_ios) {
if (!is_ios && !is_fuchsia) {
deps += [
"//cc:cc_unittests",
"//chrome/test:telemetry_perf_unittests",
Expand Down Expand Up @@ -193,7 +198,7 @@ group("gn_all") {
"//url/ipc:url_ipc_unittests",
"//v8:gn_all",
]
} else {
} else if (is_ios) {
deps += [ "//ios:all" ]
}

Expand Down Expand Up @@ -397,7 +402,7 @@ group("gn_all") {

# TODO(GYP): Figure out which of these should (and can) build
# for chromeos/ios.
if (!is_chromeos && !is_ios) {
if (!is_chromeos && !is_ios && !is_fuchsia) {
deps += [
"//base:build_utf8_validator_tables",
"//base:check_example",
Expand Down Expand Up @@ -574,11 +579,11 @@ group("gn_all") {
]
}

if (!is_android && !is_ios) {
if (!is_android && !is_ios && !is_fuchsia) {
deps += [ "//content/browser/bluetooth/tools:bluetooth_metrics_hash" ]
}

if (!is_android && !is_ios && !is_chromeos) {
if (!is_android && !is_ios && !is_chromeos && !is_fuchsia) {
deps += [ "//components/proximity_auth:proximity_auth_unittests" ]
}

Expand Down Expand Up @@ -812,7 +817,7 @@ group("gn_visibility") {
}
}

if (!is_ios) {
if (!is_ios && !is_fuchsia) {
# This group includes all of the targets needed to build and test Blink,
# including running the layout tests (see below).
group("blink_tests") {
Expand Down Expand Up @@ -942,7 +947,7 @@ group("chromium_swarm_tests") {
group("chromium_builder_perf") {
testonly = true

if (!is_ios && !is_android && !is_chromecast) {
if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) {
data_deps = [
"//cc:cc_perftests",
"//chrome/test:load_library_perf_tests",
Expand Down Expand Up @@ -982,7 +987,7 @@ group("chromium_builder_perf") {
}
}

if (!is_ios && !is_android && !is_chromecast) {
if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) {
group("chromium_builder_asan") {
testonly = true

Expand Down
1 change: 1 addition & 0 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
'OS_CAT', # For testing.
'OS_CHROMEOS',
'OS_FREEBSD',
'OS_FUCHSIA',
'OS_IOS',
'OS_LINUX',
'OS_MACOSX',
Expand Down
16 changes: 8 additions & 8 deletions build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#endif
#elif defined(_WIN32)
#define OS_WIN 1
#elif defined(__Fuchsia__)
#define OS_FUCHSIA 1
#elif defined(__FreeBSD__)
#define OS_FREEBSD 1
#elif defined(__NetBSD__)
Expand Down Expand Up @@ -77,10 +79,10 @@

// For access to standard POSIXish features, use OS_POSIX instead of a
// more specific macro.
#if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \
defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_NACL) || \
defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_QNX) || \
defined(OS_SOLARIS)
#if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \
defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_MACOSX) || \
defined(OS_NACL) || defined(OS_NETBSD) || defined(OS_OPENBSD) || \
defined(OS_QNX) || defined(OS_SOLARIS)
#define OS_POSIX 1
#endif

Expand Down Expand Up @@ -165,12 +167,10 @@
// Type detection for wchar_t.
#if defined(OS_WIN)
#define WCHAR_T_IS_UTF16
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
defined(__WCHAR_MAX__) && \
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
#define WCHAR_T_IS_UTF32
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
defined(__WCHAR_MAX__) && \
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
// compile in this mode (in particular, Chrome doesn't). This is intended for
Expand Down
23 changes: 22 additions & 1 deletion build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ declare_args() {
# to configure warnings.
is_clang =
current_os == "mac" || current_os == "ios" || current_os == "chromeos" ||
current_os == "fuchsia" ||
(current_os == "linux" && current_cpu != "s390x" &&
current_cpu != "s390" && current_cpu != "ppc64" && current_cpu != "ppc")

Expand All @@ -163,7 +164,8 @@ declare_args() {
#
# For more information see
# https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md
is_component_build = is_debug && current_os != "ios"
is_component_build =
is_debug && current_os != "ios" && current_os != "fuchsia"
}

assert(!(is_debug && is_official_build), "Can't do official debug builds")
Expand Down Expand Up @@ -233,6 +235,8 @@ if (target_os == "android") {
} else {
_default_toolchain = "//build/toolchain/linux:$target_cpu"
}
} else if (target_os == "fuchsia") {
_default_toolchain = "//build/toolchain/fuchsia:$target_cpu"
} else if (target_os == "ios") {
_default_toolchain = "//build/toolchain/mac:ios_clang_$target_cpu"
} else if (target_os == "mac") {
Expand Down Expand Up @@ -285,6 +289,7 @@ if (current_os == "win" || current_os == "winrt_81" ||
current_os == "winrt_81_phone" || current_os == "winrt_10") {
is_android = false
is_chromeos = false
is_fuchsia = false
is_ios = false
is_linux = false
is_mac = false
Expand All @@ -294,6 +299,7 @@ if (current_os == "win" || current_os == "winrt_81" ||
} else if (current_os == "mac") {
is_android = false
is_chromeos = false
is_fuchsia = false
is_ios = false
is_linux = false
is_mac = true
Expand All @@ -303,6 +309,7 @@ if (current_os == "win" || current_os == "winrt_81" ||
} else if (current_os == "android") {
is_android = true
is_chromeos = false
is_fuchsia = false
is_ios = false
is_linux = false
is_mac = false
Expand All @@ -312,6 +319,7 @@ if (current_os == "win" || current_os == "winrt_81" ||
} else if (current_os == "chromeos") {
is_android = false
is_chromeos = true
is_fuchsia = false
is_ios = false
is_linux = true
is_mac = false
Expand All @@ -324,15 +332,27 @@ if (current_os == "win" || current_os == "winrt_81" ||
# Posix variant.
is_android = false
is_chromeos = false
is_fuchsia = false
is_ios = false
is_linux = false
is_mac = false
is_nacl = true
is_posix = true
is_win = false
} else if (current_os == "fuchsia") {
is_android = false
is_chromeos = false
is_fuchsia = true
is_ios = false
is_linux = false
is_mac = false
is_nacl = false
is_posix = true
is_win = false
} else if (current_os == "ios") {
is_android = false
is_chromeos = false
is_fuchsia = false
is_ios = true
is_linux = false
is_mac = false
Expand All @@ -342,6 +362,7 @@ if (current_os == "win" || current_os == "winrt_81" ||
} else if (current_os == "linux") {
is_android = false
is_chromeos = false
is_fuchsia = false
is_ios = false
is_linux = true
is_mac = false
Expand Down
2 changes: 1 addition & 1 deletion build/config/allocator.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import("//build/config/sanitizers/sanitizers.gni")

# Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors.
if (is_android || current_cpu == "mipsel" || is_mac || is_ios || is_asan ||
is_lsan || is_tsan || is_msan || is_win || is_syzyasan ||
is_lsan || is_tsan || is_msan || is_win || is_syzyasan || is_fuchsia ||
(is_linux && target_cpu == "arm64")) {
_default_allocator = "none"
} else {
Expand Down
4 changes: 3 additions & 1 deletion build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ config("compiler") {
configs += [ "//build/config/mac:compiler" ]
} else if (is_ios) {
configs += [ "//build/config/ios:compiler" ]
} else if (is_fuchsia) {
configs += [ "//build/config/fuchsia:compiler" ]
} else if (current_os == "aix") {
configs += [ "//build/config/aix:compiler" ]
}
Expand Down Expand Up @@ -308,7 +310,7 @@ config("compiler") {

# Linux/Android common flags setup.
# ---------------------------------
if (is_linux || is_android) {
if (is_linux || is_android || is_fuchsia) {
if (use_pic) {
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
Expand Down
14 changes: 8 additions & 6 deletions build/config/compiler/compiler.gni
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ declare_args() {

declare_args() {
# Whether to use the gold linker from binutils instead of lld or bfd.
use_gold = !use_lld && !(is_chromecast && is_linux &&
(current_cpu == "arm" || current_cpu == "mipsel")) &&
((is_linux && (current_cpu == "x64" || current_cpu == "x86" ||
current_cpu == "arm" || current_cpu == "mipsel")) ||
(is_android && (current_cpu == "x86" || current_cpu == "x64" ||
current_cpu == "arm" || current_cpu == "arm64")))
use_gold =
!use_lld && !(is_chromecast && is_linux &&
(current_cpu == "arm" || current_cpu == "mipsel")) &&
((is_linux && (current_cpu == "x64" || current_cpu == "x86" ||
current_cpu == "arm" || current_cpu == "mipsel")) ||
(is_android && (current_cpu == "x86" || current_cpu == "x64" ||
current_cpu == "arm" || current_cpu == "arm64")) ||
is_fuchsia)
}

# If it wasn't manually set, set to an appropriate default.
Expand Down
30 changes: 30 additions & 0 deletions build/config/fuchsia/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/sysroot.gni")

assert(is_fuchsia)
assert(is_posix)

config("compiler") {
defines = [ "SYSROOT_VERSION=$sysroot_version" ]
cflags = []
ldflags = []
if (current_cpu == "arm64") {
cflags += [ "--target=aarch64-fuchsia" ]
ldflags += [ "--target=aarch64-fuchsia" ]
} else if (current_cpu == "x64") {
cflags += [ "--target=x86_64-fuchsia" ]
ldflags += [ "--target=x86_64-fuchsia" ]
} else {
assert(false, "Unsupported architecture")
}
asmflags = cflags

libs = [
"mxio",
"magenta",
"unwind",
]
}
1 change: 1 addition & 0 deletions build/config/fuchsia/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scottmg@chromium.org
10 changes: 10 additions & 0 deletions build/config/fuchsia/config.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(current_os == "fuchsia")

declare_args() {
# Path to Fuchsia SDK.
fuchsia_sdk = "//third_party/fuchsia-sdk"
}
11 changes: 11 additions & 0 deletions build/config/sysroot.gni
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ if (current_os == target_os && current_cpu == target_cpu &&
} else if (is_ios) {
import("//build/config/ios/ios_sdk.gni")
sysroot = ios_sdk_path
} else if (is_fuchsia) {
import("//build/config/fuchsia/config.gni")
if (current_cpu == "arm64") {
sysroot = fuchsia_sdk + "/sysroot/aarch64-fuchsia"
} else if (current_cpu == "x64") {
sysroot = fuchsia_sdk + "/sysroot/x86_64-fuchsia"
} else {
sysroot = ""
}
sysroot_stamp = rebase_path("$sysroot/.stamp")
sysroot_version = read_file(sysroot_stamp, "trim string")
} else {
sysroot = ""
}
16 changes: 16 additions & 0 deletions build/toolchain/fuchsia/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/toolchain/gcc_toolchain.gni")
import("//build/config/fuchsia/config.gni")

clang_toolchain("x64") {
assert(current_cpu == "x64")
assert(host_os == "linux")

toolchain_args = {
current_cpu = "x64"
current_os = "fuchsia"
}
}
1 change: 1 addition & 0 deletions build/toolchain/fuchsia/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scottmg@chromium.org
2 changes: 1 addition & 1 deletion extensions/features/features.gni
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import("//build/config/features.gni")

declare_args() {
enable_extensions = !is_android && !is_ios
enable_extensions = !is_android && !is_ios && !is_fuchsia

# Enables Wi-Fi Display functionality
# WARNING: This enables MPEG Transport Stream (MPEG-TS) encoding!
Expand Down
2 changes: 1 addition & 1 deletion remoting/remoting_enable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import("//build/config/ui.gni")
import("//media/media_options.gni")

declare_args() {
enable_remoting = !is_chromecast && enable_webrtc
enable_remoting = !is_chromecast && !is_fuchsia && enable_webrtc
}
1 change: 1 addition & 0 deletions third_party/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
/flatbuffers/src
/fontconfig/src
/freetype/src
/fuchsia-sdk
/gestures/gestures
/gles2_conform
/glslang/src
Expand Down
Loading

0 comments on commit 2f97ee1

Please sign in to comment.