Add support for building code for Debian armhf

I think this will work with the Ubuntu-based distribution on the TK1
too.

Change-Id: I62350d2f7a8914fb13c421be427388c6e46c5481
diff --git a/tools/BUILD b/tools/BUILD
index 22ce501..59cf695 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -20,6 +20,10 @@
   values = {'cpu': 'roborio'},
 )
 config_setting(
+  name = 'cpu_armhf',
+  values = {'cpu': 'armhf-debian'},
+)
+config_setting(
   name = 'has_asan',
   values = {'copt': '-fsanitize=address'},
 )
@@ -27,3 +31,7 @@
   name = 'has_tsan',
   values = {'copt': '-fsanitize=thread'},
 )
+config_setting(
+  name = 'has_ubsan',
+  values = {'copt': '-fsanitize=undefined'},
+)
diff --git a/tools/build_rules/select.bzl b/tools/build_rules/select.bzl
index 18701ef..151283f 100644
--- a/tools/build_rules/select.bzl
+++ b/tools/build_rules/select.bzl
@@ -3,18 +3,27 @@
 # quickly find issues where something new isn't handled.
 # It will also make adding ORs when it makes sense easy to do nicely.
 
-all_cpus = ['amd64', 'roborio']
+all_cpus = ['amd64', 'roborio', 'armhf']
 '''All of the CPUs we know about.'''
 
 '''A select wrapper for CPU architectures.
 
 Args:
   values: A mapping from architecture names (as strings) to other things.
-          Currently amd64 and roborio are recognized.
+          Currently amd64, roborio, and armhf are recognized.
           'else' is also allowed as a default.
+          'arm' is allowed instead of roborio and armhf.
 Returns a select which evaluates to the correct element of values.
 '''
 def cpu_select(values):
+  if 'arm' in values:
+    new_values = {}
+    for cpu in values:
+      if cpu != 'arm':
+        new_values[cpu] = values[cpu]
+    new_values['armhf'] = values['arm']
+    new_values['roborio'] = values['arm']
+    values = new_values
   for cpu in all_cpus:
     if cpu not in values:
       if 'else' in values:
