Skip to content

Commit

Permalink
For building v8 using gn on aix_ppc64, linux_s390x and linux_ppc64(bo…
Browse files Browse the repository at this point in the history
…th LE and BE).

Also add support for host_byteorder logic which is used in the following v8 and icu issues respectively -
https://codereview.chromium.org/2809963004/
https://codereview.chromium.org/2812173002/

R=machenbach@chromium.org, dpranke@chromium.org, adamk@chromium.org
BUG=706728

Review-Url: https://codereview.chromium.org/2815453004
Cr-Commit-Position: refs/heads/master@{#470463}
  • Loading branch information
rayb authored and Commit bot committed May 10, 2017
1 parent e69195a commit 367a042
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ config("executable_config") {
"//build/config/ios:ios_dynamic_flags",
"//build/config/ios:ios_executable_flags",
]
} else if (is_linux || is_android) {
} else if (is_linux || is_android || current_os == "aix") {
configs += [ "//build/config/gcc:executable_ldconfig" ]
if (is_android) {
configs += [ "//build/config/android:executable_config" ]
Expand Down
30 changes: 24 additions & 6 deletions build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ declare_args() {

# Set to true when compiling with the Clang compiler. Typically this is used
# to configure warnings.
is_clang = current_os == "mac" || current_os == "ios" ||
current_os == "linux" || current_os == "chromeos"
is_clang =
current_os == "mac" || current_os == "ios" || current_os == "chromeos" ||
(current_os == "linux" && current_cpu != "s390x" &&
current_cpu != "s390" && current_cpu != "ppc64" && current_cpu != "ppc")

# Allows the path to a custom target toolchain to be injected as a single
# argument, and set as the default toolchain.
Expand Down Expand Up @@ -207,6 +209,8 @@ if (host_toolchain == "") {
} else {
host_toolchain = "//build/toolchain/win:$target_cpu"
}
} else if (host_os == "aix") {
host_toolchain = "//build/toolchain/aix:$host_cpu"
} else {
assert(false, "Unsupported host_os: $host_os")
}
Expand Down Expand Up @@ -242,6 +246,8 @@ if (target_os == "android") {
} else {
_default_toolchain = "//build/toolchain/win:$target_cpu"
}
} else if (target_os == "aix") {
_default_toolchain = "//build/toolchain/aix:$target_cpu"
} else if (target_os == "winrt_81" || target_os == "winrt_81_phone" ||
target_os == "winrt_10") {
_default_toolchain = "//build/toolchain/win:winrt_$target_cpu"
Expand Down Expand Up @@ -342,6 +348,15 @@ if (current_os == "win" || current_os == "winrt_81" ||
is_nacl = false
is_posix = true
is_win = false
} else if (current_os == "aix") {
is_android = false
is_chromeos = false
is_ios = false
is_linux = false
is_mac = false
is_nacl = false
is_posix = true
is_win = false
}

# =============================================================================
Expand Down Expand Up @@ -370,6 +385,7 @@ if (!is_posix) {
"*\bposix/*",
]
}

if (!is_win) {
sources_assignment_filter += [
"*_win.cc",
Expand Down Expand Up @@ -498,11 +514,13 @@ if (current_os == "winrt_81" || current_os == "winrt_81_phone" ||
current_os == "winrt_10") {
default_compiler_configs += [ "//build/config/win:target_winrt" ]
}

if (is_posix) {
default_compiler_configs += [
"//build/config/gcc:no_exceptions",
"//build/config/gcc:symbol_visibility_hidden",
]
default_compiler_configs += [ "//build/config/gcc:no_exceptions" ]
if (current_os != "aix") {
default_compiler_configs +=
[ "//build/config/gcc:symbol_visibility_hidden" ]
}
}

if (is_android) {
Expand Down
50 changes: 50 additions & 0 deletions build/config/aix/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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/sanitizers/sanitizers.gni")
import("//build/toolchain/toolchain.gni")

# This is included by reference in the //build/config/compiler config that
# is applied to all targets. It is here to separate out the logic.

config("compiler") {
# These flags are shared between the C compiler and linker.
defines = [
"_LINUX_SOURCE_COMPAT=1",
"__STDC_FORMAT_MACROS",
"_ALL_SOURCE=1",
]

cflags = [
"-Wall",
"-Wno-unused-parameter",
"-pthread",
"-Wmissing-field-initializers",
"-Wno-uninitialized",
"-mcpu=power5+",
"-mfprnd",
"-mno-popcntb",
"-maix64",
"-fdata-sections",
"-ffunction-sections",
"-O3",

# "-Werror"
# We need to find a way to fix the TOC warnings if we want to enable this.
]

cflags_cc = [
"-std=gnu++11",
"-fno-rtti",
"-fno-exceptions",
"-Wno-narrowing",
"-Wnon-virtual-dtor",
]

ldflags = [
"-pthread",
"-maix64",
"-Wl,-bbigtoc",
]
}
33 changes: 22 additions & 11 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ config("compiler") {
configs += [ "//build/config/mac:compiler" ]
} else if (is_ios) {
configs += [ "//build/config/ios:compiler" ]
} else if (current_os == "aix") {
configs += [ "//build/config/aix:compiler" ]
}

# See the definitions below.
Expand All @@ -186,12 +188,16 @@ config("compiler") {
# Common GCC compiler flags setup.
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
cflags_cc += [
# Not exporting C++ inline functions can generally be applied anywhere
# so we do so here. Normal function visibility is controlled by
# //build/config/gcc:symbol_visibility_hidden.
"-fvisibility-inlines-hidden",
]

# Visibility attribute is not supported on AIX.
if (current_os != "aix") {
cflags_cc += [
# Not exporting C++ inline functions can generally be applied anywhere
# so we do so here. Normal function visibility is controlled by
# //build/config/gcc:symbol_visibility_hidden.
"-fvisibility-inlines-hidden",
]
}

# Stack protection.
if (is_mac) {
Expand All @@ -210,14 +216,16 @@ config("compiler") {
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else {
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}

# Linker warnings.
if (fatal_linker_warnings && !(is_chromeos && current_cpu == "arm") &&
!(is_android && use_order_profiling) && !is_mac && !is_ios) {
!(is_android && use_order_profiling) && !is_mac && !is_ios &&
current_os != "aix") {
# TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580
# TODO(lizeb,pasko): Fix link errors when linking with order_profiling=1
# crbug.com/485542
Expand Down Expand Up @@ -446,7 +454,7 @@ config("compiler") {

# C++11 compiler flags setup.
# ---------------------------
if (is_linux || is_android || (is_nacl && is_clang)) {
if (is_linux || is_android || (is_nacl && is_clang) || current_os == "aix") {
# gnu++11 instead of c++11 is needed because some code uses typeof() (a
# GNU extension).
# TODO(thakis): Eventually switch this to c++11 instead,
Expand Down Expand Up @@ -1169,7 +1177,9 @@ config("chromium_code") {
]

if (!is_debug && !using_sanitizer &&
(!is_linux || !is_clang || is_official_build)) {
(!is_linux || !is_clang || is_official_build) &&
current_cpu != "s390x" && current_cpu != "s390" &&
current_cpu != "ppc64" && current_cpu != "ppc64") {
# _FORTIFY_SOURCE isn't really supported by Clang now, see
# http://llvm.org/bugs/show_bug.cgi?id=16821.
# It seems to work fine with Ubuntu 12 headers though, so use it in
Expand Down Expand Up @@ -1389,8 +1399,9 @@ if (is_win) {
# Mac dead code stripping requires symbols.
common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
}
} else {
} else if (current_os != "aix") {
# Non-Mac Posix flags.
# Aix does not support these.

common_optimize_on_cflags += [
# Don't emit the GCC version ident directives, they just end up in the
Expand Down
2 changes: 1 addition & 1 deletion build/config/gcc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ config("executable_ldconfig") {
}
}

if (!is_android || !use_gold) {
if ((!is_android || !use_gold) && current_os != "aix") {
# Find the path containing shared libraries for this toolchain
# relative to the build directory. ${root_out_dir} will be a
# subdirectory of ${root_build_dir} when cross compiling.
Expand Down
11 changes: 11 additions & 0 deletions build/config/get_host_byteorder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python
# 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.

"""Get Byteorder of host architecture"""


import sys

print sys.byteorder
27 changes: 27 additions & 0 deletions build/config/host_byteorder.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 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.

# This header file defines the "host_byteorder" variable.
# Not that this is currently used only for building v8.
# The chromium code generally assumes little-endianness.
declare_args() {
host_byteorder = "undefined"
}

# Detect host byteorder
# ppc64 can be either BE or LE
if (host_cpu == "ppc64") {
if (current_os == "aix") {
host_byteorder = "big"
} else {
# Only use the script when absolutely necessary
host_byteorder =
exec_script("//build/config/get_host_byteorder.py", [], "trim string")
}
} else if (host_cpu == "ppc" || host_cpu == "s390" || host_cpu == "s390x" ||
host_cpu == "mips" || host_cpu == "mips64") {
host_byteorder = "big"
} else {
host_byteorder = "little"
}
5 changes: 3 additions & 2 deletions build/config/sysroot.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ declare_args() {
# The absolute path to directory containing linux sysroot images
target_sysroot_dir = "//build/linux"

use_sysroot = true
use_sysroot = current_cpu != "s390x" && current_cpu != "s390" &&
current_cpu != "ppc64" && current_cpu != "ppc"
}

if (current_os == target_os && current_cpu == target_cpu &&
target_sysroot != "") {
target_sysroot != "") {
sysroot = target_sysroot
} else if (is_android) {
import("//build/config/android/config.gni")
Expand Down
1 change: 1 addition & 0 deletions build/dotfile_settings.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build_dotfile_settings = {
"//build/config/android/rules.gni",
"//build/config/compiler/BUILD.gn",
"//build/config/gcc/gcc_version.gni",
"//build/config/host_byteorder.gni",
"//build/config/ios/ios_sdk.gni",
"//build/config/linux/BUILD.gn",
"//build/config/linux/pkg_config.gni",
Expand Down
21 changes: 21 additions & 0 deletions build/toolchain/aix/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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")

gcc_toolchain("ppc64") {
cc = "gcc"
cxx = "g++"

readelf = "readelf"
nm = "nm"
ar = "ar"
ld = cxx

toolchain_args = {
current_cpu = "ppc64"
current_os = "aix"
is_clang = false
}
}
22 changes: 17 additions & 5 deletions build/toolchain/gcc_ar_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,24 @@ def main():
help='Input files')
args = parser.parse_args()

if args.resource_whitelist:
whitelist_candidates = wrapper_utils.ResolveRspLinks(args.inputs)
wrapper_utils.CombineResourceWhitelists(
whitelist_candidates, args.resource_whitelist)
# Specifies the type of object file ar should examine.
# The ar on linux ignores this option.
object_mode = []
if sys.platform.startswith('aix'):
# The @file feature is not avaliable on ar for AIX.
# For linux (and other posix like systems), the @file_name
# option reads the contents of file_name as command line arguments.
# For AIX we must parse these (rsp files) manually.
# Read rspfile.
args.inputs = wrapper_utils.ResolveRspLinks(args.inputs)
object_mode = ['-X64']
else:
if args.resource_whitelist:
whitelist_candidates = wrapper_utils.ResolveRspLinks(args.inputs)
wrapper_utils.CombineResourceWhitelists(
whitelist_candidates, args.resource_whitelist)

command = [args.ar, args.operation]
command = [args.ar] + object_mode + [args.operation]
if args.plugin is not None:
command += ['--plugin', args.plugin]
command.append(args.output)
Expand Down
18 changes: 16 additions & 2 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,13 @@ template("gcc_toolchain") {
# POSIX-like toolchains such as NaCl on Windows).
ar_wrapper =
rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir)
command = "$python_path \"$ar_wrapper\"$whitelist_flag --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\""
if (current_os == "aix") {
# We use slightly different arflags for AIX.
extra_arflags = "rcsT"
} else {
extra_arflags = "rcsD"
}
command = "$python_path \"$ar_wrapper\"$whitelist_flag --output={{output}} --ar=\"$ar\" {{arflags}} $extra_arflags @\"$rspfile\""
description = "AR {{output}}"
rspfile_content = "{{inputs}}"
outputs = [
Expand Down Expand Up @@ -499,9 +505,17 @@ template("gcc_toolchain") {
map_switch = " --map-file \"$map_file\""
}

link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" -Wl,--start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
start_group_flag = ""
end_group_flag = ""
if (current_os != "aix") {
# the "--start-group .. --end-group" feature isn't available on the aix ld.
start_group_flag = "-Wl,--start-group"
end_group_flag = "-Wl,--end-group "
}
link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" {{solibs}} $end_group_flag $libs_section_prefix {{libs}} $libs_section_postfix"

strip_switch = ""

if (defined(invoker.strip)) {
strip_switch = " --strip=\"${invoker.strip}\" --unstripped-file=\"$unstripped_outfile\""
}
Expand Down
Loading

0 comments on commit 367a042

Please sign in to comment.