clang package: Stop shipping 32-bit asan on win, and 32-bit libraries on linux.

See "Does anyone use the 32-bit asan runtime on Windows?" on chromium-dev
for Windows. (We sadly still need the 32-bit profile library, so the build
script doesn't get any simpler.)

We haven't supported 32-bit builds on linux in a while, so those libs should
be safe to remove as well.

If anyone needs these, shout and we can add them back.

Also use ' instead of " for strings added in my previous change.

Linux package size: 48.73MB -> 47.49MB; main build 3924 -> 3526 build steps.
Windows package size 43.49MB -> 41.56MB; 32-bit compiler-rt build 207 -> 18 build steps.

Bug: 959966
Change-Id: I8c326dab4e07df69ee734f6390cda7291bfd7642
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635410
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664523}
diff --git a/tools/clang/scripts/build.py b/tools/clang/scripts/build.py
index 1f29fb6..7849efd0 100755
--- a/tools/clang/scripts/build.py
+++ b/tools/clang/scripts/build.py
@@ -443,16 +443,16 @@
       # libraries are needed though, and only libclang_rt (i.e.
       # COMPILER_RT_BUILD_BUILTINS).
       bootstrap_args.extend([
-          "-DDARWIN_osx_ARCHS=x86_64",
-          "-DCOMPILER_RT_BUILD_BUILTINS=ON",
-          "-DCOMPILER_RT_BUILD_CRT=OFF",
-          "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF",
-          "-DCOMPILER_RT_BUILD_PROFILE=OFF",
-          "-DCOMPILER_RT_BUILD_SANITIZERS=OFF",
-          "-DCOMPILER_RT_BUILD_XRAY=OFF",
-          "-DCOMPILER_RT_ENABLE_IOS=OFF",
-          "-DCOMPILER_RT_ENABLE_WATCHOS=OFF",
-          "-DCOMPILER_RT_ENABLE_TVOS=OFF",
+          '-DDARWIN_osx_ARCHS=x86_64',
+          '-DCOMPILER_RT_BUILD_BUILTINS=ON',
+          '-DCOMPILER_RT_BUILD_CRT=OFF',
+          '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF',
+          '-DCOMPILER_RT_BUILD_PROFILE=OFF',
+          '-DCOMPILER_RT_BUILD_SANITIZERS=OFF',
+          '-DCOMPILER_RT_BUILD_XRAY=OFF',
+          '-DCOMPILER_RT_ENABLE_IOS=OFF',
+          '-DCOMPILER_RT_ENABLE_WATCHOS=OFF',
+          '-DCOMPILER_RT_ENABLE_TVOS=OFF',
           ])
     if cc is not None:  bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc)
     if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
@@ -480,27 +480,33 @@
 
 
   compiler_rt_args = [
-    "-DCOMPILER_RT_BUILD_CRT=OFF",
-    "-DCOMPILER_RT_BUILD_LIBFUZZER=ON",
-    "-DCOMPILER_RT_BUILD_PROFILE=ON",
-    "-DCOMPILER_RT_BUILD_SANITIZERS=ON",
-    "-DCOMPILER_RT_BUILD_XRAY=OFF",
+    '-DCOMPILER_RT_BUILD_CRT=OFF',
+    '-DCOMPILER_RT_BUILD_LIBFUZZER=ON',
+    '-DCOMPILER_RT_BUILD_PROFILE=ON',
+    '-DCOMPILER_RT_BUILD_SANITIZERS=ON',
+    '-DCOMPILER_RT_BUILD_XRAY=OFF',
   ]
   if sys.platform == 'darwin':
     compiler_rt_args.extend([
-        "-DCOMPILER_RT_BUILD_BUILTINS=ON",
-        "-DCOMPILER_RT_ENABLE_IOS=ON",
-        "-DCOMPILER_RT_ENABLE_WATCHOS=OFF",
-        "-DCOMPILER_RT_ENABLE_TVOS=OFF",
+        '-DCOMPILER_RT_BUILD_BUILTINS=ON',
+        '-DCOMPILER_RT_ENABLE_IOS=ON',
+        '-DCOMPILER_RT_ENABLE_WATCHOS=OFF',
+        '-DCOMPILER_RT_ENABLE_TVOS=OFF',
         # armv7 is A5 and earlier, armv7s is A6+ (2012 and later, before 64-bit
         # iPhones). armv7k is Apple Watch, which we don't need.
-        "-DDARWIN_ios_ARCHS=armv7;armv7s;arm64",
-        "-DDARWIN_iossim_ARCHS=i386;x86_64",
+        '-DDARWIN_ios_ARCHS=armv7;armv7s;arm64',
+        '-DDARWIN_iossim_ARCHS=i386;x86_64',
         # We don't need 32-bit intel support for macOS, we only ship 64-bit.
-        "-DDARWIN_osx_ARCHS=x86_64",
+        '-DDARWIN_osx_ARCHS=x86_64',
         ])
   else:
