[cfe-dev] How can I tell clang to use (link to) a specific libc++ shared library?

Steven Lu stevenlu443 at gmail.com
Thu Sep 18 16:38:43 PDT 2014


Thanks Jon, this is starting to make more sense now. This must mean that on
Darwin, a -lc++ is just automatically added to the args for all
compilations! This naturally grabs /usr/lib/libc++.dylib.

The digging I did that resulted in otool -L showing a dependency on
libc++.dylib must then in fact be due to simply using Apple's clang 5.1
(based on 3.4-svn) to build the clang (3.6.0-svn) that I am testing. This
is just a case of clang itself needing to use the C standard library, as it
should in this situation.

So to achieve my goals it would appear that I need to do two things:

1. Install freshly built libcxx to e.g. /opt/foo
2. Somehow coerce clang to look somewhere inside /opt/foo to grab both its
libc++ headers and libc++.dylib

I would hope that configuring a clang build for /opt/foo as sysroot will do
exactly this (where I can conveniently remember that all i need to access
my new clang is to use the one that resides in /opt/foo/bin).

Then I don't even have to patch any code or anything!

On Thu, Sep 18, 2014 at 7:07 PM, Jonathan Roelofs <jonathan at codesourcery.com
> wrote:

>
>
> On 9/18/14 4:13 PM, Steven Lu wrote:
>
>> Hi all,
>>
>>
>> My follow-up question to this is: Can you show me where it is hardcoded?
>>
> See clang/lib/Driver/ToolChains.cpp. A specific example is around line
> 600 in `void DarwinClang::AddCXXStdlibLibArgs()`
>
> If you want to install your own, the best bet is to make a separate
> sysroot (in, say, /opt/foo), and install it there. Installing in the root
> directory, as you say, is pretty dangerous on OSX.
>
>
> Cheers,
>
> Jon
>
>>
>> Thanks
>> Steven
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
> --
> Jon Roelofs
> jonathan at codesourcery.com
> CodeSourcery / Mentor Embedded
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140918/3d4c355b/attachment.html>


More information about the cfe-dev mailing list