baoyachi / shadow-rs

A build-time information stored in your rust project.(binary,lib,cdylib,dylib)
https://docs.rs/shadow-rs
MIT License
447 stars 41 forks source link

Order of generated code is not reproducible #96

Closed emixa-d closed 2 years ago

emixa-d commented 2 years ago

The ordering of the lines of the generated shadow.rs is irreproducible, leading to build failures with antioxidant (because dependency $foo is compiled against dependency $bar using shadow-rs, compiled on machine $X and dependency $baz is compiled against dependency $bar on another machine $Y).

The issue appears to be that hash maps are used. For now, I've worked around things by replacing

        for (k, v) in self.map.clone() {

by

        for (k, v) in std::collections::BTreeMap::from_iter(self.map.clone().iter()) {

and likewise for iteration over self.maps.keys().

(That was for rust-shadow-rs@0.8, but looking at the code it would seem that the same holds for the latest version.)

baoyachi commented 2 years ago

Maybe use BTreeMap instead of HashMap