-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: add more LLVM components #686
Conversation
lib/Module/CMakeLists.txt
Outdated
ipo | ||
linker | ||
mc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What part of mc
do we depend on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you are right. I blindly added everything what linker screamed is missing. So non-llvm-config
configuration is more broken than llvm-config
?
Really, llvm_map_components_to_libnames
returns less what it really should (opposing to llvm-config), it seems. No transitive closure of internal LLVM dependencies there. I'm at LLVM 4.
lib/Module/CMakeLists.txt
Outdated
@@ -23,9 +23,14 @@ set(LLVM_COMPONENTS | |||
bitreader | |||
bitwriter | |||
codegen | |||
instcombine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is wrong here. Both the llvm-config
and CMake approach should see that transformutils
is a dependency of instcombine.
If you take a look at the installed LLVMExports.cmake
file you'll see something like
# Create imported target LLVMInstCombine
add_library(LLVMInstCombine STATIC IMPORTED)
set_target_properties(LLVMInstCombine PROPERTIES
INTERFACE_LINK_LIBRARIES "LLVMAnalysis;LLVMCore;LLVMSupport;LLVMTransformUtils"
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the difference is:
llvm_map_components_to_libraries(LLVM_LIBS1 instcombine)
llvm_map_components_to_libnames(LLVM_LIBS2 instcombine)
message("old ${LLVM_LIBS1}")
message("new ${LLVM_LIBS2}")
old LLVMInstCombine;LLVMTransformUtils;LLVMAnalysis;LLVMProfileData;LLVMObject;LLVMMCParser;LLVMMC;LLVMBitReader;LLVMCore;LLVMSupport;LLVMDemangle
new LLVMInstCombine
So we should use llvm_map_components_to_libnames differently, apparently :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works much better:
llvm_map_components_to_libraries(LLVM_LIBS1 instcombine)
llvm_map_components_to_libnames(LLVM_LIBS2_T instcombine)
llvm_expand_dependencies(LLVM_LIBS2 ${LLVM_LIBS2_T})
message("old ${LLVM_LIBS1}")
message("new ${LLVM_LIBS2}")
old LLVMInstCombine;LLVMTransformUtils;LLVMAnalysis;LLVMProfileData;LLVMObject;LLVMMCParser;LLVMMC;LLVMBitReader;LLVMCore;LLVMSupport;LLVMDemangle
new LLVMInstCombine;LLVMTransformUtils;LLVMAnalysis;LLVMProfileData;LLVMObject;LLVMMCParser;LLVMMC;LLVMBitReader;LLVMCore;LLVMSupport;LLVMDemangle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this works this is the wrong approach. llvm_map_components_to_libnames()
is the way you used above will only give back LLVMInstCombine
. The LLVMInstCombine
library will have INTERFACE
dependencies which should transitively cover all the dependent libraries. If it does not then there is a bug somewhere which we should report upstream.
Using llvm_expand_dependencies()
is fine for a temporary fix but a comment should be added stating such and it should point at the relevant LLVM bugs
I have another project which uses LLVM 4.0 via CMake on my system so I'll try to take a look today at where the problem is and report it upstream if I can figure out what's going on.
When we use -DUSE_CMAKE_FIND_PACKAGE_LLVM=ON, we do not expand dependecies and build fails with linker errors like: /usr/bin/ld: lib/libkleeModule.a(ModuleUtil.cpp.o): undefined reference to symbol '_ZNK4llvm6object7Archive5Child7getNameEv' /usr/lib64/../lib64/libLLVMObject.so.4: error adding symbols: DSO missing from command line clang-4.0.0: error: linker command failed with exit code 1 (use -v to see invocation) So let LLVM compute also the transitive close as it used to do so in LLVM < 3.5. Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Hmm LLVMObject is in the list of transitively expanded dependencies. Adding some hacky code to walk the dependencies. cmake_policy(SET CMP0057 NEW)
llvm_map_components_to_libnames(LLVM_DEP_HACK instcombine)
message(STATUS "LLVM_DEP_HACK: ${LLVM_DEP_HACK}")
set(_work_list ${LLVM_DEP_HACK})
set(_final_deps "")
set(_changed TRUE)
while(${_changed})
set(_new_work_list "")
set(_changed FALSE)
foreach(dep ${_work_list})
if (TARGET "${dep}")
message(STATUS "Adding dep ${dep}")
list(APPEND _final_deps "${dep}")
# Get INTERFACE dependencies
set(dep_interface_deps "")
message(STATUS "Getting interface deps of target \"${dep}\"")
get_target_property(dep_interface_deps ${dep} INTERFACE_LINK_LIBRARIES)
message(STATUS "Deps are ${dep_interface_deps}")
if (dep_interface_deps)
list(LENGTH dep_interface_deps length_dep_interface_deps)
if ("${length_dep_interface_deps}" GREATER 0)
# Only append dependencies that we haven't seen bfore
#message(STATUS "Append deps ${dep_interface_deps} from ${dep}")
foreach(new_dep ${dep_interface_deps})
if (TARGET ${new_dep})
if (NOT ("${new_dep}" IN_LIST _final_deps))
if (NOT ("${new_dep}" IN_LIST _new_work_list))
if (NOT ("${new_dep}" IN_LIST _work_list))
list(APPEND _new_work_list ${new_dep})
message(STATUS "Appending ${new_dep} to work list")
set(_changed TRUE)
endif()
endif()
endif()
endif()
endforeach()
endif()
endif()
endif()
endforeach()
set(_work_list ${_new_work_list})
unset(_new_work_list)
endwhile()
message(STATUS "transitive dependencies: ${_final_deps}")
I need to see the link line that the generated build system uses when linking fails. Either |
Should I provide the output?
|
These are properties of LLVMInstCombine:
So there is no |
Something about your set up is very different to mine. I have a build of LLVM 4.0 on my system and in the build tree there is the file
and in that there are the following lines
the Is your set up like this? If not where are the differences? |
I have this:
I.e. my |
Oh. So you're building LLVM with http://llvm.org/docs/CMake.html#llvm-specific-variables
This configuration (individual components built as individual shared libraries) probably doesn't get much testing. So to me this seems like a bug in LLVM's build system. The dependency information is missing from the exported targets which is not something we can really fix on KLEE's side. I suggest you report this bug upstream and cc @bradking (Brad King), myself, and @llvm-beanz (Chris Bieneman). |
It's not actually me. It is LLVM distributed by openSUSE :).
Ok, thanks. |
Eurgh. They really shouldn't be doing that. So looks like you have two bug reports, one for openSUSE and one for upstream LLVM :) Maybe openSUSE have a good reason for doing this but going against a project's recommended practice seems like a bad idea. |
openSUSE side: |
When This can cause problems if the header files for an LLVM component have inlined code that calls into another component, and in that situation our transitive dependency information would be incomplete. You can file a bug on LLVM.org to investigate fixing that, however it is unlikely that much attention will be given to the |
@llvm-beanz Thanks for the confirmation. I'll leave it up to @jirislaby whether or not to file a bug for this. To me it seems like the problem is on the openSUSE side for going against recommended practice. |
The reply from openSUSE LLVM maintainers:
So |
The change that caused that bug was altered, and while the issue with cl::opt exists, that problem shouldn't exist in any recent LLVM release or on trunk. So... don't think that is a legitimate answer from openSUSE unless they have modifications to LLVM that are causing other bugs which haven't been reported. |
openSUSE switched to |
With
-DUSE_CMAKE_FIND_PACKAGE_LLVM=ON
, I have to specify these as theyare used by our
libModule
.