]> granicus.if.org Git - clang/commitdiff
[clang] Fix clean build of generate-order-file
authorAlexander Shaposhnikov <shal1t712@gmail.com>
Sat, 31 Dec 2016 05:25:52 +0000 (05:25 +0000)
committerAlexander Shaposhnikov <shal1t712@gmail.com>
Sat, 31 Dec 2016 05:25:52 +0000 (05:25 +0000)
This diff fixes the clean build of the target generate-order-file.
In llvm/tools/clang/CMakeLists.txt
add_subdirectory(utils/perf-training) should go after the block where
the value of the variable CLANG_ORDER_FILE is set - otherwise
(tested with cmake's version 3.6.2) the arguments of perf-helper.py gen-order-file
will be ill-formed (CLANG_ORDER_FILE will be empty).

Differential revision: https://reviews.llvm.org/D28153

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290781 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
utils/perf-training/CMakeLists.txt

index 509c7a428f6b1cbaf87644852e43c53c17e1686e..c09b75f990e5f5a487a99a32392fe6a96910f573 100644 (file)
@@ -421,6 +421,29 @@ else()
 endif()
 add_subdirectory(examples)
 
+if(APPLE)
+  # this line is needed as a cleanup to ensure that any CMakeCaches with the old
+  # default value get updated to the new default.
+  if(CLANG_ORDER_FILE STREQUAL "")
+    unset(CLANG_ORDER_FILE CACHE)
+    unset(CLANG_ORDER_FILE)
+  endif()
+
+
+  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
+    "Order file to use when compiling clang in order to improve startup time (Darwin Only - requires ld64).")
+
+  if(NOT EXISTS ${CLANG_ORDER_FILE})
+    string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
+    if(PATH_START EQUAL 0)
+      file(WRITE ${CLANG_ORDER_FILE} "\n")
+    else()
+      message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not exist.")
+    endif()
+  endif()
+endif()
+
+
 if( CLANG_INCLUDE_TESTS )
   if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
     add_subdirectory(unittests)
@@ -455,29 +478,6 @@ if( CLANG_INCLUDE_DOCS )
   add_subdirectory(docs)
 endif()
 
-
-if(APPLE)
-  # this line is needed as a cleanup to ensure that any CMakeCaches with the old
-  # default value get updated to the new default.
-  if(CLANG_ORDER_FILE STREQUAL "")
-    unset(CLANG_ORDER_FILE CACHE)
-    unset(CLANG_ORDER_FILE)
-  endif()
-
-
-  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
-    "Order file to use when compiling clang in order to improve startup time (Darwin Only - requires ld64).")
-
-  if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE})
-    string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
-    if(PATH_START EQUAL 0)
-      file(WRITE ${CLANG_ORDER_FILE} "\n")
-    else()
-      message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not exist.")
-    endif()
-  endif()
-endif()
-
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)
index 07d90246107babb24e6334da73203b9b5830a5f1..c046a1dac40bcc87fe9d34f4dc05ec67e9275d20 100644 (file)
@@ -40,7 +40,7 @@ if(LLVM_BUILD_INSTRUMENTED)
 endif()
 
 find_program(DTRACE dtrace)
-if(DTRACE)
+if(APPLE AND DTRACE)
   configure_lit_site_cfg(
     ${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
     ${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
@@ -56,6 +56,10 @@ if(DTRACE)
     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
     COMMENT "Clearing old dtrace data")
 
+  if(NOT CLANG_ORDER_FILE)
+    message(FATAL_ERROR "Output clang order file is not set")
+  endif()
+
   add_custom_target(generate-order-file
     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary $<TARGET_FILE:clang> --output ${CLANG_ORDER_FILE} ${CMAKE_CURRENT_BINARY_DIR}
     COMMENT "Generating order file"