Created
September 4, 2019 20:21
-
-
Save jakelang/d913148fe432912bd1fdc6486329f580 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
if [[ $1 == "--help" ]]; then | |
echo "Usage: compile-test <source>" | |
echo "Utility for small evm backend test cases. Takes a C source file, compiles it to llvm IR, and runs the backend." | |
echo "All data, including the source file, llvm IR, output, and logs are moved to a directory of the same name for ease of organization." | |
echo "IMPORTANT: a symlink to the correct llc must be present in the current directory. Please make one, or this will fail silently." | |
exit 0 | |
fi | |
if [[ $# -ne 1 ]]; then | |
echo "incorrect number of arguments" >&2; exit 1 | |
fi | |
IR_OUT="$1.ll" | |
EVM_OUT="$1.out" | |
TEST_DIR="test-$1" | |
echo "test directory: $TEST_DIR" | |
mkdir ./$TEST_DIR | |
clang --version | |
./llc --version | |
# Generate IR | |
clang -S -emit-llvm $1 -o $TEST_DIR/$IR_OUT | |
if [[ $? -ne 0 ]]; then | |
echo "clang failed; exiting" >&2 | |
rm -rf $TEST_DIR; exit 1 | |
fi | |
echo "wrote clang output to $TEST_DIR/$IR_OUT" | |
echo "calling evm backend..." | |
./llc -mtriple=evm -debug $TEST_DIR/$IR_OUT -o $TEST_DIR/$EVM_OUT 2>$TEST_DIR/log.txt | |
if [[ $? -ne 0 ]]; then | |
echo "backend failed. refer to $TEST_DIR/backendlog.txt if present."; exit 1 | |
fi | |
mv $1 $TEST_DIR/$1 | |
echo "backend succeeded; moved source to test dir" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment