Use sandboxed clang

Change-Id: I0b9b5b7940b441aba6c6214e621d8997feef90b1
diff --git a/third_party/gflags/BUILD b/third_party/gflags/BUILD
index 2b84041..5e8b505 100644
--- a/third_party/gflags/BUILD
+++ b/third_party/gflags/BUILD
@@ -1,52 +1,53 @@
-licenses(['notice'])
+licenses(["notice"])
 
 common_copts = [
-  '-Ithird_party/gflags/include/gflags',
-  '-Ithird_party/empty_config_h',
-
-  '-DHAVE_STDINT_H=',
-  '-DHAVE_SYS_TYPES_H=',
-  '-DHAVE_INTTYPES_H=',
-  '-DHAVE_SYS_STAT_H=',
-  '-DHAVE_UNISTD_H=',
-  '-DHAVE_FNMATCH_H=',
-  '-DHAVE_STRTOLL=',
-  '-DHAVE_PTHREAD=',
-  '-DHAVE_RWLOCK=',
-  '-D__STDC_FORMAT_MACROS=1',
-  '-DPATH_SEPARATOR=\"\'/\'\"',
-  '-DGFLAGS_IS_A_DLL=0',
-  '-DGFLAGS_DLL_DECL=',
-  '-DGFLAGS_DLL_DEFINE_FLAG=',
-
-  '-Wno-format-nonliteral',
-  '-Wno-unused-local-typedefs',
-  '-Wno-sign-compare',
-  '-Wno-missing-field-initializers',
+    "-Ithird_party/gflags/include/gflags",
+    "-Ithird_party/empty_config_h",
+    "-DHAVE_STDINT_H=",
+    "-DHAVE_SYS_TYPES_H=",
+    "-DHAVE_INTTYPES_H=",
+    "-DHAVE_SYS_STAT_H=",
+    "-DHAVE_UNISTD_H=",
+    "-DHAVE_FNMATCH_H=",
+    "-DHAVE_STRTOLL=",
+    "-DHAVE_PTHREAD=",
+    "-DHAVE_RWLOCK=",
+    "-D__STDC_FORMAT_MACROS=1",
+    "-DPATH_SEPARATOR=\"'/'\"",
+    "-DGFLAGS_IS_A_DLL=0",
+    "-DGFLAGS_DLL_DECL=",
+    "-DGFLAGS_DLL_DEFINE_FLAG=",
+    "-Wno-format-nonliteral",
+    "-Wno-unused-local-typedefs",
+    "-Wno-sign-compare",
+    "-Wno-missing-field-initializers",
 ]
 
 cc_library(
-  name = 'gflags',
-  visibility = ['//visibility:public'],
-  srcs = glob([
-    'src/*.cc',
-    'src/*.h',
-  ], exclude=[
-    'src/windows_*',
-  ]) + [
-    'include/gflags/gflags_declare.h',
-    'include/gflags/gflags_gflags.h',
-  ],
-  hdrs = [
-    'include/gflags/gflags.h',
-    'include/gflags/gflags_completions.h',
-  ],
-  deps = [
-    '//third_party/empty_config_h',
-  ],
-  linkopts = [
-    '-pthread',
-  ],
-  copts = common_copts,
-  includes = [ 'include' ],
+    name = "gflags",
+    srcs = glob(
+        [
+            "src/*.cc",
+            "src/*.h",
+        ],
+        exclude = [
+            "src/windows_*",
+        ],
+    ) + [
+        "include/gflags/gflags_declare.h",
+        "include/gflags/gflags_gflags.h",
+    ],
+    hdrs = [
+        "include/gflags/gflags.h",
+        "include/gflags/gflags_completions.h",
+    ],
+    copts = common_copts,
+    includes = ["include"],
+    linkopts = [
+        "-lpthread",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        "//third_party/empty_config_h",
+    ],
 )
diff --git a/third_party/googletest/BUILD b/third_party/googletest/BUILD
index 67ada7c..c082b0c 100644
--- a/third_party/googletest/BUILD
+++ b/third_party/googletest/BUILD
@@ -6,32 +6,27 @@
 # build targets here, the libraries are independent of their location in
 # a more straightforward way.
 
