Add nacl_toolchain to //build and flip to using it in the GN Build.
With this change, in the Chromium repo NaCl will now be built solely using Chromium's versions of the GN build files, rather than a mixture of chromium and NaCl files. This will allow us to delete the NaCl versions in a subsequent NaCl-side CL and switch to pulling the chromium versions in via a DEPS entry, and thus "unfork" the build. R=brettw@chromium.org, ncbray@chromium.org, mcgrathr@chromium.org BUG=433528 Review URL: https://codereview.chromium.org/1312813003 Cr-Original-Commit-Position: refs/heads/master@{#346452} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: fa6ffe2fb9f488ddb859555f5abc29de72407a62
This commit is contained in:
Родитель
eb5900a50f
Коммит
3d822fcafd
|
@ -0,0 +1,81 @@
|
|||
# Copyright (c) 2014 The Native Client Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Native Client Definitions
|
||||
config("nacl_defines") {
|
||||
defines = [
|
||||
"NACL_ANDROID=0",
|
||||
"_DEFAULT_SOURCE=1",
|
||||
"_BSD_SOURCE=1",
|
||||
"_POSIX_C_SOURCE=199506",
|
||||
"_XOPEN_SOURCE=600",
|
||||
"_GNU_SOURCE=1",
|
||||
"__STDC_LIMIT_MACROS=1",
|
||||
]
|
||||
|
||||
if (is_win) {
|
||||
defines += [ "NACL_WINDOWS=1" ]
|
||||
} else {
|
||||
defines += [ "NACL_WINDOWS=0" ]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
defines += [ "NACL_LINUX=1" ]
|
||||
} else {
|
||||
defines += [ "NACL_LINUX=0" ]
|
||||
}
|
||||
|
||||
if (is_mac) {
|
||||
defines += [ "NACL_OSX=1" ]
|
||||
} else {
|
||||
defines += [ "NACL_OSX=0" ]
|
||||
}
|
||||
|
||||
if (current_cpu == "arm") {
|
||||
defines += [
|
||||
"NACL_BUILD_ARCH=arm",
|
||||
"NACL_BUILD_SUBARCH=32",
|
||||
]
|
||||
}
|
||||
|
||||
if (current_cpu == "mips") {
|
||||
defines += [
|
||||
"NACL_BUILD_ARCH=mips",
|
||||
"NACL_BUILD_SUBARCH=32",
|
||||
]
|
||||
}
|
||||
|
||||
if (current_cpu == "x86") {
|
||||
defines += [
|
||||
"NACL_BUILD_ARCH=x86",
|
||||
"NACL_BUILD_SUBARCH=32",
|
||||
]
|
||||
}
|
||||
|
||||
if (current_cpu == "x64") {
|
||||
defines += [
|
||||
"NACL_BUILD_ARCH=x86",
|
||||
"NACL_BUILD_SUBARCH=64",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
config("nexe_defines") {
|
||||
defines = [
|
||||
"DYNAMIC_ANNOTATIONS_ENABLED=1",
|
||||
"DYNAMIC_ANNOTATIONS_PREFIX=NACL_",
|
||||
]
|
||||
}
|
||||
|
||||
# The base target that all targets in the NaCl build should depend on.
|
||||
# This allows configs to be modified for everything in the NaCl build, even when
|
||||
# the NaCl build is composed into the Chrome build. (GN has no functionality to
|
||||
# add flags to everythin in //native_client, having a base target works around
|
||||
# that limitation.)
|
||||
source_set("nacl_base") {
|
||||
public_configs = [ ":nacl_defines" ]
|
||||
if (current_os == "nacl") {
|
||||
public_configs += [ ":nexe_defines" ]
|
||||
}
|
||||
}
|
|
@ -1,63 +1,203 @@
|
|||
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
# Copyright (c) 2014 The Native Client Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
toolchain("x86_newlib") {
|
||||
toolprefix = "gen/sdk/toolchain/linux_x86_newlib/bin/x86_64-nacl-"
|
||||
import("//build/config/sysroot.gni")
|
||||
import("//build/toolchain/nacl_toolchain.gni")
|
||||
|
||||
nacl_toolchain_dir = rebase_path("//native_client/toolchain", root_build_dir)
|
||||
os_toolchain_dir = "${nacl_toolchain_dir}/${current_os}_x86"
|
||||
|
||||
# Add the toolchain revision as a preprocessor define so that sources are
|
||||
# rebuilt when a toolchain is updated.
|
||||
# Idea we could use the toolchain deps feature, but currently that feature is
|
||||
# bugged and does not trigger a rebuild.
|
||||
# https://code.google.com/p/chromium/issues/detail?id=431880
|
||||
# Calls to get the toolchain revision are relatively slow, so do them all in a
|
||||
# single batch to amortize python startup, etc.
|
||||
revisions = exec_script("//native_client/build/get_toolchain_revision.py",
|
||||
[
|
||||
"nacl_arm_newlib",
|
||||
"nacl_x86_newlib",
|
||||
"nacl_x86_glibc",
|
||||
"pnacl_newlib",
|
||||
],
|
||||
"trim list lines")
|
||||
nacl_arm_newlib_rev = revisions[0]
|
||||
nacl_x86_newlib_rev = revisions[1]
|
||||
nacl_x86_glibc_rev = revisions[2]
|
||||
pnacl_newlib_rev = revisions[3]
|
||||
|
||||
nacl_toolchain("newlib_arm") {
|
||||
toolchain_package = "nacl_arm_newlib"
|
||||
toolchain_revision = nacl_arm_newlib_rev
|
||||
toolchain_cpu = "arm"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/arm-nacl-"
|
||||
|
||||
cc = toolprefix + "gcc"
|
||||
cxx = toolprefix + "g++"
|
||||
ld = toolprefix + "g++"
|
||||
|
||||
tool("cc") {
|
||||
command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out"
|
||||
description = "CC(NaCl x86 Newlib) \$out"
|
||||
depfile = "\$out.d"
|
||||
depsformat = "gcc"
|
||||
}
|
||||
tool("cxx") {
|
||||
# cflags_pch_cc
|
||||
command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out"
|
||||
description = "CXX(NaCl x86 Newlib) \$out"
|
||||
depfile = "\$out.d"
|
||||
depsformat = "gcc"
|
||||
}
|
||||
tool("alink") {
|
||||
command = "rm -f \$out && ${toolprefix}ar rcs \$out \$in"
|
||||
description = "AR(NaCl x86 Newlib) \$out"
|
||||
}
|
||||
tool("solink") {
|
||||
command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi"
|
||||
description = "SOLINK(NaCl x86 Newlib) \$lib"
|
||||
|
||||
#pool = "link_pool"
|
||||
restat = "1"
|
||||
}
|
||||
tool("link") {
|
||||
command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs"
|
||||
description = "LINK(NaCl x86 Newlib) \$out"
|
||||
|
||||
#pool = "link_pool"
|
||||
}
|
||||
|
||||
if (is_win) {
|
||||
tool("stamp") {
|
||||
command = "$python_path gyp-win-tool stamp \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
} else {
|
||||
tool("stamp") {
|
||||
command = "touch \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
}
|
||||
|
||||
toolchain_args() {
|
||||
# Override the default OS detection. The build config will set the is_*
|
||||
# flags accordingly.
|
||||
current_os = "nacl"
|
||||
|
||||
# Component build not supported in NaCl, since it does not support shared
|
||||
# libraries.
|
||||
is_component_build = false
|
||||
}
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
}
|
||||
|
||||
nacl_toolchain("newlib_x86") {
|
||||
toolchain_package = "nacl_x86_newlib"
|
||||
toolchain_revision = nacl_x86_newlib_rev
|
||||
toolchain_cpu = "x86"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-"
|
||||
|
||||
cc = toolprefix + "gcc"
|
||||
cxx = toolprefix + "g++"
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
}
|
||||
|
||||
nacl_toolchain("newlib_x64") {
|
||||
toolchain_package = "nacl_x86_newlib"
|
||||
toolchain_revision = nacl_x86_newlib_rev
|
||||
toolchain_cpu = "x64"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-"
|
||||
|
||||
cc = toolprefix + "gcc"
|
||||
cxx = toolprefix + "g++"
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
}
|
||||
|
||||
nacl_toolchain("newlib_pnacl") {
|
||||
toolchain_package = "pnacl_newlib"
|
||||
toolchain_revision = pnacl_newlib_rev
|
||||
toolchain_cpu = "pnacl"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/pnacl-"
|
||||
|
||||
cc = toolprefix + "clang"
|
||||
cxx = toolprefix + "clang++"
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
executable_extension = ".pexe-debug"
|
||||
|
||||
finalize = toolprefix + "finalize"
|
||||
nonfinal_file =
|
||||
"{{root_out_dir}}/{{target_output_name}}${executable_extension}"
|
||||
finalized_file = "{{root_out_dir}}/{{target_output_name}}.pexe"
|
||||
postlink = "$finalize $nonfinal_file -o $finalized_file"
|
||||
link_outputs = [ finalized_file ]
|
||||
}
|
||||
|
||||
nacl_toolchain("glibc_x86") {
|
||||
toolchain_package = "nacl_x86_glibc"
|
||||
toolchain_revision = nacl_x86_glibc_rev
|
||||
toolchain_cpu = "x86"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-"
|
||||
|
||||
cc = toolprefix + "gcc"
|
||||
cxx = toolprefix + "g++"
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
}
|
||||
|
||||
nacl_toolchain("glibc_x64") {
|
||||
toolchain_package = "nacl_x86_glibc"
|
||||
toolchain_revision = nacl_x86_glibc_rev
|
||||
toolchain_cpu = "x64"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-"
|
||||
|
||||
cc = toolprefix + "gcc"
|
||||
cxx = toolprefix + "g++"
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
}
|
||||
|
||||
nacl_toolchain("clang_newlib_x86") {
|
||||
toolchain_package = "pnacl_newlib"
|
||||
toolchain_revision = pnacl_newlib_rev
|
||||
toolchain_cpu = "x86"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-"
|
||||
is_clang = true
|
||||
|
||||
cc = toolprefix + "clang"
|
||||
cxx = toolprefix + "clang++"
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
}
|
||||
|
||||
nacl_toolchain("clang_newlib_x64") {
|
||||
toolchain_package = "pnacl_newlib"
|
||||
toolchain_revision = pnacl_newlib_rev
|
||||
toolchain_cpu = "x64"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-"
|
||||
is_clang = true
|
||||
|
||||
cc = toolprefix + "clang"
|
||||
cxx = toolprefix + "clang++"
|
||||
ar = toolprefix + "ar"
|
||||
ld = cxx
|
||||
}
|
||||
|
||||
link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir)
|
||||
|
||||
nacl_toolchain("irt_x86") {
|
||||
toolchain_package = "pnacl_newlib"
|
||||
toolchain_revision = pnacl_newlib_rev
|
||||
toolchain_cpu = "x86"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-"
|
||||
is_clang = true
|
||||
|
||||
cc = toolprefix + "clang"
|
||||
cxx = toolprefix + "clang++"
|
||||
ar = toolprefix + "ar"
|
||||
readelf = toolprefix + "readelf"
|
||||
|
||||
# Some IRT implementations (notably, Chromium's) contain C++ code,
|
||||
# so we need to link w/ the C++ linker.
|
||||
ld = "${python_path} ${link_irt} --tls-edit=tls_edit --link-cmd=${cxx} --readelf-cmd=${readelf}"
|
||||
|
||||
# TODO(ncbray): depend on link script
|
||||
deps = [
|
||||
"//native_client/src/tools/tls_edit:tls_edit($host_toolchain)",
|
||||
]
|
||||
}
|
||||
|
||||
nacl_toolchain("irt_x64") {
|
||||
toolchain_package = "pnacl_newlib"
|
||||
toolchain_revision = pnacl_newlib_rev
|
||||
toolchain_cpu = "x64"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-"
|
||||
is_clang = true
|
||||
|
||||
cc = toolprefix + "clang"
|
||||
cxx = toolprefix + "clang++"
|
||||
ar = toolprefix + "ar"
|
||||
readelf = toolprefix + "readelf"
|
||||
|
||||
# Some IRT implementations (notably, Chromium's) contain C++ code,
|
||||
# so we need to link w/ the C++ linker.
|
||||
ld = "${python_path} ${link_irt} --tls-edit=tls_edit --link-cmd=${cxx} --readelf-cmd=${readelf}"
|
||||
|
||||
# TODO(ncbray): depend on link script
|
||||
deps = [
|
||||
"//native_client/src/tools/tls_edit:tls_edit($host_toolchain)",
|
||||
]
|
||||
}
|
||||
|
||||
# Uses newlib to match the Chrome build.
|
||||
nacl_toolchain("irt_arm") {
|
||||
toolchain_package = "nacl_arm_newlib"
|
||||
toolchain_revision = nacl_arm_newlib_rev
|
||||
toolchain_cpu = "arm"
|
||||
toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/arm-nacl-"
|
||||
|
||||
cc = toolprefix + "gcc"
|
||||
cxx = toolprefix + "g++"
|
||||
ar = toolprefix + "ar"
|
||||
readelf = toolprefix + "readelf"
|
||||
|
||||
# Some IRT implementations (notably, Chromium's) contain C++ code,
|
||||
# so we need to link w/ the C++ linker.
|
||||
ld = "${python_path} ${link_irt} --tls-edit=tls_edit --link-cmd=${cxx} --readelf-cmd=${readelf}"
|
||||
|
||||
# TODO(ncbray): depend on link script
|
||||
deps = [
|
||||
"//native_client/src/tools/tls_edit:tls_edit($host_toolchain)",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
# Copyright (c) 2014 The Native Client 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")
|
||||
|
||||
# This template defines a NaCl toolchain.
|
||||
#
|
||||
# It requires the following variables specifying the executables to run:
|
||||
# - cc
|
||||
# - cxx
|
||||
# - ar
|
||||
# - ld
|
||||
# and the following which is used in the toolchain_args
|
||||
# - toolchain_cpu (What "current_cpu" should be set to when invoking a
|
||||
# build using this toolchain.)
|
||||
|
||||
template("nacl_toolchain") {
|
||||
assert(defined(invoker.cc), "nacl_toolchain() must specify a \"cc\" value")
|
||||
assert(defined(invoker.cxx), "nacl_toolchain() must specify a \"cxx\" value")
|
||||
assert(defined(invoker.ar), "nacl_toolchain() must specify a \"ar\" value")
|
||||
assert(defined(invoker.ld), "nacl_toolchain() must specify a \"ld\" value")
|
||||
assert(defined(invoker.toolchain_cpu),
|
||||
"nacl_toolchain() must specify a \"toolchain_cpu\"")
|
||||
|
||||
toolchain_os = "nacl"
|
||||
if (defined(invoker.is_clang)) {
|
||||
is_clang = invoker.is_clang
|
||||
}
|
||||
if (defined(invoker.executable_extension)) {
|
||||
executable_extension = invoker.executable_extension
|
||||
} else {
|
||||
executable_extension = ".nexe"
|
||||
}
|
||||
toolchain_cpu = invoker.toolchain_cpu
|
||||
|
||||
cc = invoker.cc
|
||||
cxx = invoker.cxx
|
||||
ar = invoker.ar
|
||||
ld = invoker.ld
|
||||
if (defined(invoker.postlink)) {
|
||||
postlink = invoker.postlink
|
||||
}
|
||||
if (defined(invoker.link_outputs)) {
|
||||
link_outputs = invoker.link_outputs
|
||||
}
|
||||
|
||||
# We do not wish to suport shared builds with the NaCl toolchains.
|
||||
is_component_build = false
|
||||
|
||||
gcc_toolchain(target_name) {
|
||||
rebuild_define = "NACL_TC_REV=" + invoker.toolchain_revision
|
||||
if (defined(invoker.deps)) {
|
||||
deps = invoker.deps
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче