Undefined LLVM reference when loading Clang Static Analyzer plugin

Hi,

We have a Clang Static Analyzer plugin that registers a bunch of custom checkers. We’re using LLVM and Clang 3.3.

Clang 3.3 is able to compile, and the Static Analyzer also runs without our plugin being loaded.

On one of our test machines (a Suse Linux 11), trying to load our plugin fails:

clang++ -cc1 -load lib-checkers.so
error: unable to load plugin ‘lib-checkers.so’: ‘lib-checkers.so: undefined symbol: _ZTIN4llvm18RefCountedBaseVPTRE’

Our plugin does not use llvm::RefCountedBaseVPTR, although it does make direct use of some LLVM types, such as llvm::Optional, llvm::DenseMap and so on.

When building our plugin, we do not link against any LLVM or Clang libraries, except for clangASTMatchers. We also tried linking against them, but it doesn’t seem to make any difference.

Both Clang and the plugin are built with the same compiler and on the same system.

As far as we can determine, this issue only appears when trying to load our plugin, and Clang is able to function perfectly when we don’t try to load it.

Any idea on what could be the issue? We’re totally clueless here.

Thanks!

Running this through c++filt shows that it’s a typeinfo object. I’m still not sure why you’d have a reference to it, but perhaps your plugin is being compiled with -frtti instead of -fno-rtti?

Jordan

Hi Gabor,

I was planning on reporting the following issue (or caveat) for some
time. This might explain your problem.

After installing clang in release mode (for me ./configure
--disable-assertions --enable-optimized), the installed binary of
clang cannot load plugins any more. One needs to copy the original
binary manually and strip it with option -x (or not at all).

Failing to do so gives an error comparable to the one you report.

Hoping this helps,

Hi all,

Thank you for the answers.

I’m still not sure why you’d have a reference to it, but perhaps your plugin is being compiled with -frtti instead of -fno-rtti?

We usually build our plugin using flags we get from llvm-config --cxxflags --ldflags, etc. However, on this particular server, this didn’t work for some reason, so we provided the args manually. I’ll check whether we indeed missed -fno-rtti. Thanks for the tip!

After installing clang in release mode (for me ./configure --disable-assertions --enable-optimized), the installed binary of clang cannot load plugins any more. One needs to copy the original binary manually and strip it with option -x (or not at all).

We are not actually installing the binary, just building it. The test machine is a server environment where we don’t have (i.e. cannot expect to) have root access.

Thanks for mentioning it though, it’s again something we have to watch out for.

Thanks Jordan, you were correct. Somehow llvm-config --cxxflags didn’t include the -fno-rtti flag.