Synchronize GN build configuration with Chrome

This is necessary to roll newer version of Native Client. We also
had to roll in new version of Gn as well as other third party libraries
to resolve various compilation issues.

BUG= https://github.com/domokit/mojo/issues/396
R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/1418653002 .
diff --git a/DEPS b/DEPS
index 34be7a3..04e99ff 100644
--- a/DEPS
+++ b/DEPS
@@ -20,9 +20,9 @@
 vars = {
   'chromium_git': 'https://chromium.googlesource.com',
   'skia_revision': '2ced78866fcadd98895777c8dffe92e229775181',
-  'v8_revision': '230d131d173ab2d60291d303177bc04ec3f6e519',
+  'v8_revision': '3f036fc0ba4ca4483fe77822f8605c277d37ee24',
   'angle_revision': 'bdd419f9f5b006e913606e7363125942c8ae06bc',
-  'buildtools_revision': '565d04e8741429fb1b4f26d102f2c6c3b849edeb',
+  'buildtools_revision': 'ef7f1f539cff0441c4401d8c052e54cfd01bff07',
   'dart_revision': '9416219c28e500a354ff0086765601efa5b1378e',
   'dart_root_certificates_revision': 'c3a41df63afacec62fcb8135196177e35fe72f71',
   'dart_observatory_packages_revision': '5c199c5954146747f75ed127871207718dc87786',
@@ -30,7 +30,7 @@
   'boringssl_revision': '642f1498d056dbba3e50ed5a232ab2f482626dec',
   'lss_revision': '6f97298fe3794e92c8c896a6bc06e0b36e4c3de3',
   'nss_revision': 'bb4e75a43d007518ae7d618665ea2f25b0c60b63',
-  'nacl_revision': '19d52fd1ca55c92c4cb086084657d9a121096ef7',
+  'nacl_revision': '71fa851c91658c498758494b790ddba548aae7be',
 }
 
 # Only these hosts are allowed for dependencies in this DEPS file.
@@ -55,7 +55,7 @@
    Var('chromium_git') + '/angle/angle.git' + '@' +  Var('angle_revision'),
 
   'src/third_party/icu':
-   Var('chromium_git') + '/chromium/deps/icu.git' + '@' + 'c3f79166089e5360c09e3053fce50e6e296c3204',
+   Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '94e4b770ce2f6065d4261d29c32683a6099b9d93',
 
   'src/tools/grit':
     Var('chromium_git') + '/external/grit-i18n.git' + '@' + 'c1b1591a05209c1ad467e845ba8543c22f9072af', # from svn revision 189
diff --git a/apps/moterm/BUILD.gn b/apps/moterm/BUILD.gn
index 3513168..a69461c 100644
--- a/apps/moterm/BUILD.gn
+++ b/apps/moterm/BUILD.gn
@@ -75,18 +75,15 @@
     "//mojo/services/surfaces/interfaces",
   ]
 
-  forward_dependent_configs_from = [
-    "//mojo/public/c/gpu",
-    "//mojo/services/gpu/interfaces",
-    "//mojo/services/surfaces/interfaces",
-  ]
-
   public_deps = [
     "//base",
+    "//mojo/public/c/gpu",
     "//mojo/public/c/gpu:GLES2",
     "//mojo/services/geometry/cpp",
     "//mojo/services/geometry/interfaces",
+    "//mojo/services/gpu/interfaces",
     "//mojo/services/surfaces/cpp",
+    "//mojo/services/surfaces/interfaces",
     "//mojo/services/surfaces/interfaces:surface_id",
   ]
 }
@@ -116,10 +113,9 @@
     "//third_party/libteken",
   ]
 
-  forward_dependent_configs_from = [ "//third_party/libteken" ]
-
   public_deps = [
     "//base",
+    "//third_party/libteken",
   ]
 }
 
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 38d5e0d..089610f 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -1426,7 +1426,7 @@
       "android/java/src/org/chromium/base/metrics/RecordUserAction.java",
     ]
 
-    deps = [
+    public_deps = [
       ":android_runtime_jni_headers",
     ]
 
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index 1649547..785c8f2 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -664,9 +664,6 @@
       if (defined(invoker.direct_dependent_configs)) {
         direct_dependent_configs = invoker.direct_dependent_configs
       }
-      if (defined(invoker.forward_dependent_configs_from)) {
-        forward_dependent_configs_from = invoker.forward_dependent_configs_from
-      }
       if (defined(invoker.include_dirs)) {
         include_dirs = invoker.include_dirs
       }
@@ -755,9 +752,6 @@
       if (defined(invoker.direct_dependent_configs)) {
         direct_dependent_configs = invoker.direct_dependent_configs
       }
-      if (defined(invoker.forward_dependent_configs_from)) {
-        forward_dependent_configs_from = invoker.forward_dependent_configs_from
-      }
       if (defined(invoker.include_dirs)) {
         include_dirs = invoker.include_dirs
       }
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index 0c135b3..aa5fe9e 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -324,7 +324,7 @@
     if (defined(invoker.visibility)) {
       visibility = invoker.visibility
     }
-    deps = [
+    public_deps = [
       ":$zip_srcjar_target_name",
     ]
   }
@@ -411,7 +411,7 @@
     if (defined(invoker.visibility)) {
       visibility = invoker.visibility
     }
-    deps = [
+    public_deps = [
       ":$zip_srcjar_target_name",
     ]
   }
@@ -1860,7 +1860,9 @@
     if (defined(invoker.deps)) {
       deps += invoker.deps
     }
-    data_deps = [ "//tools/android/md5sum" ]
+    data_deps = [
+      "//tools/android/md5sum",
+    ]
     if (host_os == "linux") {
       data_deps += [ "//tools/android/forwarder2" ]
     }
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index af59c1f..6410563 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -13,7 +13,7 @@
 if (is_posix) {
   import("//build/config/gcc/gcc_version.gni")
 }
-
+import("//build/config/nacl/config.gni")
 import("//build/toolchain/ccache.gni")
 import("//build/config/sanitizers/sanitizers.gni")
 
@@ -84,6 +84,7 @@
 # where stuff should go. Put warning related stuff in the "warnings" config.
 
 config("compiler") {
+  asmflags = []
   cflags = []
   cflags_c = []
   cflags_cc = []
@@ -574,11 +575,119 @@
       }
     }
   }
+
+  # Assign any flags set for the C compiler to asmflags so that they are sent
+  # to the assembler.
+  asmflags += cflags
+  asmflags += cflags_c
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in.  Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+  cflags = []
+  ldflags = []
+
+  if (is_posix && !(is_mac || is_ios)) {
+    # CPU architecture. We may or may not be doing a cross compile now, so for
+    # simplicity we always explicitly set the architecture.
+    if (current_cpu == "x64") {
+      cflags += [
+        "-m64",
+        "-march=x86-64",
+      ]
+      ldflags += [ "-m64" ]
+    } else if (current_cpu == "x86") {
+      cflags += [ "-m32" ]
+      ldflags += [ "-m32" ]
+    } else if (current_cpu == "arm") {
+      if (is_clang && !is_android && !is_nacl) {
+        cflags += [
+          "-target",
+          "arm-linux-gnueabihf",
+        ]
+        ldflags += [
+          "-target",
+          "arm-linux-gnueabihf",
+        ]
+      }
+      if (!is_nacl) {
+        cflags += [
+          "-march=$arm_arch",
+          "-mfloat-abi=$arm_float_abi",
+        ]
+        if (arm_use_thumb) {
+          cflags += [ "-mthumb" ]
+          if (is_android && !is_clang) {
+            # Clang doesn't support this option.
+            cflags += [ "-mthumb-interwork" ]
+          }
+        }
+      }
+      if (arm_tune != "") {
+        cflags += [ "-mtune=$arm_tune" ]
+      }
+    } else if (current_cpu == "mipsel") {
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips32r6",
+          "-Wa,-mips32r6",
+        ]
+        if (is_android) {
+          ldflags += [
+            "-mips32r6",
+            "-Wl,-melf32ltsmip",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips32r2",
+          "-Wa,-mips32r2",
+        ]
+        if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+          cflags += [ "-m$mips_fpu_mode" ]
+        }
+      } else if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mips32",
+          "-Wa,-mips32",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips64el") {
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips64r6",
+          "-Wa,-mips64r6",
+        ]
+        ldflags += [ "-mips64r6" ]
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips64r2",
+          "-Wa,-mips64r2",
+        ]
+        ldflags += [ "-mips64r2" ]
+      }
+    }
+  }
+
+  asmflags = cflags
 }
 
 config("compiler_arm_fpu") {
   if (current_cpu == "arm" && !is_ios) {
     cflags = [ "-mfpu=$arm_fpu" ]
+    asmflags = cflags
   }
 }
 
@@ -1234,6 +1343,20 @@
   }
 }
 
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+  if (is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # It gets optimized the same way regardless of the type of build.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else if (is_debug) {
+    configs = [ ":no_optimize" ]
+  } else {
+    configs = [ ":optimize" ]
+  }
+}
+
 # Symbols ----------------------------------------------------------------------
 
 config("symbols") {
@@ -1250,6 +1373,8 @@
     if (use_debug_fission) {
       cflags += [ "-gsplit-dwarf" ]
     }
+    asmflags = cflags
+    ldflags = []
   }
 }
 
@@ -1262,11 +1387,27 @@
     if (use_debug_fission) {
       cflags += [ "-gsplit-dwarf" ]
     }
+    asmflags = cflags
+    ldflags = []
   }
 }
 
 config("no_symbols") {
   if (!is_win) {
     cflags = [ "-g0" ]
+    asmflags = cflags
+  }
+}
+
+# Default symbols.
+config("default_symbols") {
+  if (symbol_level == 0) {
+    configs = [ ":no_symbols" ]
+  } else if (symbol_level == 1) {
+    configs = [ ":minimal_symbols" ]
+  } else if (symbol_level == 2) {
+    configs = [ ":symbols" ]
+  } else {
+    assert(false)
   }
 }
diff --git a/build/config/mac/BUILD.gn b/build/config/mac/BUILD.gn
index 47538c5..1234af1 100644
--- a/build/config/mac/BUILD.gn
+++ b/build/config/mac/BUILD.gn
@@ -11,6 +11,7 @@
     "-mmacosx-version-min=10.9",
   ]
 
+  asmflags = common_flags
   cflags = common_flags
   ldflags = common_flags
 }
diff --git a/build/config/nacl/BUILD.gn b/build/config/nacl/BUILD.gn
index d2643b8..452a68a 100644
--- a/build/config/nacl/BUILD.gn
+++ b/build/config/nacl/BUILD.gn
@@ -2,6 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/nacl/config.gni")
+
 # Native Client Definitions
 config("nacl_defines") {
   defines = [
@@ -32,3 +34,61 @@
     public_configs += [ ":nexe_defines" ]
   }
 }
+
+config("compiler") {
+  cflags = []
+
+  if (is_clang && current_cpu != "pnacl") {
+    # -no-integrated-as is the default in nacl-clang for historical
+    # compatibility with inline assembly code and so forth.  But there
+    # are no such cases in Chromium code, and -integrated-as is nicer in
+    # general.  Moreover, the IRT must be built using LLVM's assembler
+    # on x86-64 to preserve sandbox base address hiding.  Use it
+    # everywhere for consistency (and possibly quicker builds).
+    cflags += [ "-integrated-as" ]
+  }
+
+  asmflags = cflags
+}
+
+config("compiler_codegen") {
+  cflags = []
+
+  if (is_nacl_irt) {
+    cflags += [
+      # A debugger should be able to unwind IRT call frames.  This is
+      # the default behavior on x86-64 and when compiling C++ with
+      # exceptions enabled; the change is for the benefit of x86-32 C.
+      # The frame pointer is unnecessary when unwind tables are used.
+      "-fasynchronous-unwind-tables",
+      "-fomit-frame-pointer",
+    ]
+
+    if (current_cpu == "x86") {
+      # The x86-32 IRT needs to be callable with an under-aligned
+      # stack; so we disable SSE instructions, which can fault on
+      # misaligned addresses.  See
+      # https://code.google.com/p/nativeclient/issues/detail?id=3935
+      cflags += [
+        "-mstackrealign",
+        "-mno-sse",
+      ]
+    }
+  }
+
+  asmflags = cflags
+}
+
+config("irt_optimize") {
+  cflags = [
+    # Optimize for space, keep the IRT nexe small.
+    "-Os",
+
+    # These are omitted from non-IRT libraries to keep the libraries
+    # themselves small.
+    "-ffunction-sections",
+    "-fdata-sections",
+  ]
+
+  ldflags = [ "-Wl,--gc-sections" ]
+}
diff --git a/build/config/nacl/config.gni b/build/config/nacl/config.gni
index 325dfd5..b743910 100644
--- a/build/config/nacl/config.gni
+++ b/build/config/nacl/config.gni
@@ -7,8 +7,9 @@
   # is assumed to be the default one; use this to determine whether Glibc
   # is being used instead.
   is_nacl_glibc = false
-
-  # Native Client has a portable (PNaCl) and native variant; use this to
-  # determine which one is currently being used.
-  is_pnacl = false
 }
+
+nacl_toolchain_dir = "//native_client/toolchain/${host_os}_x86"
+
+nacl_irt_toolchain = "//build/toolchain/nacl:irt_" + target_cpu
+is_nacl_irt = current_toolchain == nacl_irt_toolchain
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni
index f2045e1..77e93c5 100644
--- a/build/toolchain/gcc_toolchain.gni
+++ b/build/toolchain/gcc_toolchain.gni
@@ -49,6 +49,15 @@
 #      default setting.
 #  - is_nacl_glibc
 #      Whether NaCl code is built using Glibc instead of Newlib.
+#  - use_ccache
+#      Override the global use_ccache setting, useful to opt-out of ccache in
+#      a particular toolchain by setting use_ccache = false in it.
+#  - use_goma
+#      Override the global use_goma setting, useful to opt-out of goma in a
+#      particular toolchain by setting use_gome = false in it.
+#  - use_gold
+#      Override the global use_gold setting, useful if the particular
+#      toolchain has a custom link step that is not actually using Gold.
 template("gcc_toolchain") {
   toolchain(target_name) {
     assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
@@ -159,7 +168,7 @@
     tool("asm") {
       # For GCC we can just use the C compiler to compile assembly.
       depfile = "{{output}}.d"
-      command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
+      command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
       depsformat = "gcc"
       description = "ASM {{output}}"
       outputs = [
@@ -273,9 +282,50 @@
                                "is_clang",
                                "is_component_build",
                                "is_nacl_glibc",
+                               "use_gold",
+                               "symbol_level",
                              ])
     }
 
     forward_variables_from(invoker, [ "deps" ])
   }
 }
+
+# This is a shorthand for gcc_toolchain instances based on the
+# Chromium-built version of Clang.  Only the toolchain_cpu and
+# toolchain_os variables need to be specified by the invoker, and
+# optionally toolprefix if it's a cross-compile case.  Note that for
+# a cross-compile case this toolchain requires a config to pass the
+# appropriate -target option, or else it will actually just be doing
+# a native compile.  The invoker can optionally override use_gold too.
+template("clang_toolchain") {
+  assert(defined(invoker.toolchain_cpu),
+         "clang_toolchain() must specify a \"toolchain_cpu\"")
+  assert(defined(invoker.toolchain_os),
+         "clang_toolchain() must specify a \"toolchain_os\"")
+  if (defined(invoker.toolprefix)) {
+    toolprefix = invoker.toolprefix
+  } else {
+    toolprefix = ""
+  }
+
+  gcc_toolchain(target_name) {
+    prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
+                         root_build_dir)
+    cc = "$prefix/clang"
+    cxx = "$prefix/clang++"
+    ld = cxx
+    is_clang = true
+
+    readelf = "${toolprefix}readelf"
+    ar = "${toolprefix}ar"
+    nm = "${toolprefix}nm"
+
+    forward_variables_from(invoker,
+                           [
+                             "toolchain_cpu",
+                             "toolchain_os",
+                             "use_gold",
+                           ])
+  }
+}
diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn
index da4ca05..0894700 100644
--- a/build/toolchain/mac/BUILD.gn
+++ b/build/toolchain/mac/BUILD.gn
@@ -71,7 +71,7 @@
     tool("asm") {
       # For GCC we can just use the C compiler to compile assembly.
       depfile = "{{output}}.d"
-      command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
+      command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
       depsformat = "gcc"
       description = "ASM {{output}}"
       outputs = [
diff --git a/build/toolchain/nacl/BUILD.gn b/build/toolchain/nacl/BUILD.gn
index 6869602..5329f18 100644
--- a/build/toolchain/nacl/BUILD.gn
+++ b/build/toolchain/nacl/BUILD.gn
@@ -3,11 +3,9 @@
 # found in the LICENSE file.
 
 import("//build/config/sysroot.gni")
+import("//build/config/nacl/config.gni")
 import("//build/toolchain/nacl_toolchain.gni")
 
-nacl_toolchain_dir = rebase_path("//native_client/toolchain", root_build_dir)
-os_toolchain_dir = "${nacl_toolchain_dir}/${host_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
@@ -28,7 +26,9 @@
   toolchain_package = "pnacl_newlib"
   toolchain_revision = pnacl_newlib_rev
   toolchain_cpu = "pnacl"
-  toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/pnacl-"
+  toolprefix =
+      rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/pnacl-",
+                  root_build_dir)
 
   cc = toolprefix + "clang"
   cxx = toolprefix + "clang++"
@@ -48,7 +48,9 @@
   toolchain_package = "nacl_x86_glibc"
   toolchain_revision = nacl_x86_glibc_rev
   toolchain_cpu = "x86"
-  toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-"
+  toolprefix =
+      rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/i686-nacl-",
+                  root_build_dir)
   is_clang = false
   is_nacl_glibc = true
 
@@ -62,7 +64,9 @@
   toolchain_package = "nacl_x86_glibc"
   toolchain_revision = nacl_x86_glibc_rev
   toolchain_cpu = "x64"
-  toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-"
+  toolprefix =
+      rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-",
+                  root_build_dir)
   is_clang = false
   is_nacl_glibc = true
 
@@ -78,8 +82,9 @@
 
   toolchain_package = "pnacl_newlib"
   toolchain_revision = pnacl_newlib_rev
-  toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/" +
-               invoker.toolchain_tuple + "-"
+  toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" +
+                               invoker.toolchain_tuple + "-",
+                           root_build_dir)
 
   nacl_toolchain("clang_newlib_" + toolchain_cpu) {
     is_clang = true
@@ -96,8 +101,9 @@
 
   toolchain_package = "pnacl_newlib"
   toolchain_revision = pnacl_newlib_rev
-  toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/" +
-               invoker.toolchain_tuple + "-"
+  toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" +
+                               invoker.toolchain_tuple + "-",
+                           root_build_dir)
 
   link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir)
 
@@ -115,6 +121,10 @@
     ar = toolprefix + "ar"
     readelf = toolprefix + "readelf"
 
+    # Always build the IRT with full debugging symbols, regardless of
+    # how Chromium itself is being built (or other NaCl executables).
+    symbol_level = 2
+
     # 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}"
diff --git a/build/toolchain/nacl_toolchain.gni b/build/toolchain/nacl_toolchain.gni
index a07620d..c851885 100644
--- a/build/toolchain/nacl_toolchain.gni
+++ b/build/toolchain/nacl_toolchain.gni
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/nacl/config.gni")
 import("//build/toolchain/gcc_toolchain.gni")
 
 # This template defines a NaCl toolchain.
@@ -42,10 +43,11 @@
                              "ld",
                              "link_outputs",
                              "postlink",
+                             "symbol_level",
                              "toolchain_cpu",
                            ])
 
-    # We do not suport component builds or sanitizers with the NaCl toolchains.
+    # We do not suport component builds with the NaCl toolchains.
     is_component_build = false
 
     rebuild_define = "NACL_TC_REV=" + invoker.toolchain_revision
diff --git a/examples/pdf_viewer/BUILD.gn b/examples/pdf_viewer/BUILD.gn
index 6024328..58bf26e 100644
--- a/examples/pdf_viewer/BUILD.gn
+++ b/examples/pdf_viewer/BUILD.gn
@@ -21,5 +21,6 @@
     "//mojo/services/network/interfaces",
     "//mojo/services/view_manager/cpp",
     "//third_party/pdfium",
+    "//v8",
   ]
 }