-    compiler_rt_args.append("-DCOMPILER_RT_BUILD_BUILTINS=OFF")
+    compiler_rt_args.append('-DCOMPILER_RT_BUILD_BUILTINS=OFF')
+  if sys.platform.startswith('linux'):
+    # Only build the 64-bit runtime, we don't need the 32-bit one.
+    compiler_rt_args.extend([
+        '-DCMAKE_C_COMPILER_TARGET=x86_64-unknown-linux-gnu',
+        '-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON',
+    ])
 
   # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
   # needed, on OS X it requires libc++. clang only automatically links to libc++
@@ -635,8 +641,7 @@
   rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
                                 RELEASE_VERSION, 'lib', platform)
 
-  # Do an out-of-tree build of compiler-rt for 32-bit Win ASan.
-  # TODO(hans): Do we use 32-bit ASan? Can we drop it?
+  # Do an out-of-tree build of compiler-rt for 32-bit Win clang_rt.profile.lib.
   if sys.platform == 'win32':
     if os.path.isdir(COMPILER_RT_BUILD_DIR):
       RmTree(COMPILER_RT_BUILD_DIR)
@@ -646,10 +651,17 @@
       # The bootstrap compiler produces 64-bit binaries by default.
       cflags += ['-m32']
       cxxflags += ['-m32']
-    compiler_rt_args = base_cmake_args + compiler_rt_args + [
+    compiler_rt_args = base_cmake_args + [
         '-DLLVM_ENABLE_THREADS=OFF',
         '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
-        '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags)]
+        '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
+        '-DCOMPILER_RT_BUILD_BUILTINS=OFF',
+        '-DCOMPILER_RT_BUILD_CRT=OFF',
+        '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF',
+        '-DCOMPILER_RT_BUILD_PROFILE=ON',
+        '-DCOMPILER_RT_BUILD_SANITIZERS=OFF',
+        '-DCOMPILER_RT_BUILD_XRAY=OFF',
+        ]
     RunCommand(['cmake'] + compiler_rt_args +
                [os.path.join(LLVM_DIR, 'llvm')],
                msvc_arch='x86', env=deployment_env)
@@ -658,9 +670,6 @@
     # Copy select output to the main tree.
     rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang',
                                   RELEASE_VERSION, 'lib', platform)
-    # Blacklists:
-    CopyDirectoryContents(os.path.join(rt_lib_src_dir, '..', '..', 'share'),
-                          os.path.join(rt_lib_dst_dir, '..', '..', 'share'))
     # Static and dynamic libraries:
     CopyDirectoryContents(rt_lib_src_dir, rt_lib_dst_dir)
 
diff --git a/tools/clang/scripts/package.py b/tools/clang/scripts/package.py
index ae8a0fd..0af8d16 100755
--- a/tools/clang/scripts/package.py
+++ b/tools/clang/scripts/package.py
@@ -260,12 +260,10 @@
       'bin/llvm-ar',
 
       # AddressSanitizer C runtime (pure C won't link with *_cxx).
-      'lib/clang/$V/lib/linux/libclang_rt.asan-i386.a',
       'lib/clang/$V/lib/linux/libclang_rt.asan-x86_64.a',
       'lib/clang/$V/lib/linux/libclang_rt.asan-x86_64.a.syms',
 
       # AddressSanitizer C++ runtime.
-      'lib/clang/$V/lib/linux/libclang_rt.asan_cxx-i386.a',
       'lib/clang/$V/lib/linux/libclang_rt.asan_cxx-x86_64.a',
       'lib/clang/$V/lib/linux/libclang_rt.asan_cxx-x86_64.a.syms',
 
@@ -289,7 +287,6 @@
       'lib/clang/$V/lib/linux/libclang_rt.msan_cxx-x86_64.a.syms',
 
       # Profile runtime (used by profiler and code coverage).
