-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding scripts for coverage, not tested yet
- Loading branch information
Showing
20 changed files
with
2,110 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
shopt -s extglob # Activate extended pattern matching in bash | ||
|
||
working_folder=$1 | ||
|
||
sudo apt-get install make | ||
sudo apt-get install flex -y | ||
sudo apt-get install -y bison | ||
|
||
# Downloading LLVM and Csmith sources, building Csmith | ||
TMP_SOURCE_FOLDER=$(mktemp -d $working_folder/.sources.XXXXXXX.tmp) | ||
cd $TMP_SOURCE_FOLDER | ||
## Get gcc | ||
git clone git://gcc.gnu.org/git/gcc.git | ||
cd gcc | ||
git checkout releases/gcc-10 | ||
## Get pre-req. isl-0.18.tar.bz2;gmp-6.1.0.tar.bz2;mpc-1.0.3.tar.gz; mpfr-3.1.4.tar.bz2 => works for gcc-10 | ||
## GMP | ||
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 | ||
bunzip2 gmp-6.1.0.tar.bz2 | ||
tar xvf gmp-6.1.0.tar | ||
cd gmp-6.1.0 | ||
./configure --disable-shared --enable-static --prefix=/tmp/gcc | ||
make && make check && make install | ||
cd .. | ||
## MPFR | ||
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 | ||
bunzip2 mpfr-3.1.4.tar.bz2 | ||
tar xvf mpfr-3.1.4.tar | ||
cd mpfr-3.1.4 | ||
./configure --disable-shared --enable-static --prefix=/tmp/gcc --with-gmp=/tmp/gcc | ||
make && make check && make install | ||
cd .. | ||
## MPC | ||
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz | ||
tar zxvf mpc-1.0.3.tar.gz | ||
cd mpc-1.0.3 | ||
./configure --disable-shared --enable-static --prefix=/tmp/gcc --with-gmp=/tmp/gcc --with-mpfr=/tmp/gcc | ||
make && make check && make install | ||
cd .. | ||
## ISL | ||
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 | ||
bunzip2 isl-0.18.tar.bz2 | ||
tar xvf isl-0.18.tar | ||
cd isl-0.18 | ||
./configure --with-gmp-prefix=/tmp/gcc --disable-shared --enable-static --prefix=/tmp/isl | ||
make -j $THREADS && make install | ||
echo ">> Downloading GCC (trunk) source files ($TMP_SOURCE_FOLDER)" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
working_folder=$1 | ||
|
||
# Downloading LLVM and Csmith sources, building Csmith | ||
TMP_SOURCE_FOLDER=$(mktemp -d $working_folder/.sources.XXXXXXX.tmp) | ||
cd $TMP_SOURCE_FOLDER | ||
## LLVM | ||
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/llvm-11.0.0.src.tar.xz | ||
tar -xvf llvm-11.0.0.src.tar.xz | ||
rm llvm-11.0.0.src.tar.xz | ||
mv llvm-11.0.0.src llvm-source | ||
cd ./llvm-source/tools | ||
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/clang-11.0.0.src.tar.xz | ||
tar -xvf clang-11.0.0.src.tar.xz | ||
rm clang-11.0.0.src.tar.xz | ||
mv clang-11.0.0.src clang | ||
echo ">> Downloading LLVM 11 source filese ($TMP_SOURCE_FOLDER)" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#!/bin/bash | ||
shopt -s extglob # Activate extended pattern matching in bash | ||
working_folder=$1 ## base folder | ||
TMP_SOURCE_FOLDER=$2 ## Input from 0- script | ||
nb_processes=$3 ## How many copies | ||
|
||
timeB=$(date +"%T") | ||
echo ">> Start Script <$timeB>" | ||
|
||
## Assure we are in gcc-10! | ||
sudo apt install gcc-10 g++-10 | ||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 990 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 | ||
sudo rm -f /usr/bin/cpp /usr/bin/gcc /usr/bin/g++ /usr/bin/gcov | ||
sudo rm -f /usr/local/bin/cpp /usr/local/bin/gcc /usr/local/bin/g++ /usr/local/bin/gcov | ||
sudo ln -s /usr/bin/cpp-10 /usr/bin/cpp | ||
sudo ln -s /usr/bin/gcc-10 /usr/bin/gcc | ||
sudo ln -s /usr/bin/g++-10 /usr/bin/g++ | ||
sudo ln -s /usr/bin/gcov-10 /usr/bin/gcov | ||
echo ">> End Settings" | ||
|
||
# Copying GCC source and Csmith exe to parallel execution folders, then install GCC with coverage data in each folder | ||
i=0 # compile a basic one - never to use. | ||
while (( $i <= $nb_processes )); | ||
do | ||
## Start loop i | ||
echo ">> Copy gcc folder-$i of gcc" | ||
|
||
### Create a working folder with GCC source | ||
rm -rf $working_folder/gcc-csmith-$i ## Remove the old version | ||
mkdir $working_folder/gcc-csmith-$i ## Create a new version | ||
cp -r $TMP_SOURCE_FOLDER/* $working_folder/gcc-csmith-$i ## Copy the data from the temp download folder | ||
|
||
### Update Csmith settings | ||
cd $working_folder/gcc-csmith-$i | ||
echo $working_folder/gcc-csmith-$i"/gcc-install/bin/gcc -O2" > ./csmith/scripts/compiler_test.in | ||
|
||
### GCC PART: with instrumentation | ||
# Setting the env. + cov. and keeping information of the versions | ||
cd $working_folder/gcc-csmith-$i; mkdir compilation_info; mv $working_folder/gcc-csmith-$i/gcc $working_folder/gcc-csmith-$i/gcc-source | ||
cd gcc-source; git status > $working_folder/gcc-csmith-$i/compilation_info/git_info.txt; git log | head -10 >> $working_folder/gcc-csmith-$i/compilation_info/git_info.txt | ||
gcc --version > $working_folder/gcc-csmith-$i/compilation_info/gcc-version.txt; g++ --version >> $working_folder/gcc-csmith-$i/compilation_info/gcc-version.txt; gcov --version >> $working_folder/gcc-csmith-$i/compilation_info/gcc-version.txt; cpp --version >> $working_folder/gcc-csmith-$i/compilation_info/gcc-version.txt | ||
cd $working_folder/gcc-csmith-$i ## Assure we are now here. | ||
|
||
## Finish settings and moving files | ||
echo ">> gcc folder-$i is set" | ||
|
||
if (( 0 < $i )); then | ||
## Compile with coverage | ||
( | ||
## Set output folders | ||
sudo mkdir -p /tmp/gcc/deleteme/coverage_gcda_files/application_run-init | ||
mkdir gcc-build gcc-install | ||
cd ./gcc-build | ||
|
||
# Covarage flags: | ||
export GCOV_PREFIX=/tmp/gcc/deleteme/coverage_gcda_files/application_run-init ## Send gcda of build to temp. | ||
export GCOV_PREFIX_STRIP=0 | ||
export CFLAGS='-g -O0 --coverage -ftest-coverage -fprofile-arcs' | ||
export CXXFLAGS='-g -O0 --coverage -ftest-coverage -fprofile-arcs' | ||
export LDFLAGS='-lgcov --coverage -ftest-coverage -fprofile-arcs' | ||
|
||
./../gcc-source/configure --disable-multilib --disable-bootstrap --enable-coverage=noopt --enable-targets='X86' --enable-languages='c,c++,lto,objc,obj-c++' --with-gmp=/tmp/gcc/ --with-mpfr=/tmp/gcc/ --with-mpc=/tmp/gcc/ --with-isl=/tmp/isl --prefix=$working_folder/gcc-csmith-$i/gcc-install/ CFLAGS_FOR_TARGET='-g -O0 --coverage -ftest-coverage -fprofile-arcs' CXXFLAGS_FOR_TARGET='-g -O0 --coverage -ftest-coverage -fprofile-arcs' > $working_folder/gcc-csmith-$i/compilation_info/config_output.txt 2>&1 | ||
|
||
make -j$(nproc) > $working_folder/gcc-csmith-$i/compilation_info/build_output.txt 2>&1 | ||
make -j$(nproc) install > $working_folder/gcc-csmith-$i/compilation_info/install_output.txt 2>&1 | ||
#### WE KEEP build, install and source folders sperated. #### | ||
|
||
# Cleaning after build | ||
sudo rm -rf /tmp/gcc/deleteme/coverage_gcda_files/application_run-init | ||
unset CFLAGS | ||
unset CXXFLAGS | ||
unset LDFLAGS | ||
unset GCOV_PREFIX | ||
unset GCOV_PREFIX_STRIP | ||
) | ||
## Shall be here: cd $working_folder/gcc-csmith-$i/gcc | ||
cd $working_folder/gcc-csmith-$i/gcc-source | ||
|
||
## Remove other languages: brig, fortran, go, d | ||
rm -rf libgfortran # FORTRAN | ||
rm -rf libgo gotools # GO | ||
rm -rf libphobos # D (also GDC is D) | ||
rm -rf libada # ADA | ||
## Remove testsuite folders (gcc does not include these into coverage) | ||
rm -rf gcc/testsuite libatomic/testsuite libffi/testsuite libgomp/testsuite libiberty/testsuite libitm/testsuite | ||
rm -rf libstdc++-v3/testsuite libvtv/testsuite | ||
|
||
# stat for core: | ||
c1=`find $working_folder/gcc-csmith-$i/gcc-source/ -name *.c | wc -l` | ||
c2=`find $working_folder/gcc-csmith-$i/gcc-source/ -name *.h | wc -l` | ||
c3=`find $working_folder/gcc-csmith-$i/gcc-build/ -name *.gcno | wc -l` | ||
c4=`find $working_folder/gcc-csmith-$i/gcc-build/ -name *.gcda | wc -l` | ||
echo ">> Built GCC in $working_folder/gcc-csmith-$i/gcc-build/, installed in $working_folder/gcc-csmith-$i/gcc-install/." | ||
echo ">> Compilation info. in $working_folder/gcc-csmith-$i/compilation_info/." | ||
echo ">> Total ($c1) C-files, ($c2) header files, ($c3) gcno files, ($c4) gcda files." | ||
find $working_folder/gcc-csmith-$i/gcc-source/ -name *.c > $working_folder/gcc-csmith-$i/compilation_info/gcc_c_files.txt | ||
find $working_folder/gcc-csmith-$i/gcc-source/ -name *.h > $working_folder/gcc-csmith-$i/compilation_info/gcc_h_files.txt | ||
find $working_folder/gcc-csmith-$i/gcc-build/ -name *.gcno > $working_folder/gcc-csmith-$i/compilation_info/gcc_gcno_files.txt | ||
find . -name *.gcda -exec rm -rf {} \; | ||
echo " --> Removed $c4 gcda files." | ||
#### TESTS #### | ||
else | ||
## Compile without coverage | ||
( | ||
## Set output folders | ||
mkdir gcc-build gcc-install | ||
cd ./gcc-build | ||
|
||
## Config, compile and install: | ||
./../gcc-source/configure --disable-multilib --disable-bootstrap --enable-targets='X86' --enable-languages='c,c++,lto,objc,obj-c++' --with-gmp=/tmp/gcc --with-mpfr=/tmp/gcc --with-mpc=/tmp/gcc --with-isl=/tmp/isl --prefix=$working_folder/gcc-csmith-$i/gcc-install/ > $working_folder/gcc-csmith-$i/compilation_info/config_output.txt 2>&1 | ||
|
||
make -j$(nproc) > $working_folder/gcc-csmith-$i/compilation_info/build_output.txt 2>&1 | ||
make -j$(nproc) install > $working_folder/gcc-csmith-$i/compilation_info/install_output.txt 2>&1 | ||
#### WE KEEP build, install and source folders sperated. #### | ||
) | ||
fi | ||
|
||
## Zip it with soft links - unzip with h option: tar -xhzvf gcc-csmith-0.tar.gz | ||
cd $working_folder | ||
tar -czvf gcc-csmith-$i.tar.gz gcc-csmith-$i/ | ||
# Next core | ||
i=$(($i+1)) | ||
|
||
## Assure we are using the built gcc: | ||
usrLib=$working_folder/gcc-csmith-0/gcc-install | ||
sudo rm -f /usr/bin/cpp /usr/bin/gcc /usr/bin/g++ /usr/bin/gcov | ||
sudo rm -f /usr/local/bin/cpp /usr/local/bin/gcc /usr/local/bin/g++ /usr/local/bin/gcov | ||
sudo ln -s $usrLib/bin/cpp /usr/bin/cpp | ||
sudo ln -s $usrLib/bin/gcc /usr/bin/gcc | ||
sudo ln -s $usrLib/bin/g++ /usr/bin/g++ | ||
sudo ln -s $usrLib/bin/gcov /usr/bin/gcov | ||
done | ||
|
||
## Revert back all gcc changes: | ||
sudo rm -f /usr/bin/cpp /usr/bin/gcc /usr/bin/g++ /usr/bin/gcov | ||
sudo rm -f /usr/local/bin/cpp /usr/local/bin/gcc /usr/local/bin/g++ /usr/local/bin/gcov | ||
sudo ln -s /usr/bin/cpp-10 /usr/bin/cpp | ||
sudo ln -s /usr/bin/gcc-10 /usr/bin/gcc | ||
sudo ln -s /usr/bin/g++-10 /usr/bin/g++ | ||
sudo ln -s /usr/bin/gcov-10 /usr/bin/gcov | ||
|
||
#rm -rf $TMP_SOURCE_FOLDER |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
shopt -s extglob # Activate extended pattern matching in bash | ||
working_folder=$1 ## base folder | ||
TMP_SOURCE_FOLDER=$2 ## Input from 0- script | ||
nb_processes=$3 ## How many copies | ||
|
||
timeB=$(date +"%T") | ||
echo ">> Start Script <$timeB>" | ||
|
||
# Copying LLVM source and Csmith exe to parallel execution folders, then install LLVM with coverage data in each folder | ||
i=1 | ||
while (( $i <= $nb_processes )); | ||
do | ||
### Create a working folder with LLVM source | ||
rm -rf $working_folder/llvm-csmith-$i ## Remove the old version | ||
mkdir $working_folder/llvm-csmith-$i ## Create a new version | ||
cp -rf $TMP_SOURCE_FOLDER/* $working_folder/llvm-csmith-$i ## Copy the data from the temp download folder | ||
|
||
### Update Csmith settings | ||
mkdir $working_folder/llvm-csmith-$i/csmith/scripts/ ## Just incase it isn't there | ||
cd $working_folder/llvm-csmith-$i | ||
echo $working_folder/llvm-csmith-$i"/llvm-install/usr/local/bin/clang -O3" > ./csmith/scripts/compiler_test.in | ||
|
||
## Save information regarding the version and how we compile it | ||
mkdir compilation_info | ||
echo ">> Adding compilation_info" | ||
echo " - date: $(date '+%Y-%m-%d at %H:%M.%S')" > $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt | ||
echo " - host name $(hostname -f)" >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt | ||
echo " - current path: $(pwd)" >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt | ||
gcc-10 --version >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt; g++-10 --version >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt; gcov-10 --version >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt; cpp-10 --version >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt; /usr/bin/cc --version >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt; /usr/bin/c++ --version >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt | ||
|
||
### LLVM PART: with instrumentation | ||
# Setting the env. + cov. | ||
{ | ||
mkdir llvm-build llvm-install | ||
cd ./llvm-build | ||
set CFLAGS='--coverage -ftest-coverage -fprofile-arcs -fno-inline' | ||
set CXXFLAGS='--coverage -ftest-coverage -fprofile-arcs -fno-inline' | ||
set LDFLAGS='-lgcov --coverage -ftest-coverage -fprofile-arcs' | ||
set CXX=g++-10 | ||
set CC=gcc-10 | ||
|
||
# Cmake and build of LLVM | ||
timeS=$(date +"%T") | ||
echo "Configuration: cmake -GNinja ../llvm-source -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_BUILD_TESTS=OFF -DLLVM_BUILD_DOCS=OFF -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage <$timeS>" >> $working_folder/llvm-csmith-$i/compilation_info/llvm-version.txt | ||
cmake -GNinja ../llvm-source -DCMAKE_BUILD_TYPE="Release" -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_BUILD_EXAMPLES="OFF" -DLLVM_BUILD_TESTS="OFF" -DLLVM_BUILD_DOCS="OFF" -DCMAKE_C_FLAGS="--coverage" -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_EXE_LINKER_FLAGS="--coverage" > $working_folder/llvm-csmith-$i/compilation_info/config_output.txt 2>&1 | ||
timeB=$(date +"%T") | ||
echo ">> Build LLVM with ninja to ./llvm-build <$timeB>" | ||
ninja > $working_folder/llvm-csmith-$i/compilation_info/build_output.txt 2>&1 | ||
ninja check-clang >> $working_folder/llvm-csmith-$i/compilation_info/build_output.txt 2>&1 | ||
grep "FAILED:" $working_folder/llvm-csmith-$i/compilation_info/build_output.txt | ||
timeI=$(date +"%T") | ||
echo ">> Install LLVM locallly with ninja to ./llvm-install <$timeI>" | ||
DESTDIR=../llvm-install ninja install -k 10 > $working_folder/llvm-csmith-$i/compilation_info/install_output.txt 2>&1 | ||
grep "FAILED:" $working_folder/llvm-csmith-$i/compilation_info/install_output.txt | ||
|
||
# Cleaning after build | ||
unset CFLAGS | ||
unset CXXFLAGS | ||
unset LDFLAGS | ||
unset CXX | ||
unset CC | ||
} | ||
|
||
# Next core | ||
cd .. | ||
cd .. | ||
timeT=$(date +"%T") | ||
echo ">> Create .tar of LLVM local installation <$timeT>" | ||
tar -czvf llvm-csmith-$i.tar.gz llvm-csmith-$i/ >> $working_folder/llvm-csmith-$i/compilation_info/install_output.txt 2>&1 | ||
i=$(($i+1)) | ||
done | ||
timeE=$(date +"%T") | ||
echo "Done. <$timeE>" | ||
rm -rf $TMP_SOURCE_FOLDER |
Oops, something went wrong.