r244070 - [CMake] First pass at adding support for clang bootstrap builds to CMake

Chandler Carruth via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 3 15:33:38 PST 2016


Hey Chris, I just noticed that this option is only available when you build
Clang as a standalone project, as opposed to building all of LLVM. Was that
intentional? Is there any plan to support this in more normal whole-LLVM
builds? It seems substantially more useful for stuff like picking up
miscompiles...

-Chandler

On Wed, Aug 5, 2015 at 10:39 AM Chris Bieneman <beanz at apple.com> wrote:

> Author: cbieneman
> Date: Wed Aug  5 12:38:12 2015
> New Revision: 244070
>
> URL: http://llvm.org/viewvc/llvm-project?rev=244070&view=rev
> Log:
> [CMake] First pass at adding support for clang bootstrap builds to CMake
>
> Summary:
> This patch adds a new CLANG_ENABLE_BOOTSTRAP option to CMake which adds
> targets for building a stage2 bootstrap compiler. The targets are:
>
> bootstrap-configure
> bootstrap-build
> bootstrap (same as bootstrap-configure and bootstrap-build)
> bootstrap-install
> bootstrap-check-llvm
> bootstrap-check-clang
> bootstrap-check-all
>
> If you are using 3.3.20150708 or greater it utilizes the ninja
> USES_TERMINAL_* settings on the external project so that the output is
> properly buffered.
>
> Reviewers: bogner, chandlerc
>
> Subscribers: filcab, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D11743
>
> Modified:
>     cfe/trunk/CMakeLists.txt
>
> Modified: cfe/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=244070&r1=244069&r2=244070&view=diff
>
> ==============================================================================
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Wed Aug  5 12:38:12 2015
> @@ -96,6 +96,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>
>    option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
>      "Set to ON to force using an old, unsupported host toolchain." OFF)
> +  option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
>
>    include(AddLLVM)
>    include(TableGen)
> @@ -551,3 +552,76 @@ if (CLANG_BUILT_STANDALONE)
>      ${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake
>      COPYONLY)
>  endif ()
> +
> +if (CLANG_ENABLE_BOOTSTRAP)
> +  include(ExternalProject)
> +
> +  if(CMAKE_VERSION VERSION_LESS 3.3.20150708)
> +    set(cmake_3_4_USES_TERMINAL_OPTIONS)
> +  else()
> +    set(cmake_3_4_USES_TERMINAL_OPTIONS
> +      USES_TERMINAL_CONFIGURE 1
> +      USES_TERMINAL_BUILD 1
> +      USES_TERMINAL_INSTALL 1
> +      )
> +  endif()
> +
> +  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-stamps/)
> +  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-bins/)
> +
> +  add_custom_target(bootstrap-clear
> +    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
> +    )
> +  add_custom_command(
> +    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
> +    DEPENDS clang
> +    COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
> +    COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
> +    COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
> +    COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR}
> +    COMMAND ${CMAKE_COMMAND} -E touch
> ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
> +    COMMENT "Clobberring bootstrap build and stamp directories"
> +    )
> +
> +  ExternalProject_Add(bootstrap
> +    DEPENDS clang
> +    PREFIX bootstrap
> +    SOURCE_DIR ${CMAKE_SOURCE_DIR}
> +    STAMP_DIR ${STAMP_DIR}
> +    BINARY_DIR ${BINARY_DIR}
> +    CMAKE_ARGS
> +                # We shouldn't need to set this here, but INSTALL_DIR
> doesn't
> +                # seem to work, so instead I'm passing this through
> +                -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
> +                ${CLANG_BOOTSTRAP_CMAKE_ARGS}
> +                -DCMAKE_CXX_COMPILER=${CMAKE_BINARY_DIR}/bin/clang++
> +                -DCMAKE_C_COMPILER=${CMAKE_BINARY_DIR}/bin/clang
> +    INSTALL_COMMAND ""
> +    STEP_TARGETS configure build
> +    ${cmake_3_4_USES_TERMINAL_OPTIONS}
> +    )
> +
> +  # exclude really-install from main target
> +  set_target_properties(bootstrap PROPERTIES
> _EP_really-install_EXCLUDE_FROM_MAIN On)
> +  ExternalProject_Add_Step(bootstrap really-install
> +    COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install
> +    COMMENT "Performing install step for 'bootstrap'"
> +    DEPENDEES build
> +  )
> +  ExternalProject_Add_StepTargets(bootstrap really-install)
> +  add_custom_target(bootstrap-install DEPENDS bootstrap-really-install)
> +
> +
> +  set(ADDITIONAL_TARGETS_TO_ADD check-llvm check-clang check-all)
> +  foreach(target ${ADDITIONAL_TARGETS_TO_ADD})
> +    # exclude from main target
> +    set_target_properties(bootstrap PROPERTIES
> _EP_${target}_EXCLUDE_FROM_MAIN On)
> +
> +    ExternalProject_Add_Step(bootstrap ${target}
> +      COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target ${target}
> +      COMMENT "Performing ${target} for 'bootstrap'"
> +      DEPENDEES configure
> +    )
> +    ExternalProject_Add_StepTargets(bootstrap ${target})
> +  endforeach()
> +endif()
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160103/efa28a9e/attachment.html>


More information about the cfe-commits mailing list