Building VST3 with Clang/VS on Windows

Has anyone got to build a VST3 plugin with Clang and Visual Studio on Windows? I can’t get it to make the DLL. It makes the standalone alright, doesn’t give any error (though it does give a lot of warnings for the VST SDK, mainly for pragma packs), then generates a tiny VST3 file that doesn’t work. It seems like a link issue, because the shared code is compiled right and also the obj for the VST client. I’ve tried changing options here and there and nothing seems to work… Any idea?

Well, I still can’t build the DLL with Clang but I got it to build the shared code lib, which is the part I cared about, and then do the rest with MSVC. Apart from setting the toolset, I had to disable link time code generation in the librarian (it doesn’t ignore it and fails), and enable extensions in the compiler with -mavx and -mfma (that’s what I use). Also, I replaced these lines in juce_PlatformDefs.h

#if JUCE_MSVC
 #define JUCE_CALLTYPE   __stdcall
 #define JUCE_CDECL      __cdecl
#else
 #define JUCE_CALLTYPE
 #define JUCE_CDECL
#endif

with

#if JUCE_MSVC || JUCE_CLANG
 #define JUCE_CALLTYPE __stdcall
#else
 #define JUCE_CALLTYPE
#endif

#if JUCE_MSVC
 #define JUCE_CDECL __cdecl
#else
 #define JUCE_CDECL
#endif

otherwise it fails to link for x86 (Clang compiles with cdecl what the VST code compiled by MSVC expects to be stdcall).

I cared about this because I get a ~15% boost in audio thread performance with Clang after amalgamating all my processing code. Without that, MSVC is usually faster by <5% -I guess LTCG makes the difference there.

1 Like