[PATCH] D99620: [CMake][Compiler-rt] Compute LLVM_MAIN_SRC_DIR assuming the monorepo layout.
Dan Liew via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 2 12:03:34 PDT 2021
delcypher updated this revision to Diff 335005.
delcypher added a comment.
- Hoist code out of `LLVM_CONFIG_PATH` branch.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99620/new/
https://reviews.llvm.org/D99620
Files:
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -219,6 +219,12 @@
"Reconfigure with -DLLVM_CONFIG_PATH=path/to/llvm-config.")
endif()
endif()
+
+ # Compute path to LLVM sources assuming the monorepo layout.
+ # We don't set `LLVM_MAIN_SRC_DIR` directly to avoid overriding a user provided
+ # CMake cache value.
+ get_filename_component(LLVM_MAIN_SRC_DIR_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ABSOLUTE)
+
if (LLVM_CONFIG_PATH)
execute_process(
COMMAND ${LLVM_CONFIG_PATH} "--obj-root" "--bindir" "--libdir" "--src-root" "--includedir"
@@ -231,15 +237,28 @@
list(GET CONFIG_OUTPUT 0 BINARY_DIR)
list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
- list(GET CONFIG_OUTPUT 3 MAIN_SRC_DIR)
+ list(GET CONFIG_OUTPUT 3 MAIN_SOURCE_DIR)
list(GET CONFIG_OUTPUT 4 INCLUDE_DIR)
set(LLVM_BINARY_DIR ${BINARY_DIR} CACHE PATH "Path to LLVM build tree")
set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
- set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Paths to LLVM headers")
+ if (NOT EXISTS "${LLVM_MAIN_SRC_DIR_DEFAULT}")
+ # TODO(dliew): Remove this legacy fallback path.
+ message(WARNING
+ "LLVM source tree not found at \"${LLVM_MAIN_SRC_DIR_DEFAULT}\". "
+ "You are not using the monorepo layout. "
+ "This configuration is DEPRECATED. Consulting llvm-config for the LLVM source path"
+ "as a fallback. This behavior will be removed in the future."
+ )
+ # We don't set `LLVM_MAIN_SRC_DIR` directly to avoid overriding a user
+ # provided CMake cache value.
+ set(LLVM_MAIN_SRC_DIR_DEFAULT "${MAIN_SOURCE_DIR}")
+ message(STATUS "Using LLVM source path (${LLVM_MAIN_SRC_DIR_DEFAULT}) from llvm-config")
+ endif()
+
# Detect if we have the LLVMXRay and TestingSupport library installed and
# available from llvm-config.
execute_process(
@@ -305,6 +324,20 @@
set(LLVM_LIBRARY_OUTPUT_INTDIR
${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
endif()
+
+ # Finally set the cache variable now that `llvm-config` has also had a chance
+ # to set `LLVM_MAIN_SRC_DIR_DEFAULT`.
+ set(LLVM_MAIN_SRC_DIR "${LLVM_MAIN_SRC_DIR_DEFAULT}" CACHE PATH "Path to LLVM source tree")
+ message(STATUS "LLVM_MAIN_SRC_DIR: \"${LLVM_MAIN_SRC_DIR}\"")
+ if (NOT EXISTS "${LLVM_MAIN_SRC_DIR}")
+ # TODO(dliew): Make this a hard error
+ message(WARNING "LLVM_MAIN_SRC_DIR (${LLVM_MAIN_SRC_DIR}) does not exist. "
+ "You can override the inferred path by adding "
+ "`-DLLVM_MAIN_SRC_DIR=<path_to_llvm_src>` to your CMake invocation "
+ "where `<path_to_llvm_src>` is the path to the `llvm` directory in "
+ "the `llvm-project` repo. "
+ "This will be treated as error in the future.")
+ endif()
endmacro()
macro(construct_compiler_rt_default_triple)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99620.335005.patch
Type: text/x-patch
Size: 3337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210402/b2222290/attachment-0001.bin>
More information about the llvm-commits
mailing list