commit 665cc8453c924e8df533d2477a42e4d9c328d9b1 Author: Matthew Finkel sysrqb@torproject.org Date: Thu Jan 21 00:08:36 2021 +0000
Bug 40208: Mitigate uniffi non-deterministic code generation --- projects/uniffi-rs/btreeset.patch | 31 +++++++++++++++++++++++++++++++ projects/uniffi-rs/build | 8 ++++++++ projects/uniffi-rs/config | 1 + 3 files changed, 40 insertions(+)
diff --git a/projects/uniffi-rs/btreeset.patch b/projects/uniffi-rs/btreeset.patch new file mode 100644 index 0000000..cb81a00 --- /dev/null +++ b/projects/uniffi-rs/btreeset.patch @@ -0,0 +1,31 @@ +diff --git a/uniffi_bindgen/src/interface/types.rs b/uniffi_bindgen/src/interface/types.rs +index 6448d58..b7efd22 100644 +--- a/uniffi_bindgen/src/interface/types.rs ++++ b/uniffi_bindgen/src/interface/types.rs +@@ -26,7 +26,7 @@ + use anyhow::bail; + use anyhow::Result; + use std::convert::TryFrom; +-use std::{collections::hash_map::Entry, collections::HashMap, collections::HashSet}; ++use std::{collections::hash_map::Entry, collections::HashMap, collections::BTreeSet}; + + use super::Attributes; + +@@ -71,7 +71,7 @@ pub enum FFIType { + /// Represents all the different high-level types that can be used in a component interface. + /// At this level we identify user-defined types by name, without knowing any details + /// of their internal structure apart from what type of thing they are (record, enum, etc). +-#[derive(Debug, Clone, Eq, PartialEq, Hash)] ++#[derive(Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)] + pub enum Type { + // Primitive types. + UInt8, +@@ -195,7 +195,7 @@ pub(crate) struct TypeUniverse { + // Named type definitions (including aliases). + type_definitions: HashMap<String, Type>, + // All the types in the universe, by canonical type name. +- all_known_types: HashSet<Type>, ++ all_known_types: BTreeSet<Type>, + } + + impl TypeUniverse { diff --git a/projects/uniffi-rs/build b/projects/uniffi-rs/build index 60ba1b1..1663071 100644 --- a/projects/uniffi-rs/build +++ b/projects/uniffi-rs/build @@ -22,6 +22,14 @@ replace-with = "vendored-sources" directory = "/var/tmp/build/uniffi-rs/vendor" EOF
+# We change the data type of the `all_known_types` Set from HashSet to BTreeSet. +# Uniffi iterates over the elements of this set, and iteration over a HashSet occurs +# in an arbitrary order, while iteration over a BTreeSet orders in a defined (and +# deterministic) order. This patch solves a build reproducibility issue, see +# tor-browser-build#40208. +# +# Upstream bug: https://github.com/mozilla/uniffi-rs/issues/374 +patch -p1 < $rootdir/btreeset.patch # We usually use --frozen but there is no Cargo.lock file available. Thus resort # to --offline. cargo build --release --offline --target x86_64-unknown-linux-gnu diff --git a/projects/uniffi-rs/config b/projects/uniffi-rs/config index 5dda990..7d89cc2 100644 --- a/projects/uniffi-rs/config +++ b/projects/uniffi-rs/config @@ -15,3 +15,4 @@ input_files: # `cargo vendor vendor` in the `uniffi-rs` directory has vendored the sources. - URL: https://people.torproject.org/~gk/mirrors/sources/uniffi-rs-vendor-%5B% c('version') %].tar.bz2 sha256sum: 71d912237208c35a762b3c812afe0a758823792dd745c1253314bcccc1694b7f + - filename: btreeset.patch
tbb-commits@lists.torproject.org