[cfe-dev] Using Clang plugins with release version of clang on OS X

Jonathan 'Rynn' Sauer jonathan.sauer at gmx.de
Sun Jun 29 23:51:49 PDT 2014


Hello,

>> On 30 Jun 2014, at 04:04, Alp Toker <alp at nuanti.com> wrote:
>> 
>> clang plugins will in fact only load and run properly in the exact same build configuration and source tree version (SVN revision+patches) of LLVM and clang. The compiler used to build either also needs to match, so that's unlikely to ever work.
> 
> Thanks for this information, it would have saved me hours if I knew it earlier. Could this limitation be mentioned on the Clang Tooling page so that people know that plugins aren't suitable for use cases like mine?
> 
> I'll look into other options. Thanks again.

One of those options might be to replace Xcode's clang. For me the following works (after making a backup
of the original files of course ;-):

Replace clang's executables/libraries (libclang must be replaced because recent clang versions changed
the serialization scheme for error messages, so with Xcode's libclang Xcode cannot read clang's output
anymore):

	/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
	/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib

Not sure if this one needs to be replaced:

	/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib


Optionally replace the libc++ headers:

	/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1


Copy clang's header and runtime support libraries to:

	/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/<version>


Please note that after doing this MacPorts will no longer work, as the version schemes of Xcode's clang and
LLVM's clang differ, so MacPorts fails to recognize it. I just temporarily switch back to Xcode's original
clang (executable is enough) to work around this.


HTH,
Jonathan





More information about the cfe-dev mailing list