I have just committed support to llvm-ar for creating thin archives. The idea of thin archives is that they contain just the symbol table and the path to find the original .o files. By locally making thin archives the default I was able to build llvm+lld+clang with them. The total size of the .a files goes from 181,658,164 to 7,116,900 bytes. Is there any way to do that with cmake without having to have a hacked llvm-ar? All that is needed is for cmake to run .../llvm-ar cqT foo.a .... instead of .../llvm-ar cq foo.a .... Thanks, Rafael
> On Jul 15, 2015, at 6:00 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote: > > I have just committed support to llvm-ar for creating thin archives. > The idea of thin archives is that they contain just the symbol table > and the path to find the original .o files. > > By locally making thin archives the default I was able to build > llvm+lld+clang with them. The total size of the .a files goes from > 181,658,164 to 7,116,900 bytes.Nice!> > Is there any way to do that with cmake without having to have a hacked > llvm-ar? All that is needed is for cmake to run > > .../llvm-ar cqT foo.a .... > > instead of > > .../llvm-ar cq foo.a ….I found an answer, but its not much better than having a hacked up version of llvm-ar: http://stackoverflow.com/questions/5659225/how-to-set-the-options-for-cmake-ar <http://stackoverflow.com/questions/5659225/how-to-set-the-options-for-cmake-ar> Cheers, Pete> > Thanks, > Rafael > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150715/f12f5526/attachment.html>
FYI, I override CMAKE_CXX_CREATE_STATIC_LIBRARY. See, http://bb.pgr.jp/builders/clang-3stage-x86_64-linux/builds/8687/steps/CMake/logs/stdio 2015年7月16日(木) 12:37 Pete Cooper <peter_cooper at apple.com>:> On Jul 15, 2015, at 6:00 PM, Rafael Espíndola <rafael.espindola at gmail.com> > wrote: > > I have just committed support to llvm-ar for creating thin archives. > The idea of thin archives is that they contain just the symbol table > and the path to find the original .o files. > > By locally making thin archives the default I was able to build > llvm+lld+clang with them. The total size of the .a files goes from > 181,658,164 to 7,116,900 bytes. > > Nice! > > > Is there any way to do that with cmake without having to have a hacked > llvm-ar? All that is needed is for cmake to run > > .../llvm-ar cqT foo.a .... > > instead of > > .../llvm-ar cq foo.a …. > > I found an answer, but its not much better than having a hacked up version > of llvm-ar: > > http://stackoverflow.com/questions/5659225/how-to-set-the-options-for-cmake-ar > <https://urldefense.proofpoint.com/v2/url?u=http-3A__stackoverflow.com_questions_5659225_how-2Dto-2Dset-2Dthe-2Doptions-2Dfor-2Dcmake-2Dar&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=Jpp1nE_QdPfy53TuYzax1tQ9vm54WtEfIxOzgPgQd20&s=tsgr0UMk83KCBHpabWCkl7li3BJKlRMW1wjGKpCoN7k&e=> > > Cheers, > Pete > > > Thanks, > Rafael > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150716/4968087e/attachment.html>
On 07/15/2015 09:00 PM, Rafael Espíndola wrote:> I have just committed support to llvm-ar for creating thin archives. > The idea of thin archives is that they contain just the symbol table > and the path to find the original .o files.Neat! Is this expected to be used only for non-installed archives?> Is there any way to do that with cmake without having to have a hacked > llvm-ar? All that is needed is for cmake to run > > .../llvm-ar cqT foo.a .... > > instead of > > .../llvm-ar cq foo.a ....CMake has undocumented variables set by the Modules/Platform/* files to specify the rules for creating archives. These are: CMAKE_<LANG>_ARCHIVE_{CREATE,APPEND,FINISH} for creating, appending to, and finishing an archive. For tools/platforms that do not support separate steps we also have: CMAKE_<LANG>_CREATE_STATIC_LIBRARY One or both of these may need to be updated to handle this. However, if this should be done only for a subset of archives then it needs to be optional on a per-target bases. For this you may be able to just use the STATIC_LIBRARY_FLAGS property: http://www.cmake.org/cmake/help/v3.3/prop_tgt/STATIC_LIBRARY_FLAGS.html I don't recall off the top of my head though where the flags will be placed for "ar" and whether they will apply on all three archiving steps. Hopefully the above is enough info to get you started. -Brad
On 17 July 2015 at 07:19, Brad King <brad.king at kitware.com> wrote:> On 07/15/2015 09:00 PM, Rafael Espíndola wrote: >> I have just committed support to llvm-ar for creating thin archives. >> The idea of thin archives is that they contain just the symbol table >> and the path to find the original .o files. > > Neat! Is this expected to be used only for non-installed archives?Yes, the idea is to speed up a regular development build.>> Is there any way to do that with cmake without having to have a hacked >> llvm-ar? All that is needed is for cmake to run >> >> .../llvm-ar cqT foo.a .... >> >> instead of >> >> .../llvm-ar cq foo.a .... > > CMake has undocumented variables set by the Modules/Platform/* > files to specify the rules for creating archives. These are: > > CMAKE_<LANG>_ARCHIVE_{CREATE,APPEND,FINISH}I went with this one on my run-cmake script, thanks. Cheers, Rafael
> CMake has undocumented variables set by the Modules/Platform/* > files to specify the rules for creating archives. These are: > > CMAKE_<LANG>_ARCHIVE_{CREATE,APPEND,FINISH} > > for creating, appending to, and finishing an archive. For > tools/platforms that do not support separate steps we also > have: > > CMAKE_<LANG>_CREATE_STATIC_LIBRARYSetting CMAKE_CXX_CREATE_STATIC_LIBRARY works on OS X and linux, but on windows I still see a call to "lld-link2 /lib..." when CMAKE_CXX_CREATE_STATIC_LIBRARY is set to use llvm-lib. Cheers, Rafael