Add patch to pin the autocfg version and delete temporary files.

autocfg 1.4 uses different, non-deterministic filenames. We don't
actually depend on these files, and the contents are nondeterministic,
so just get rid of them.

Also regenerate Android.bp

Bug: http://b/339424309
Test: treehugger
Change-Id: Iefc612bc1d5b0226144b83f30a4ec6ee50ef8355
diff --git a/Android.bp b/Android.bp
index 11f65e4..2054852 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,56 +1,23 @@
 // This file is generated by cargo_embargo.
-// Do not modify this file after the first "rust_*" or "genrule" module
-// because the changes will be overridden on upgrade.
-// Content before the first "rust_*" or "genrule" module is preserved.
+// Do not modify this file because the changes will be overridden on upgrade.
 
 package {
     default_applicable_licenses: ["external_rust_crates_num-bigint_license"],
+    default_team: "trendy_team_android_rust",
 }
 
-// Added automatically by a large-scale-change that took the approach of
-// 'apply every license found to every target'. While this makes sure we respect
-// every license restriction, it may not be entirely correct.
-//
-// e.g. GPL in an MIT project might only apply to the contrib/ directory.
-//
-// Please consider splitting the single license below into multiple licenses,
-// taking care not to lose any license_kind information, and overriding the
-// default license using the 'licenses: [...]' property on targets as needed.
-//
-// For unused files, consider creating a 'fileGroup' with "//visibility:private"
-// to attach the license to, and including a comment whether the files may be
-// used in the current project.
-//
-// large-scale-change included anything that looked like it might be a license
-// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
-//
-// Please consider removing redundant or irrelevant files from 'license_text:'.
-// See: http://go/android-license-faq
 license {
     name: "external_rust_crates_num-bigint_license",
     visibility: [":__subpackages__"],
-    license_kinds: [
-        "SPDX-license-identifier-Apache-2.0",
-        "SPDX-license-identifier-BSD",
-        "SPDX-license-identifier-MIT",
-    ],
-    license_text: [
-        "LICENSE-APACHE",
-        "LICENSE-MIT",
-    ],
+    license_kinds: ["SPDX-license-identifier-Apache-2.0"],
+    license_text: ["LICENSE"],
 }
 
 genrule {
     name: "copy_num-bigint_build_out",
     srcs: ["out/*"],
     cmd: "cp $(in) $(genDir)",
-    out: [
-        "probe0.ll",
-        "probe1.ll",
-        "probe2.ll",
-        "probe3.ll",
-        "radix_bases.rs",
-    ],
+    out: ["radix_bases.rs"],
 }
 
 rust_library {
diff --git a/Cargo.toml b/Cargo.toml
index 2656b5f..7e93523 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -93,7 +93,10 @@
 default-features = false
 
 [build-dependencies.autocfg]
-version = "1"
+# autocfg 1.4 uses different, non-deterministic filenames. We don't
+# actually depend on these files, but they are present in the out/
+# directory, and it's simpler to keep them around.
+version = "=1.1.0"
 
 [features]
 default = ["std"]
diff --git a/build.rs b/build.rs
index 5d5406c..82b7a43 100644
--- a/build.rs
+++ b/build.rs
@@ -37,6 +37,15 @@
         }
     }
 
+    // autocfg generates probe files in $OUT_DIR with nondeterministic contents.
+    // (In autocfg 1.4, the filenames are nondeterministic as well.)
+    let out_dir_env = env::var("OUT_DIR").unwrap();
+    let out_dir = Path::new(&out_dir_env);
+    std::fs::remove_file(out_dir.join("probe0.ll")).unwrap();
+    std::fs::remove_file(out_dir.join("probe1.ll")).unwrap();
+    std::fs::remove_file(out_dir.join("probe2.ll")).unwrap();
+    std::fs::remove_file(out_dir.join("probe3.ll")).unwrap();
+
     autocfg::rerun_path("build.rs");
 
     write_radix_bases().unwrap();
diff --git a/out/probe0.ll b/out/probe0.ll
deleted file mode 100644
index 304b8db..0000000
--- a/out/probe0.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; ModuleID = 'probe0.7ce72c5dd1a2f6c1-cgu.0'
-source_filename = "probe0.7ce72c5dd1a2f6c1-cgu.0"
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-!llvm.module.flags = !{!0, !1}
-!llvm.ident = !{!2}
-
-!0 = !{i32 8, !"PIC Level", i32 2}
-!1 = !{i32 2, !"RtLibUseGOT", i32 1}
-!2 = !{!"rustc version 1.74.1-dev (a28077b28 2023-12-04) (Android Rust Toolchain version linux-11359135)"}
diff --git a/out/probe1.ll b/out/probe1.ll
deleted file mode 100644
index 0264507..0000000
--- a/out/probe1.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; ModuleID = 'probe1.c3864d9408e8f73b-cgu.0'
-source_filename = "probe1.c3864d9408e8f73b-cgu.0"
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-!llvm.module.flags = !{!0, !1}
-!llvm.ident = !{!2}
-
-!0 = !{i32 8, !"PIC Level", i32 2}
-!1 = !{i32 2, !"RtLibUseGOT", i32 1}
-!2 = !{!"rustc version 1.74.1-dev (a28077b28 2023-12-04) (Android Rust Toolchain version linux-11359135)"}
diff --git a/out/probe2.ll b/out/probe2.ll
deleted file mode 100644
index 8614afd..0000000
--- a/out/probe2.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; ModuleID = 'probe2.9623900266cad2ed-cgu.0'
-source_filename = "probe2.9623900266cad2ed-cgu.0"
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-!llvm.module.flags = !{!0, !1}
-!llvm.ident = !{!2}
-
-!0 = !{i32 8, !"PIC Level", i32 2}
-!1 = !{i32 2, !"RtLibUseGOT", i32 1}
-!2 = !{!"rustc version 1.74.1-dev (a28077b28 2023-12-04) (Android Rust Toolchain version linux-11359135)"}
diff --git a/out/probe3.ll b/out/probe3.ll
deleted file mode 100644
index 605bbe6..0000000
--- a/out/probe3.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; ModuleID = 'probe3.971c5a3bb38f7b08-cgu.0'
-source_filename = "probe3.971c5a3bb38f7b08-cgu.0"
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-!llvm.module.flags = !{!0, !1}
-!llvm.ident = !{!2}
-
-!0 = !{i32 8, !"PIC Level", i32 2}
-!1 = !{i32 2, !"RtLibUseGOT", i32 1}
-!2 = !{!"rustc version 1.74.1-dev (a28077b28 2023-12-04) (Android Rust Toolchain version linux-11359135)"}
diff --git a/patches/pin-autocfg-version.patch b/patches/pin-autocfg-version.patch
new file mode 100644
index 0000000..7930756
--- /dev/null
+++ b/patches/pin-autocfg-version.patch
@@ -0,0 +1,16 @@
+diff --git a/Cargo.toml b/Cargo.toml
+index 2656b5f..159937f 100644
+--- a/Cargo.toml
++++ b/Cargo.toml
+@@ -93,7 +93,10 @@ optional = true
+ default-features = false
+ 
+ [build-dependencies.autocfg]
+-version = "1"
++# autocfg 1.4 uses different, non-deterministic filenames. We don't
++# actually depend on these files, but they are present in the out/
++# directory, and it's simpler to keep them around.
++version = "=1.1.0"
+ 
+ [features]
+ default = ["std"]
diff --git a/patches/remove-probe-files.patch b/patches/remove-probe-files.patch
new file mode 100644
index 0000000..0292603
--- /dev/null
+++ b/patches/remove-probe-files.patch
@@ -0,0 +1,20 @@
+diff --git a/build.rs b/build.rs
+index 5d5406c..82b7a43 100644
+--- a/build.rs
++++ b/build.rs
+@@ -37,6 +37,15 @@ fn main() {
+         }
+     }
+ 
++    // autocfg generates probe files in $OUT_DIR with nondeterministic contents.
++    // (In autocfg 1.4, the filenames are nondeterministic as well.)
++    let out_dir_env = env::var("OUT_DIR").unwrap();
++    let out_dir = Path::new(&out_dir_env);
++    std::fs::remove_file(out_dir.join("probe0.ll")).unwrap();
++    std::fs::remove_file(out_dir.join("probe1.ll")).unwrap();
++    std::fs::remove_file(out_dir.join("probe2.ll")).unwrap();
++    std::fs::remove_file(out_dir.join("probe3.ll")).unwrap();
++
+     autocfg::rerun_path("build.rs");
+ 
+     write_radix_bases().unwrap();