Skip to content

Commit

Permalink
Produce the *_gnu import libraries more deterministically (#1967)
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Aug 22, 2022
1 parent 044ab37 commit 53bc4d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Binary file modified crates/targets/i686_gnu/lib/libwindows.a
Binary file not shown.
Binary file modified crates/targets/x86_64_gnu/lib/libwindows.a
Binary file not shown.
16 changes: 16 additions & 0 deletions crates/tools/gnu/src/main.rs
Expand Up @@ -82,8 +82,24 @@ EXPORTS
cmd.arg(format!("{}.def", library));
cmd.arg("-l");
cmd.arg(format!("lib{}.a", library));
// Ensure consistency in the prefixes used by dlltool.
cmd.arg("-t");
if library.contains('.') {
cmd.arg(format!("{}_", library).replace('.', "_").replace('-', "_"));
} else {
cmd.arg(format!("{}_dll_", library).replace('-', "_"));
}
cmd.output().unwrap();

// Work around lack of determinism in dlltool output.
std::fs::rename(output.join(format!("lib{}.a", library)), output.join("tmp.a")).unwrap();
let mut cmd = std::process::Command::new("objcopy");
cmd.current_dir(&output);
cmd.arg("tmp.a");
cmd.arg(format!("lib{}.a", library));
cmd.output().unwrap();

std::fs::remove_file(output.join("tmp.a")).unwrap();
std::fs::remove_file(output.join(format!("{}.def", library))).unwrap();
}

Expand Down

0 comments on commit 53bc4d7

Please sign in to comment.