<div dir="ltr">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...<div><br></div><div>-Chandler<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 5, 2015 at 10:39 AM Chris Bieneman <<a href="mailto:beanz@apple.com">beanz@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: cbieneman<br>
Date: Wed Aug 5 12:38:12 2015<br>
New Revision: 244070<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244070&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244070&view=rev</a><br>
Log:<br>
[CMake] First pass at adding support for clang bootstrap builds to CMake<br>
<br>
Summary:<br>
This patch adds a new CLANG_ENABLE_BOOTSTRAP option to CMake which adds targets for building a stage2 bootstrap compiler. The targets are:<br>
<br>
bootstrap-configure<br>
bootstrap-build<br>
bootstrap (same as bootstrap-configure and bootstrap-build)<br>
bootstrap-install<br>
bootstrap-check-llvm<br>
bootstrap-check-clang<br>
bootstrap-check-all<br>
<br>
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.<br>
<br>
Reviewers: bogner, chandlerc<br>
<br>
Subscribers: filcab, cfe-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D11743" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11743</a><br>
<br>
Modified:<br>
cfe/trunk/CMakeLists.txt<br>
<br>
Modified: cfe/trunk/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=244070&r1=244069&r2=244070&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=244070&r1=244069&r2=244070&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/CMakeLists.txt (original)<br>
+++ cfe/trunk/CMakeLists.txt Wed Aug 5 12:38:12 2015<br>
@@ -96,6 +96,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR<br>
<br>
option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN<br>
"Set to ON to force using an old, unsupported host toolchain." OFF)<br>
+ option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)<br>
<br>
include(AddLLVM)<br>
include(TableGen)<br>
@@ -551,3 +552,76 @@ if (CLANG_BUILT_STANDALONE)<br>
${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake<br>
COPYONLY)<br>
endif ()<br>
+<br>
+if (CLANG_ENABLE_BOOTSTRAP)<br>
+ include(ExternalProject)<br>
+<br>
+ if(CMAKE_VERSION VERSION_LESS 3.3.20150708)<br>
+ set(cmake_3_4_USES_TERMINAL_OPTIONS)<br>
+ else()<br>
+ set(cmake_3_4_USES_TERMINAL_OPTIONS<br>
+ USES_TERMINAL_CONFIGURE 1<br>
+ USES_TERMINAL_BUILD 1<br>
+ USES_TERMINAL_INSTALL 1<br>
+ )<br>
+ endif()<br>
+<br>
+ set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-stamps/)<br>
+ set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-bins/)<br>
+<br>
+ add_custom_target(bootstrap-clear<br>
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared<br>
+ )<br>
+ add_custom_command(<br>
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared<br>
+ DEPENDS clang<br>
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}<br>
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}<br>
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}<br>
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR}<br>
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared<br>
+ COMMENT "Clobberring bootstrap build and stamp directories"<br>
+ )<br>
+<br>
+ ExternalProject_Add(bootstrap<br>
+ DEPENDS clang<br>
+ PREFIX bootstrap<br>
+ SOURCE_DIR ${CMAKE_SOURCE_DIR}<br>
+ STAMP_DIR ${STAMP_DIR}<br>
+ BINARY_DIR ${BINARY_DIR}<br>
+ CMAKE_ARGS<br>
+ # We shouldn't need to set this here, but INSTALL_DIR doesn't<br>
+ # seem to work, so instead I'm passing this through<br>
+ -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}<br>
+ ${CLANG_BOOTSTRAP_CMAKE_ARGS}<br>
+ -DCMAKE_CXX_COMPILER=${CMAKE_BINARY_DIR}/bin/clang++<br>
+ -DCMAKE_C_COMPILER=${CMAKE_BINARY_DIR}/bin/clang<br>
+ INSTALL_COMMAND ""<br>
+ STEP_TARGETS configure build<br>
+ ${cmake_3_4_USES_TERMINAL_OPTIONS}<br>
+ )<br>
+<br>
+ # exclude really-install from main target<br>
+ set_target_properties(bootstrap PROPERTIES _EP_really-install_EXCLUDE_FROM_MAIN On)<br>
+ ExternalProject_Add_Step(bootstrap really-install<br>
+ COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install<br>
+ COMMENT "Performing install step for 'bootstrap'"<br>
+ DEPENDEES build<br>
+ )<br>
+ ExternalProject_Add_StepTargets(bootstrap really-install)<br>
+ add_custom_target(bootstrap-install DEPENDS bootstrap-really-install)<br>
+<br>
+<br>
+ set(ADDITIONAL_TARGETS_TO_ADD check-llvm check-clang check-all)<br>
+ foreach(target ${ADDITIONAL_TARGETS_TO_ADD})<br>
+ # exclude from main target<br>
+ set_target_properties(bootstrap PROPERTIES _EP_${target}_EXCLUDE_FROM_MAIN On)<br>
+<br>
+ ExternalProject_Add_Step(bootstrap ${target}<br>
+ COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target ${target}<br>
+ COMMENT "Performing ${target} for 'bootstrap'"<br>
+ DEPENDEES configure<br>
+ )<br>
+ ExternalProject_Add_StepTargets(bootstrap ${target})<br>
+ endforeach()<br>
+endif()<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div>