Ok, I have just found the cause of the error messages I am getting, and it now makes sense to me why the ‘normal’ build works fine on Windows, Linux and OS X, and why my personal build works on Linux and OS X, but not on Windows. However, I still don’t understand why I am getting the error messages I am getting.
Anyway, it has to do with wanting to export some classes and function, including clang::driver::Compilation. Now, since the export/import of classes/function is not supported by the LLVM+Clang project (incidentally, I really wish it was!), I had to modify the definition of the classes and functions that I need in order to have something like:
class LLVM_EXPORT Compilation { … };
rather than
class Compilation { … };
with LLVM_EXPORT being defined as:
#ifdef _WIN32
#ifdef BUILD_LLVM
#define LLVM_EXPORT __declspec(dllexport)
#else
#define LLVM_EXPORT __declspec(dllimport)
#endif
#else
#define LLVM_EXPORT
#endif
Now, as I mentioned before, that approach works fine up to LLVM+Clang 3.5.1, but it fails with LLVM+Clang 3.6. Not for all the classes/functions that I need to export/import though, only some of them (in Clang, it would seem).
To convince myself, I set up a very simple CMake+Ninja project to build tools/clang/lib/Driver/Compilation.cpp (and nothing else since it’s just for checking) and it builds fine if I have:
class Compilation { … };
but not if I have:
class declspec(dllexport) Compilation { … };
So… my question is: why?! More importantly: what do I need to do to be able to export/import a class such as clang::driver::Compilation?
Cheers, Alan.