Skip to content

Instantly share code, notes, and snippets.

@rashkur
Last active June 4, 2019 12:03
Show Gist options
  • Save rashkur/dc9733998d4af036a80b7c6ee4655734 to your computer and use it in GitHub Desktop.
Save rashkur/dc9733998d4af036a80b7c6ee4655734 to your computer and use it in GitHub Desktop.
build clang from tar.xz sources on centos 7
yum -y install centos-release-scl which devtoolset-7-gcc* libxml2-devel zlib-devel
scl enable devtoolset-7 bash
gcc --version
cat >/tmp/llvm.sh <<'EOL'
#LLVMDIR="/usr/local/src/llvm"
#build in ramdisk if it's >= 8GB
LLVMDIR="/run/llvm"
LLVMVER="8.0.0"
TEST_CC="/opt/rh/devtoolset-7/root/usr/bin/cc"
TEST_GCC="/opt/rh/devtoolset-7/root/usr/bin/gcc"
rm -rf "$LLVMDIR/build"
ls "$LLVMDIR" || mkdir -p "$LLVMDIR"
cd "$LLVMDIR"
wget "http://releases.llvm.org/$LLVMVER/llvm-$LLVMVER.src.tar.xz"
tar xf "llvm-$LLVMVER.src.tar.xz" --no-same-owner
cd "llvm-$LLVMVER.src/projects"
wget "http://releases.llvm.org/$LLVMVER/compiler-rt-$LLVMVER.src.tar.xz"
tar xf "compiler-rt-$LLVMVER.src.tar.xz" --no-same-owner
mv "compiler-rt-$LLVMVER.src" compiler-rt
wget "http://releases.llvm.org/$LLVMVER/libcxx-$LLVMVER.src.tar.xz"
tar xf "libcxx-$LLVMVER.src.tar.xz" --no-same-owner
mv "libcxx-$LLVMVER.src" libcxx
wget "http://releases.llvm.org/$LLVMVER/libcxxabi-$LLVMVER.src.tar.xz"
tar xf "libcxxabi-$LLVMVER.src.tar.xz" --no-same-owner
mv "libcxxabi-$LLVMVER.src" libcxxabi
wget "http://releases.llvm.org/$LLVMVER/libunwind-$LLVMVER.src.tar.xz"
tar xf "libunwind-$LLVMVER.src.tar.xz" --no-same-owner
mv "libunwind-$LLVMVER.src" libunwind
rm -f *.src.tar.xz
cd "$LLVMDIR"/llvm-$LLVMVER.src/tools
wget "http://releases.llvm.org/$LLVMVER/cfe-$LLVMVER.src.tar.xz"
tar xf "cfe-$LLVMVER.src.tar.xz" --no-same-owner
mv "cfe-$LLVMVER.src" clang
wget "http://releases.llvm.org/$LLVMVER/lld-$LLVMVER.src.tar.xz"
tar xf "lld-$LLVMVER.src.tar.xz" --no-same-owner
mv "lld-$LLVMVER.src" lld
wget "http://releases.llvm.org/$LLVMVER/lldb-$LLVMVER.src.tar.xz"
tar xf "lldb-$LLVMVER.src.tar.xz" --no-same-owner
mv "lldb-$LLVMVER.src" lldb
rm -f *.src.tar.xz
mkdir "$LLVMDIR/build" && cd "$LLVMDIR/build"
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DLLVM_LIBDIR_SUFFIX=64 -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON -DLLDB_TEST_C_COMPILER="$TEST_CC" -DLLDB_TEST_CXX_COMPILER="$TEST_GCC" ../llvm-$LLVMVER.src
#cmake --build .
cmake --build . --target install -- -j $(nproc)
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/src/clang/1 -P cmake_install.cmake
EOL
bash /tmp/llvm.sh >> /tmp/llvm.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment