Alan Garny
2015-Mar-10 12:20 UTC
[LLVMdev] LLVM 3.6: problems building on Windows using MSVC 2013
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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150310/56e71c4a/attachment.html>
Hans Wennborg
2015-Mar-10 16:05 UTC
[LLVMdev] LLVM 3.6: problems building on Windows using MSVC 2013
On Tue, Mar 10, 2015 at 5:20 AM, Alan Garny <agarny at hellix.com> wrote:> 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?It looks like MSVC is trying to synthesize and export the copy assignment operator and copy constructur. This is interesting, as I thought it wouldn't do that if the class turns out not to be non-copyable. Does adding the following to the class (and similarly for others that are failing) work? Compilation& operator=(Compilation&) = delete; Compilation(Compilation&) = delete - Hans
Alan Garny
2015-Mar-10 16:14 UTC
[LLVMdev] LLVM 3.6: problems building on Windows using MSVC 2013
> > 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? > > It looks like MSVC is trying to synthesize and export the copy assignment > operator and copy constructur. This is interesting, as I thought it wouldn't do > that if the class turns out not to be non-copyable. > > Does adding the following to the class (and similarly for others that are > failing) work? > > Compilation& operator=(Compilation&) = delete; > Compilation(Compilation&) = deleteGood timing. This is the conclusion and solution to which I came too. I have tried it on my test case and it is working fine. I am now going to try it on my project and see how it goes, but at least that seems promising. Alan
Seemingly Similar Threads
- [LLVMdev] LLVM 3.6: problems building on Windows using MSVC 2013
- [LLVMdev] LLVM 3.6: problems building on Windows using MSVC 2013
- [LLVMdev] LLVM 3.6: problems building on Windows using MSVC 2013
- [LLVMdev] Workaround for Bug 22963?
- [LLVMdev] Building LLVM as a shared library using Visual C++ 2010?