4 use std::io::{Read, Write};
7 let mut dst = env::current_exe().unwrap();
9 dst.push("linker-arguments1");
12 dst.push("linker-arguments2");
13 assert!(!dst.exists());
16 let mut out = String::new();
17 for arg in env::args().skip(1) {
18 let path = Path::new(&arg);
25 let mut contents = Vec::new();
26 File::open(path).unwrap().read_to_end(&mut contents).unwrap();
28 // This file is produced during linking in a temporary directory.
29 let arg = if arg.ends_with("/symbols.o") || arg.ends_with("\\symbols.o") {
34 out.push_str(&format!("{}: {}\n", arg, hash(&contents)));
37 File::create(dst).unwrap().write_all(out.as_bytes()).unwrap();
41 fn hash(contents: &[u8]) -> u64 {
42 let mut hash = 0xcbf29ce484222325;
44 for byte in contents {
45 hash = hash ^ (*byte as u64);
46 hash = hash.wrapping_mul(0x100000001b3);