Skip to content

Commit a000386

Browse files
Cache the result of building an LLVM lib in run-with-tarball.sh (#3807)
This change hashes the LLVM `definition.kore` file, extracted from a tarball and checks if we already have a compiled LLVM library cached from before. This is useful when re-running a full set of tarballs several times, but also speeds up things on a single run as many of the definitions within a set of tests are the same. --------- Co-authored-by: Jost Berthold <[email protected]>
1 parent d5f0b20 commit a000386

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

scripts/run-with-tarball.sh

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,9 @@ MODULE=$(grep -o -e "^module [A-Z0-9-]*" $kore | tail -1 | sed -e "s/module //")
6767
# build llvm backend unless provided
6868
if [ -z "${LLVM_LIB}" ]; then
6969
tar xf $tarball -O llvm_definition/definition.kore > $TEMPD/llvm-definition.kore
70-
if [ ! -d "${PLUGIN_DIR}" ]; then
71-
echo "Either LLVM_LIB or PLUGIN_DIR must be provided"
72-
exit 2
73-
fi
74-
#generate matching data
75-
(cd $TEMPD && mkdir -p dt && llvm-kompile-matching llvm-definition.kore qbaL ./dt 1/2)
76-
# find library dependencies and source files
77-
for lib in libff libcryptopp blake2; do
78-
LIBFILE=$(find ${PLUGIN_DIR} -name "${lib}.a" | head -1)
79-
[ -z "$LIBFILE" ] && (echo "[Error] Unable to locate ${lib}.a"; exit 1)
80-
PLUGIN_LIBS+="$LIBFILE "
81-
PLUGIN_INCLUDE+="-I$(dirname $LIBFILE)/../include "
82-
done
83-
PLUGIN_CPP="${PLUGIN_DIR}/include/plugin-c/blake2.cpp ${PLUGIN_DIR}/include/plugin-c/crypto.cpp ${PLUGIN_DIR}/include/plugin-c/plugin_util.cpp"
84-
85-
# kompile llvm-definition to interpreter
70+
71+
LLVM_DEFINITION_SHA=$(sha1sum $TEMPD/llvm-definition.kore | awk '{ print $1 }')
72+
8673
case "$OSTYPE" in
8774
linux*)
8875
LPROCPS="-lprocps"
@@ -93,11 +80,33 @@ if [ -z "${LLVM_LIB}" ]; then
9380
LIBSUFFIX="dylib"
9481
;;
9582
esac
96-
llvm-kompile $TEMPD/llvm-definition.kore $TEMPD/dt c -- \
97-
-fPIC -std=c++17 -o $TEMPD/interpreter \
98-
$PLUGIN_LIBS $PLUGIN_INCLUDE $PLUGIN_CPP \
99-
-lcrypto -lssl $LPROCPS
100-
lib=$TEMPD/interpreter.$LIBSUFFIX
83+
84+
if [ ! -f "$log_dir/$LLVM_DEFINITION_SHA.$LIBSUFFIX" ]; then
85+
if [ ! -d "${PLUGIN_DIR}" ]; then
86+
echo "Either LLVM_LIB or PLUGIN_DIR must be provided"
87+
exit 2
88+
fi
89+
#generate matching data
90+
(cd $TEMPD && mkdir -p dt && llvm-kompile-matching llvm-definition.kore qbaL ./dt 1/2)
91+
# find library dependencies and source files
92+
for lib in libff libcryptopp blake2; do
93+
LIBFILE=$(find ${PLUGIN_DIR} -name "${lib}.a" | head -1)
94+
[ -z "$LIBFILE" ] && (echo "[Error] Unable to locate ${lib}.a"; exit 1)
95+
PLUGIN_LIBS+="$LIBFILE "
96+
PLUGIN_INCLUDE+="-I$(dirname $LIBFILE)/../include "
97+
done
98+
PLUGIN_CPP="${PLUGIN_DIR}/include/plugin-c/crypto.cpp ${PLUGIN_DIR}/include/plugin-c/plugin_util.cpp"
99+
100+
# kompile llvm-definition to interpreter
101+
llvm-kompile $TEMPD/llvm-definition.kore $TEMPD/dt c -- \
102+
-fPIC -std=c++17 -o $TEMPD/interpreter \
103+
$PLUGIN_LIBS $PLUGIN_INCLUDE $PLUGIN_CPP \
104+
-lcrypto -lssl $LPROCPS
105+
lib=$TEMPD/interpreter.$LIBSUFFIX
106+
cp $TEMPD/interpreter.$LIBSUFFIX $log_dir/$LLVM_DEFINITION_SHA.$LIBSUFFIX
107+
else
108+
lib=$log_dir/$LLVM_DEFINITION_SHA.$LIBSUFFIX
109+
fi
101110
else
102111
lib=$(realpath ${LLVM_LIB})
103112
fi

0 commit comments

Comments
 (0)