[PATCH] D116850: [cmake] Enable users to specify archive creation commands

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 7 21:05:53 PST 2022


alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: MaskRay, compnerd, pete.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a subscriber: mgorny.
alexander-shaposhnikov requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This diff enables users to override CMAKE_C_ARCHIVE_CREATE & CMAKE_CXX_ARCHIVE_CREATE (currently set in HandleLLVMOptions.cmake).
For example, one can specify

  cmake -DCMAKE_C_ARCHIVE_CREATE="<CMAKE_AR> TDqc <TARGET> <LINK_FLAGS> <OBJECTS>" \
              -DCMAKE_CXX_ARCHIVE_CREATE="<CMAKE_AR> TDqc <TARGET> <LINK_FLAGS> <OBJECTS>" ...

to make the build create thin archives instead of regular ones.
Perhaps, having a variable  (e.g. LLVM_USE_THIN_ARCHIVES) might be useful (to make this switch more easily usable) - any suggestions would be welcome.

P.S. for a clean run `ninja lld` using thin archives seems to reduce the size of the build directory from ~14GB to ~8GB


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116850

Files:
  llvm/cmake/modules/HandleLLVMOptions.cmake


Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -189,11 +189,13 @@
                     ERROR_QUIET
                     )
     if(${RANLIB_RESULT} EQUAL 0)
-      set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
+      set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>"
+          CACHE STRING "archive create command")
       set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq  <TARGET> <LINK_FLAGS> <OBJECTS>")
       set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
 
-      set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
+      set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>"
+          CACHE STRING "archive create command")
       set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> Dq  <TARGET> <LINK_FLAGS> <OBJECTS>")
       set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
     endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116850.398296.patch
Type: text/x-patch
Size: 1077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220108/a197f265/attachment.bin>


More information about the llvm-commits mailing list