aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Hinton <hintonda@gmail.com>2019-05-21 17:56:45 +0000
committerDon Hinton <hintonda@gmail.com>2019-05-21 17:56:45 +0000
commitbd467cfe4bcdfbe105ecf7b7d4a3da3fcfa92703 (patch)
tree00fe2edc97e9eac3eb66c343ce67955690fea92a
parent92febc64980f0bdd3f6aa7455927b780178651de (diff)
downloadllvm-bd467cfe4bcdfbe105ecf7b7d4a3da3fcfa92703.zip
llvm-bd467cfe4bcdfbe105ecf7b7d4a3da3fcfa92703.tar.gz
llvm-bd467cfe4bcdfbe105ecf7b7d4a3da3fcfa92703.tar.bz2
[cmake] Add custom command to touch archives on Darwin so ninja won't rebuild them.
Summary: clang and newer versions of ninja use high-resolutions timestamps, but older versions of libtool on Darwin don't, so the archive will often get an older timestamp than the last object that was added or updated. To fix this, we add a custom command to touch the archive after it's been built so that ninja won't rebuild it unnecessarily the next time it's run. Reviewed By: beanz Tags: #llvm Differential Revision: https://reviews.llvm.org/D62172 llvm-svn: 361280
-rw-r--r--llvm/cmake/config-ix.cmake16
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake12
2 files changed, 28 insertions, 0 deletions
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 66c7382..7b61f9d 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -554,6 +554,22 @@ find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold
set(LLVM_BINUTILS_INCDIR "" CACHE PATH
"PATH to binutils/include containing plugin-api.h for gold plugin.")
+if(CMAKE_GENERATOR STREQUAL "Ninja")
+ include(CMakeNInjaFindMake)
+ if(CMAKE_MAKE_PROGRAM)
+ execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
+ OUTPUT_VARIABLE NINJA_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(NINJA_VERSION ${NINJA_VERSION} CACHE STRING "Ninja version number" FORCE)
+ endif()
+endif()
+
+if(CMAKE_GENERATOR STREQUAL "Ninja" AND
+ NINJA_VERSION VERSION_GREATER_EQUAL "1.9.0" AND
+ CMAKE_HOST_APPLE AND CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER "15.6.0")
+ set(LLVM_TOUCH_STATIC_LIBRARIES ON)
+endif()
+
if(CMAKE_HOST_APPLE AND APPLE)
if(NOT CMAKE_XCRUN)
find_program(CMAKE_XCRUN NAMES xcrun)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 3f84802..4151275 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -596,6 +596,18 @@ function(llvm_add_library name)
llvm_externalize_debuginfo(${name})
llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
endif()
+ # clang and newer versions of ninja use high-resolutions timestamps,
+ # but older versions of libtool on Darwin don't, so the archive will
+ # often get an older timestamp than the last object that was added
+ # or updated. To fix this, we add a custom command to touch archive
+ # after it's been built so that ninja won't rebuild it unnecessarily
+ # the next time it's run.
+ if(ARG_STATIC AND LLVM_TOUCH_STATIC_LIBRARIES)
+ add_custom_command(TARGET ${name}
+ POST_BUILD
+ COMMAND touch ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}
+ )
+ endif()
endfunction()
function(add_llvm_install_targets target)