-load('//tools/build_rules:empty_main.bzl', 'empty_main_if_asan')
+load("//tools/build_rules:empty_main.bzl", "empty_main_if_asan")
 
 licenses(["notice"])
 
 cc_library(
     name = "googletest",
-    visibility = ["//visibility:public"],
     srcs = glob([
-    	"googletest/src/gtest.cc",
-    	"googletest/src/gtest-death-test.cc",
-    	"googletest/src/gtest-filepath.cc",
-    	"googletest/src/gtest-internal-inl.h",
-    	"googletest/src/gtest-port.cc",
-    	"googletest/src/gtest-printers.cc",
-    	"googletest/src/gtest-test-part.cc",
-    	"googletest/src/gtest-typed-test.cc",
-    	"googletest/include/gtest/internal/*.h",
-    	"googletest/include/gtest/internal/custom/*.h",
+        "googletest/src/gtest.cc",
+        "googletest/src/gtest-death-test.cc",
+        "googletest/src/gtest-filepath.cc",
+        "googletest/src/gtest-internal-inl.h",
+        "googletest/src/gtest-port.cc",
+        "googletest/src/gtest-printers.cc",
+        "googletest/src/gtest-test-part.cc",
+        "googletest/src/gtest-typed-test.cc",
+        "googletest/include/gtest/internal/*.h",
+        "googletest/include/gtest/internal/custom/*.h",
     ]),
     hdrs = glob([
-    	"googletest/include/gtest/*.h"
+        "googletest/include/gtest/*.h",
     ]),
-    includes = [
-        "googletest",
-        "googletest/include",
-    ],
     copts = [
         "-g",
         "-Wall",
@@ -40,25 +35,29 @@
         "-Wno-switch-enum",
         "-Wno-missing-field-initializers",
     ],
+    includes = [
+        "googletest",
+        "googletest/include",
+    ],
     linkopts = [
-        "-pthread",
+        "-lpthread",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+cc_library(
+    name = "googletest_main",
+    srcs = [
+        "googletest/src/gtest_main.cc",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":googletest",
     ],
 )
 
 cc_library(
-  name = "googletest_main",
-  visibility = ["//visibility:public"],
-  srcs = [
-    "googletest/src/gtest_main.cc",
-  ],
-  deps = [
-    ":googletest",
-  ],
-)
-
-cc_library(
-	name = "googlemock",
-    visibility = ["//visibility:public"],
+    name = "googlemock",
     srcs = glob([
         "googlemock/src/gmock-cardinalities.cc",
         "googlemock/src/gmock.cc",
@@ -70,13 +69,8 @@
         "googlemock/include/gmock/internal/custom/*.h",
     ]),
     hdrs = glob([
-        "googlemock/include/gmock/*.h"
+        "googlemock/include/gmock/*.h",
     ]),
-    includes = [
-        "googletest/include",
-        "googlemock",
-        "googlemock/include",
-    ],
     copts = [
         "-std=c++11",
         "-g",
@@ -86,9 +80,15 @@
         "-Wno-missing-field-initializers",
         "-Wno-unused-parameter",
     ],
-    linkopts = [
-        "-pthread",
+    includes = [
+        "googlemock",
+        "googlemock/include",
+        "googletest/include",
     ],
+    linkopts = [
+        "-lpthread",
+    ],
+    visibility = ["//visibility:public"],
     deps = [
         ":googletest",
     ],
@@ -104,35 +104,35 @@
 )
 
 cc_library(
-	name = "googletest_sample_libs",
-	hdrs = [
-	    "googletest/samples/prime_tables.h",
-	    "googletest/samples/sample1.h",
-	    "googletest/samples/sample2.h",
-	    "googletest/samples/sample3-inl.h",
-	    "googletest/samples/sample4.h",
-	],
-	srcs = [
-	    "googletest/samples/sample1.cc",
-	    "googletest/samples/sample2.cc",
-	    "googletest/samples/sample4.cc",
-	],
+    name = "googletest_sample_libs",
+    srcs = [
+        "googletest/samples/sample1.cc",
+        "googletest/samples/sample2.cc",
+        "googletest/samples/sample4.cc",
+    ],
+    hdrs = [
+        "googletest/samples/prime_tables.h",
+        "googletest/samples/sample1.h",
+        "googletest/samples/sample2.h",
+        "googletest/samples/sample3-inl.h",
+        "googletest/samples/sample4.h",
+    ],
 )
 
 test_suite(
-	name = "googletest_example_tests",
-	tests = [
-	    ":googletest_sample1_test",
-	    ":googletest_sample2_test",
-	    ":googletest_sample3_test",
-	    ":googletest_sample4_test",
-	    ":googletest_sample5_test",
-	    ":googletest_sample6_test",
-  	    ":googletest_sample7_test",
-	    ":googletest_sample8_test",
-	    ":googletest_sample9_test",
-	    ":googletest_sample10_test",
-	],
+    name = "googletest_example_tests",
+    tests = [
+        ":googletest_sample10_test",
+        ":googletest_sample1_test",
+        ":googletest_sample2_test",
+        ":googletest_sample3_test",
+        ":googletest_sample4_test",
+        ":googletest_sample5_test",
+        ":googletest_sample6_test",
+        ":googletest_sample7_test",
+        ":googletest_sample8_test",
+        ":googletest_sample9_test",
+    ],
 )
 
 test_suite(
@@ -181,104 +181,105 @@
 )
 
 cc_test(
-	name = "googletest_sample1_test",
-	srcs = ["googletest/samples/sample1_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample1_test",
+    srcs = ["googletest/samples/sample1_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample2_test",
-	srcs = ["googletest/samples/sample2_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample2_test",
+    srcs = ["googletest/samples/sample2_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample3_test",
-	srcs = ["googletest/samples/sample3_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample3_test",
+    srcs = ["googletest/samples/sample3_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample4_test",
-	srcs = ["googletest/samples/sample4_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample4_test",
+    srcs = ["googletest/samples/sample4_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample5_test",
-	srcs = ["googletest/samples/sample5_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample5_test",
+    srcs = ["googletest/samples/sample5_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample6_test",
-	srcs = ["googletest/samples/sample6_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample6_test",
+    srcs = ["googletest/samples/sample6_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample7_test",
-	srcs = ["googletest/samples/sample7_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample7_test",
+    srcs = ["googletest/samples/sample7_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample8_test",
-	srcs = ["googletest/samples/sample8_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample8_test",
+    srcs = ["googletest/samples/sample8_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample9_test",
-	srcs = ["googletest/samples/sample9_unittest.cc"],
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample9_test",
+    srcs = ["googletest/samples/sample9_unittest.cc"],
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 cc_test(
-	name = "googletest_sample10_test",
-	srcs = empty_main_if_asan(["googletest/samples/sample10_unittest.cc"]),
-	deps = [
-	    ":googletest_main",
-	    ":googletest_sample_libs",
-	],
+    name = "googletest_sample10_test",
+    srcs = empty_main_if_asan(["googletest/samples/sample10_unittest.cc"]),
+    deps = [
+        ":googletest_main",
+        ":googletest_sample_libs",
+    ],
 )
 
 """ Tests on the googletest library itself."""
+
 cc_library(
     name = "gtest_production",
-    hdrs = [
-        "googletest/test/production.h",
-    ],
     srcs = [
         "googletest/test/production.cc",
     ],
+    hdrs = [
+        "googletest/test/production.h",
+    ],
     deps = [
         ":googletest_main",
     ],
@@ -333,12 +334,12 @@
     srcs = [
         "googletest/test/gtest-port_test.cc",
     ],
+    copts = [
+        "-Wno-empty-body",
+    ],
     deps = [
         ":googletest_main",
     ],
-    copts = [
-        "-Wno-empty-body",
-    ]
 )
 
 cc_test(
@@ -379,8 +380,8 @@
 cc_test(
     name = "googletest_gtest_typed_test_test",
     srcs = [
-        "googletest/test/gtest-typed-test_test.h",
         "googletest/test/gtest-typed-test_test.cc",
+        "googletest/test/gtest-typed-test_test.h",
     ],
     deps = [
         ":googletest_main",
@@ -390,8 +391,8 @@
 cc_test(
     name = "googletest_gtest_typed_test2_test",
     srcs = [
-        "googletest/test/gtest-typed-test_test.h",
         "googletest/test/gtest-typed-test2_test.cc",
+        "googletest/test/gtest-typed-test_test.h",
     ],
     deps = [
         ":googletest_main",
@@ -403,20 +404,20 @@
     srcs = [
         "googletest/test/gtest_unittest.cc",
     ],
-    deps = [
-        ":googletest_main",
-    ],
     copts = [
         "-Wno-empty-body",
         "-Wno-missing-field-initializers",
-    ]
+    ],
+    deps = [
+        ":googletest_main",
+    ],
 )
 
 cc_test(
     name = "googletest_gtest_production_test",
     srcs = [
-        "googletest/test/production.h",
         "googletest/test/production.cc",
+        "googletest/test/production.h",
     ],
     deps = [
         ":googletest_main",
@@ -424,6 +425,7 @@
 )
 
 """ Tests on the googlemock library itself."""
+
 cc_test(
     name = "googlemock_gmock_actions_test",
     srcs = [
@@ -449,7 +451,7 @@
     ],
 )
 
-'''
+"""
 cc_test(
     name = "googlemock_gmock_ex_test",
     srcs = [
@@ -460,7 +462,7 @@
         ":googletest_main",
     ],
 )
-'''
+"""
 
 cc_test(
     name = "googlemock_gmock_generated_actions_test",
@@ -500,13 +502,13 @@
     srcs = [
         "googlemock/test/gmock-generated-matchers_test.cc",
     ],
+    copts = [
+        "-Wno-unused-parameter",
+    ],
     deps = [
         ":googlemock",
         ":googletest_main",
     ],
-    copts = [
-        "-Wno-unused-parameter",
-    ],
 )
 
 cc_test(
@@ -536,8 +538,8 @@
 cc_test(
     name = "googlemock_gmock_link_test",
     srcs = [
-        "googlemock/test/gmock_link_test.h",
         "googlemock/test/gmock_link_test.cc",
+        "googlemock/test/gmock_link_test.h",
     ],
     deps = [
         ":googlemock",
@@ -548,8 +550,8 @@
 cc_test(
     name = "googlemock_gmock_link2_test",
     srcs = [
-        "googlemock/test/gmock_link_test.h",
         "googlemock/test/gmock_link2_test.cc",
+        "googlemock/test/gmock_link_test.h",
     ],
     deps = [
         ":googlemock",
@@ -562,13 +564,13 @@
     srcs = [
         "googlemock/test/gmock-matchers_test.cc",
     ],
+    copts = [
+        "-Wno-unused-parameter",
+    ],
     deps = [
         ":googlemock",
         ":googletest_main",
     ],
-    copts = [
-        "-Wno-unused-parameter",
-    ],
 )
 
 cc_test(
diff --git a/third_party/gperftools/BUILD b/third_party/gperftools/BUILD
index c0fa7c0..d5a742e 100644
--- a/third_party/gperftools/BUILD
+++ b/third_party/gperftools/BUILD
@@ -1,426 +1,429 @@
-licenses(['notice'])
+licenses(["notice"])
 
-load('//tools/build_rules:select.bzl', 'cpu_select', 'compiler_select')
-load('//tools/build_rules:empty_main.bzl', 'empty_main_if_asan')
+load("//tools/build_rules:select.bzl", "cpu_select", "compiler_select")
+load("//tools/build_rules:empty_main.bzl", "empty_main_if_asan")
 
 common_copts = [
-  # Stuff from their Makefile.
-  '-Wno-cast-align',
-  '-Wno-sign-compare',
-  '-fno-builtin-malloc',
-  '-fno-builtin-free',
-  '-fno-builtin-realloc',
-  '-fno-builtin-calloc',
-  '-fno-builtin-cfree',
-  '-fno-builtin-memalign',
-  '-fno-builtin-posix_memalign',
-  '-fno-builtin-valloc',
-  '-fno-builtin-pvalloc',
-  '-Wno-unused-result',
-  '-fno-omit-frame-pointer',
-  '-DNDEBUG',
+    # Stuff from their Makefile.
+    "-Wno-cast-align",
+    "-Wno-sign-compare",
+    "-fno-builtin-malloc",
+    "-fno-builtin-free",
+    "-fno-builtin-realloc",
+    "-fno-builtin-calloc",
+    "-fno-builtin-cfree",
+    "-fno-builtin-memalign",
+    "-fno-builtin-posix_memalign",
+    "-fno-builtin-valloc",
+    "-fno-builtin-pvalloc",
+    "-Wno-unused-result",
+    "-fno-omit-frame-pointer",
+    "-DNDEBUG",
 
-  # Stuff to make it work for us.
-  '-Ithird_party/gperftools/src/',
-  '-Ithird_party/empty_config_h',
-  '-Wno-unused-parameter',
-  '-Wno-missing-field-initializers',
-  '-Wno-unused-function',
-  '-Wno-unused-variable',
-  '-Wno-format-nonliteral',
-  '-Wno-switch-enum',
-  '-Wno-error=cast-align',
-  '-Wno-error=cast-qual',
+    # Stuff to make it work for us.
+    "-Ithird_party/gperftools/src/",
+    "-Ithird_party/empty_config_h",
+    "-Wno-unused-parameter",
+    "-Wno-missing-field-initializers",
+    "-Wno-unused-function",
+    "-Wno-unused-variable",
+    "-Wno-format-nonliteral",
+    "-Wno-switch-enum",
+    "-Wno-error=cast-align",
+    "-Wno-error=cast-qual",
 
-  # Stuff pulled out of config.h.
-  '-DHAVE_BUILTIN_EXPECT=1',
-  '-DHAVE_DECL_CFREE=1',
-  '-DHAVE_DECL_MEMALIGN=1',
-  '-DHAVE_DECL_POSIX_MEMALIGN=1',
-  '-DHAVE_DECL_PVALLOC=1',
-  '-DHAVE_DECL_UNAME=1',
-  '-DHAVE_DECL_VALLOC=1',
-  '-DHAVE_DLFCN_H=1',
-  '-DHAVE_ELF32_VERSYM=1',
-  '-DHAVE_EXECINFO_H=1',
-  '-DHAVE_FCNTL_H=1',
-  '-DHAVE_FEATURES_H=1',
-  '-DHAVE_FORK=1',
-  '-DHAVE_GETEUID=1',
-  '-DHAVE_GLOB_H=1',
-  '-DHAVE_GRP_H=1',
-  '-DHAVE_INTTYPES_H=1',
-  '-DHAVE_LINUX_PTRACE_H=1',
-  '-DHAVE_LINUX_SIGEV_THREAD_ID=1',
-  '-DHAVE_MALLOC_H=1',
-  '-DHAVE_MEMORY_H=1',
-  '-DHAVE_MMAP=1',
-  '-DHAVE_NAMESPACES=1',
-  '-DHAVE_POLL_H=1',
-  '-DHAVE_PROGRAM_INVOCATION_NAME=1',
-  '-DHAVE_PTHREAD=1',
-  '-DHAVE_PWD_H=1',
-  '-DHAVE_SBRK=1',
-  '-DHAVE_SCHED_H=1',
-  '-DHAVE_STDINT_H=1',
-  '-DHAVE_STDLIB_H=1',
-  '-DHAVE_STRINGS_H=1',
-  '-DHAVE_STRING_H=1',
-  '-DHAVE_STRUCT_MALLINFO=1',
-  '-DHAVE_SYS_CDEFS_H=1',
-  '-DHAVE_SYS_PRCTL_H=1',
-  '-DHAVE_SYS_RESOURCE_H=1',
-  '-DHAVE_SYS_SOCKET_H=1',
-  '-DHAVE_SYS_STAT_H=1',
-  '-DHAVE_SYS_SYSCALL_H=1',
-  '-DHAVE_SYS_TYPES_H=1',
-  '-DHAVE_SYS_UCONTEXT_H=1',
-  '-DHAVE_SYS_WAIT_H=1',
-  '-DHAVE_TLS=1',
-  '-DHAVE_UCONTEXT_H=1',
-  '-DHAVE_UNISTD_H=1',
-  '-DHAVE_UNWIND_H=1',
-  '-DHAVE___ATTRIBUTE__=1',
-  '-DHAVE___ENVIRON=1',
-  '-DMALLOC_HOOK_MAYBE_VOLATILE=volatile',
-  '-DPERFTOOLS_DLL_DECL=',
-  '-DSTDC_HEADERS=1',
-  '-DSTL_NAMESPACE=std',
-  '-DPACKAGE_STRING=\\"gperftools\\ 2.4\\"',
-  '-DPACKAGE_BUGREPORT=\\"http://frc971.org/contact\\"',
-  '-DPACKAGE_VERSION=\\"2.4\\"',
+    # Stuff pulled out of config.h.
+    "-DHAVE_BUILTIN_EXPECT=1",
+    "-DHAVE_DECL_CFREE=1",
+    "-DHAVE_DECL_MEMALIGN=1",
+    "-DHAVE_DECL_POSIX_MEMALIGN=1",
+    "-DHAVE_DECL_PVALLOC=1",
+    "-DHAVE_DECL_UNAME=1",
+    "-DHAVE_DECL_VALLOC=1",
+    "-DHAVE_DLFCN_H=1",
+    "-DHAVE_ELF32_VERSYM=1",
+    "-DHAVE_EXECINFO_H=1",
+    "-DHAVE_FCNTL_H=1",
+    "-DHAVE_FEATURES_H=1",
+    "-DHAVE_FORK=1",
+    "-DHAVE_GETEUID=1",
+    "-DHAVE_GLOB_H=1",
+    "-DHAVE_GRP_H=1",
+    "-DHAVE_INTTYPES_H=1",
+    "-DHAVE_LINUX_PTRACE_H=1",
+    "-DHAVE_LINUX_SIGEV_THREAD_ID=1",
+    "-DHAVE_MALLOC_H=1",
+    "-DHAVE_MEMORY_H=1",
+    "-DHAVE_MMAP=1",
+    "-DHAVE_NAMESPACES=1",
+    "-DHAVE_POLL_H=1",
+    "-DHAVE_PROGRAM_INVOCATION_NAME=1",
+    "-DHAVE_PTHREAD=1",
+    "-DHAVE_PWD_H=1",
+    "-DHAVE_SBRK=1",
+    "-DHAVE_SCHED_H=1",
+    "-DHAVE_STDINT_H=1",
+    "-DHAVE_STDLIB_H=1",
+    "-DHAVE_STRINGS_H=1",
+    "-DHAVE_STRING_H=1",
+    "-DHAVE_STRUCT_MALLINFO=1",
+    "-DHAVE_SYS_CDEFS_H=1",
+    "-DHAVE_SYS_PRCTL_H=1",
+    "-DHAVE_SYS_RESOURCE_H=1",
+    "-DHAVE_SYS_SOCKET_H=1",
+    "-DHAVE_SYS_STAT_H=1",
+    "-DHAVE_SYS_SYSCALL_H=1",
+    "-DHAVE_SYS_TYPES_H=1",
+    "-DHAVE_SYS_UCONTEXT_H=1",
+    "-DHAVE_SYS_WAIT_H=1",
+    "-DHAVE_TLS=1",
+    "-DHAVE_UCONTEXT_H=1",
+    "-DHAVE_UNISTD_H=1",
+    "-DHAVE_UNWIND_H=1",
+    "-DHAVE___ATTRIBUTE__=1",
+    "-DHAVE___ENVIRON=1",
+    "-DMALLOC_HOOK_MAYBE_VOLATILE=volatile",
+    "-DPERFTOOLS_DLL_DECL=",
+    "-DSTDC_HEADERS=1",
+    "-DSTL_NAMESPACE=std",
+    "-DPACKAGE_STRING=\\\"gperftools\ 2.4\\\"",
+    "-DPACKAGE_BUGREPORT=\\\"http://frc971.org/contact\\\"",
+    "-DPACKAGE_VERSION=\\\"2.4\\\"",
 ] + cpu_select({
-  'amd64': [
-    '-DHAVE_GETPAGESZE=1',
-    '-DHAVE_SYS_PARAM_H=1',
-    '-DPC_FROM_UCONTEXT=uc_mcontext.gregs[REG_RIP]',
-    '-DPRIdS=\\"ld\\"',
-    '-DPRIuS=\\"lu\\"',
-    '-DPRIxS=\\"lx\\"',
-  ],
-  'arm': [
-    '-DPC_FROM_UCONTEXT=uc_mcontext.arm_pc',
-    '-DPRIdS=\\"d\\"',
-    '-DPRIuS=\\"u\\"',
-    '-DPRIxS=\\"x\\"',
-  ],
+    "amd64": [
+        "-DHAVE_GETPAGESZE=1",
+        "-DHAVE_SYS_PARAM_H=1",
+        "-DPC_FROM_UCONTEXT=uc_mcontext.gregs[REG_RIP]",
+        "-DPRIdS=\\\"ld\\\"",
+        "-DPRIuS=\\\"lu\\\"",
+        "-DPRIxS=\\\"lx\\\"",
+    ],
+    "arm": [
+        "-DPC_FROM_UCONTEXT=uc_mcontext.arm_pc",
+        "-DPRIdS=\\\"d\\\"",
+        "-DPRIuS=\\\"u\\\"",
+        "-DPRIxS=\\\"x\\\"",
+    ],
 }) + compiler_select({
-  'clang': [
-    '-Wno-unused-const-variable',
-    '-Wno-gnu-alignof-expression',
-    '-Wno-unused-private-field',
-  ],
-  'gcc': [],
+    "clang": [
+        "-Wno-unused-const-variable",
+        "-Wno-gnu-alignof-expression",
+        "-Wno-unused-private-field",
+    ],
+    "gcc": [],
 })
 
 cc_library(
-  name = 'tcmalloc',
-  visibility = ['//visibility:public'],
-  hdrs = glob([
-    'src/*.h',
-    'src/base/*.h',
-    'src/gperftools/*.h',
-  ]) + [
-    'src/third_party/valgrind.h',
-  ],
-  srcs = glob(include = [
-    'src/*.cc',
-    'src/*.c',
-    'src/base/*.cc',
-    'src/base/*.c',
-  ], exclude = [
-    '**/*_unittest.cc',
-    '**/*_test.cc',
-    'src/debugallocation.cc',
-  ]),
-  deps = [
-    '//third_party/empty_config_h',
-  ],
-  copts = common_copts,
-  linkopts = [
-    '-lrt',
-    '-pthread',
-  ],
-  alwayslink = True,
-  nocopts = '-std=gnu\+\+1y',
+    name = "tcmalloc",
+    srcs = glob(
+        include = [
+            "src/*.cc",
+            "src/*.c",
+            "src/base/*.cc",
+            "src/base/*.c",
+        ],
+        exclude = [
+            "**/*_unittest.cc",
+            "**/*_test.cc",
+            "src/debugallocation.cc",
+        ],
+    ),
+    hdrs = glob([
+        "src/*.h",
+        "src/base/*.h",
+        "src/gperftools/*.h",
+    ]) + [
+        "src/third_party/valgrind.h",
+    ],
+    copts = common_copts,
+    linkopts = [
+        "-lrt",
+        "-lpthread",
+    ],
+    nocopts = "-std=gnu\+\+1y",
+    visibility = ["//visibility:public"],
+    deps = [
+        "//third_party/empty_config_h",
+    ],
+    alwayslink = True,
 )
 
 cc_library(
-  name = 'testutil',
-  srcs = [
-    'src/tests/testutil.cc',
-  ],
-  hdrs = [
-    'src/tests/testutil.h',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-)
-
-cc_test(
-  name = 'low_level_alloc_unittest',
-  srcs = [
-    'src/tests/low_level_alloc_unittest.cc',
-  ],
-  defines = [
-    'NO_TCMALLOC_SAMPLES',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'medium',
-)
-
-cc_test(
-  name = 'atomicops_unittest',
-  srcs = [
-    'src/tests/atomicops_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
-)
-
-cc_test(
-  name = 'stacktrace_unittest',
-  srcs = [
-    'src/tests/stacktrace_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
-)
-
-cc_test(
-  name = 'tcmalloc_unittest',
-  srcs = empty_main_if_asan([
-    'src/tests/tcmalloc_unittest.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-    ':testutil',
-  ],
-  copts = common_copts + [
-    '-fno-builtin',
-    # Add this back in when we upgrade clang.
-    #'-Wno-mismatched-new-delete',
-  ],
-  size = 'small',
-)
-
-cc_test(
-  name = 'tcmalloc_large_unittest',
-  srcs = empty_main_if_asan([
-    'src/tests/tcmalloc_large_unittest.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts + [
-    '-fno-builtin',
-  ],
-  size = 'small',
-)
-
-cc_test(
-  name = 'addressmap_unittest',
-  srcs = [
-    'src/tests/addressmap_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'medium',
-)
-
-cc_test(
-  name = 'system_alloc_unittest',
-  srcs = empty_main_if_asan([
-    'src/tests/system-alloc_unittest.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts + [
-    '-fno-builtin',
-  ],
-  size = 'small',
-)
-
-cc_test(
-  name = 'packed_cache_test',
-  srcs = [
-    'src/tests/packed-cache_test.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
-)
-
-cc_test(
-  name = 'frag_unittest',
-  srcs = [
-    'src/tests/frag_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
-)
-
-cc_test(
-  name = 'markidle_unittest',
-  srcs = empty_main_if_asan([
-    'src/tests/markidle_unittest.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-    ':testutil',
-  ],
-  copts = common_copts,
-  size = 'small',
-)
-
-cc_test(
-  name = 'current_allocated_bytes_test',
-  srcs = [
-    'src/tests/current_allocated_bytes_test.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
-)
-
-cc_test(
-  name = 'malloc_hook_test',
-  srcs = [
-    'src/tests/malloc_hook_test.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-    ':testutil',
-  ],
-  copts = common_copts + compiler_select({
-    'gcc': [
-      '-Wno-maybe-uninitialized',
+    name = "testutil",
+    srcs = [
+        "src/tests/testutil.cc",
     ],
-    'clang': [],
-  }),
-  size = 'small',
+    hdrs = [
+        "src/tests/testutil.h",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'malloc_extension_test',
-  srcs = empty_main_if_asan([
-    'src/tests/malloc_extension_test.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "low_level_alloc_unittest",
+    size = "medium",
+    srcs = [
+        "src/tests/low_level_alloc_unittest.cc",
+    ],
+    copts = common_copts,
+    defines = [
+        "NO_TCMALLOC_SAMPLES",
+    ],
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'malloc_extension_c_test',
-  srcs = empty_main_if_asan([
-    'src/tests/malloc_extension_c_test.c',
-  ]),
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "atomicops_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/atomicops_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'memalign_unittest',
-  srcs = empty_main_if_asan([
-    'src/tests/memalign_unittest.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-    ':testutil',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "stacktrace_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/stacktrace_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'page_heap_test',
-  srcs = [
-    'src/tests/page_heap_test.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "tcmalloc_unittest",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/tcmalloc_unittest.cc",
+    ]),
+    copts = common_copts + [
+        "-fno-builtin",
+        # Add this back in when we upgrade clang.
+        #'-Wno-mismatched-new-delete',
+    ],
+    deps = [
+        ":tcmalloc",
+        ":testutil",
+    ],
 )
 
 cc_test(
-  name = 'pagemap_unittest',
-  srcs = empty_main_if_asan([
-    'src/tests/pagemap_unittest.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "tcmalloc_large_unittest",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/tcmalloc_large_unittest.cc",
+    ]),
+    copts = common_copts + [
+        "-fno-builtin",
+    ],
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'realloc_unittest',
-  srcs = [
-    'src/tests/realloc_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "addressmap_unittest",
+    size = "medium",
+    srcs = [
+        "src/tests/addressmap_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'stack_trace_table_test',
-  srcs = [
-    'src/tests/stack_trace_table_test.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "system_alloc_unittest",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/system-alloc_unittest.cc",
+    ]),
+    copts = common_copts + [
+        "-fno-builtin",
+    ],
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'thread_dealloc_unittest',
-  srcs = [
-    'src/tests/thread_dealloc_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-    ':testutil',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "packed_cache_test",
+    size = "small",
+    srcs = [
+        "src/tests/packed-cache_test.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
-'''
+cc_test(
+    name = "frag_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/frag_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "markidle_unittest",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/markidle_unittest.cc",
+    ]),
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+        ":testutil",
+    ],
+)
+
+cc_test(
+    name = "current_allocated_bytes_test",
+    size = "small",
+    srcs = [
+        "src/tests/current_allocated_bytes_test.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "malloc_hook_test",
+    size = "small",
+    srcs = [
+        "src/tests/malloc_hook_test.cc",
+    ],
+    copts = common_copts + compiler_select({
+        "gcc": [
+            "-Wno-maybe-uninitialized",
+        ],
+        "clang": [],
+    }),
+    deps = [
+        ":tcmalloc",
+        ":testutil",
+    ],
+)
+
+cc_test(
+    name = "malloc_extension_test",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/malloc_extension_test.cc",
+    ]),
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "malloc_extension_c_test",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/malloc_extension_c_test.c",
+    ]),
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "memalign_unittest",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/memalign_unittest.cc",
+    ]),
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+        ":testutil",
+    ],
+)
+
+cc_test(
+    name = "page_heap_test",
+    size = "small",
+    srcs = [
+        "src/tests/page_heap_test.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "pagemap_unittest",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/pagemap_unittest.cc",
+    ]),
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "realloc_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/realloc_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "stack_trace_table_test",
+    size = "small",
+    srcs = [
+        "src/tests/stack_trace_table_test.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
+)
+
+cc_test(
+    name = "thread_dealloc_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/thread_dealloc_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+        ":testutil",
+    ],
+)
+
+"""
 We don't build this because it actually needs to be in a separate binary.
 cc_test(
   name = 'debugallocation_test',
@@ -433,91 +436,91 @@
   copts = common_copts,
   size = 'small',
 )
-'''
+"""
 
 cc_test(
-  name = 'tcmalloc_large_heap_fragmentation_unittest',
-  srcs = empty_main_if_asan([
-    'src/tests/large_heap_fragmentation_unittest.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "tcmalloc_large_heap_fragmentation_unittest",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/large_heap_fragmentation_unittest.cc",
+    ]),
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'raw_printer_test',
-  srcs = [
-    'src/tests/raw_printer_test.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "raw_printer_test",
+    size = "small",
+    srcs = [
+        "src/tests/raw_printer_test.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'getpc_test',
-  srcs = empty_main_if_asan([
-    'src/tests/getpc_test.cc',
-  ]),
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "getpc_test",
+    size = "small",
+    srcs = empty_main_if_asan([
+        "src/tests/getpc_test.cc",
+    ]),
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'profiledata_unittest',
-  srcs = [
-    'src/tests/profiledata_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "profiledata_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/profiledata_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'profile_handler_unittest',
-  srcs = [
-    'src/tests/profile-handler_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  flaky = True,
-  size = 'small',
+    name = "profile_handler_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/profile-handler_unittest.cc",
+    ],
+    copts = common_copts,
+    flaky = True,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'heap_profiler_unittest',
-  srcs = [
-    'src/tests/heap-profiler_unittest.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts,
-  size = 'small',
+    name = "heap_profiler_unittest",
+    size = "small",
+    srcs = [
+        "src/tests/heap-profiler_unittest.cc",
+    ],
+    copts = common_copts,
+    deps = [
+        ":tcmalloc",
+    ],
 )
 
 cc_test(
-  name = 'sampler_test',
-  srcs = [
-    'src/tests/sampler_test.cc',
-  ],
-  deps = [
-    ':tcmalloc',
-  ],
-  copts = common_copts + [
-    '-Wno-type-limits',
-  ],
-  size = 'small',
+    name = "sampler_test",
+    size = "small",
+    srcs = [
+        "src/tests/sampler_test.cc",
+    ],
+    copts = common_copts + [
+        "-Wno-type-limits",
+    ],
+    deps = [
+        ":tcmalloc",
+    ],
 )
diff --git a/third_party/protobuf/gmock.BUILD b/third_party/protobuf/gmock.BUILD
index 82abf27..f8b486c 100644
--- a/third_party/protobuf/gmock.BUILD
+++ b/third_party/protobuf/gmock.BUILD
@@ -15,14 +15,14 @@
         "gmock-1.7.0/gtest/include",
         "gmock-1.7.0/include",
     ],
-    linkopts = ["-pthread"],
+    linkopts = ["-lpthread"],
     visibility = ["//visibility:public"],
 )
 
 cc_library(
     name = "gtest_main",
     srcs = ["gmock-1.7.0/src/gmock_main.cc"],
-    linkopts = ["-pthread"],
+    linkopts = ["-lpthread"],
     visibility = ["//visibility:public"],
     deps = [":gtest"],
 )