Skip to content

Cache the result of building an LLVM lib in run-with-tarball.sh #3807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions scripts/run-with-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,9 @@ MODULE=$(grep -o -e "^module [A-Z0-9-]*" $kore | tail -1 | sed -e "s/module //")
# build llvm backend unless provided
if [ -z "${LLVM_LIB}" ]; then
tar xf $tarball -O llvm_definition/definition.kore > $TEMPD/llvm-definition.kore
if [ ! -d "${PLUGIN_DIR}" ]; then
echo "Either LLVM_LIB or PLUGIN_DIR must be provided"
exit 2
fi
#generate matching data
(cd $TEMPD && mkdir -p dt && llvm-kompile-matching llvm-definition.kore qbaL ./dt 1/2)
# find library dependencies and source files
for lib in libff libcryptopp blake2; do
LIBFILE=$(find ${PLUGIN_DIR} -name "${lib}.a" | head -1)
[ -z "$LIBFILE" ] && (echo "[Error] Unable to locate ${lib}.a"; exit 1)
PLUGIN_LIBS+="$LIBFILE "
PLUGIN_INCLUDE+="-I$(dirname $LIBFILE)/../include "
done
PLUGIN_CPP="${PLUGIN_DIR}/include/plugin-c/blake2.cpp ${PLUGIN_DIR}/include/plugin-c/crypto.cpp ${PLUGIN_DIR}/include/plugin-c/plugin_util.cpp"

# kompile llvm-definition to interpreter

LLVM_DEFINITION_SHA=$(sha1sum $TEMPD/llvm-definition.kore | awk '{ print $1 }')

case "$OSTYPE" in
linux*)
LPROCPS="-lprocps"
Expand All @@ -93,11 +80,33 @@ if [ -z "${LLVM_LIB}" ]; then
LIBSUFFIX="dylib"
;;
esac
llvm-kompile $TEMPD/llvm-definition.kore $TEMPD/dt c -- \
-fPIC -std=c++17 -o $TEMPD/interpreter \
$PLUGIN_LIBS $PLUGIN_INCLUDE $PLUGIN_CPP \
-lcrypto -lssl $LPROCPS
lib=$TEMPD/interpreter.$LIBSUFFIX

if [ ! -f "$log_dir/$LLVM_DEFINITION_SHA.$LIBSUFFIX" ]; then
if [ ! -d "${PLUGIN_DIR}" ]; then
echo "Either LLVM_LIB or PLUGIN_DIR must be provided"
exit 2
fi
#generate matching data
(cd $TEMPD && mkdir -p dt && llvm-kompile-matching llvm-definition.kore qbaL ./dt 1/2)
# find library dependencies and source files
for lib in libff libcryptopp blake2; do
LIBFILE=$(find ${PLUGIN_DIR} -name "${lib}.a" | head -1)
[ -z "$LIBFILE" ] && (echo "[Error] Unable to locate ${lib}.a"; exit 1)
PLUGIN_LIBS+="$LIBFILE "
PLUGIN_INCLUDE+="-I$(dirname $LIBFILE)/../include "
done
PLUGIN_CPP="${PLUGIN_DIR}/include/plugin-c/crypto.cpp ${PLUGIN_DIR}/include/plugin-c/plugin_util.cpp"

# kompile llvm-definition to interpreter
llvm-kompile $TEMPD/llvm-definition.kore $TEMPD/dt c -- \
-fPIC -std=c++17 -o $TEMPD/interpreter \
$PLUGIN_LIBS $PLUGIN_INCLUDE $PLUGIN_CPP \
-lcrypto -lssl $LPROCPS
lib=$TEMPD/interpreter.$LIBSUFFIX
cp $TEMPD/interpreter.$LIBSUFFIX $log_dir/$LLVM_DEFINITION_SHA.$LIBSUFFIX
else
lib=$log_dir/$LLVM_DEFINITION_SHA.$LIBSUFFIX
fi
else
lib=$(realpath ${LLVM_LIB})
fi
Expand Down