Clang Plugin Xcode headaches


Recently I have been writing a plugin for the Clang C/C++ compiler in order to generate code just before compile time.

This has been going fairly smoothly until I decided to create an Xcode project to allow easier breakpoint debugging with gdb.

Setting up the compiler flags was fairly straightforward, the main problems came from the linking stage.

Using the exact same linking flags as the working build script Xcode kept complaining about undefined functions such as “raw_fd_ostream” in the llvm library.

It turns out that there is an easy fix but it wasn’t clear where to look. For anyone else experiencing the same issue make sure to set the standard library settings in XCode to “Compiler Default” like so:

This will allow any clang plugins you are developing to compile and link succesfully :)

It is such a simple solution now but I was so sure that it was a problem in the internals of my LLVM build process that I managed to spend a whole morning getting very frustrated modifying the LLVM libraries when all I needed to do was Change those compiler settings!!

Table of Contents