diff --git a/scripts/llvm/3.8.1-libstdcxx/script.sh b/scripts/llvm/3.8.1-libstdcxx/script.sh index 583fee6d9..5ad968e20 100755 --- a/scripts/llvm/3.8.1-libstdcxx/script.sh +++ b/scripts/llvm/3.8.1-libstdcxx/script.sh @@ -13,18 +13,4 @@ export MASON_BASE_VERSION=${MASON_VERSION/-libstdcxx/} # inherit all functions from llvm base source ${HERE}/../../${MASON_NAME}/base/common.sh -function setup_release() { - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/llvm-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/ 6de84b7bb71e49ef2764d364c4318e01fda1e1e3 - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/cfe-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang 9a05f9c1c8dc865c064782dedbbbfb533c3909ac - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/compiler-rt-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/compiler-rt 678cbff6e177a18f4e2d0662901a744163da3347 - if [[ ${BUILD_AND_LINK_LIBCXX} == true ]]; then - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/libcxx-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxx d15220e86eb8480e58a4378a4c977bbb5463fb79 - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/libcxxabi-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxxabi b7508c64ab8e670062ee57a12ae1e542bcb2bfb4 - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/libunwind-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libunwind 90c0184ca72e1999fec304f76bfa10340f038ee5 - fi - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/lld-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lld 416c36ded12ead42dc4739d52eabf22267300883 - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/clang-tools-extra-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang/tools/extra ea40e36d54dc8c9bb21cbebcc872a3221a2ed685 - get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/lldb-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lldb c8c38fa9ab92f9021067678f1a1c8f07ea75ac93 -} - mason_run "$@" diff --git a/scripts/llvm/3.8.1/script.sh b/scripts/llvm/3.8.1/script.sh index 22878b697..4da183158 100755 --- a/scripts/llvm/3.8.1/script.sh +++ b/scripts/llvm/3.8.1/script.sh @@ -10,15 +10,6 @@ MASON_VERSION=$(basename $HERE) source ${HERE}/../../${MASON_NAME}/base/common.sh function setup_release() { - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/llvm-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/ 6de84b7bb71e49ef2764d364c4318e01fda1e1e3 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/cfe-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang 9a05f9c1c8dc865c064782dedbbbfb533c3909ac - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/compiler-rt-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/compiler-rt 678cbff6e177a18f4e2d0662901a744163da3347 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxx-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxx d15220e86eb8480e58a4378a4c977bbb5463fb79 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxxabi-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxxabi b7508c64ab8e670062ee57a12ae1e542bcb2bfb4 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libunwind-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libunwind 90c0184ca72e1999fec304f76bfa10340f038ee5 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lld-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lld 416c36ded12ead42dc4739d52eabf22267300883 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/clang-tools-extra-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang/tools/extra ea40e36d54dc8c9bb21cbebcc872a3221a2ed685 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lldb-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lldb c8c38fa9ab92f9021067678f1a1c8f07ea75ac93 get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use 2b5c5be3c7dcbe555a481083363408399b40e0c8 } diff --git a/scripts/llvm/3.9.1/script.sh b/scripts/llvm/3.9.1/script.sh index 7e636afc7..4d1efe5b8 100755 --- a/scripts/llvm/3.9.1/script.sh +++ b/scripts/llvm/3.9.1/script.sh @@ -10,17 +10,6 @@ MASON_VERSION=$(basename $HERE) source ${HERE}/../../${MASON_NAME}/base/common.sh function setup_release() { - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/llvm-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/ 282e47884738e362ff4dc70910d2e08c242f161a - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/cfe-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang 211b70f3cc75ef318dfa4efd57a2e9c547375f94 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/compiler-rt-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/compiler-rt 19981bad5a444b36b2834d5bfd3edd5c66c7ca22 - if [[ ${BUILD_AND_LINK_LIBCXX} == true ]]; then - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxx-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxx 2fdaf6017fe742974eb06f9529321a915e84a034 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxxabi-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxxabi 277446b2957d2a82ef10d173b3882b64d68ca5d0 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libunwind-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libunwind 0df57c982fda5ba8b97698525ed6fea09f87ea15 - fi - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lld-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lld 6c8018e5caf82f1f771d24b532af11c67228f333 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/clang-tools-extra-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang/tools/extra a3f5d99cd3d4ccdfc6d4dba15db616d53a654c3f - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lldb-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lldb c8e35a599bd366d1fc122526d3b7a1902890d1ed get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use 7e5c73ce1a2fdd1ffd29fad1ae2628d0134368c6 } diff --git a/scripts/llvm/4.0.0/script.sh b/scripts/llvm/4.0.0/script.sh index 7a1cd9bd9..24da65144 100755 --- a/scripts/llvm/4.0.0/script.sh +++ b/scripts/llvm/4.0.0/script.sh @@ -10,19 +10,7 @@ MASON_VERSION=$(basename $HERE) source ${HERE}/../../${MASON_NAME}/base/common.sh function setup_release() { - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/llvm-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/ c872366ec69fb425ce9336741dba04d9adf16c3e - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/cfe-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang 61ca17979e0c2ec7dc5f66cb54ac0b8ec0e653a9 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/compiler-rt-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/compiler-rt bbf0ad69a296548a44019ed953bdfffc3d3f95d5 - if [[ ${BUILD_AND_LINK_LIBCXX} == true ]]; then - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxx-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxx ab37f78c83c739d862099a874ad91c3ab295f6b7 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxxabi-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxxabi d36cb0be6c8fa54534a1cb067bdb4a6b3389d3d3 - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libunwind-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libunwind 5178ea6b1834a7cd3d6be610709b811255255a11 - fi - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lld-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lld 137e8c9d5d73a0e3dfec1ffd63abb5173473e95b - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/clang-tools-extra-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang/tools/extra 9c9ad20062c41f22f4078dcfea38daebfce2c2ed - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lldb-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lldb 5b17f041631670e40718ab89f99f1c8347766d92 - #get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use - get_llvm_project "https://github.com/include-what-you-use/include-what-you-use.git" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use + get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use } mason_run "$@" diff --git a/scripts/llvm/4.0.1/script.sh b/scripts/llvm/4.0.1/script.sh index f97b4955f..c60efc6ca 100755 --- a/scripts/llvm/4.0.1/script.sh +++ b/scripts/llvm/4.0.1/script.sh @@ -12,22 +12,7 @@ MASON_VERSION=$(basename $HERE) source ${HERE}/../../${MASON_NAME}/base/common.sh function setup_release() { - # usage: get_llvm_project [url or git url] [path to download to] - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/llvm-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/ - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/cfe-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/compiler-rt-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/compiler-rt - if [[ ${BUILD_AND_LINK_LIBCXX} == true ]]; then - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxx-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxx - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxxabi-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxxabi - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libunwind-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libunwind - fi - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lld-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lld - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/clang-tools-extra-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang/tools/extra - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lldb-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lldb get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use - # Note: the below commented line uses a custom gitsha to pin to a working commit if the include-what-you-use team has not yet created a tag for the given clang major version - # This happended previously a https://github.com/include-what-you-use/include-what-you-use/issues/397#issuecomment-313479507 - #get_llvm_project "https://github.com/include-what-you-use/include-what-you-use.git" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use "" 45e1264507f5e2725289ca3a0f4de98108e964c7 } mason_run "$@" diff --git a/scripts/llvm/5.0.0/script.sh b/scripts/llvm/5.0.0/script.sh index 425cac774..ba9913b25 100755 --- a/scripts/llvm/5.0.0/script.sh +++ b/scripts/llvm/5.0.0/script.sh @@ -11,23 +11,10 @@ MASON_VERSION=$(basename $HERE) # inherit all functions from llvm base source ${HERE}/../../${MASON_NAME}/base/common.sh -function setup_release() { - # usage: get_llvm_project [url or git url] [path to download to] - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/llvm-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/ - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/cfe-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/compiler-rt-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/compiler-rt - if [[ ${BUILD_AND_LINK_LIBCXX} == true ]]; then - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxx-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxx - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libcxxabi-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libcxxabi - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/libunwind-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/libunwind - fi - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lld-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lld - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/clang-tools-extra-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang/tools/extra - get_llvm_project "http://llvm.org/releases/${MASON_VERSION}/lldb-${MASON_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lldb - #get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use - # Note: the below commented line uses a custom gitsha to pin to a working commit if the include-what-you-use team has not yet created a tag for the given clang major version - # This happended previously a https://github.com/include-what-you-use/include-what-you-use/issues/397#issuecomment-313479507 - #get_llvm_project "https://github.com/include-what-you-use/include-what-you-use.git" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use "" 45e1264507f5e2725289ca3a0f4de98108e964c7 -} +# broken with: +# ../tools/clang/tools/include-what-you-use/iwyu_ast_util.cc:455:3: error: use of undeclared identifier 'printTemplateArgumentList' +# function setup_release() { +# get_llvm_project "https://github.com/include-what-you-use/include-what-you-use.git" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use "" 5788b34c2e22fa97630c4a5b1153d828698f9ac1 +# } mason_run "$@" diff --git a/scripts/llvm/base/common.sh b/scripts/llvm/base/common.sh index 6f97a5c8c..2412033b2 100755 --- a/scripts/llvm/base/common.sh +++ b/scripts/llvm/base/common.sh @@ -9,8 +9,10 @@ export MASON_BASE_VERSION=${MASON_BASE_VERSION:-${MASON_VERSION}} export MAJOR_MINOR=$(echo ${MASON_BASE_VERSION} | cut -d '.' -f1-2) if [[ $(uname -s) == 'Darwin' ]]; then - export BUILD_AND_LINK_LIBCXX=false - # avoids this kind of problem with include-what-you-use + export BUILD_AND_LINK_LIBCXX=true + + # not installing libcxx avoids this kind of problem with include-what-you-use + export INSTALL_LIBCXX=false # because iwyu hardcodes at https://github.com/include-what-you-use/include-what-you-use/blob/da5c9b17fec571e6b2bbca29145463d7eaa3582e/iwyu_driver.cc#L219 : ' /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:167:44: error: declaration conflicts with target of using declaration already in scope @@ -21,6 +23,7 @@ if [[ $(uname -s) == 'Darwin' ]]; then ' else export BUILD_AND_LINK_LIBCXX=${BUILD_AND_LINK_LIBCXX:-true} + export INSTALL_LIBCXX=${INSTALL_LIBCXX:-true} fi # we use this custom function rather than "mason_download" since we need to easily grab multiple packages @@ -62,7 +65,7 @@ function get_llvm_project() { fi export OBJECT_HASH=$(git hash-object ${local_file_or_checkout}) if [[ ${EXPECTED_HASH:-false} == false ]]; then - mason_error "NOTICE: detected object has of ${OBJECT_HASH}, optionally add this the 'setup_release' function in your script.sh in order to assert this never changes" + mason_error "NOTICE: detected object has of ${OBJECT_HASH}, optionally add this hash to the 'setup_release' function in your script.sh in order to assert this never changes" else if [[ $3 != ${OBJECT_HASH} ]]; then mason_error "Error: hash mismatch ${EXPECTED_HASH} (expected) != ${OBJECT_HASH} (actual)" @@ -80,8 +83,7 @@ function get_llvm_project() { fi } -# Note: override this function to set custom hash -function setup_release() { +function setup_base_tools() { get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/llvm-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/ get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/cfe-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/compiler-rt-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/projects/compiler-rt @@ -93,7 +95,19 @@ function setup_release() { get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/lld-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lld get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/clang-tools-extra-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/clang/tools/extra get_llvm_project "http://llvm.org/releases/${MASON_BASE_VERSION}/lldb-${MASON_BASE_VERSION}.src.tar.xz" ${MASON_BUILD_PATH}/tools/lldb - get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use + # The include-what-you-use project often lags behind llvm releases, causing compile problems when you try to build it within llvm (and I don't know how feasible it is to build separately) + # Hence this is disabled by default and must be either enabled here or added to a `setup_release` function per package version + # pulls from a tagged version: + #get_llvm_project "https://github.com/include-what-you-use/include-what-you-use/archive/clang_${MAJOR_MINOR}.tar.gz" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use + # pulls from a gitsha (useful to pin to a working commit if the include-what-you-use team has not yet created a tag for the given clang major version) + # This happened previously with https://github.com/include-what-you-use/include-what-you-use/issues/397#issuecomment-313479507 + #get_llvm_project "https://github.com/include-what-you-use/include-what-you-use.git" ${MASON_BUILD_PATH}/tools/clang/tools/include-what-you-use "" 45e1264507f5e2725289ca3a0f4de98108e964c7 + +} + +# Note: add `setup_release` function to downstream script to override this stub and be able to install custom tools per version +function setup_release() { + : } function mason_load_source { @@ -104,15 +118,19 @@ function mason_load_source { if [[ -d ${MASON_BUILD_PATH}/ ]]; then rm -rf ${MASON_BUILD_PATH}/ fi + setup_base_tools # NOTE: this setup_release can be overridden per package to assert on different hash setup_release } function mason_prepare_compile { - CCACHE_VERSION=3.3.1 - CMAKE_VERSION=3.7.2 - NINJA_VERSION=1.7.1 - CLANG_VERSION=4.0.0 + CCACHE_VERSION=3.3.4 + CMAKE_VERSION=3.8.2 + NINJA_VERSION=1.7.2 + CLANG_VERSION=5.0.0 + LIBEDIT_VERSION=3.1 + BINUTILS_VERSION=2.30 + NCURSES_VERSION=6.1 ${MASON_DIR}/mason install clang++ ${CLANG_VERSION} MASON_CLANG=$(${MASON_DIR}/mason prefix clang++ ${CLANG_VERSION}) @@ -122,9 +140,12 @@ function mason_prepare_compile { MASON_CMAKE=$(${MASON_DIR}/mason prefix cmake ${CMAKE_VERSION}) ${MASON_DIR}/mason install ninja ${NINJA_VERSION} MASON_NINJA=$(${MASON_DIR}/mason prefix ninja ${NINJA_VERSION}) + ${MASON_DIR}/mason install libedit ${LIBEDIT_VERSION} + MASON_LIBEDIT=$(${MASON_DIR}/mason prefix libedit ${LIBEDIT_VERSION}) + ${MASON_DIR}/mason install ncurses ${NCURSES_VERSION} + MASON_NCURSES=$(${MASON_DIR}/mason prefix ncurses ${NCURSES_VERSION}) if [[ $(uname -s) == 'Linux' ]]; then - BINUTILS_VERSION=2.28 ${MASON_DIR}/mason install binutils ${BINUTILS_VERSION} LLVM_BINUTILS_INCDIR=$(${MASON_DIR}/mason prefix binutils ${BINUTILS_VERSION})/include fi @@ -147,8 +168,11 @@ function mason_compile { ) fi - export CXX="${CXX:-${MASON_CLANG}/bin/clang++}" - export CC="${CC:-${MASON_CLANG}/bin/clang}" + export CXX="${CUSTOM_CXX:-${MASON_CLANG}/bin/clang++}" + export CC="${CUSTOM_CC:-${MASON_CLANG}/bin/clang}" + echo "using CXX=${CXX}" + echo "using CC=${CC}" + # knock out lldb doc building, to remove doxygen dependency perl -i -p -e "s/add_subdirectory\(docs\)//g;" tools/lldb/CMakeLists.txt @@ -171,8 +195,6 @@ function mason_compile { echo 'add_subdirectory(include-what-you-use)' >> tools/clang/tools/CMakeLists.txt fi - mkdir -p ./build - cd ./build if [[ $(uname -s) == 'Darwin' ]]; then : ' Note: C_INCLUDE_DIRS and DEFAULT_SYSROOT are critical options to understand to ensure C and C++ headers are predictably found. @@ -239,6 +261,10 @@ function mason_compile { export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCLANG_DEFAULT_CXX_STDLIB=libstdc++" fi + if [[ ${INSTALL_LIBCXX} == false ]]; then + export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DLIBCXX_INSTALL_LIBRARY=OFF -DLIBCXX_INSTALL_HEADERS=OFF" + fi + # TODO: test this #-DLLVM_ENABLE_LTO=ON \ @@ -246,30 +272,30 @@ function mason_compile { # https://blogs.gentoo.org/gsoc2016-native-clang/2016/05/31/build-gnu-free-executables-with-clang/ if [[ ${BUILD_AND_LINK_LIBCXX} == true ]]; then - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DLIBCXX_ENABLE_ASSERTIONS=OFF -DLIBCXX_ENABLE_SHARED=OFF -DLIBCXXABI_ENABLE_SHARED=OFF -DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON -DLIBUNWIND_USE_COMPILER_RT=ON -DLIBUNWIND_ENABLE_STATIC=ON -DLIBUNWIND_ENABLE_SHARED=OFF" + CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DLIBCXX_ENABLE_ASSERTIONS=OFF -DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC=ON -DLIBCXXABI_ENABLE_SHARED=OFF -DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON -DLIBUNWIND_USE_COMPILER_RT=ON -DLIBUNWIND_ENABLE_STATIC=ON -DLIBUNWIND_ENABLE_SHARED=OFF" fi - ${MASON_CMAKE}/bin/cmake ../ -G Ninja -DCMAKE_INSTALL_PREFIX=${MASON_PREFIX} \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_INCLUDE_DOCS=OFF \ - -DLLVM_TARGETS_TO_BUILD="X86" \ - -DCMAKE_CXX_COMPILER_LAUNCHER="${MASON_CCACHE}/bin/ccache" \ - -DCMAKE_CXX_COMPILER="$CXX" \ - -DCMAKE_C_COMPILER="$CC" \ - -DLLVM_ENABLE_ASSERTIONS=OFF \ - -DCLANG_VENDOR="mapbox/mason" \ - -DCLANG_REPOSITORY_STRING="https://github.com/mapbox/mason" \ - -DCLANG_VENDOR_UTI="org.mapbox.llvm" \ - -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ - -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ - -DLLDB_DISABLE_PYTHON=1 -DLLDB_DISABLE_CURSES=1 -DLLDB_DISABLE_LIBEDIT=1 -DLLVM_ENABLE_TERMINFO=0 \ - -DCMAKE_MAKE_PROGRAM=${MASON_NINJA}/bin/ninja \ - ${CMAKE_EXTRA_ARGS} + echo "creating build directory" + mkdir -p ./build + cd ./build + + export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -G Ninja -DCMAKE_MAKE_PROGRAM=${MASON_NINJA}/bin/ninja -DLLVM_ENABLE_ASSERTIONS=OFF -DCLANG_VENDOR=mapbox/mason -DCMAKE_CXX_COMPILER_LAUNCHER=${MASON_CCACHE}/bin/ccache" + export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${MASON_PREFIX} -DCMAKE_BUILD_TYPE=Release -DLLVM_INCLUDE_DOCS=OFF" + export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DLLVM_TARGETS_TO_BUILD=BPF;X86 -DCLANG_REPOSITORY_STRING=https://github.com/mapbox/mason -DCLANG_VENDOR_UTI=org.mapbox.llvm" + export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DLLDB_RELOCATABLE_PYTHON=1 -DLLDB_DISABLE_PYTHON=1 -DLLVM_ENABLE_TERMINFO=0" + # look for curses and libedit on linux + export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_PREFIX_PATH=${MASON_NCURSES};${MASON_LIBEDIT}" + + # note: python would need swig + # -DLLDB_DISABLE_CURSES=1 -DLLDB_DISABLE_LIBEDIT=1 + + echo "running cmake configure for llvm+friends build" + ${MASON_CMAKE}/bin/cmake ../ ${CMAKE_EXTRA_ARGS} -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_COMPILER="$CC" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" if [[ ${BUILD_AND_LINK_LIBCXX} == true ]]; then ${MASON_NINJA}/bin/ninja unwind -j${MASON_CONCURRENCY} - # make libc++ and libc++abi first + # make libc++ and libc++abi first (to fail quick if they don't build) ${MASON_NINJA}/bin/ninja cxx -j${MASON_CONCURRENCY} ${MASON_NINJA}/bin/ninja lldb -j${MASON_CONCURRENCY} @@ -281,27 +307,57 @@ function mason_compile { # install it all ${MASON_NINJA}/bin/ninja install - if [[ $(uname -s) == 'Darwin' ]]; then + # This could, theoretically, produce a toolchain to be used within Xcode, but I've not tried to get it working yet. + # So, commented for now since this otherwise takes up disk space. + #if [[ $(uname -s) == 'Darwin' ]]; then # https://reviews.llvm.org/D13605 - ${MASON_NINJA}/bin/ninja install-xcode-toolchain -j${MASON_CONCURRENCY} - fi + # ${MASON_NINJA}/bin/ninja install-xcode-toolchain -j${MASON_CONCURRENCY} + #fi # install the asan_symbolizer.py tool cp -a ../projects/compiler-rt/lib/asan/scripts/asan_symbolize.py ${MASON_PREFIX}/bin/ # set up symlinks to match what llvm.org binaries provide - cd ${MASON_PREFIX}/bin/ - ln -s "clang++" "clang++-${MAJOR_MINOR}" - ln -s "asan_symbolize.py" "asan_symbolize" + (cd ${MASON_PREFIX}/bin/ && \ + ln -s "clang++" "clang++-${MAJOR_MINOR}" && \ + ln -s "asan_symbolize.py" "asan_symbolize") # symlink so that we use the system libc++ headers on osx - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ ${INSTALL_LIBCXX} == false ]] && [[ $(uname -s) == 'Darwin' ]]; then mkdir -p ${MASON_PREFIX}/include - cd ${MASON_PREFIX}/include # note: passing -nostdinc++ will result in this local path being ignored - ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++ c++ + (cd ${MASON_PREFIX}/include && ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++ c++) fi + # Address+Undefined + echo "now building libc++ with address+undefined sanitizers" + # https://libcxx.llvm.org/docs/BuildingLibcxx.html + ${MASON_CMAKE}/bin/cmake ../ ${CMAKE_EXTRA_ARGS} -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_COMPILER="$CC" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ + -DCMAKE_INSTALL_PREFIX="${MASON_PREFIX}/asan" -DLLVM_USE_SANITIZER="Address;Undefined" \ + -DLIBCXX_INSTALL_LIBRARY=ON -DLIBCXX_INSTALL_HEADERS=ON + ${MASON_NINJA}/bin/ninja cxx cxxabi -j${MASON_CONCURRENCY} + ${MASON_NINJA}/bin/ninja install-cxx install-libcxxabi -j${MASON_CONCURRENCY} + + # MemoryWithOrigins + if [[ $(uname -s) == 'Darwin' ]]; then + echo "skipping libc++ with memory sanitizer, which is not supported on OS X" + else + echo "now building libc++ with memory sanitizer" + ${MASON_CMAKE}/bin/cmake ../ ${CMAKE_EXTRA_ARGS} -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_COMPILER="$CC" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ + -DCMAKE_INSTALL_PREFIX="${MASON_PREFIX}/msan" -DLLVM_USE_SANITIZER="MemoryWithOrigins" \ + -DLIBCXX_INSTALL_LIBRARY=ON -DLIBCXX_INSTALL_HEADERS=ON + ${MASON_NINJA}/bin/ninja cxx cxxabi -j${MASON_CONCURRENCY} + ${MASON_NINJA}/bin/ninja install-cxx install-libcxxabi -j${MASON_CONCURRENCY} + fi + + # Thread + echo "now building libc++ with thread sanitizer" + ${MASON_CMAKE}/bin/cmake ../ ${CMAKE_EXTRA_ARGS} -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_COMPILER="$CC" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ + -DCMAKE_INSTALL_PREFIX="${MASON_PREFIX}/tsan" -DLLVM_USE_SANITIZER="Thread" \ + -DLIBCXX_INSTALL_LIBRARY=ON -DLIBCXX_INSTALL_HEADERS=ON + ${MASON_NINJA}/bin/ninja cxx cxxabi -j${MASON_CONCURRENCY} + ${MASON_NINJA}/bin/ninja install-cxx install-libcxxabi -j${MASON_CONCURRENCY} + }