diff --git a/gpu/command_buffer/client/BUILD.gn b/gpu/command_buffer/client/BUILD.gn
index d86edd4..3be0a06 100644
--- a/gpu/command_buffer/client/BUILD.gn
+++ b/gpu/command_buffer/client/BUILD.gn
@@ -46,6 +46,7 @@
   visibility = [
     ":gles2_cmd_helper",
     "//gpu",
+    "//mojo/gles2:control_thunks",
   ]
   sources = [
     "gles2_cmd_helper.cc",
diff --git a/mojo/BUILD.gn b/mojo/BUILD.gn
index c4924cb..debdf0f 100644
--- a/mojo/BUILD.gn
+++ b/mojo/BUILD.gn
@@ -5,16 +5,17 @@
 import("//build/module_args/mojo.gni")
 import("//mojo/public/mojo.gni")
 
+declare_args() {
+  mojo_use_go = false
+
+  # TODO(ncbray): support ASAN once NaCl's GN build is unforked.
+  mojo_use_nacl = is_linux && !is_asan
+  mojo_use_nacl_nonsfi = (is_linux || is_android) && !is_asan
+}
+
 group("mojo") {
   # Meta-target, don't link into production code.
   testonly = true
-  declare_args() {
-    mojo_use_go = false
-
-    # TODO(ncbray): support ASAN once NaCl's GN build is unforked.
-    mojo_use_nacl = is_linux && !is_asan
-    mojo_use_nacl_nonsfi = (is_linux || is_android) && !is_asan
-  }
   deps = [
     ":system_thunks",
     ":tests",
diff --git a/mojo/gles2/BUILD.gn b/mojo/gles2/BUILD.gn
index 6ff568a..d2875b5 100644
--- a/mojo/gles2/BUILD.gn
+++ b/mojo/gles2/BUILD.gn
@@ -28,6 +28,7 @@
     "//mojo/public/c/system",
     "//gpu/command_buffer/client",
     "//gpu/command_buffer/client:gles2_cmd_helper",
+    "//gpu/command_buffer/client:gles2_cmd_helper_sources",
     "//gpu/command_buffer/client:gles2_implementation",
     "//gpu/command_buffer/common",
     "//mojo/public/c/gpu:MGL",
diff --git a/mojo/nacl/nonsfi/BUILD.gn b/mojo/nacl/nonsfi/BUILD.gn
index 6f85538..ad69c95 100644
--- a/mojo/nacl/nonsfi/BUILD.gn
+++ b/mojo/nacl/nonsfi/BUILD.gn
@@ -60,7 +60,7 @@
 
 group("mojo_pnacl_tests") {
   testonly = true
-  deps = [
+  public_deps = [
     "//mojo/nacl:monacl_test(//build/toolchain/nacl:newlib_pnacl)",
   ]
 }
diff --git a/mojo/public/dart/rules.gni b/mojo/public/dart/rules.gni
index a4a29df..4456992 100644
--- a/mojo/public/dart/rules.gni
+++ b/mojo/public/dart/rules.gni
@@ -83,7 +83,7 @@
   }
 
   group(target_name) {
-    deps = [
+    public_deps = [
       ":gen_${bundle_prefix}_bundle",
     ]
   }
diff --git a/mojo/public/mojo_application.gni b/mojo/public/mojo_application.gni
index 975ab7c..9b759c1 100644
--- a/mojo/public/mojo_application.gni
+++ b/mojo/public/mojo_application.gni
@@ -81,7 +81,6 @@
       }
       forward_variables_from(invoker,
                              [
-                               "forward_dependent_configs_from",
                                "public_deps",
                                "all_dependent_configs",
                                "public_configs",
diff --git a/testing/test.gni b/testing/test.gni
index c99df90..c648fc3 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -75,9 +75,6 @@
       if (defined(invoker.direct_dependent_configs)) {
         direct_dependent_configs = invoker.direct_dependent_configs
       }
-      if (defined(invoker.forward_dependent_configs_from)) {
-        forward_dependent_configs_from = invoker.forward_dependent_configs_from
-      }
       if (defined(invoker.include_dirs)) {
         include_dirs = invoker.include_dirs
       }
@@ -215,9 +212,6 @@
       if (defined(invoker.direct_dependent_configs)) {
         direct_dependent_configs = invoker.direct_dependent_configs
       }
-      if (defined(invoker.forward_dependent_configs_from)) {
-        forward_dependent_configs_from = invoker.forward_dependent_configs_from
-      }
       if (defined(invoker.include_dirs)) {
         include_dirs = invoker.include_dirs
       }
diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn
index 521042f..1f1f47f 100644
--- a/ui/gfx/BUILD.gn
+++ b/ui/gfx/BUILD.gn
@@ -101,6 +101,7 @@
     "//base:i18n",
     "//skia",
     "//third_party/harfbuzz-ng",
+    "//third_party/libjpeg_turbo:libjpeg",
     "//third_party/libpng",
     "//third_party/zlib",
     "//third_party:jpeg",
diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn
index 1d7a8ea..80c84dc 100644
--- a/ui/gl/BUILD.gn
+++ b/ui/gl/BUILD.gn
@@ -293,13 +293,13 @@
   }
 
   generate_jni("gl_jni_headers") {
-    deps = [
-      ":surface_jni_headers",
-    ]
     sources = [
       "../android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java",
       "../android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java",
     ]
+    public_deps = [
+      ":surface_jni_headers",
+    ]
     jni_package = "ui/gl"
   }
 }