mozilla / dxr

DEPRECATED - Powerful search for large codebases
https://dxr.readthedocs.org/
Other
811 stars 203 forks source link

Undefined symbol clang::~PPCallbacks in libclang-index-plugin.so #131

Closed kraptr closed 2 years ago

kraptr commented 11 years ago

When I try to make in the tests/test_basic directory, the compilation of the hello world program fails with this error.

I am building on a local machine, using the virtualenv. I updated the makefiles in the dxr/plugins/clang/ directory to point to the clang header files directories. I also tried a few things, like explicitly linking libclang-index-plugin.so with -lclang but I continue to see this error.

Please note, the symbol name above in the Title is the demangled name of the symbol.

Any help would be appreciated. Thanks!

erikrose commented 11 years ago

What version of LLVM and clang are you using? dxr is known to work with 3.2 and to not work with 3.1 or 3.3.

kraptr commented 11 years ago

Yes, I am using the 3.2 version for both LLVM and Clang.

kraptr commented 11 years ago

The exact failure log from the make in tests/test_basic:

Build command for 'code' failed, exited non-zero! Log follows: | make[1]: Entering directory /home/lokeshk/oss/dxr/tests/test_basic/code' | rm -rf code | make[1]: Leaving directory/home/lokeshk/oss/dxr/tests/test_basic/code' | make[1]: Entering directory /home/lokeshk/oss/dxr/tests/test_basic/code' | clang++ -Xclang -load -Xclang /home/lokeshk/oss/dxr/dxr/plugins/clang/libclang-index-plugin.so -Xclang -add-plugin -Xclang dxr-index -Xclang -plugin-arg-dxr-index -Xclang /home/lokeshk/oss/dxr/tests/test_basic/code -o code main.cc | error: unable to load plugin '/home/lokeshk/oss/dxr/dxr/plugins/clang/libclang-index-plugin.so': '/home/lokeshk/oss/dxr/dxr/plugins/clang/libclang-index-plugin.so: undefined symbol: _ZTIN5clang11PPCallbacksE' | make[1]: *** [code] Error 1 | make[1]: Leaving directory/home/lokeshk/oss/dxr/tests/test_basic/code'

sanirudh commented 10 years ago

The headers you include might belong to a previous/later version of clang. Make sure that the clang headers in the include paths (/usr/local/include/ etc) are from version 3.2

xsyr commented 10 years ago

Hi, I saw a commit said "Add support for clang 3.4.", and it still doesn't work with Clang 3.4.

~/src/dxr/tests/test_basic$ make

# Link paths in dxr.config.in to current working directory # replaces PWD with pwd and produces dxr.config cat dxr.config.in | sed -e 's?PWD?'pwd'?g' > dxr.config # Navigate into the DXR folder, build using config file LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../trilite dxr-build.py Generating target folder Creating tables Indexing files from the 'code' tree (finished in 0:00:00.055884) Building the 'code' tree Build command for 'code' failed, exited non-zero. Log follows: | make[1]: Entering directory/home/xsyr/src/dxr/tests/test_basic/code' | rm -rf code | make[1]: Leaving directory /home/xsyr/src/dxr/tests/test_basic/code' | make[1]: Entering directory/home/xsyr/src/dxr/tests/test_basic/code' | clang++ -Xclang -load -Xclang /home/xsyr/src/dxr/dxr/plugins/clang/libclang-index-plugin.so -Xclang -add-plugin -Xclang dxr-index -Xclang -plugin-arg-dxr-index -Xclang /home/xsyr/src/dxr/tests/test_basic/code -o code main.c | clang-3.4: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated | error: unable to load plugin '/home/xsyr/src/dxr/dxr/plugins/clang/libclang-index-plugin.so': '/home/xsyr/src/dxr/dxr/plugins/clang/libclang-index-plugin.so: undefined symbol: _ZTIN5clang11PPCallbacksE' | make[1]: *\ [code] Error 1 | make[1]: Leaving directory `/home/xsyr/src/dxr/tests/test_basic/code'

make: *\ [all] Error 1

erikrose commented 10 years ago

I noticed that as well the other day when I tried to upgrade the OS on the Vagrant box to Saucy. I should have filed it then; you folks really keep me on my toes. :-) I thought we had tried 3.4, but apparently we did not. @abbeyj?

abbeyj commented 10 years ago

I'm using 3.4 built from source with no issues. Are you sure your headers and binaries match? Perhaps you have v3.2 headers and v3.4 binaries or something? What's the output from the following? which llvm-config which clang++ llvm-config --version clang++ --version llvm-config --includedir cat $(llvm-config --includedir)/clang/Basic/Version.inc grep LLVM_VERSION $(llvm-config --includedir)/llvm/Config/config.h

On Mon, Feb 10, 2014 at 11:29 AM, Erik Rose notifications@github.comwrote:

I noticed that as well the other day when I tried to upgrade the OS on the Vagrant box to Saucy. I should have filed it then; you folks really keep me on my toes. :-) I thought we had tried 3.4, but apparently we did not. @abbeyj https://github.com/abbeyj?

Reply to this email directly or view it on GitHubhttps://github.com/mozilla/dxr/issues/131#issuecomment-34651062 .

erikrose commented 10 years ago

It's possible I hadn't linked llvm-config to the llvm-config-3.4 at the time. I don't have that box around anymore. Let's see what Chenglin says.

xsyr commented 10 years ago

The error mean the symbol _ZTIN5clang11PPCallbacksE can not be found when load libclang-index-plugin.so, it declare in clang/Lex/Lexer.h. But it isn't exported by clang or libclangLex.a.

My machine: Linux xsyr-ubuntu 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

gcc 4.8.1 clang 3.4 build from source

which llvm-config: /usr/bin/llvm-config

which clang++: /usr/bin/clang++

llvm-config --version: 3.4svn

clang++ --version: clang version 3.4 (201150) Target: x86_64-unknown-linux-gnu Thread model: posix

llvm-config --includedir: /usr/include

cat $(llvm-config --includedir)/clang/Basic/Version.inc:

#define CLANG_VERSION 3.4
#define CLANG_VERSION_MAJOR 3
#define CLANG_VERSION_MINOR 4
#if 0
#define CLANG_VERSION_PATCHLEVEL 
#endif

grep LLVM_VERSION $(llvm-config --includedir)/llvm/Config/config.h:

#define LLVM_VERSION_MAJOR 3
#define LLVM_VERSION_MINOR 4
abbeyj commented 10 years ago

_ZTIN5clang11PPCallbacksE demangles to "typeinfo for clang::PPCallbacks" but the plugin should have been compiled with -fno-rtti and not be dependent on typeinfos. What does "llvm-config --cxxflags" produce for you? If you run "make clean" and then "make" in the dxr/dxr/plugins/clang/ directory can you capture the command being used to compile dxr-index.cpp?

On Tue, Feb 11, 2014 at 10:58 AM, Chenglin Huang notifications@github.comwrote:

The error mean the symbol _ZTIN5clang11PPCallbacksE can not be found when load libclang-index-plugin.so, it declare in clang/Lex/Lexer.h. But it isn't exported by clang or libclangLex.a.

My machine: Linux xsyr-ubuntu 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

gcc 4.8.1 clang 3.4 build from source

which llvm-config: /usr/bin/llvm-config

which clang++: /usr/bin/clang++

llvm-config --version: 3.4svn

clang++ --version: clang version 3.4 (201150) Target: x86_64-unknown-linux-gnu Thread model: posix

llvm-config --includedir: /usr/include

cat $(llvm-config --includedir)/clang/Basic/Version.inc:

define CLANG_VERSION 3.4#define CLANG_VERSION_MAJOR 3#define CLANG_VERSION_MINOR 4#if 0#define CLANG_VERSION_PATCHLEVEL #endif

grep LLVM_VERSION $(llvm-config --includedir)/llvm/Config/config.h:

define LLVM_VERSION_MAJOR 3#define LLVM_VERSION_MINOR 4

Reply to this email directly or view it on GitHubhttps://github.com/mozilla/dxr/issues/131#issuecomment-34768288 .

xsyr commented 10 years ago

@abbeyj You are right, after add -fno-rtti option, everything works fine. Thanks.

abbeyj commented 10 years ago

Thanks for confirming that that worked. It should have been picked up automatically though. Would you consider posting the output from "llvm-config --cxxflags" and from running "make clean; make" so we can try to track down what went wrong and avoid this problem for other people in the future?

On Wed, Feb 12, 2014 at 6:11 AM, Chenglin Huang notifications@github.comwrote:

@abbeyj https://github.com/abbeyj You are right, after add -fno-rttioption, everything works fine. Thanks.

Reply to this email directly or view it on GitHubhttps://github.com/mozilla/dxr/issues/131#issuecomment-34859090 .

xsyr commented 10 years ago

$ llvm-config --cxxflags -I/usr/include -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wnon-virtual-dtor -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS