Last active
August 2, 2019 11:13
-
-
Save jonas-schievink/18cf82523262b8ca62f94d54bef6f905 to your computer and use it in GitHub Desktop.
Compare metadata produced by successive invocations of rustc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [ -z "$RUSTC" ]; then | |
RUSTC=rustc | |
fi | |
crate="$1" | |
if [ -z "$crate" ]; then | |
echo "usage: metadiff.sh <crate-name>" | |
echo | |
echo "Compiles the given crate (.rs file) twice, comparing the produced metadata." | |
exit 1 | |
fi | |
function compile { | |
output="$1" | |
echo "Compiling $crate to $output ..." | |
$RUSTC --crate-type=rlib "$crate" -o "$output" | |
} | |
function extract { | |
rlib="$1" | |
output="$2" | |
echo "Extracting metadata from $rlib to $output ..." | |
ar p "$rlib" rust.metadata.bin > "$output" | |
} | |
$RUSTC -V | |
compile "first.rlib" & | |
compile "second.rlib" & | |
wait %% %- | |
extract "first.rlib" "metadata.0" | |
extract "second.rlib" "metadata.1" | |
echo "Diffing metadata files ..." | |
diffoscope --html-dir diffoscope metadata.0 metadata.1 \ | |
--max-diff-block-lines 5000 \ | |
--max-diff-input-lines 10000000 \ | |
--max-report-size 204800000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment