[cfe-dev] how to build llvm 3.4 to use system libc++ on darwin13?

Jack Howarth howarth at bromo.med.uc.edu
Tue Nov 19 08:55:31 PST 2013


On Tue, Nov 19, 2013 at 12:22:00AM -0500, Rafael EspĂ­ndola wrote:
> The current design is for clang to use a libc++ installed with it. You
> should be able to do that by just checking out libc++ into
> llvm/projects.

Building as...

mv ../clang-3.4 tools/clang
mv ../compiler-rt-3.4 projects/compiler-rt
mv ../libcxx-3.4 projects/libcxx
mv ../test-suite-3.4 projects/test-suite
mv ../polly-3.4 tools/polly
mkdir build
pushd build
cmake -DLLVM_BUILD_32_BITS:BOOL=OFF -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_INSTALL_PREFIX=/sw/opt/llvm-3.4 -DLLVM_ENABLE_ASSERTIONS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT:STRING=/ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="" -DCLOOG_FIND_REQUIRED=0 ..
make -j 16
make install

produces a /sw/opt/llvm-3.4/bin/clang++ compiler that defaults to libstdc++ on darwin12 and
that defaults to libc++ on darwin13 as expected. However, while the build installed a set of
/sw/opt/llvm-3.4/lib/libc++.1.0.dylib, /sw/opt/llvm-3.4/lib/libc++.1.dylib and
/sw/opt/llvm-3.4/lib/libc++.dylib files, the -stdlib=libc++ option in both cases
linked to the system /usr/lib/libc++.1.dylib.
    While I assume that this is the intended behavior, isn't there a risk of dissociating
the headers used by the llvm 3.4 clang++ compiler, which a quick test with --save-temps shows
to be from /sw/opt/llvm-3.4/bin/../include/c++/v1/, from the newer libc++ shared library?
While this might not be an issue with darwin13, which has a much newer system libc++ shared
library (current version 120.0.0), it seems much more dangerous with darwin12's libc++ 
(current version 65.1.0). Does clang++ have a flag to override the default location for
the libc++ shared library so that the llvm 3.4 copy can be used?
        Jack

with gnu make 4.0. 
> 
> On 18 November 2013 20:55, Jack Howarth <howarth at bromo.med.uc.edu> wrote:
> >     Currently on darwin12 and earlier, the cmake buld of llvm/compiler-rt/clang defaults
> > to use the system libstdc++ c++ headers for the clang++ compiler. Is it possible to
> > build llvm 3.4 on darwin13 so that the default behavior is to use -stdlib=libc++ and
> > to use the same libc++ c++ headers that the sytem clang++ compiler from Xcode uses?
> > Thanks in advance for any advice on this issue.
> >          Jack
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list