[PATCH] D32835: [compiler-rt] [cmake] Support generic installation

Catherine Moore via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 16:19:00 PDT 2017


clm created this revision.
Herald added subscribers: mgorny, dberris.

By default, compiler-rt its libraries in subdirectories such as lib/linux of the specified CMAKE_INSTALL_PREFIX, with names such as libclang_rt.builtins-x86_64.a.

This patch creates a new CMake boolean named COMPILER_RT_GENERIC_BUILD that would cause the builtin library to be installed in lib/libclang_rt.builtins.a.  This is intended to be used when compiler-rt is being built standalone.

To provide context, we are working on an embedded toolchain using llvm and would like to build and install separate copies of each multilib.


https://reviews.llvm.org/D32835

Files:
  CMakeLists.txt
  cmake/Modules/AddCompilerRT.cmake
  cmake/base-config-ix.cmake


Index: cmake/base-config-ix.cmake
===================================================================
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -64,11 +64,17 @@
 endif()
 
 string(TOLOWER ${CMAKE_SYSTEM_NAME} COMPILER_RT_OS_DIR)
-set(COMPILER_RT_LIBRARY_OUTPUT_DIR
-  ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
-set(COMPILER_RT_LIBRARY_INSTALL_DIR
-  ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
 
+if(COMPILER_RT_GENERIC_BUILD)
+  set(COMPILER_RT_LIBRARY_OUTPUT_DIR ${COMPILER_RT_OUTPUT_DIR}/lib)
+  set(COMPILER_RT_LIBRARY_INSTALL_DIR ${COMPILER_RT_INSTALL_PATH}/lib)
+else()
+  set(COMPILER_RT_LIBRARY_OUTPUT_DIR
+    ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
+  set(COMPILER_RT_LIBRARY_INSTALL_DIR
+    ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+endif()
+
 if(APPLE)
   # On Darwin if /usr/include doesn't exist, the user probably has Xcode but not
   # the command line tools. If this is the case, we need to find the OS X
Index: cmake/Modules/AddCompilerRT.cmake
===================================================================
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -134,6 +134,14 @@
         format_object_libs(sources_${libname} ${os} ${LIB_OBJECT_LIBS})
       endif()
     endforeach()
+  elseif(COMPILER_RT_GENERIC_BUILD)
+    set(libname "${name}")
+    set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX})
+    message(STATUS "Setting libname to ${libname}")
+    message(STATUS "COMPILER_RT_OS_SUFFIX is ${COMPILER_RT_OS_SUFFIX}")
+    set(sources_${libname} ${LIB_SOURCES})
+    set(libnames ${libnames} ${libname})
+    set(extra_cflags_${libname} ${LIB_CFLAGS})
   else()
     foreach(arch ${LIB_ARCHS})
       if(NOT CAN_TARGET_${arch})
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -31,6 +31,10 @@
 option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
 mark_as_advanced(COMPILER_RT_BUILD_XRAY)
 
+set(COMPILER_RT_GENERIC_BUILD OFF CACHE BOOLEAN
+  "Build with the CMake options passed by the user and install with a generic name
+  to a generic location.")
+
 if (COMPILER_RT_STANDALONE_BUILD)
   load_llvm_config()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32835.97739.patch
Type: text/x-patch
Size: 2282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170503/3836f16d/attachment.bin>


More information about the llvm-commits mailing list