Page MenuHomePhabricator

[CMake] Do not use libtool on Apple platforms when building LLVM with (full) LTO.
AbandonedPublic

Authored by fhahn on Apr 30 2019, 3:00 PM.

Details

Summary

libtool does not support bitcode files generated by upstream LLVM in the latest
toolchains. When building LLVM with full LTO, we should use llvm-ranlib/llvm-ar.

I am not sure if this is the best way to solve the underlying problem:
being able to do a stage2 bootstrap build of LLVM master with LTO on
Darwin. Unfortunately, CMAKE_AR/CMAKE_RANLIB are automatically populated
if they are not provided. Otherwise we could limit avoiding using
libtool only when the user specified CMAKE_AR/CMAKE_RANLIB manually with LTO.

Any thoughts very appreciated!

Event Timeline

fhahn created this revision.Apr 30 2019, 3:00 PM

Shouldn't this just send DYLD_LIBRARY_PATH through to the second stage, so that ar and ranlib use the just-built libLTO.dylib?

mehdi_amini added inline comments.Apr 30 2019, 3:53 PM
llvm/CMakeLists.txt
55

Why is this specific to full LTO? Isn't the same mechanism used for ThinLTO to build the symbol table for the archive?

If you use cmake variable CLANG_ENABLE_BOOTSTRAP, it should take care of DYLD_LIBRARY_PATH so libtool is using the just built libLTO to create static library. The setup of the DYLD_LIBRARY_PATH is just below.

llvm/CMakeLists.txt
97

This sets up DYLD_LIBRARY_PATH

fhahn added a comment.May 1 2019, 1:25 PM

Thanks for taking a look so quickly! I'll look into how to best set-up DYLD_LIBRARY_PATH in that case. I am after a more lightweight solution than CLANG_ENABLE_BOOTSTRAP, i.e. creating/configuring the separate build stages manually.

When you are manually configuring the bootstrap, I still don't think trying to bypass libtool is the correct fix because you still need to specify the correct llvm-ar to use. The default CMAKE_AR inferred by cmake will not work. Maybe it is an option to add the control to force llvm-ar if wished, then you have two options when you manually configuring bootstrap:

  • DYLD_LIBRARY_PATH points to libLTO.dylib directory
  • CMAKE_AR points to just built llvm-ar and set the variable to force llvm-ar

I don't think the second one is easier than the first one.

fhahn abandoned this revision.Jul 17 2019, 6:48 AM

Thanks for the feedback, setting DYLD_LIBRARY_PATH as suggested does what I want :)