[cfe-dev] Compiling clang on Mac OS is not straight forward

Eric Fiselier via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 12 06:07:50 PDT 2016


If you just upgraded to 10.12 then you need to re-run it.

/Eric

On Wed, Oct 12, 2016 at 6:56 AM, Sebastian Biallas <sb at biallas.net> wrote:

> Hi Eric,
>
> I’m pretty sure that I have the xcode command line tools installed (I
> already have a gcc/clang installed and I guess this is also where svn comes
> from).
>
> But I just noticed that my cmake comes from brew, so maybe my cmake doing
> something wrong here.
>
> Best
> Sebastian
>
> > Am 12.10.2016 um 13:32 schrieb Eric Fiselier <eric at efcs.ca>:
> >
> > The easiest way to get everything working it to install the XCode
> Command line tools using `xcode-select --install`.
> >
> > Then everything should work.
> >
> > /Eric
> >
> > On Wed, Oct 12, 2016 at 5:17 AM, Sebastian Biallas via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> > Hi all,
> >
> > I’m compiling clang (in particular clang-check) from source on Mac OS.
> Getting it to actually work, however, was a bit involved on my system. See
> below for what I did (and where either I did something work or the
> instructions could be improved).
> >
> > I used qtcreator to run cmake and compile, which seems to work fine
> except that the resulting clang has some problems finding the required
> headers to parse anything non-trivial. It does not find, e.g., <vector>.
> >
> > Ok, so according to the "getting started" page I apparently have to set
> GCC_INSTALL_PREFIX to point to these headers. I seems that the C++ headers
> are located somewhere around /Applications/Xcode.app/
> Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/ on my system.
> This is at least where gcc (which actually is an apple-flavored clang)
> picks them up.
> >
> > Anyway, I tried to set this (with and without /bin/ at the end),
> recompiled, but it did not seem to affect clang in any way. But it also did
> not complain.
> >
> > Then I saw that the resulting clang tries to find the C++ headers first
> in its build directory. So I put a symbolic link there to the C++ headers
> on my system. Then it could find <vector> but not <string.h> (which is
> transitively included by vector).
> >
> > Next thing I tried is, I gathered all the search directories of my
> compiler using:
> > g++ -E -x c++ - -v < /dev/null
> >
> > Then, in an act of brute force, added all these directories to
> C_INCLUDE_DIRS for clang. This now at least had an effect, but still did
> not work:
> >
> > /Users/biallas/prog/build-llvm-Desktop-Vorgabe/bin/../include/c++/v1/cstdint:175:8:
> error: no member named
> >       'int_fast32_t' in the global namespace
> > using::int_fast32_t;
> >
> > At this point, I thought that maybe my system C++ headers are too old or
> not compatible with the newest clang. So I checked out libstdc++ as well
> and put it into the project directory. I removed my custom flags and
> recompiled.
> >
> > The resulting clang now spills out the following (slightly amusing)
> message:
> >
> > $ /Users/biallas/prog/build-llvm-Desktop-Vorgabe/bin/clang -c move.cc
> > In file included from move.cc:1:
> > In file included from /Users/biallas/prog/build-
> llvm-Desktop-Vorgabe/bin/../include/c++/v1/vector:265:
> > In file included from /Users/biallas/prog/build-
> llvm-Desktop-Vorgabe/bin/../include/c++/v1/iosfwd:90:
> > /Users/biallas/prog/build-llvm-Desktop-Vorgabe/bin/../include/c++/v1/wchar.h:119:15:
> fatal error:
> >       'wchar.h' file not found
> > #include_next <wchar.h>
> >
> > Hmm… So maybe it’s now finding the correct C++ stuff but the C stuff is
> still broken. I set C_INCLUDE_DIRS to
> > /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include (because this
> is where gcc picks the C stuff up) and, Eureka!, it finally works.
> >
> > My question now is: Isn’t C_INCLUDE_DIRS supposed to be set
> automatically? At some point either I messed up or the build script could
> be improved.
> >
> > My system is a pretty standard Mac OS 10.12. The only thing that might
> confuse is a clang-format installed using brew.
> >
> > Best,
> > Sebastian
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161012/74a19bb1/attachment.html>


More information about the cfe-dev mailing list