-      'lib/clang/$V/lib/linux/libclang_rt.profile-i386.a',
       'lib/clang/$V/lib/linux/libclang_rt.profile-x86_64.a',
       'lib/clang/$V/lib/linux/libclang_rt.profile-aarch64-android.a',
       'lib/clang/$V/lib/linux/libclang_rt.profile-arm-android.a',
@@ -303,12 +300,10 @@
       'lib/clang/$V/lib/linux/libclang_rt.tsan_cxx-x86_64.a.syms',
 
       # UndefinedBehaviorSanitizer C runtime (pure C won't link with *_cxx).
-      'lib/clang/$V/lib/linux/libclang_rt.ubsan_standalone-i386.a',
       'lib/clang/$V/lib/linux/libclang_rt.ubsan_standalone-x86_64.a',
       'lib/clang/$V/lib/linux/libclang_rt.ubsan_standalone-x86_64.a.syms',
 
       # UndefinedBehaviorSanitizer C++ runtime.
-      'lib/clang/$V/lib/linux/libclang_rt.ubsan_standalone_cxx-i386.a',
       'lib/clang/$V/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a',
       'lib/clang/$V/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a.syms',
 
@@ -322,28 +317,22 @@
   elif sys.platform == 'win32':
     want.extend([
       # AddressSanitizer C runtime (pure C won't link with *_cxx).
-      'lib/clang/$V/lib/windows/clang_rt.asan-i386.lib',
       'lib/clang/$V/lib/windows/clang_rt.asan-x86_64.lib',
 
       # AddressSanitizer C++ runtime.
-      'lib/clang/$V/lib/windows/clang_rt.asan_cxx-i386.lib',
       'lib/clang/$V/lib/windows/clang_rt.asan_cxx-x86_64.lib',
 
       # Fuzzing instrumentation (-fsanitize=fuzzer-no-link).
       'lib/clang/$V/lib/windows/clang_rt.fuzzer_no_main-x86_64.lib',
 
       # Thunk for AddressSanitizer needed for static build of a shared lib.
-      'lib/clang/$V/lib/windows/clang_rt.asan_dll_thunk-i386.lib',
       'lib/clang/$V/lib/windows/clang_rt.asan_dll_thunk-x86_64.lib',
 
       # AddressSanitizer runtime for component build.
-      'lib/clang/$V/lib/windows/clang_rt.asan_dynamic-i386.dll',
-      'lib/clang/$V/lib/windows/clang_rt.asan_dynamic-i386.lib',
       'lib/clang/$V/lib/windows/clang_rt.asan_dynamic-x86_64.dll',
       'lib/clang/$V/lib/windows/clang_rt.asan_dynamic-x86_64.lib',
 
       # Thunk for AddressSanitizer for component build of a shared lib.
-      'lib/clang/$V/lib/windows/clang_rt.asan_dynamic_runtime_thunk-i386.lib',
       'lib/clang/$V/lib/windows/clang_rt.asan_dynamic_runtime_thunk-x86_64.lib',
 
       # Profile runtime (used by profiler and code coverage).
@@ -351,11 +340,9 @@
       'lib/clang/$V/lib/windows/clang_rt.profile-x86_64.lib',
 
       # UndefinedBehaviorSanitizer C runtime (pure C won't link with *_cxx).
-      'lib/clang/$V/lib/windows/clang_rt.ubsan_standalone-i386.lib',
       'lib/clang/$V/lib/windows/clang_rt.ubsan_standalone-x86_64.lib',
 
       # UndefinedBehaviorSanitizer C++ runtime.
-      'lib/clang/$V/lib/windows/clang_rt.ubsan_standalone_cxx-i386.lib',
       'lib/clang/$V/lib/windows/clang_rt.ubsan_standalone_cxx-x86_64.lib',
     ])
 
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
index ca65631..082dc5e 100755
--- a/tools/clang/scripts/update.py
+++ b/tools/clang/scripts/update.py
@@ -38,7 +38,7 @@
 # Reverting problematic clang rolls is safe, though.
 CLANG_REVISION = '67510fac36d27b2e22c7cd955fc167136b737b93'
 CLANG_SVN_REVISION = '361212'
-CLANG_SUB_REVISION = 3
+CLANG_SUB_REVISION = 4
 
 PACKAGE_VERSION = '%s-%s-%s' % (CLANG_SVN_REVISION, CLANG_REVISION[:8],
                                 CLANG_SUB_REVISION)