Skip to content

Instantly share code, notes, and snippets.

@androm3da
Created March 7, 2017 19:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save androm3da/f2f411152e63dafb2d729f906144c301 to your computer and use it in GitHub Desktop.
Save androm3da/f2f411152e63dafb2d729f906144c301 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
CC="clang"
CXX="clang++"
export PATH=/local/mnt/workspace/install/binutils-2.27/bin:${PATH}
SRCTOP=$(readlink -f ${PWD})
INSTALL=${1-${SRCTOP}/install}
if [[ ! -d ${SRCTOP}/llvm ]]; then
echo Expected to find the source in ${SRCTOP}/llvm but it is missing
exit 3
fi
HAS_AVX=$(egrep -c '^flags.*\bavx\b' /proc/cpuinfo)
#ignore: covered by -march=native
if [[ ${HAS_AVX} != 0 ]]; then
AVX_FLAG="-mavx"
fi
which gold
if [[ $? -eq 0 ]]; then
USE_GOLD="-DLLVM_USE_LINKER=gold"
fi
build()
{
# Asan seems to fail while cmake in libcxx
# due to unresolved references to compiler-rt stuff
# -DLLVM_USE_SANITIZER="Address" \
# -DLLVM_USE_SANITIZE_COVERAGE=YES \
# This option:
# -DGCC_INSTALL_PREFIX=/usr/lib/gcc/x86_64-linux-gnu/4.8 \
# causes:
# $ /local/mnt/workspace/install/clang_nightly/bin/clang++ tryit.cpp
# /usr/bin/ld: cannot find crtbegin.o: No such file or directory
# /usr/bin/ld: cannot find -lstdc++
# /usr/bin/ld: cannot find -lgcc_s
# /usr/bin/ld: cannot find -lgcc
# clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
# NOTES:
# $ /local/mnt/workspace/install/clang_nightly/bin/clang++ tryit.cpp -###
# clang version 5.0.0 (https://github.com/llvm-mirror/clang/ a7325b067d8d0ebf370ffbffb0f861d9252c551c) (llvm/ 8da2185645137949cd41133cb3e48a3b6b9c791d)
# Target: x86_64-unknown-linux-gnu
# Thread model: posix
# InstalledDir: /local/mnt/workspace/install/clang_nightly/bin
# "/local/mnt/workspace/install/clang_nightly/bin/clang-5.0" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "tryit.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" "/local/mnt/workspace/install/clang_nightly/lib/clang/5.0.0" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/local/mnt/workspace/install/clang_nightly/lib/clang/5.0.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" "-fdebug-compilation-dir" "/local/mnt/workspace/tmp/make_it_happen" "-ferror-limit" "19" "-fmessage-length" "195" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/tryit-ac02df.o" "-x" "c++" "tryit.cpp"
# # "/usr/bin/ld" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "a.out" "/usr/lib/x86_64-linux-gnu/crt1.o" "/usr/lib/x86_64-linux-gnu/crti.o" "crtbegin.o" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/local/mnt/workspace/install/clang_nightly/bin/../lib" "-L/lib" "-L/usr/lib" "/tmp/tryit-ac02df.o" "-lstdc++" "-lm" "-lgcc_s" "-lgcc" "-lc" "-lgcc_s" "-lgcc" "crtend.o" "/usr/lib/x86_64-linux-gnu/crtn.o"
mkdir -p obj
cd obj
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_CXX_FLAGS="-march=native -O3" \
-DCMAKE_C_FLAGS="-march=native -O3" \
-DCMAKE_INSTALL_PREFIX=${INSTALL} \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE \
${USE_GOLD} \
-DLLVM_TARGETS_TO_BUILD="X86;Hexagon" \
-DLLVM_PARALLEL_LINK_JOBS:INT=6 \
-DLLVM_ENABLE_ASSERTIONS:BOOL=ON \
${SRCTOP}/llvm
\time cmake --build ${PWD}
\time cmake --build ${PWD} -- check-all
\time cmake --build ${PWD} -- install
}
build 2>&1 | tee build.log
du -hs ${INSTALL}
#!/bin/bash -ex
export PATH=/local/mnt/workspace/install/clang-latest/bin:/pkg/qct/software/cmake/3.5.2/bin:${PATH}:/opt/pypy-latest/bin:/opt/pypy3-latest/bin:/pkg/icetools/bin/:/pkg/qct/software/llvm/build_tools/bin
set -euo pipefail
WORKING_DIR=${1}
INSTALL_BASE=/local/mnt/workspace/install
CLANG_NIGHTLY=clang_nightly_$(date +"%Y_%b%d")
INSTALL_DIR=${INSTALL_BASE}/${CLANG_NIGHTLY}
mkdir -p ${WORKING_DIR}
rm -rf ${WORKING_DIR}/*
run_build()
{
cd ${WORKING_DIR}
~/src/upstream/cloneit.sh
if [[ -d ${INSTALL_DIR} ]]; then
rm -rf ${INSTALL_DIR}_prev
mv ${INSTALL_DIR} ${INSTALL_DIR}_prev
fi
~/src/upstream/build.sh ${INSTALL_DIR} && (cd ${INSTALL_BASE} ; ln -sf ${CLANG_NIGHTLY} clang_nightly )
}
LOGFILE=${INSTALL_BASE}/clang_nightly_build_$(date +"%Y_%b%d_%H%M").log
run_build > ${LOGFILE} 2>&1
echo build result ${?}
tail ${LOGFILE}
MAX_AGE_DAYS=4
find ${INSTALL_BASE} -mindepth 1 -maxdepth 1 -type d -name 'clang_nightly_*' -ctime +${MAX_AGE_DAYS} xargs rm -rf
#!/bin/bash -ex
export PATH=/pkg/qct/software/llvm/build_tools/llvm38_160329/bin/:$PATH
export PATH=/pkg/qct/software/python/2.7.3/bin:$PATH
export LD_LIBRARY_PATH="/pkg/qct/software/llvm/build_tools/llvm38_160329/lib"
CC="clang"
CXX="clang++"
CXXFLAGS="-std=c++11 -stdlib=libc++"
LDFLAGS="-L/pkg/qct/software/llvm/build_tools/llvm38_160329/lib -lc++"
SRCTOP=$(readlink -f ${PWD})
INSTALL=${SRCTOP}/install
if [[ ! -d ${SRCTOP}/llvm ]]; then
echo Expected to find the source in ${SRCTOP}/llvm but it is missing
exit 3
fi
build()
{
mkdir -p obj
cd obj
cmake -G 'Unix Makefiles' \
-DCMAKE_C_COMPILER:STRING=${CC} \
-DCMAKE_CXX_COMPILER:STRING=${CXX} \
-DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS}" \
-DCMAKE_LINK_FLAGS:STRING="${LDFLAGS}" \
-DCMAKE_INSTALL_PREFIX:STRING=${INSTALL} \
-DCLANG_DEFAULT_CXX_STDLIB:STRING=libc++ \
-C ${SRCTOP}/llvm/tools/clang/cmake/caches/PGO.cmake \
-DLLVM_PARALLEL_LINK_JOBS:INT=3 \
-DLLVM_ENABLE_LIBCXX:BOOL=ON \
-DLIBCXX_ENABLE_STATIC:BOOL=ON \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY:BOOL=ON \
${SRCTOP}/llvm
make -j$(nproc) stage2
make install
}
build 2>&1 | tee build.log
du -hs ${INSTALL}
#!/bin/bash -ex
git clone https://github.com/llvm-mirror/llvm/
git clone -q https://github.com/llvm-mirror/clang/ llvm/tools/clang &
git clone -q https://github.com/llvm-mirror/compiler-rt/ llvm/projects/compiler-rt &
# git clone -q https://github.com/llvm-mirror/clang-tools-extra/ llvm/tools/clang/tools/extra &
# git clone -q https://github.com/llvm-mirror/lldb/ llvm/projects/lldb &
git clone -q https://github.com/llvm-mirror/test-suite llvm/projects/test-suite &
git clone -q https://github.com/llvm-mirror/libcxx/ llvm/projects/libcxx &
git clone -q https://github.com/llvm-mirror/libcxxabi/ llvm/projects/libcxxabi &
wait
#!/bin/bash -ex
#git clone https://github.com/llvm-mirror/llvm/
#git clone -q https://github.com/llvm-mirror/clang/ llvm/tools/clang &
#git clone -q https://github.com/llvm-mirror/compiler-rt/ llvm/projects/compiler-rt &
#git clone -q https://github.com/llvm-mirror/libcxx/ llvm/projects/libcxx &
#git clone -q https://github.com/llvm-mirror/libcxxabi/ llvm/projects/libcxxabi &
wait
SRCTOP=$(readlink -f ${PWD})
mkdir -p obj
cd obj
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX} \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_USE_SANITIZER="Address" \
-DLLVM_USE_SANITIZE_COVERAGE=YES \
-DLLVM_USE_LIBCXX=YES \
${SRCTOP}/llvm
\time cmake --build ${PWD}
\time cmake --build ${PWD} -- check
\time cmake --build ${PWD} -- install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment