FS#22799 - clang/llvm configuration is broken
Attached to Project:
Community Packages
Opened by nsf (nsf) - Monday, 07 February 2011, 12:38 GMT
Last edited by Evangelos Foutras (foutrelis) - Friday, 11 February 2011, 15:55 GMT
Opened by nsf (nsf) - Monday, 07 February 2011, 12:38 GMT
Last edited by Evangelos Foutras (foutrelis) - Friday, 11 February 2011, 15:55 GMT
|
Details
Description:
Ok, there is a tricky line in clang/llvm PKGBUILD, here it is: ------------------------------------------------------------------- # Fix installation directories, ./configure doesn't seem to set them right sed -i -e 's:\$(PROJ_prefix)/etc/llvm:/etc/llvm:' \ -e 's:\$(PROJ_prefix)/lib:$(PROJ_prefix)/lib/llvm:' \ -e 's:\$(PROJ_prefix)/docs/llvm:$(PROJ_prefix)/share/doc/llvm:' \ Makefile.config.in ------------------------------------------------------------------- It is supposed to "fix" things, but actually it breaks things. You see, changing $(PROJ_prefix)/lib to $(PROJ_prefix)/lib/llvm is ok in some cases. But for instance it breaks libclang functionality and c-index-test functionality. Clang itself works fine, because it uses the binary path as a starting point (for some reason): [nsf @ 2.8]$ clang -print-search-dirs programs: =/usr/bin:/usr/bin libraries: =/usr/bin/../lib/clang/2.8/:/lib/:/usr/lib/:/lib32/:/usr/lib32/:/lib64/:/usr/lib64/ If you're interested in that, it can be seen in this source file: clang-2.8/lib/Driver/Driver.cpp:74 But when we are trying to use c-index-test and libclang (for example some kind of an autocompletion tool based on libclang), we have the following: (here test.c is a C file that includes stddef.h) [nsf @ ccode]$ c-index-test -test-inclusion-stack-source -v test.c ... skipped ... ignoring nonexistent directory "/usr/lib/llvm/../lib/clang/2.8/include" ... skipped ... test.c:1:10: fatal error: 'stddef.h' file not found Now it becomes interesting, clang can't see its header (/usr/lib/clang/2.8/include/stddef.h), let's take another look at the source code: clang-2.8/tools/libclang/CIndexer.cpp:67 Here clang takes the address of the .so file, which has the function 'clang_createTranslationUnit', and on archlinux usually it is: /usr/lib/llvm/libclang.so Then it removes library name, and adds "../bin/clang", which results in a wrong path already: /usr/lib/llvm/../bin/clang In the next few lines of the source code, it firgures out a resource directory using the path we have above, and you can see that here in the source code: clang-2.8/tools/libclang/CIndexer.cpp:82 It removes "bin/clang" part and adds instead "lib/clang/2.8" and we have: /usr/lib/llvm/../lib/clang/2.8 Which then gets transformed into a "/usr/lib/llvm/../lib/clang/2.8/include" and that is the path from an error message of the c-index-test run. The same stuff works fine on my friend's mac machine. I mean, seriously.. the installation is broken. Maybe clang guys have already fixed that mess with resource directory in the SVN trunk, but I haven't checked. And I have no idea how you can fix that either. But changing that way $(PROJ_prefix)/lib to $(PROJ_prefix)/lib/llvm is not a good idea. |
This task depends upon
Closed by Evangelos Foutras (foutrelis)
Friday, 11 February 2011, 15:55 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in clang 2.8-5.
Friday, 11 February 2011, 15:55 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in clang 2.8-5.
clang-2.8/tools/libclang/CIndexer.cpp:71
Should be:
// We now have the CIndex directory, locate clang relative to it.
CIndexPath.eraseComponent();
CIndexPath.appendComponent("..");
CIndexPath.appendComponent("..");
CIndexPath.appendComponent("bin");
CIndexPath.appendComponent("clang");
Because CIndexPath on arch is: /usr/lib/llvm/libclang.so
For now I've just tweaked the path in a similar way to the one you suggested.
Could you please grab {llvm,clang}-2.8-5 from [community-testing] and test if that works fine for you?
[1] http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexer.cpp?view=markup