[PATCH] D109977: LLVM Driver Multicall tool
Michał Górny via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 19 09:06:08 PDT 2022
mgorny added a comment.
Ok, I think the key to reproducing it is `-DLLVM_LINK_LLVM_DYLIB=ON`. We pass that while building LLVM, so it gets passed on to clang but I suppose passing it to clang build might be sufficient to reproduce the problem.
The actual problem is that you're passing `${USE_SHARED}` to `llvm_config()` (in `add_llvm_executable`) before it's defined. Moving the definition earlier fixed this error but uncovers another problem:
CMake Error at cmake/modules/AddClang.cmake:188 (target_link_libraries):
The keyword signature for target_link_libraries has already been used with
the target "obj.clang". All uses of target_link_libraries with a target
must be either all-keyword or all-plain.
The uses of the keyword signature are here:
* /usr/lib/llvm/15/lib64/cmake/llvm/LLVM-Config.cmake:92 (target_link_libraries)
Call Stack (most recent call first):
tools/driver/CMakeLists.txt:37 (clang_target_link_libraries)
Now, if you move `USE_SHARED` definition using the following patch:
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 8e1385e90b82..c37c1c3aa59d 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -890,6 +890,10 @@ macro(add_llvm_executable name)
set_target_properties(${obj_name} PROPERTIES FOLDER "Object Libraries")
endif()
+ if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
+ set(USE_SHARED USE_SHARED)
+ endif()
+
if (ARG_GENERATE_DRIVER)
string(REPLACE "-" "_" TOOL_NAME ${name})
foreach(path ${CMAKE_MODULE_PATH})
@@ -964,10 +968,6 @@ macro(add_llvm_executable name)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif(LLVM_EXPORTED_SYMBOL_FILE)
- if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
- set(USE_SHARED USE_SHARED)
- endif()
-
set(EXCLUDE_FROM_ALL OFF)
set_output_directory(${name} BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR} LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
llvm_config( ${name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
you should be able to reproduce the latter error using a regular in-tree build, e.g.:
cmake ../llvm -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PROJECTS='llvm;clang' -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109977/new/
https://reviews.llvm.org/D109977
More information about the cfe-commits
mailing list