-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild_sysc_all.sh
More file actions
executable file
·77 lines (62 loc) · 4.34 KB
/
build_sysc_all.sh
File metadata and controls
executable file
·77 lines (62 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
set -e # exit on error
DIR=$1
if ! [[ -d $DIR ]]; then
DIR="$(pwd)"
fi
echo "Setting working directory to $DIR"
PREFIX="$DIR/systemc-dist"
version=2.3.3
source=systemc-$version.tar.gz
if [ ! -f "$source" ]; then
wget http://www.accellera.org/images/downloads/standards/systemc/$source
fi
tar xf $source
mkdir -p $PREFIX
SOURCEFOLDER=$DIR/systemc-$version
cd $SOURCEFOLDER
echo "first, build the normal systemc (also for include files)"
mkdir -p native-build && cd native-build
../configure --quiet CC=clang CCFLAGS="" CXX=clang++ CXXFLAGS="-std=c++17 -stdlib=libc++" --prefix=$PREFIX --with-arch-suffix=-native
make --no-print-directory -j$(nproc)
make -s install
cd $SOURCEFOLDER
# now building bytecode
LIBNAME=llvm
echo "Now building bytecode manually ($LIBNAME)"
mkdir -p $LIBNAME-build && cd $LIBNAME-build
# not that important what is set here, as we overwrite it anyways in cmake command
../configure --quiet --target=x86_64-pc-linux-gnu CC=clang CFLAGS='' CXX=clang++ CXXFLAGS='-std=c++17' --prefix=$PREFIX --with-arch-suffix=-$LIBNAME
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -D CMAKE_CXX_FLAGS="-DUSE_KLEE -fcxx-exceptions -stdlib=libc++ -std=c++17 -emit-llvm -flto -c -Xclang -disable-O0-optnone" -D CMAKE_CXX_CREATE_STATIC_LIBRARY="llvm-link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -D CMAKE_CXX_LINK_EXECUTABLE="llvm-link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>" -DCMAKE_LINKER=llvm-link -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PREFIX -DINSTALL_TO_LIB_TARGET_ARCH_DIR=$LIBNAME ..
echo "Building in first pass, to let the C-Checks pass"
make --no-print-directory
echo "changing c compiler flags to also emit bitcode. This is needed as checks (and include path search) fail with this set to on."
cmake -DCMAKE_C_FLAGS="-emit-llvm" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -D CMAKE_CXX_FLAGS="-DUSE_KLEE -fcxx-exceptions -stdlib=libc++ -std=c++17 -emit-llvm -flto -c -Xclang -disable-O0-optnone" -D CMAKE_CXX_CREATE_STATIC_LIBRARY="llvm-link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -D CMAKE_CXX_LINK_EXECUTABLE="llvm-link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>" -DCMAKE_LINKER=llvm-link -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PREFIX -DINSTALL_TO_LIB_TARGET_ARCH_DIR=$LIBNAME ..
#cmake -D CMAKE_C_COMPILER=clang -D CMAKE_C_COMPILER_WORKS=1 -DCMAKE_C_FLAGS='-emit-llvm' -DCMAKE_LINKER=$(which llvm-link) -DCMAKE_C_LINK_FLAGS="" -D CMAKE_C_CREATE_STATIC_LIBRARY="llvm-link <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>" -D CMAKE_C_LINK_EXECUTABLE="llvm-link <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>" -DCMAKE_CXX_COMPILER=clang++ -D CMAKE_CXX_FLAGS="-DUSE_KLEE -fcxx-exceptions -stdlib=libc++ -std=c++17 -emit-llvm -flto -c -Xclang -disable-O0-optnone" -D CMAKE_CXX_CREATE_STATIC_LIBRARY="llvm-link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -D CMAKE_CXX_LINK_EXECUTABLE="llvm-link -only-needed <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>" -DCMAKE_LINKER=llvm-link -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PREFIX -DINSTALL_TO_LIB_TARGET_ARCH_DIR=$LIBNAME ..
make --no-print-directory -j$(nproc) || echo "Ignore Errors, as some ASM files can't be built in bytecode"
cd src
set -x # enable echo
llvm-link -o libsystemc.so.$version $(find -iname *.c*.o | xargs echo)
set +x # disable again
# manual install in different dir for lib
INSTALLDIR=$PREFIX/lib-$LIBNAME
mkdir -p $INSTALLDIR
cp -p libsystemc* $INSTALLDIR
# It is important that it ends with bc for CMake to determine correct linker script.
if [ -f $INSTALLDIR/libsystemc.so.bc ]; then
rm $INSTALLDIR/libsystemc.so.bc
fi
ln -sT $INSTALLDIR/libsystemc.so{,.bc}
cd $SOURCEFOLDER
echo "Now building with WLLVM"
LIBNAME=wllvm
INSTALLDIR=$PREFIX/lib-$LIBNAME
mkdir -p $LIBNAME-build && cd $LIBNAME-build
export LLVM_COMPILER=clang
../configure --quiet CC=wllvm CXX=wllvm++ --prefix="$PREFIX" --build=x86_64-pc-linux-gnu --enable-debug CXXFLAGS='-std=c++17' --with-arch-suffix=-wllvm #--enable-shared=NO --enable-static=YES
make -j$(nproc) --no-print-directory install
cd $INSTALLDIR
extract-bc libsystemc.a
extract-bc -b libsystemc.a
cd $SOURCEFOLDER
echo "SystemC libs now available at $(ls -l $PREFIX/lib-*/libsystemc.*)"