Skip to content

Instantly share code, notes, and snippets.

@daniel-j-h
Last active March 24, 2016 17:11
Show Gist options
  • Save daniel-j-h/8ee8c511f89ebe80821b to your computer and use it in GitHub Desktop.
Save daniel-j-h/8ee8c511f89ebe80821b to your computer and use it in GitHub Desktop.
Script for building a local LLVM 3.8 distribution from source (with clang, libc++, lldb, ...); in addition scripts to then build Boost and Intel TBB against LLVM 3.8 and libc++
#!/usr/bin/env bash
# Builds a local Boost 1.60 distribution from source
# Usage: ./build-boost-1-60.sh directory
set -o errexit
set -o pipefail
set -o nounset
readonly where=$(realpath ${1:-boost-dev})
mkdir -p ${where}/sources && cd $_
readonly packages=(
"https://downloads.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.bz2"
)
echo "Downloading Boost 1.60 sources .."
for package in ${packages[@]}
do
wget --quiet --continue ${package} &
done
wait
echo "Verifying checksums for Boost 1.60 sources .."
sha256sum --check --quiet --status << EOF
686affff989ac2488f79a97b9479efb9f2abae035b5ed4d8226de6857933fd3b boost_1_60_0.tar.bz2
EOF
echo "Extracting Boost 1.60 sources .."
for package in *.tar.bz2
do
tar xf ${package} &
done
wait
echo "Configuring Boost 1.60 .."
cd ${where}/sources/boost_1_60_0
./bootstrap.sh --with-toolset=clang --prefix=${where}
echo "Building Boost 1.60 .."
./b2 -j $(nproc) toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++" variant=release link=shared runtime-link=shared
echo "Installing Boost 1.60 .."
./b2 install --prefix=${where}
echo "Append the following to ~/.profile"
echo
echo "export CPLUS_INCLUDE_PATH=\"${where}/include:\$CPLUS_INCLUDE_PATH\""
echo "export LD_LIBRARY_PATH=\"${where}/lib:\$LD_LIBRARY_PATH\""
#!/usr/bin/env bash
# Builds a local Intel TBB 4.4.3 distribution from source
# Usage: ./build-intel-tbb-4-4-u3.sh directory
set -o errexit
set -o pipefail
set -o nounset
readonly where=$(realpath ${1:-tbb-dev})
mkdir -p ${where}/sources && cd $_
readonly packages=(
"https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb44_20160128oss_src_0.tgz"
)
echo "Downloading Intel TBB 4.4.3 sources .."
for package in ${packages[@]}
do
wget --quiet --continue ${package} &
done
wait
echo "Verifying checksums for Intel TBB 4.4.3 sources .."
sha256sum --check --quiet --status << EOF
8d256bf13aef1b0726483af9f955918f04e3de4ebbf6908aa1b0c94cbe784ad7 tbb44_20160128oss_src_0.tgz
EOF
echo "Extracting Intel TBB 4.4.3 sources .."
for package in *.tgz
do
tar xf ${package} &
done
wait
echo "Configuring Intel TBB 4.4.3 .."
mkdir -p ${where}/build
cd ${where}/sources/tbb44_20160128oss
echo "Building Intel TBB 4.4.3 .."
make -j $(nproc) compiler=clang stdlib=libc++ cpp0x=1 lambdas=1 tbb_build_dir=${where}/build tbb_build_prefix=tbb
echo "Installing Intel TBB 4.4.3 .."
mkdir -p ${where}/lib
cp -r ${where}/sources/tbb44_20160128oss/include ${where}/include
cp ${where}/build/tbb_release/*.so ${where}/lib
echo "Append the following to ~/.profile"
echo
echo "export CPLUS_INCLUDE_PATH=\"${where}/include:\$CPLUS_INCLUDE_PATH\""
echo "export LD_LIBRARY_PATH=\"${where}/lib:\$LD_LIBRARY_PATH\""
#!/usr/bin/env bash
# Builds a local LLVM 3.8 distribution from source
# Usage: ./build-llvm-3.8.sh directory
set -o errexit
set -o pipefail
set -o nounset
readonly where=$(realpath ${1:-llvm-dev})
mkdir -p ${where}/sources && cd $_
readonly packages=(
"http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/cfe-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/compiler-rt-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/libcxx-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/libcxxabi-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/libunwind-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/lld-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/lldb-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/openmp-3.8.0.src.tar.xz"
"http://llvm.org/releases/3.8.0/clang-tools-extra-3.8.0.src.tar.xz"
)
echo "Downloading LLVM 3.8 sources .."
for package in ${packages[@]}
do
wget --quiet --continue ${package} &
done
wait
echo "Verifying checksums for LLVM 3.8 sources .."
sha256sum --check --quiet --status << EOF
04149236de03cf05232d68eb7cb9c50f03062e339b68f4f8a03b650a11536cf9 cfe-3.8.0.src.tar.xz
afbda810106a6e64444bc164b921be928af46829117c95b996f2678ce4cb1ec4 clang-tools-extra-3.8.0.src.tar.xz
c8d3387e55f229543dac1941769120f24dc50183150bf19d1b070d53d29d56b0 compiler-rt-3.8.0.src.tar.xz
36804511b940bc8a7cefc7cb391a6b28f5e3f53f6372965642020db91174237b libcxx-3.8.0.src.tar.xz
c5ee0871aff6ec741380c4899007a7d97f0b791c81df69d25b744eebc5cee504 libcxxabi-3.8.0.src.tar.xz
af3eaf39ecdc3b9e89863fb62e1aa3c135cfde7e9415424e4e396d7486a9422b libunwind-3.8.0.src.tar.xz
94704dda228c9f75f4403051085001440b458501ec97192eee06e8e67f7f9f0c lld-3.8.0.src.tar.xz
e3f68f44147df0433e7989bf6ed1c58ff28d7c68b9c47553cb9915f744785a35 lldb-3.8.0.src.tar.xz
555b028e9ee0f6445ff8f949ea10e9cd8be0d084840e21fbbe1d31d51fc06e46 llvm-3.8.0.src.tar.xz
92510e3f62e3de955e3a0b6708cebee1ca344d92fb02369cba5fdd5c68f773a0 openmp-3.8.0.src.tar.xz
EOF
echo "Extracting LLVM 3.8 sources .."
for package in *.tar.xz
do
tar xf ${package} &
done
wait
echo "Assembling LLVM 3.8 subprojects .."
mv cfe-3.8.0.src llvm-3.8.0.src/tools/clang
mv clang-tools-extra-3.8.0.src llvm-3.8.0.src/tools/clang/tools/extra
mv compiler-rt-3.8.0.src llvm-3.8.0.src/projects/compiler-rt
mv libcxx-3.8.0.src llvm-3.8.0.src/projects/libcxx
mv libcxxabi-3.8.0.src llvm-3.8.0.src/projects/libcxxabi
mv libunwind-3.8.0.src llvm-3.8.0.src/projects/libunwind
mv openmp-3.8.0.src llvm-3.8.0.src/projects/openmp
mv lldb-3.8.0.src llvm-3.8.0.src/tools/lldb
mv lld-3.8.0.src llvm-3.8.0.src/tools/lld
echo "Configuring LLVM 3.8 .."
mkdir -p ${where}/build && cd $_
cmake ../sources/llvm-3.8.0.src \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${where} \
-G Ninja \
-DCLANG_INCLUDE_DOCS=OFF \
-DCLANG_INCLUDE_TESTS=OFF \
-DCOMPILER_RT_INCLUDE_TESTS=OFF \
-DLIBCXX_INCLUDE_DOCS=OFF \
-DLIBCXX_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_GO_TESTS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_TARGETS_TO_BUILD=X86
echo "Building LLVM 3.8 .."
cmake --build .
echo "Installing LLVM 3.8 .."
cmake --build . --target install
echo "Append the following to ~/.profile"
echo
echo "export PATH=\"${where}/bin:\$PATH\""
echo "export C_INCLUDE_PATH=\"${where}/include:\$C_INCLUDE_PATH\""
echo "export CPLUS_INCLUDE_PATH=\"${where}/include:\$CPLUS_INCLUDE_PATH\""
echo "export LD_LIBRARY_PATH=\"${where}/lib:\$LD_LIBRARY_PATH\""
echo
echo "Usage: clang++ -Wall -Wextra -pedantic -std=c++14 -stdlib=libc++ -lc++ -lc++abi main.cc && readelf --dynamic a.out"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment