From 21397c854c2c07b5952ae80bbb24e2fe56254f57 Mon Sep 17 00:00:00 2001 From: Shamil Date: Mon, 17 Jul 2023 13:48:59 +0530 Subject: [PATCH] Regenerate the oracle for Python testing Python wheels are built in GLIBc ~ 2.17 so some functions are not demangled properly. So we rebuild them using the ir2vec binary and test the Python output against it. The ir2vec binary output is tested against the actual oracle in another workflow. So, this should be fine. --- Manylinux2014_Compliant_Source/pkg/build.sh | 4 ++ .../pkg/regen-oracle.sh | 39 +++++++++++++++++++ Manylinux2014_Compliant_Source/pkg/setup.py | 6 ++- .../pkg/tests/test_ir2vec.py | 2 +- 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 Manylinux2014_Compliant_Source/pkg/regen-oracle.sh diff --git a/Manylinux2014_Compliant_Source/pkg/build.sh b/Manylinux2014_Compliant_Source/pkg/build.sh index c9180490..ab9b40bd 100644 --- a/Manylinux2014_Compliant_Source/pkg/build.sh +++ b/Manylinux2014_Compliant_Source/pkg/build.sh @@ -1,6 +1,8 @@ #!/bin/bash set -eu +export CXX=clang++ +export CC=clang rm -rf build || true mkdir build @@ -18,3 +20,5 @@ cmake -DCMAKE_BUILD_TYPE=Release ../src && make -j"$(nproc)" && make install cd .. cp src/include/utils.h Manylinux2014_Compliant_Source/pkg/IR2Vec/ cp vocabulary/seedEmbeddingVocab-*.txt Manylinux2014_Compliant_Source/pkg/IR2Vec/ + +bash Manylinux2014_Compliant_Source/pkg/regen-oracle.sh diff --git a/Manylinux2014_Compliant_Source/pkg/regen-oracle.sh b/Manylinux2014_Compliant_Source/pkg/regen-oracle.sh new file mode 100644 index 00000000..f976cbee --- /dev/null +++ b/Manylinux2014_Compliant_Source/pkg/regen-oracle.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -eu + +cd src/test-suite + +rm -rf oracle + +SEED_VERSION="llvm12" +SRC_WD="PE-benchmarks" +DEST_FOLDER_LL="PE-benchmarks-llfiles-${SEED_VERSION}" +DEST_FOLDER_SYM="oracle/SYM_${SEED_VERSION}_f" +DEST_FOLDER_FA="oracle/FA_${SEED_VERSION}_f" +DEST_FOLDER_SYM_P="oracle/SYM_${SEED_VERSION}" +DEST_FOLDER_FA_P="oracle/FA_${SEED_VERSION}" + +mkdir -p ${DEST_FOLDER_LL} + +for d in ${SRC_WD}/*.c ${SRC_WD}/*.cpp ${SRC_WD}/*.cc; do + name=$(basename ${d}) && oname=${name%.*} && clang -S -emit-llvm -Xclang -disable-O0-optnone ${d} -o ${DEST_FOLDER}/${oname}.ll & +done +wait + +mkdir -p ${DEST_FOLDER_SYM} +mkdir -p ${DEST_FOLDER_FA} +mkdir -p ${DEST_FOLDER_SYM_P} +mkdir -p ${DEST_FOLDER_FA_P} + +IR2VEC_PATH=../../build/bin/ir2vec + +VOCAB_PATH="../../vocabulary/seedEmbeddingVocab-300-${SEED_VERSION}.txt" + +while IFS= read -r d; do + ${IR2VEC_PATH} -sym -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_SYM}/ir2vec.txt -level f ${d} &>/dev/null + ${IR2VEC_PATH} -fa -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_FA}/ir2vec.txt -level f ${d} &>/dev/null + ${IR2VEC_PATH} -sym -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_SYM_P}/ir2vec.txt -level p ${d} >/dev/null + ${IR2VEC_PATH} -fa -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_FA_P}/ir2vec.txt -level p ${d} >/dev/null +done