driver: compile runtime package with nil check removed

Panics in the runtime are uncatchable throws, which will crash
the program anyway. We don't have to worry about if it panics at
the exact memory state as the program order.

With the previous CL, the effect of this CL is allowing the
backend to reorder instructions across a potentially faulting
instruction. The faulting instruction is not removed. So if there
is actually a bug in the runtime causing nil check to fail, it
still crash the program.

Change-Id: Ic87b0fb351be234b3b6727ecb97093257c07a7cf
Reviewed-by: Than McIntosh <>
diff --git a/driver/CompileGo.cpp b/driver/CompileGo.cpp
index dc23698..d6c3b8f 100644
--- a/driver/CompileGo.cpp
+++ b/driver/CompileGo.cpp
@@ -685,7 +685,9 @@
-  args.nil_check_size_threshold = -1;
+  args.nil_check_size_threshold =
+      (args.compiling_runtime && args.pkgpath && strcmp(args.pkgpath, "runtime") == 0 ?
+       4096 : -1);
   args.linemap = linemap_.get();
   args.backend = bridge_.get();
   go_create_gogo (&args);