Last active
October 13, 2015 14:48
-
-
Save ttilley/4211790 to your computer and use it in GitHub Desktop.
build llvm svn and friends on mac
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
#!/usr/bin/env bash | |
set -e | |
xcsel='xcode-select --print-path' | |
xcodepath="$($xcsel)" | |
platform='MacOSX' | |
export TRIPLE='x86_64-apple-darwin11' | |
export MACOSX_DEPLOYMENT_TARGET='10.7' | |
export SDK="$platform$MACOSX_DEPLOYMENT_TARGET" | |
export SDKROOT="$xcodepath/Platforms/$platform.platform/Developer/SDKs/$SDK.sdk" | |
export TCROOT="$xcodepath/Toolchains/XcodeDefault.xctoolchain" | |
export PATH="${TCROOT}/usr/bin:${PATH}" | |
export CC="${CC:="$(xcrun -sdk "$SDKROOT" -find clang)"}" | |
export CXX="${CXX:="$(xcrun -sdk "$SDKROOT" -find clang++)"}" | |
unset platform | |
unset xcodepath | |
unset xcsel | |
# export PATH="/opt/clang32/bin:${PATH}" | |
# export CC="/opt/clang32/bin/clang" | |
# export CXX="/opt/clang32/bin/clang++" | |
# export PATH="/opt/toolchain/bin:${PATH}" | |
# export CC="/opt/toolchain/bin/clang" | |
# export CXX="/opt/toolchain/bin/clang++" | |
export REQUIRES_RTTI=1 | |
SVN_BASE="${SVN_BASE:-http://llvm.org/svn/llvm-project}" | |
# SVN_BRANCH="${SVN_BRANCH:-trunk}" | |
SVN_BRANCH="${SVN_BRANCH:-branches/release_32}" | |
SVN_BRANCH_CLANG="${SVN_BRANCH_CLANG:-$SVN_BRANCH}" | |
SVN_BRANCH_CLANG_TOOLS_EXTRA="${SVN_BRANCH_CLANG_TOOLS_EXTRA:-$SVN_BRANCH}" | |
SVN_BRANCH_COMPILER_RT="${SVN_BRANCH_COMPILER_RT:-$SVN_BRANCH}" | |
SVN_BRANCH_LIBCXX="${SVN_BRANCH_LIBCXX:-$SVN_BRANCH}" | |
SVN_BRANCH_LLD="${SVN_BRANCH_LLD:-$SVN_BRANCH}" | |
SVN_BRANCH_LLDB="${SVN_BRANCH_LLDB:-$SVN_BRANCH}" | |
SVN_BRANCH_LLVM="${SVN_BRANCH_LLVM:-$SVN_BRANCH}" | |
SVN_BRANCH_LLVM_TEST_SUITE="${SVN_BRANCH_LLVM_TEST_SUITE:-$SVN_BRANCH}" | |
SVN_BRANCH_POLLY="${SVN_BRANCH_POLLY:-$SVN_BRANCH}" | |
SVN_BRANCH_POOLALLOC="${SVN_BRANCH_POOLALLOC:-$SVN_BRANCH}" | |
SVN_BRANCH_SAFECODE="${SVN_BRANCH_SAFECODE:-$SVN_BRANCH}" | |
CLANG_SVN="${SVN_BASE}/cfe/${SVN_BRANCH_CLANG}" | |
CLANG_TOOLS_EXTRA_SVN="${SVN_BASE}/clang-tools-extra/${SVN_BRANCH_CLANG_TOOLS_EXTRA}" | |
COMPILER_RT_SVN="${SVN_BASE}/compiler-rt/${SVN_BRANCH_COMPILER_RT}" | |
LIBCXX_SVN="${SVN_BASE}/libcxx/${SVN_BRANCH_LIBCXX}" | |
LLD_SVN="${SVN_BASE}/lld/${SVN_BRANCH_LLD}" | |
LLDB_SVN="${SVN_BASE}/lldb/${SVN_BRANCH_LLDB}" | |
LLVM_SVN="${SVN_BASE}/llvm/${SVN_BRANCH_LLVM}" | |
POLLY_SVN="${SVN_BASE}/polly/${SVN_BRANCH_POLLY}" | |
POOLALLOC_SVN="${SVN_BASE}/poolalloc/${SVN_BRANCH_POOLALLOC}" | |
SAFECODE_SVN="${SVN_BASE}/safecode/${SVN_BRANCH_SAFECODE}" | |
TESTSUITE_SVN="${SVN_BASE}/test-suite/${SVN_BRANCH_LLVM_TEST_SUITE}" | |
BASE="$(pwd)" | |
LLVM_SRC="${BASE}/llvm" | |
PROJECTS_SRC="${LLVM_SRC}/projects" | |
TOOLS_SRC="${LLVM_SRC}/tools" | |
CLANG_SRC="${TOOLS_SRC}/clang" | |
CLANG_TOOLS_EXTRA_SRC="${CLANG_SRC}/tools/extra" | |
COMPILER_RT_SRC="${PROJECTS_SRC}/compiler-rt" | |
LIBCXX_SRC="${PROJECTS_SRC}/libcxx" | |
LLD_SRC="${TOOLS_SRC}/lld" | |
LLDB_SRC="${TOOLS_SRC}/lldb" | |
POLLY_SRC="${TOOLS_SRC}/polly" | |
POOLALLOC_SRC="${PROJECTS_SRC}/poolalloc" | |
SAFECODE_SRC="${PROJECTS_SRC}/safecode" | |
TESTSUITE_SRC="${PROJECTS_SRC}/test-suite" | |
LLVM_BUILD="${BASE}/build" | |
LLVM_BOOTSTRAP="${BASE}/bootstrap" | |
# LLVM_INSTALL="${LLVM_INSTALL:-/usr/local/Cellar/llvm/HEAD}" | |
LLVM_INSTALL="${LLVM_INSTALL:-/opt/toolchain}" | |
svn checkout "${LLVM_SVN}" "${LLVM_SRC}" | |
svn checkout "${TESTSUITE_SVN}" "${TESTSUITE_SRC}" | |
svn checkout "${CLANG_SVN}" "${CLANG_SRC}" | |
svn checkout "${CLANG_TOOLS_EXTRA_SVN}" "${CLANG_TOOLS_EXTRA_SRC}" | |
svn checkout "${COMPILER_RT_SVN}" "${COMPILER_RT_SRC}" | |
svn checkout "${LIBCXX_SVN}" "${LIBCXX_SRC}" | |
svn checkout "${POLLY_SVN}" "${POLLY_SRC}" | |
svn checkout "${POOLALLOC_SVN}" "${POOLALLOC_SRC}" | |
# svn checkout "${SAFECODE_SVN}" "${SAFECODE_SRC}" | |
# svn checkout "${LLDB_SVN}" "${LLDB_SRC}" | |
# svn checkout "${LLD_SVN}" "${LLD_SRC}" | |
rm -rf "${LLVM_BOOTSTRAP}" | |
mkdir -p "${LLVM_BOOTSTRAP}" | |
pushd "${LLVM_BOOTSTRAP}" | |
$LLVM_SRC/configure \ | |
--disable-option-checking \ | |
--prefix="${LLVM_BOOTSTRAP}/install" \ | |
--build="${TRIPLE}" \ | |
--disable-optimized --enable-assertions \ | |
--enable-expensive-checks \ | |
--disable-bindings \ | |
--enable-targets=host-only \ | |
--enable-libcpp \ | |
--without-llvmgcc --without-llvmgxx \ | |
--enable-pic --with-pic \ | |
--with-optimize-option="-Os" \ | |
--disable-polly | |
make -j6 REQUIRES_RTTI=1 NO_PEDANTIC=1 ENABLE_PIC=1 | |
make check-all | |
# make polly-test -C tools/polly/test | |
sudo make install | |
sudo cp -vR "$TCROOT/usr/lib/arc" "${LLVM_BOOTSTRAP}/install/lib/" | |
sudo chown -R $(whoami) "${LLVM_BOOTSTRAP}/install" | |
sudo chown -R $(whoami) "${LLVM_BOOTSTRAP}" | |
export PATH="${LLVM_BOOTSTRAP}/install/bin:${PATH}" | |
export CC="${LLVM_BOOTSTRAP}/install/bin/clang" | |
export CXX="${LLVM_BOOTSTRAP}/install/bin/clang++" | |
popd | |
rm -rf "${LLVM_BUILD}" | |
mkdir -p "${LLVM_BUILD}" | |
pushd "${LLVM_BUILD}" | |
$LLVM_SRC/configure \ | |
--disable-option-checking \ | |
--prefix="${LLVM_INSTALL}" \ | |
--datadir="${LLVM_INSTALL}/share" \ | |
--enable-docs \ | |
--build="${TRIPLE}" \ | |
--enable-optimized --disable-assertions \ | |
--disable-bindings \ | |
--enable-targets=all \ | |
--enable-libcpp \ | |
--without-llvmgcc --without-llvmgxx \ | |
--enable-pic --with-pic \ | |
--enable-shared \ | |
--with-optimize-option="-O3 -DNDEBUG" \ | |
--enable-polly \ | |
--with-gmp=/opt/toolchain \ | |
--with-isl=/opt/toolchain \ | |
--with-cloog=/opt/toolchain | |
make -j6 REQUIRES_RTTI=1 NO_PEDANTIC=1 ENABLE_PIC=1 | |
make check-all | |
make polly-test -C tools/polly/test | |
sudo make install | |
sudo cp -vR "$TCROOT/usr/lib/arc" "${LLVM_INSTALL}/lib/" | |
sudo chown -R $(whoami) "${LLVM_INSTALL}" | |
sudo chown -R $(whoami) "${LLVM_BUILD}" | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment