SmallVector linking error


#1

Hi,

I recently pulled the last version of master and got a linking error related to SmallVector.

/usr/bin/ld: ../bin/x64/Debug/libbsf.so.1.0.0: undefined reference to `bs::SmallVector<bs::ShaderVariation::Param, 4u>::~SmallVector()'

The examples compile fine, and I saw that the destructor of SmallVector is defined. Any idea what might be happening ?


#2

I am not sure. What compiler and OS is this happening on?


#3

The linking issue appears with clang on linux

clang version 7.0.0 (tags/RELEASE_700/final)
Target: x86_64-pc-linux-gnu

but not with GCC

gcc version 8.2.1 20181127 (GCC) 

I have yet to understand why.


#4

I think I had a similar issue with AppleClang on macOS, and there it seemed to be caused by the fact that this specific instantiation of SmallVector had to be linked into libbsf library, otherwise the plugin libraries would complain about an undefined symbol, even though SmallVector was header only. I assumed it has to do something with inlining and/or visibility but never properly understood the root cause. I’ll let you know when I figure it out.


#5

The issue should be resolved with 9ca81c0d. I haven’t managed to track down the actual reason for why this is happening, it might be an issue in Clang or something in the C++ standard itself. The SmallVector destructor wasn’t being implicitly instantiated when used in the core library, I just forced it though explicit instantiation and that appears to have resolved the issue.


#6

Works great, thanks.