[cmake] Enable users to specify archive creation commands
authorAlexander Shaposhnikov <ashaposhnikov@google.com>
Mon, 10 Jan 2022 18:53:31 +0000 (18:53 +0000)
committerAlexander Shaposhnikov <ashaposhnikov@google.com>
Mon, 10 Jan 2022 18:53:40 +0000 (18:53 +0000)
commit2d3ae6f4844bb5b61936d957e9328490f18ecd41
tree1a3e6c131a8de35447f64e9e25edff46c6eb57e9
parent0ba4e4b500eaeb3573d2cf32a3280f85f5a714c5
[cmake] Enable users to specify archive creation commands

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.
For a clean run `ninja lld` using thin archives seems to reduce the size
of the build directory from ~14GB to ~8GB

Differential revision: https://reviews.llvm.org/D116850
llvm/cmake/modules/HandleLLVMOptions.cmake