Remove git reference during build

Cargo attempts to use git's list-files capability in order to figure out
what parts of a source tree are truly inputs to a crate. However, this
does not work correctly if the rustc source is actually a bare git repo.

By blowing away the .git directory before the build, we can trick Cargo
into believing the directory did not come from git and convince it to
behave itself until we fix the issue in Cargo itself.

WARNING: With this change, running build.py locally becomes unsafe, as
it will blow away your git repository. This is a temporary measure since
our current Cargo prebuilt needs to be updated to ignore .git in order
to build again.

Bug: 149047263
Change-Id: If55ebc3037b0bd05dfa27e3294d1d38c444c8a05
diff --git a/build.py b/build.py
index 2f70d9f..7897b62 100755
--- a/build.py
+++ b/build.py
@@ -79,6 +79,9 @@
         if exn.errno != errno.EEXIST:
             raise
 
+    # Shoot down the .git bare reference so Cargo doesn't get confused
+    os.remove(os.path.join(paths.rustc_path(), '.git'))
+
     # Apply patches
     for filename in glob.glob(paths.patches_path('rustc-*')):
         with open(filename, 'r') as file: