Add compiler-rt package to arm board prebuilts.

compiler-rt package is required to run clang with
profiler/sanitizer options on arm boards.
To avoid breaking builders, compiler-rt will not be installed
with --usepkg option till chromiumos-sdk builder uploads new prebuilts.

BUG=chromium:604877
TEST="./setup_board --board=arm-generic --nousepkg" builds compiler-rt
TEST="./setup_board --board=arm-generic" does not  build compiler-rt

Change-Id: I22669c41065586a81f8ab04b88f591f2df73e876
Reviewed-on: https://chromium-review.googlesource.com/451977
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
diff --git a/scripts/cros_setup_toolchains.py b/scripts/cros_setup_toolchains.py
index e8c742a..4910d2e 100644
--- a/scripts/cros_setup_toolchains.py
+++ b/scripts/cros_setup_toolchains.py
@@ -52,6 +52,7 @@
     'host' : {
         'gdb' : PACKAGE_NONE,
         'ex_go' : PACKAGE_NONE,
+        'ex_compiler-rt': PACKAGE_NONE,
     },
 }
 
@@ -62,6 +63,12 @@
 )
 CROSSDEV_GO_ARGS = ['--ex-pkg', 'dev-lang/go']
 
+# Enable llvm's compiler-rt for these targets.
+TARGET_COMPILER_RT_ENABLED = (
+    'armv7a-cros-linux-gnueabi',
+)
+CROSSDEV_COMPILER_RT_ARGS = ['--ex-pkg', 'sys-libs/compiler-rt']
+
 # Overrides for {gcc,binutils}-config, pick a package with particular suffix.
 CONFIG_TARGET_SUFFIXES = {
     'binutils' : {
@@ -121,6 +128,8 @@
       cmd = ['crossdev', '--show-target-cfg', '--ex-gdb']
       if target in TARGET_GO_ENABLED:
         cmd.extend(CROSSDEV_GO_ARGS)
+      if target in TARGET_COMPILER_RT_ENABLED:
+        cmd.extend(CROSSDEV_COMPILER_RT_ARGS)
       cmd.extend(['-t', target_tuple])
       # Catch output of crossdev.
       out = cros_build_lib.RunCommand(cmd, print_cmd=False,
@@ -177,6 +186,8 @@
         elif pkg == 'ex_go':
           # Go does not have selectable versions.
           cmd.extend(CROSSDEV_GO_ARGS)
+        elif pkg == 'ex_compiler-rt':
+          cmd.extend(CROSSDEV_COMPILER_RT_ARGS)
         elif pkg in cls.MANUAL_PKGS:
           pass
         else:
@@ -1193,6 +1204,11 @@
   boards_wanted = (set(options.include_boards.split(','))
                    if options.include_boards else set())
 
+  # pylint: disable=global-statement
+  # Disable compiler-rt if using binary packages till binary package is available
+  global TARGET_COMPILER_RT_ENABLED
+  if options.usepkg:
+    TARGET_COMPILER_RT_ENABLED = ()
   if options.cfg_name:
     ShowConfig(options.cfg_name)
   elif options.create_packages: