lots compiling well but gn crashes now

Change-Id: I4924794849704528bb3c6913d03debea6fa19716
diff --git a/kernel/arch/x86/BUILD.gn b/kernel/arch/x86/BUILD.gn
index 913a8a7..9b9e074 100644
--- a/kernel/arch/x86/BUILD.gn
+++ b/kernel/arch/x86/BUILD.gn
@@ -49,6 +49,8 @@
     # USER_ASPACE_BASE from that value gives the value for USER_ASPACE_SIZE
     # below.
     "USER_ASPACE_SIZE=0x00007ffffefff000UL",
+
+    "KERNEL_LOAD_OFFSET=0x00100000",  # 1MB
   ]
 
   # For #include <arch/foo.h>.
diff --git a/kernel/syscalls/BUILD.gn b/kernel/syscalls/BUILD.gn
index 4edfda5..eead04f 100644
--- a/kernel/syscalls/BUILD.gn
+++ b/kernel/syscalls/BUILD.gn
@@ -67,7 +67,7 @@
   include_dirs = [ target_gen_dir ]
 
   deps = [
-#    ":generate-syscall-numbers",
+    ":generate-syscall-numbers",
   ]
 }
 
diff --git a/public/gn/config/BUILD.gn b/public/gn/config/BUILD.gn
index 99b8958..fbc1668 100644
--- a/public/gn/config/BUILD.gn
+++ b/public/gn/config/BUILD.gn
@@ -185,6 +185,8 @@
     "-Werror=implicit-function-declaration",
     "-Wstrict-prototypes",
     "-Wwrite-strings",
+  ]
+  cflags_cc = [
     "-Wconversion",
     "-Wno-sign-conversion",
   ]
@@ -196,7 +198,6 @@
   } else {
     cflags += [
       "-Wno-address-of-packed-member",
-      "-Wthread-safety",
       "-Wimplicit-fallthrough",
     ]
   }
@@ -248,10 +249,12 @@
 }
 
 config_group("frame_pointers") {
+  defines = [ "WITH_FRAME_POINTERS=1" ]
   cflags = [ "-fno-omit-frame-pointer" ]
 }
 
 config_group("no_frame_pointers") {
+  defines = [ "WITH_FRAME_POINTERS=0" ]
   cflags = [ "-fomit-frame-pointer" ]
 }
 
diff --git a/public/gn/host_tool_action.gni b/public/gn/host_tool_action.gni
new file mode 100644
index 0000000..1d3e5f1
--- /dev/null
+++ b/public/gn/host_tool_action.gni
@@ -0,0 +1,81 @@
+# Copyright 2018 The Fuchsia 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("$zx/public/gn/toolchain/select_toolchain.gni")
+
+template("_host_tool_action_target") {
+  action_target = target_name
+
+  assert(defined(invoker.tool), "tool must be defined for $target_name")
+  assert(defined(invoker.outputs), "outputs must be defined for $target_name")
+  assert(defined(invoker.args), "args must be defined for $target_name")
+
+  # Dispatch to a host toolchain to get the tool built.
+  select_toolchain("_tool.$action_target") {
+    visibility = [ ":$action_target" ]
+    cpu = host_cpu
+    os = host_os
+    deps = [
+      invoker.tool,
+    ]
+  }
+
+  target(invoker._target_type, action_target) {
+    forward_variables_from(invoker,
+                           [
+                             "depfile",
+                             "deps",
+                             "inputs",
+                             "outputs",
+                             "public_deps",
+                             "sources",
+                             "testonly",
+                             "visibility",
+                           ])
+    if (!defined(deps)) {
+      deps = []
+    }
+    if (!defined(inputs)) {
+      inputs = []
+    }
+
+    deps += [ ":_tool.$action_target" ]
+
+    # TODO
+    if (false) {
+      script = get_metadata([ "_tool.$action_target" ],
+                            [ "host_tool_action_script" ],
+                            [ "host_tool_barrier" ])
+      inputs += [ get_metadata([ "_tool.$action_target" ],
+                               [ "host_tool_action_inputs" ],
+                               [ "host_tool_barrier" ]) ]
+      args = [ get_metadata([ "_tool.$action_target" ],
+                            [ "host_tool_action_args" ],
+                            [ "host_tool_barrier" ]) ]
+    } else {
+      _host_toolchain = "$zx/public/gn/toolchain:host-$host_cpu-$host_os-clang"
+      tool_out_dir = get_label_info("${invoker.tool}($_host_toolchain)",
+                                    "target_out_dir")
+      script = "$tool_out_dir/" +
+               get_label_info("${invoker.tool}($_host_toolchain)", "name")
+      args = []
+    }
+
+    args += invoker.args
+  }
+}
+
+template("host_tool_action") {
+  _host_tool_action_target(target_name) {
+    _target_type = "action"
+    forward_variables_from(invoker, "*")
+  }
+}
+
+template("host_tool_action_foreach") {
+  _host_tool_action_target(target_name) {
+    _target_type = "action_foreach"
+    forward_variables_from(invoker, "*")
+  }
+}
diff --git a/third_party/lib/jitterentropy/BUILD.gn b/third_party/lib/jitterentropy/BUILD.gn
index 84a8b78..3243750 100644
--- a/third_party/lib/jitterentropy/BUILD.gn
+++ b/third_party/lib/jitterentropy/BUILD.gn
@@ -20,6 +20,7 @@
   # compiler changes.
   #
   # The original Makefile also specifies -fwrapv.
+  deps -= [ "$zx/public/gn/config:opt_level" ]
   cflags = [
     "-O0",
     "-fwrapv",