[PATCH] D61346: [CMake] Do not use libtool on Apple platforms when building LLVM with (full) LTO.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 15:01:15 PDT 2019
fhahn created this revision.
fhahn added reviewers: kubamracek, aprantl, ab.
Herald added subscribers: dexonsmith, inglorion, mehdi_amini, mgorny.
Herald added a project: LLVM.
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!
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D61346
Files:
llvm/CMakeLists.txt
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -47,43 +47,50 @@
# This should only apply if you are both on an Apple host, and targeting Apple.
if(CMAKE_HOST_APPLE AND APPLE)
- # if CMAKE_LIBTOOL is not set, try and find it with xcrun or find_program
- if(NOT CMAKE_LIBTOOL)
- if(NOT CMAKE_XCRUN)
- find_program(CMAKE_XCRUN NAMES xcrun)
- endif()
- if(CMAKE_XCRUN)
- execute_process(COMMAND ${CMAKE_XCRUN} -find libtool
- OUTPUT_VARIABLE CMAKE_LIBTOOL
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- endif()
-
- if(NOT CMAKE_LIBTOOL OR NOT EXISTS CMAKE_LIBTOOL)
- find_program(CMAKE_LIBTOOL NAMES libtool)
- endif()
- endif()
- get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
- if(CMAKE_LIBTOOL)
- set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")
- message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")
-
- execute_process(COMMAND ${CMAKE_LIBTOOL} -V
- OUTPUT_VARIABLE LIBTOOL_V_OUTPUT
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if("${LIBTOOL_V_OUTPUT}" MATCHES ".*cctools-([0-9.]+).*")
- string(REGEX REPLACE ".*cctools-([0-9.]+).*" "\\1" LIBTOOL_VERSION
- ${LIBTOOL_V_OUTPUT})
- if(NOT LIBTOOL_VERSION VERSION_LESS "862")
- set(LIBTOOL_NO_WARNING_FLAG "-no_warning_for_no_symbols")
+ # Only use libtool when not doing full LTO. When bootstrapping LLVM master
+ # with LTO, we have to use llvm-ranlib/llvm-ar, as libtool may not support
+ # the newest LLVM bitcode version.
+ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO)
+ if(NOT uppercase_LLVM_ENABLE_LTO STREQUAL "FULL" OR CMAKE_AR_val)
+ # if CMAKE_LIBTOOL is not set, try and find it with xcrun or find_program
+ if(NOT CMAKE_LIBTOOL)
+ if(NOT CMAKE_XCRUN)
+ find_program(CMAKE_XCRUN NAMES xcrun)
+ endif()
+ if(CMAKE_XCRUN)
+ execute_process(COMMAND ${CMAKE_XCRUN} -find libtool
+ OUTPUT_VARIABLE CMAKE_LIBTOOL
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+
+ if(NOT CMAKE_LIBTOOL OR NOT EXISTS CMAKE_LIBTOOL)
+ find_program(CMAKE_LIBTOOL NAMES libtool)
+ endif()
endif()
- endif()
- foreach(lang ${languages})
- set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
- "\"${CMAKE_LIBTOOL}\" -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> \
- <LINK_FLAGS> <OBJECTS> ")
- endforeach()
+ get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+ if(CMAKE_LIBTOOL)
+ set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")
+ message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")
+
+ execute_process(COMMAND ${CMAKE_LIBTOOL} -V
+ OUTPUT_VARIABLE LIBTOOL_V_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if("${LIBTOOL_V_OUTPUT}" MATCHES ".*cctools-([0-9.]+).*")
+ string(REGEX REPLACE ".*cctools-([0-9.]+).*" "\\1" LIBTOOL_VERSION
+ ${LIBTOOL_V_OUTPUT})
+ if(NOT LIBTOOL_VERSION VERSION_LESS "862")
+ set(LIBTOOL_NO_WARNING_FLAG "-no_warning_for_no_symbols")
+ endif()
+ endif()
+
+ foreach(lang ${languages})
+ set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
+ "\"${CMAKE_LIBTOOL}\" -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> \
+ <LINK_FLAGS> <OBJECTS> ")
+ endforeach()
+ endif()
endif()
# If DYLD_LIBRARY_PATH is set we need to set it on archiver commands
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61346.197452.patch
Type: text/x-patch
Size: 3546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190430/be1af1fc/attachment.bin>
More information about the llvm-commits
mailing list