[PATCH] D62172: [cmake] Add custom command to touch archives so ninja won't rebuild them.

Don Hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 21:22:29 PDT 2019


hintonda created this revision.
hintonda added reviewers: thakis, beanz.
Herald added a subscriber: mgorny.
Herald added a project: LLVM.

clang and ninja use high-resolutions timestamps, but libtool
doesn'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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62172

Files:
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -596,6 +596,19 @@
     llvm_externalize_debuginfo(${name})
     llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
   endif()
+  # clang and ninja use high-resolutions timestamps, but libtool
+  # doesn'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
+      CMAKE_GENERATOR STREQUAL "Ninja" AND
+      NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+    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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62172.200396.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190521/15ba8a31/attachment.bin>


More information about the llvm-commits mailing list