-
Notifications
You must be signed in to change notification settings - Fork 13.6k
clang 10.0.0_rc1 standalone fails to build with polly #44215
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
Comments
Serge has a patch out here: https://reviews.llvm.org/D74464 |
Based on #120 it sounds like there are still issues. |
I'm not going to block on this. |
Hans, FYI, we have to take the patch in Debian/Ubuntu packages to fix a link issue with mesa |
From #191 it sounds like it's not clear that D74464 helps? |
Oh, having two bug trackers isn't optimal :( Anyway, the patch I am talking about hasn't been uploaded yet |
I've tested the package with the patch, and it didn't help. So I'm still unable to build mesa, and now hitting the same bug trying to build intel-opencl-clang. |
Could you please provide a test case which would not be "rebuild mesa" ? :) |
Well, build intel-opencl-clang instead? Much quicker.. |
thanks, I will! |
nope, didn't help, still get the same error.. |
Jan Palus shared this STR with me: $ cat test.cpp using namespace clang; int main() { EmitBackendOutput(*diags, *hsOpts, *cgOpts, *tOpts, *lOpts, *tDesc, m, *action, std::move(AsmOutStream)); $ g++ test.cpp -o test -lclangBasic -lclangCodeGen -lclangDriver -lclangFrontend -lclangFrontendTool -lclangCodeGen -lclangRewriteFrontend -lclangARCMigrate -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangCrossTU -lclangIndex -lclangFrontend -lclangDriver -lclangParse -lclangSerialization -lclangSema -lclangAnalysis -lclangEdit -lclangFormat -lclangToolingInclusions -lclangToolingCore -lclangRewrite -lclangASTMatchers -lclangAST -lclangLex -lclangBasic -ldl -lLLVMSPIRVLib /usr/lib64/libLLVM-10.so -lclangCodeGen -lclangDriver -lclangFrontend -lclangFrontendTool -lclangRewriteFrontend -lclangARCMigrate -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangCrossTU -lclangIndex -lclangParse -lclangSerialization -lclangSema -lclangAnalysis -lclangEdit -lclangFormat -lclangToolingInclusions -lclangToolingCore -lclangRewrite -lclangASTMatchers -lclangAST -lclangLex -ldl -lLLVMSPIRVLib |
With Debian packages, the command is: |
-Polly, -lPollyPPCG and -lPollyISL are missing. Where does the list of libraries come from? llvm-config? |
It appears that both opencl-clang and Mesa are constructing list of libclang* libs to be linked manually, see https://github.com/intel/opencl-clang/blob/master/CMakeLists.txt#L233 and relevant comment intel/opencl-clang#112 (comment). Could you please confirm that libPolly is now mandatory when linking against libclangCodeGen and therefore should be added to the list? Could you suggest a more robust way of obtaining proper libs? |
The Polly libraries are only dependencies when LLVM was compiled using LLVM_POLLY_LINK_INTO_TOOLS=ON, which now is the default if Polly is enabled. An introspection with CMake's find_package(LLVM) would be the most robust way to find all required libraries. Alternatively, llvm-config an be asked for this information. @serge-sans-paille: I think LLVM__LINK_INTO_TOOLS current does not add plugin dependencies into the list returned by |
Do you mean some extra steps or just find_package call? Note that there is such step already in opencl-clang but I guess it does not add libPolly: -- Looking for LLVM version 10.0.0 https://github.com/intel/opencl-clang/blob/master/CMakeLists.txt#L26 |
That's a bug! I'll have a look. |
There's currently no mode in llvm-config to gather dependency information for clang (or lld) libs. And llvm-config is probably not the right place to do this (clang can be compiled in standalone mode). Should we add a clang-config tool ? |
Please, can this be solved without requiring downstream projects to use CMake? |
In ziglang/zig#4992 I attempted to change zig to use LLVMConfig.cmake and ClangConfig.cmake, however I ran into this problem, using apt.llvm.org: "make[2]: *** No rule to make target '/usr/lib/llvm-10/lib/libPolly.a' I just got the package sources So there is definitely a packaging problem here |
In case anyone's interested I've submitted pull requests to both opencl-clang and Mesa. Not that I'm satisfied with them but I couldn't think of anything better. I really think libclangCodeGen's deps should be pulled from somewhere dynamically instead of every downstream project tracking and fixing undefined symbols for different LLVM build configurations. Also no idea why opencl-clang is fine with just -lPolly while Mesa requires both -lPolly and -lPollyISL (neither of them required Polly before). https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4511 @Andrew: I'm not familiar apt.llvm.org but I suspect it might have something to do with: Don't think it is used
https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/blob/8/debian/rules#L625 |
This has caused a lot of downstream frustrations, if you read starting here: ziglang/zig#4799 (comment) and continuing downwards. Why is Polly special? Why can't it be a normal library like all the other ones? |
I fixed the libpolly link on the apt.llvm.org side and triggered rebuilds |
In contrast to all other libraries, the Polly dependency is optional, depending on how LLVM was configured before compilation. |
Any chance to get rid of this hard symbol dependency on Polly that consists of single symbol? Ie calling dlsym(RTLD_DEFAULT, "getPollyPluginInfo") and if NULL is returned assume Polly is not available? |
Can someone summarize the status of this bug? Which commits are confirmed to fix the problem? |
I think what caused all this is the following change in D61446:
This means that every user of clangCodeGen new also needs to link Polly. This is no problem when using CMake's find_package, as CMake automatically has generated a ClangConfig.cmake containing:
hence using link_libraries(MyCompilerProject clangCodeGen) will automatically add -lPolly to the linker command line. Projects not using CMake's find_package (e.g. because they are not using CMake at all) typically hardcodes all required libraries, due to the absence of Solutions:
For opt and bugpoint, it's still only in executables (opt.cpp -> NewPMDriver.cpp; bugpoint.cpp -> bugpoint.cpp) as the pass registration takes place in the executables. |
Thanks Michael for the very nice summary. +1 for Solution 3 which looks like the lowest friction path. |
Would you prepare a patch for that? It means that |
Sure, I'm on it. |
WIP patch here: https://reviews.llvm.org/D78192 |
These patch combined: https://reviews.llvm.org/D78192 seem to solve the issue, and provide correct llvm-config + cmake integration. Tested on various setup (with / withou llvm_dylib, through cmake and llvm-config) The reproducer provided by Sylvestre Ledru also compiles fine with
|
Just commited 8f766e3 that should fix the issue. |
Merged: 5f510e5 |
mentioned in issue #44654 |
mentioned in issue llvm/llvm-bugzilla-archive#45817 |
mentioned in issue llvm/llvm-bugzilla-archive#47583 |
Extended Description
Originally filed as #120
The text was updated successfully, but these errors were encountered: