[llvm] [llvm-libgcc][CMake] Refactor llvm-libgcc (PR #65455)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 15 12:20:20 PDT 2023
================
@@ -25,18 +32,103 @@ if(NOT LLVM_LIBGCC_EXPLICIT_OPT_IN)
"to your CMake invocation and try again.")
endif()
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib${LLVMLIB_DIR_SUFFIX}")
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib${LLVMLIB_DIR_SUFFIX}")
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
+if(HAVE_COMPILER_RT AND (NOT COMPILER_RT_BUILD_BUILTINS OR COMPILER_RT_BUILTINS_HIDE_SYMBOLS))
+ message(FATAL_ERROR
+ "llvm-libgcc requires compiler-rt builtins with default symbol visibility, "
+ "add -DCOMPILER_RT_BUILD_BUILTINS=Yes -DCOMPILER_RT_BUILTINS_HIDE_SYMBOLS=No "
+ "to your CMake invocation and try again.")
+endif()
+
+#===============================================================================
+# Configure System
+#===============================================================================
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+ set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+ set(LLVM_LIBGCC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ "Path where built llvm-libgcc libraries should be installed.")
+ if(LIBCXX_LIBDIR_SUBDIR)
+ string(APPEND LLVM_LIBGCC_LIBRARY_DIR /${LLVM_LIBGCC_LIBDIR_SUBDIR})
+ string(APPEND LLVM_LIBGCC_INSTALL_LIBRARY_DIR /${LLVM_LIBGCC_LIBDIR_SUBDIR})
+ endif()
+else()
+ if(LLVM_LIBRARY_OUTPUT_INTDIR)
+ set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+ else()
+ set(LLVM_LIBGCC_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBGCC_LIBDIR_SUFFIX})
+ endif()
+ set(LLVM_LIBGCC_INSTALL_LIBRARY_DIR lib${LLVM_LIBGCC_LIBDIR_SUFFIX} CACHE PATH
+ "Path where built llvm-libgcc libraries should be installed.")
+endif()
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBGCC_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_LIBGCC_LIBRARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_LIBGCC_LIBRARY_DIR})
+
+#===============================================================================
+# Configure System
+#===============================================================================
+
+set(COMPILER_RT_BUILD_BUILTINS ON)
+set(COMPILER_RT_BUILTINS_HIDE_SYMBOLS OFF)
-set(COMPILER_RT_BUILD_BUILTINS On)
-set(COMPILER_RT_BUILTINS_HIDE_SYMBOLS Off)
-add_subdirectory("../compiler-rt" "compiler-rt")
+if(NOT HAVE_COMPILER_RT)
----------------
ur4t wrote:
It was changed, and now it is restored in [b61aed7](https://github.com/llvm/llvm-project/pull/65455/commits/b61aed75b1c5891a4f84dd053fad1c68cc60902d).
I tried to make them co-exist happily and found that it is quite hard to set necessary options without further modifying the order of runtime projects in `runtimes/CMakeLists.txt`.
This finding is documented in the commit message to explain why we chose this approach.
https://github.com/llvm/llvm-project/pull/65455
More information about the llvm-commits
mailing list