[LLVMdev] Compiling whole programs to bitcode

Russell Wallace russell.wallace at gmail.com
Fri Jun 3 21:43:38 PDT 2011


On Sat, Jun 4, 2011 at 5:39 AM, Nick Lewycky <nicholas at mxc.ca> wrote:
> If a program uses a templated function from a C++ library, either the C++
> library provides an implementation of the template instantiated to that
> type, or else the whole implementation was available in the header and ends
> up in the TU of the program, not the library ((or else you'd get a link
> error when building normally)).

Ah, but that's not the case, not with modern C++ compilers - it is
perfectly possible for a templated function to be declared in a
header, defined in a .cc file, called on a user-defined type, and
nonetheless instantiated on the fly. Of course that indeed wouldn't
work in the simple C linkage model, which is why modern C++ compilers
use one or another sort of black magic behind the scenes to deal with
it. Is it documented how Clang deals with it?



More information about the llvm-dev mailing list