summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordpranke <dpranke@chromium.org>2015-08-31 13:17:52 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-31 20:18:45 +0000
commitfa6ffe2fb9f488ddb859555f5abc29de72407a62 (patch)
tree7d915a47da7967b3d903cbca066fa6d182de79e6
parentf547b2addcab8fe2ce211188fedd530c32c38de8 (diff)
downloadchromium_src-fa6ffe2fb9f488ddb859555f5abc29de72407a62.zip
chromium_src-fa6ffe2fb9f488ddb859555f5abc29de72407a62.tar.gz
chromium_src-fa6ffe2fb9f488ddb859555f5abc29de72407a62.tar.bz2
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-Commit-Position: refs/heads/master@{#346452}
-rw-r--r--.gn3
-rw-r--r--build/config/nacl/BUILD.gn81
-rw-r--r--build/toolchain/nacl/BUILD.gn254
-rw-r--r--build/toolchain/nacl_toolchain.gni57
-rw-r--r--components/nacl/BUILD.gn2
-rw-r--r--ppapi/native_client/BUILD.gn2
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn3
-rw-r--r--remoting/tools/javascript_key_tester/BUILD.gn4
-rw-r--r--third_party/mojo/src/nacl_bindings/BUILD.gn6
9 files changed, 345 insertions, 67 deletions
diff --git a/.gn b/.gn
index 16c785e..ad3f726 100644
--- a/.gn
+++ b/.gn
@@ -128,6 +128,7 @@ exec_script_whitelist = [
"//build/linux/BUILD.gn",
"//build/toolchain/gcc_toolchain.gni",
"//build/toolchain/mac/BUILD.gn",
+ "//build/toolchain/nacl/BUILD.gn",
"//build/toolchain/win/BUILD.gn",
"//build/util/version.gni",
"//chrome/android/BUILD.gn",
@@ -167,8 +168,6 @@ exec_script_whitelist = [
"//google_apis/BUILD.gn",
"//gpu/gles2_conform_support/BUILD.gn",
"//jingle/BUILD.gn",
- "//native_client/build/toolchain/gcc_toolchain.gni",
- "//native_client/build/toolchain/nacl/BUILD.gn",
"//native_client/build/config/android/BUILD.gn",
"//native_client/build/config/gcc/gcc_version.gni",
"//native_client/build/config/ios/ios_sdk.gni",
diff --git a/build/config/nacl/BUILD.gn b/build/config/nacl/BUILD.gn
new file mode 100644
index 0000000..a8399d9
--- /dev/null
+++ b/build/config/nacl/BUILD.gn
@@ -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" ]
+ }
+}
diff --git a/build/toolchain/nacl/BUILD.gn b/build/toolchain/nacl/BUILD.gn
index 5fa637c..1a30bb9 100644
--- a/build/toolchain/nacl/BUILD.gn
+++ b/build/toolchain/nacl/BUILD.gn
@@ -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++"
+ 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++"
- 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"
+ 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)",
+ ]
}
diff --git a/build/toolchain/nacl_toolchain.gni b/build/toolchain/nacl_toolchain.gni
new file mode 100644
index 0000000..ab3b693
--- /dev/null
+++ b/build/toolchain/nacl_toolchain.gni
@@ -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
+ }
+ }
+}
diff --git a/components/nacl/BUILD.gn b/components/nacl/BUILD.gn
index 74f871b..02f0f06 100644
--- a/components/nacl/BUILD.gn
+++ b/components/nacl/BUILD.gn
@@ -44,7 +44,7 @@ if (enable_nacl) {
if (enable_nacl_untrusted) {
data_deps = [
# TODO(GYP): handle other architectures correctly.
- "//ppapi/native_client:nacl_irt(//native_client/build/toolchain/nacl:irt_x64)",
+ "//ppapi/native_client:nacl_irt(//build/toolchain/nacl:irt_x64)",
]
}
if (enable_pnacl) {
diff --git a/ppapi/native_client/BUILD.gn b/ppapi/native_client/BUILD.gn
index 008b0c9..23a2371 100644
--- a/ppapi/native_client/BUILD.gn
+++ b/ppapi/native_client/BUILD.gn
@@ -60,6 +60,6 @@ if (is_nacl) {
group("irt") {
deps = [
- ":nacl_irt_copy(//native_client/build/toolchain/nacl:irt_${target_cpu})",
+ ":nacl_irt_copy(//build/toolchain/nacl:irt_${target_cpu})",
]
}
diff --git a/ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn b/ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn
index a216088..fac4fc5 100644
--- a/ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn
+++ b/ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn
@@ -25,7 +25,8 @@ if (enable_nacl && enable_nacl_untrusted && enable_pnacl) {
# (x86-64 sandbox base address hiding). One thing we don't want is the
# IRT's secondary TLS, but that is handled by tls_edit and not compiler
# flags (so IRT compiler flags should be fine).
- shim_toolchain_base = "//native_client/build/toolchain/nacl:irt_"
+ shim_toolchain_base = "//build/toolchain/nacl:irt_"
+
shim_target_tc_label = "$shim_target_label($shim_toolchain_base$target_cpu)"
deps = [
shim_target_tc_label,
diff --git a/remoting/tools/javascript_key_tester/BUILD.gn b/remoting/tools/javascript_key_tester/BUILD.gn
index bd91953..7f6cc31 100644
--- a/remoting/tools/javascript_key_tester/BUILD.gn
+++ b/remoting/tools/javascript_key_tester/BUILD.gn
@@ -13,7 +13,7 @@ if (enable_pnacl) {
copy("javascript_key_tester_copies") {
pexe_dir = get_label_info(
- "pnacl:remoting_key_tester_newlib(//native_client/build/toolchain/nacl:newlib_pnacl)",
+ "pnacl:remoting_key_tester_newlib(//build/toolchain/nacl:newlib_pnacl)",
"root_out_dir")
sources = [
@@ -35,7 +35,7 @@ if (enable_pnacl) {
deps = [
":javascript_key_tester_jscompile",
- "pnacl:remoting_key_tester_newlib(//native_client/build/toolchain/nacl:newlib_pnacl)",
+ "pnacl:remoting_key_tester_newlib(//build/toolchain/nacl:newlib_pnacl)",
]
}
diff --git a/third_party/mojo/src/nacl_bindings/BUILD.gn b/third_party/mojo/src/nacl_bindings/BUILD.gn
index 84920ee..b8a1f99 100644
--- a/third_party/mojo/src/nacl_bindings/BUILD.gn
+++ b/third_party/mojo/src/nacl_bindings/BUILD.gn
@@ -7,8 +7,8 @@ if (!is_nacl) {
# A library for launching a NaCl sandbox connected to a Mojo embedder.
source_set("monacl_sel") {
sources = [
- "mojo_syscall_internal.h",
"mojo_syscall.cc",
+ "mojo_syscall_internal.h",
"monacl_sel_main.cc",
]
deps = [
@@ -16,7 +16,7 @@ if (!is_nacl) {
# This target makes sure we have all the pre-processor defines needed to
# use NaCl's headers.
- "//native_client/build/config/nacl:nacl_base",
+ "//build/config/nacl:nacl_base",
"//native_client/src/trusted/desc:nrd_xfer",
"//native_client/src/trusted/service_runtime:sel_main_chrome",
]
@@ -34,7 +34,7 @@ if (is_nacl) {
]
deps = [
"../mojo/public/c/system",
- "//native_client/build/config/nacl:nacl_base",
+ "//build/config/nacl:nacl_base",
"//native_client/src/untrusted/irt:irt_core_lib",
"//native_client/src/untrusted/nacl:imc_syscalls",
]