-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Download clang 3.8.1 source code in the tools
directory and compiler-rt and poolalloc source code in the projects
directory
cd tools
git clone https://github.com/llvm-mirror/clang -b release_38 --depth=1
cd ..
cd projects
git clone https://github.com/llvm-mirror/compiler-rt -b release_38 --depth=1
git clone https://github.com/jeffy1009/poolalloc_partition poolalloc -b bugfix --depth=1
depth
option helps reduce size and time if you don't need the whole history.
create build
directory and cd
into it.
sudo apt-get install ninja-build
cmake -DCMAKE_BUILD_TYPE="Release" -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_PARALLEL_COMPILE_JOBS="6" -DLLVM_PARALLEL_LINK_JOBS="1" -DLLVM_OPTIMIZED_TABLEGEN="ON" -DLLVM_BINUTILS_INCDIR=/usr/include -GNinja ../llvm-lazy-san
ninja clang
ninja llvm-ar
ninja llvm-nm
ninja llvm-ranlib
ninja LLVMgold.so
You can omit -GNinja
to use make
based build system.
export PATH=<path-to-llvm-build-dir>/bin:$PATH
export LLVM_BUILD_DIR=<path-to-llvm-build-dir>
export CC="$LLVM_BUILD_DIR/bin/clang"
export CXX="$LLVM_BUILD_DIR/bin/clang++"
export AR="$LLVM_BUILD_DIR/bin/llvm-ar"
export NM="$LLVM_BUILD_DIR/bin/llvm-nm"
export RANLIB="$LLVM_BUILD_DIR/bin/llvm-ranlib"
export LD_LIBRARY_PATH=<path-to-llvm-build-dir>/lib:$LD_LIBRARY_PATH
Using gold linker is convenient because you need minimal modification (adding a single compile flags) to the existing makefiles.
To use gold linker, ld
needs to be symbolically linked to ld.gold
$ ls /usr/bin/ld -l
lrwxrwxrwx 1 root root 7 12월 8 19:41 /usr/bin/ld -> ld.gold
ld.gold
must have plugin support. It has plugin support if the output is like this:
$ ld.gold --plugin
ld.gold: --plugin: missing argument
ld.gold: use the --help option for usage information
Example compilation flow:
clang -c -o a.o -g -flto -O1 -fno-vectorize -fno-slp-vectorize a.c
clang -c -o b.o -g -flto -O1 -fno-vectorize -fno-slp-vectorize b.c
clang -c -o c.o -g -flto -O1 -fno-vectorize -fno-slp-vectorize c.c
clang -O1 a.o b.o c.o -lm -o app -flto -fuse-ld=gold -Wl,-plugin-opt=-lazy-san,-l:ls_interposer_rt.so
copy x86_64-linux-clang.cfg
file from lazysan-materials
folder to the spec config
directory.
Then you can build SPEC benchmarks with lazy san like the following
# LTO with gold linker without lazy-san
runspec -c x86_64-linux-clang -e x86_64-linux-clang-gold --noreportable --iteration=1 --action=run <target>
# LTO with gold linker with lazy-san
runspec -c x86_64-linux-clang -e x86_64-linux-clang-gold-lazysan --noreportable --iteration=1 --action=run <target>
action
can be build
if you only want to build.
<target>
can be benchmark numbers, or names, or int
(or fp
or all
etc...)
export APACHE_INSTALL_DIR=<apache installation dir>
cd srclib/apr
./configure CFLAGS="-g -O2 -flto -fno-vectorize -fno-slp-vectorize -fno-strict-aliasing" CXXFLAGS="-g -O2 -flto -fno-vectorize -fno-slp-vectorize -fno-strict-aliasing" --prefix=$APACHE_INSTALL_DIR --enable-static --enable-shared=no
cd srclib/apr-util
./configure CFLAGS="-g -O2 -flto -fno-vectorize -fno-slp-vectorize -fno-strict-aliasing" CXXFLAGS="-g -O2 -flto -fno-vectorize -fno-slp-vectorize -fno-strict-aliasing" --with-expat=builtin --prefix=$APACHE_INSTALL_DIR --with-apr=$APACHE_INSTALL_DIR --enable-static --enable-shared=no
cd httpd
./configure CFLAGS="-g -O2 -flto -fno-vectorize -fno-slp-vectorize -fno-strict-aliasing" CXXFLAGS="-g -O2 -flto -fno-vectorize -fno-slp-vectorize -fno-strict-aliasing" LDFLAGS="-flto -O2 -g -Wl,-plugin-opt=-lazy-san -ltcmalloc -lpthread -lunwind -L/home/jsshin/projects/llvm/lazy-san/lazy-san-lib/autosetup.dir/install/lazysan/lib -L/home/jsshin/projects/llvm/lazy-san/lazy-san-lib/autosetup.dir/framework/obj/staticlib-lazysan -Wl,-whole-archive,-l:libmetadata.a,-no-whole-archive" --prefix=$APACHE_INSTALL_DIR --with-apr=$APACHE_INSTALL_DIR --with-apr-util=$APACHE_INSTALL_DIR --enable-mods-static="access_compat alias auth_basic authn_core authn_file authz_core authz_groupfile authz_host authz_user autoindex dir env filter headers log_config mime reqtimeout setenvif status unixd version cgi dumpio info log_debug logio echo"