@@ -27,6 +36,7 @@
   return select({
     '//tools:cpu_k8': values['amd64'],
     '//tools:cpu_roborio': values['roborio'],
+    '//tools:cpu_armhf': values['armhf'],
   })
 
 '''A select wrapper for address space sizes.
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index 29ba1e1..272a896 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -41,18 +41,23 @@
     '@arm-frc-linux-gnueabi-repo//:compiler_components',
     ':roborio-compiler-files',
     ':flags_compiler_inputs',
+    '@linaro_linux_gcc_4.9_repo//:compiler_components',
+    ':linaro-gcc-files',
   ],
 )
 
 # Compiler inputs given by --copt etc in //tools:bazel.rc.
 filegroup(
   name = 'flags_compiler_inputs',
-  # TODO(Brian): Change this to a select which only has the right files under
-  # the right configurations once that works.
-  srcs = [
-    'asan-blacklist',
-    'ubsan-blacklist',
-  ],
+  srcs = select({
+    '//tools:has_asan': [
+      'asan-blacklist',
+    ],
+    '//tools:has_ubsan': [
+      'ubsan-blacklist',
+    ],
+    '//conditions:default': [],
+  }),
 )
 
 cc_toolchain(
@@ -109,3 +114,48 @@
   strip_files = '//tools/cpp/arm-frc-linux-gnueabi:strip',
   supports_param_files = 1,
 )
+
+filegroup(
+  name = 'linaro-gcc-files',
+  srcs = [
+    '//tools/cpp/linaro_linux_gcc:clang-symlinks',
+    '//tools/cpp/linaro_linux_gcc:tool-wrappers',
+    '@linaro_linux_gcc_4.9_repo//:compiler_pieces',
+  ],
+)
+
+filegroup(
+  name = 'linaro_linux_linker_files',
+  srcs = [
+    '//tools/cpp/linaro_linux_gcc:gcc',
+    '//tools/cpp/linaro_linux_gcc:ld',
+    '//tools/cpp/linaro_linux_gcc:ar',
+    '//tools/cpp/linaro_linux_gcc:clang-ld',
+    '//tools/cpp/linaro_linux_gcc:clang',
+    '@linaro_linux_gcc_4.9_repo//:compiler_pieces',
+  ],
+)
+
+filegroup(
+  name = 'linaro_linux_compiler_files',
+  srcs = [
+    '//tools/cpp/linaro_linux_gcc:gcc',
+    '//tools/cpp/linaro_linux_gcc:ld',
+    '//tools/cpp/linaro_linux_gcc:clang',
+    '//tools/cpp/linaro_linux_gcc:as',
+  ],
+)
+
+cc_toolchain(
+  name = 'cc-compiler-armhf-debian',
+  all_files = ':linaro-gcc-files',
+  compiler_files = ':linaro_linux_compiler_files',
+  cpu = 'armhf',
+  dwp_files = ':empty',
+  dynamic_runtime_libs = [':empty'],
+  linker_files = ':linaro_linux_linker_files',
+  objcopy_files = '//tools/cpp/linaro_linux_gcc:objcopy',
+  static_runtime_libs = [':empty'],
+  strip_files = '//tools/cpp/linaro_linux_gcc:strip',
+  supports_param_files = 1,
+)
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL
index d76637c..0a07ba3 100644
--- a/tools/cpp/CROSSTOOL
+++ b/tools/cpp/CROSSTOOL
@@ -17,6 +17,10 @@
   toolchain_identifier: "stub_armeabi-v7a"
 }
 
+default_toolchain {
+  cpu: "armhf-debian"
+  toolchain_identifier: "clang_linux_armhf"
+}
 
 toolchain {
   abi_version: "armeabi-v7a"
@@ -97,7 +101,7 @@
   cxx_builtin_include_directory: '/usr/lib/llvm-3.6/lib/clang/3.6.2/include'
   cxx_builtin_include_directory: '/usr/include/x86_64-linux-gnu'
   cxx_builtin_include_directory: '/usr/include'
-  cxx_builtin_include_directory: '/usr/lib/clang/3.6.2/include/'
+  cxx_builtin_include_directory: '/usr/lib/clang/3.6.2/include'
 
   linker_flag: "-lstdc++"
   linker_flag: "-B/usr/bin/"
@@ -524,3 +528,253 @@
     linker_flag: "-Wl,--gc-sections"
   }
 }
+
+toolchain {
+  abi_version: "clang_3.6"
+  abi_libc_version: "glibc_2.19"
+  builtin_sysroot: ""
+  compiler: "clang"
+  host_system_name: "roborio"
+  needsPic: true
+  supports_gold_linker: false
+  supports_incremental_linker: false
+  supports_fission: false
+  supports_interface_shared_objects: false
+  supports_normalizing_ar: true
+  supports_start_end_lib: false
+  supports_thin_archives: true
+  target_libc: "glibc_2.19"
+  target_cpu: "armhf-debian"
+  target_system_name: "arm_a15"
+  toolchain_identifier: "clang_linux_armhf"
+
+  tool_path { name: "ar" path: "linaro_linux_gcc/arm-linux-gnueabihf-ar" }
+  tool_path { name: "compat-ld" path: "linaro_linux_gcc/arm-linux-gnueabihf-ld" }
+  tool_path { name: "cpp" path: "linaro_linux_gcc/clang_bin/clang" }
+  tool_path { name: "dwp" path: "linaro_linux_gcc/arm-linux-gnueabihf-dwp" }
+  tool_path { name: "gcc" path: "linaro_linux_gcc/clang_bin/clang" }
+  tool_path { name: "gcov" path: "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcov-4.9" }
+  # C(++) compiles invoke the compiler (as that is the one knowing where
+  # to find libraries), but we provide LD so other rules can invoke the linker.
+  tool_path { name: "ld" path: "linaro_linux_gcc/arm-linux-gnueabihf-ld" }
+  tool_path { name: "nm" path: "linaro_linux_gcc/arm-linux-gnueabihf-nm" }
+  tool_path { name: "objcopy" path: "linaro_linux_gcc/arm-linux-gnueabihf-objcopy" }
+  objcopy_embed_flag: "-I"
+  objcopy_embed_flag: "binary"
+  tool_path { name: "objdump" path: "linaro_linux_gcc/arm-linux-gnueabihf-objdump" }
+  tool_path { name: "strip" path: "linaro_linux_gcc/arm-linux-gnueabihf-strip" }
+
+  compiler_flag: "-target"
+  compiler_flag: "armv7a-arm-linux-gnueabif"
+  compiler_flag: "--sysroot=external/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/libc"
+  compiler_flag: "-mfloat-abi=hard"
+  compiler_flag: "-mfpu=vfpv3-d16"
+
+  compiler_flag: "-nostdinc"
+  compiler_flag: "-isystem"
+  compiler_flag: "/usr/lib/clang/3.6/include"
+  compiler_flag: "-isystem"
+  compiler_flag: "external/linaro_linux_gcc_4.9_repo/lib/gcc/arm-linux-gnueabihf/4.9.3/include"
+  compiler_flag: "-isystem"
+  compiler_flag: "external/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/libc/usr/include"
+  compiler_flag: "-isystem"
+  compiler_flag: "external/linaro_linux_gcc_4.9_repo/lib/gcc/arm-linux-gnueabihf/4.9.3/include-fixed"
+  cxx_flag: "-isystem"
+  cxx_flag: "external/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/include/c++/4.9.3/arm-linux-gnueabihf"
+  cxx_flag: "-isystem"
+  cxx_flag: "external/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/include/c++/4.9.3"
+  cxx_flag: "-isystem"
+  cxx_flag: "external/linaro_linux_gcc_4.9_repo/include/c++/4.9.3/arm-linux-gnueabihf"
+  cxx_flag: "-isystem"
+  cxx_flag: "external/linaro_linux_gcc_4.9_repo/include/c++/4.9.3"
+
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//include)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//arm-linux-gnueabihf/libc/usr/include)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//arm-linux-gnueabihf/libc/usr/lib/include)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/4.9.3/include-fixed)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//include)%/c++/4.9.3"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/4.9.3/include)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/4.9.3/include-fixed)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//lib/gcc/arm-linux-gnueabihf/4.9.3/include)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//lib/gcc/arm-linux-gnueabihf/4.9.3/include-fixed)%"
+  cxx_builtin_include_directory: "%package(@linaro_linux_gcc_4.9_repo//arm-linux-gnueabihf/include)%/c++/4.9.3"
+  cxx_builtin_include_directory: '/usr/lib/clang/3.6/include'
+
+  linker_flag: "-target"
+  linker_flag: "armv7a-arm-linux-gnueabif"
+  linker_flag: "--sysroot=external/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/libc"
+  linker_flag: "-lstdc++"
+  linker_flag: "-Ltools/cpp/linaro_linux_gcc/clang_more_libs"
+  linker_flag: "-Lexternal/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/lib"
+  linker_flag: "-Lexternal/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/libc/lib"
+  linker_flag: "-Lexternal/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/libc/usr/lib"
+  linker_flag: "-Bexternal/linaro_linux_gcc_4.9_repo/arm-linux-gnueabihf/bin"
+  linker_flag: "-Wl,--dynamic-linker=/lib/ld-linux-armhf.so.3"
+
+  feature {
+    name: "opt"
+    implies: "all_modes"
+    flag_set {
+      action: "preprocess-assemble"
+      action: "c-compile"
+      action: "c++-compile"
+      action: "c++-header-parsing"
+      action: "c++-header-preprocessing"
+      action: "c++-module-compile"
+      flag_group {
+        flag: "-DAOS_DEBUG=0"
+      }
+    }
+  }
+
+  feature {
+    name: "dbg"
+    implies: "all_modes"
+    flag_set {
+      action: "preprocess-assemble"
+      action: "c-compile"
+      action: "c++-compile"
+      action: "c++-header-parsing"
+      action: "c++-header-preprocessing"
+      action: "c++-module-compile"
+      flag_group {
+        flag: "-DAOS_DEBUG=1"
+      }
+      flag_group {
+        flag: "-fno-omit-frame-pointer"
+      }
+    }
+  }
+
+  feature {
+    name: "fastbuild"
+    implies: "all_modes"
+    flag_set {
+      action: "preprocess-assemble"
+      action: "c-compile"
+      action: "c++-compile"
+      action: "c++-header-parsing"
+      action: "c++-header-preprocessing"
+      action: "c++-module-compile"
+      flag_group {
+        flag: "-DAOS_DEBUG=0"
+      }
+    }
+  }
+
+  feature {
+    name: "all_modes"
+    flag_set {
+      action: "preprocess-assemble"
+      action: "assemble"
+      action: "c-compile"
+      flag_group {
+        flag: "-std=gnu99"
+      }
+    }
+    flag_set {
+      action: "c++-compile"
+      action: "c++-header-parsing"
+      action: "c++-header-preprocessing"
+      action: "c++-module-compile"
+      flag_group {
+        flag: "-std=gnu++1y"
+      }
+    }
+    flag_set {
+      action: "preprocess-assemble"
+      action: "assemble"
+      action: "c++-link"
+      action: "c++-compile"
+      action: "c++-header-parsing"
+      action: "c++-header-preprocessing"
+      action: "c++-module-compile"
+      action: "c-compile"
+      flag_group {
+        # We always want to compile with -pthread semantics.
+        flag: "-pthread"
+      }
+    }
+  }
+
+  # Anticipated future default.
+  # This makes GCC and Clang do what we want when called through symlinks.
+  unfiltered_cxx_flag: "-no-canonical-prefixes"
+  linker_flag: "-no-canonical-prefixes"
+
+  # Things that the code wants defined.
+  compiler_flag: "-D__STDC_FORMAT_MACROS"
+  compiler_flag: "-D__STDC_CONSTANT_MACROS"
+  compiler_flag: "-D__STDC_LIMIT_MACROS"
+  compiler_flag: "-D_FILE_OFFSET_BITS=64"
+  # TODO(Brian): Rename this or something.
+  compiler_flag: "-DAOS_ARCHITECTURE_armhf"
+
+  # Make C++ compilation deterministic. Use linkstamping instead of these
+  # compiler symbols.
+  unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
+  unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
+  unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
+  unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
+
+  # Security hardening on by default.
+  # Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.
+  # We need to undef it before redefining it as some distributions now have
+  # it enabled by default.
+  compiler_flag: "-U_FORTIFY_SOURCE"
+  compiler_flag: "-fstack-protector"
+  compiler_flag: "-fPIE"
+  linker_flag: "-pie"
+  linker_flag: "-Wl,-z,relro,-z,now"
+
+  # Pretty much everything needs this, including parts of the glibc STL...
+  linker_flag: "-lm"
+
+  # Enable coloring even if there's no attached terminal. Bazel removes the
+  # escape sequences if --nocolor is specified.
+  compiler_flag: "-fdiagnostics-color=always"
+
+  compiler_flag: "-Wall"
+  compiler_flag: "-Wextra"
+  compiler_flag: "-Wswitch-enum"
+  compiler_flag: "-Wpointer-arith"
+  compiler_flag: "-Wstrict-aliasing"
+  compiler_flag: "-Wcast-qual"
+  compiler_flag: "-Wcast-align"
+  compiler_flag: "-Wwrite-strings"
+  compiler_flag: "-Wtype-limits"
+  compiler_flag: "-Wsign-compare"
+  compiler_flag: "-Wformat=2"
+  compiler_flag: "-Werror"
+  compiler_flag: "-Wunused-local-typedefs"
+
+  # Keep stack frames for debugging, even in opt mode.
+  compiler_flag: "-fno-omit-frame-pointer"
+
+  # Don't use temp files while compiling.
+  compiler_flag: "-pipe"
+
+  # Stamp the binary with a unique identifier.
+  linker_flag: "-Wl,--build-id=md5"
+  linker_flag: "-Wl,--hash-style=gnu"
+  #linker_flag: "-Wl,--warn-execstack"
+  #linker_flag: "-Wl,--detect-odr-violations"
+
+  # Enable debug symbols.
+  compiler_flag: "-ggdb3"
+
+  compilation_mode_flags {
+    mode: OPT
+
+    compiler_flag: "-O2"
+
+    # Disable assertions
+    compiler_flag: "-DNDEBUG"
+    compiler_flag: "-D_FORTIFY_SOURCE=1"
+
+    # Removal of unused code and data at link time (can this increase binary size in some cases?).
+    compiler_flag: "-ffunction-sections"
+    compiler_flag: "-fdata-sections"
+    linker_flag: "-Wl,--gc-sections"
+  }
+}
diff --git a/tools/cpp/linaro_linux_gcc/BUILD b/tools/cpp/linaro_linux_gcc/BUILD
new file mode 100644
index 0000000..ad3dbb1
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/BUILD
@@ -0,0 +1,113 @@
+package(default_visibility = ['//tools/cpp:__pkg__'])
+
+cc_library(
+  name = 'libpthread',
+  visibility = ['//visibility:public'],
+  srcs = [
+    'clang_more_libs/libpthread.so',
+  ],
+)
+
+filegroup(
+  name = 'gcc',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:gcc',
+    'arm-linux-gnueabihf-gcc',
+  ],
+)
+
+filegroup(
+  name = 'ar',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:ar',
+    'arm-linux-gnueabihf-ar',
+  ],
+)
+
+filegroup(
+  name = 'ld',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:ld',
+    'arm-linux-gnueabihf-ld',
+  ],
+)
+
+filegroup(
+  name = 'nm',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:nm',
+    'arm-linux-gnueabihf-nm',
+  ],
+)
+
+filegroup(
+  name = 'objcopy',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:objcopy',
+    'arm-linux-gnueabihf-objcopy',
+  ],
+)
+
+filegroup(
+  name = 'objdump',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:objdump',
+    'arm-linux-gnueabihf-objdump',
+  ],
+)
+
+filegroup(
+  name = 'strip',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:strip',
+    'arm-linux-gnueabihf-strip',
+  ],
+)
+
+filegroup(
+  name = 'as',
+  srcs = [
+    '@linaro_linux_gcc_4.9_repo//:as',
+    'arm-linux-gnueabihf-as',
+  ],
+)
+
+filegroup(
+  name = 'clang',
+  srcs = [
+    'clang_bin/clang',
+  ],
+)
+
+filegroup(
+  name = 'clang-ld',
+  srcs = [
+    'clang_bin/ld',
+    ':ld',
+  ],
+)
+
+filegroup(
+  name = 'tool-wrappers',
+  srcs = [
+    ':gcc',
+    ':ar',
+    ':ld',
+    ':nm',
+    ':objcopy',
+    ':objdump',
+    ':strip',
+    ':as',
+    'clang_bin/as',
+    ':clang',
+    ':clang-ld',
+  ],
+)
+
+filegroup(
+  name = 'clang-symlinks',
+  srcs = glob([
+    'clang_more_libs/**',
+    'clang_syroot/**',
+  ]),
+)
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-ar b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-ar
new file mode 100755
index 0000000..2d4b527
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-ar
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-ar \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-ar \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-as b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-as
new file mode 100755
index 0000000..2b5b029
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-as
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-as \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-as \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-cpp b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-cpp
new file mode 100755
index 0000000..a4eb2ec
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-cpp
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-cpp \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-cpp \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-gcc b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-gcc
new file mode 100755
index 0000000..68e33da
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-gcc
@@ -0,0 +1,6 @@
+#!/bin/bash --norc
+
+PATH="${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/libexec/gcc/arm-linux-gnueabihf/4.9.3:$PATH" \
+	exec \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-gcc \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-gcov b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-gcov
new file mode 100755
index 0000000..cec171c
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-gcov
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-gcov \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-gcov \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-ld b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-ld
new file mode 100755
index 0000000..a134b14
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-ld
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-ld \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-ld \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-nm b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-nm
new file mode 100755
index 0000000..d066ebd
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-nm
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-nm \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-nm \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-objcopy b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-objcopy
new file mode 100755
index 0000000..e3ac78d
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-objcopy
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-objcopy \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-objcopy \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-objdump b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-objdump
new file mode 100755
index 0000000..f33793a
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-objdump
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-objdump \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-objdump \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-strip b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-strip
new file mode 100755
index 0000000..4f7bbf2
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/arm-linux-gnueabihf-strip
@@ -0,0 +1,5 @@
+#!/bin/bash --norc
+
+exec -a arm-linux-gnueabihf-strip \
+	${BAZEL_OUTPUT_ROOT}external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-strip \
+	"$@"
diff --git a/tools/cpp/linaro_linux_gcc/clang_bin/as b/tools/cpp/linaro_linux_gcc/clang_bin/as
new file mode 120000
index 0000000..6129ba8
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/clang_bin/as
@@ -0,0 +1 @@
+../arm-linux-gnueabihf-as
\ No newline at end of file
diff --git a/tools/cpp/linaro_linux_gcc/clang_bin/clang b/tools/cpp/linaro_linux_gcc/clang_bin/clang
new file mode 100755
index 0000000..2ed616a
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/clang_bin/clang
@@ -0,0 +1,4 @@
+#!/bin/bash --norc
+
+exec -a "$0" \
+  "/usr/bin/clang-3.6" "$@"
diff --git a/tools/cpp/linaro_linux_gcc/clang_bin/ld b/tools/cpp/linaro_linux_gcc/clang_bin/ld
new file mode 120000
index 0000000..d8097cf
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/clang_bin/ld
@@ -0,0 +1 @@
+../arm-linux-gnueabihf-ld
\ No newline at end of file
diff --git a/tools/cpp/linaro_linux_gcc/clang_more_libs/libc.so b/tools/cpp/linaro_linux_gcc/clang_more_libs/libc.so
new file mode 100644
index 0000000..631fc32
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/clang_more_libs/libc.so
@@ -0,0 +1,5 @@
+/* GNU ld script
+   Use the shared library, but some functions are only in
+   the static library, so try that secondarily.  */
+OUTPUT_FORMAT(elf32-littlearm)
+GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux-armhf.so.3 ) )
diff --git a/tools/cpp/linaro_linux_gcc/clang_more_libs/libpthread.so b/tools/cpp/linaro_linux_gcc/clang_more_libs/libpthread.so
new file mode 100644
index 0000000..71f034f
--- /dev/null
+++ b/tools/cpp/linaro_linux_gcc/clang_more_libs/libpthread.so
@@ -0,0 +1,5 @@
+/* GNU ld script
+   Use the shared library, but some functions are only in
+   the static library, so try that secondarily.  */
+OUTPUT_FORMAT(elf32-littlearm)
+GROUP ( libpthread.so.0 libpthread_nonshared.a )