Apologies in advance if this is not the appropriate mailing list.
I am struggling with a bit of confusion over some things.
I have a very long-winded question posted here (http://stackoverflow.com/questions/25920130) which essentially boils down to one basic question.
When compiling clang from source, how do I specify to it where it should fetch the libc++ library from?
I am talking about libc++.dylib (or whatever it is symlinked to) on OS X/BSD or libc++.so on Linux. This is the component of the libc++ library that has to be linked in order to work with the libc++ headers, in order to actually compile any C++ that uses the standard library, which is after all, most of the reasons to use C++ to begin with.
One possible answer is that this cannot be done, and that it is hardcoded.
My follow-up question to this is: Can you show me where it is hardcoded? I have grepped the entire clang project and strangely enough, I have seen no files in clang/llvm’s source code (aside from cmake/make/buildit files inside of the libcxx project) that reference “/usr/lib/libc++.1.dylib”.
However, I have also looked at the generated clang++ executable (whose size is 50504624 bytes) at strings inside, and found that the string “/usr/lib/libc++.1.dylib” exists at offset 2184. A more useful check yields this:
$ otool -L Release+Asserts/bin/clang
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
This leaves me puzzled because I see no straightforward code, whether in clang’s build configuration files, or in clang’s source code, that determines that it shall link /usr/lib/libc++.1.dylib, and yet there it is.
This issue does not crop up on Linux because Linux does not come with clang as part of the system. Therefore the clang install process will properly handle the library and install it where it needs to go, which I will be surprised if it turns out to be anything other than /usr/lib/.
The problem on OS X is that the OS will break if the system’s /usr/lib/libc++.1.dylib is tampered with, so I want to specify it separately so that the system continues using that one provided by Apple, and I can specify explicitly for my svn-built clang where it should go to grab its corresponding svn-built libc++ shared library.
I guess I also must mention the distinct possibility that I am getting all worked up over nothing, as would be the case if building libc++/libcxx from source yields the exact same library as the one my system already has.
However, this also is not clear:
$ cd ~/Documents/llvm/
$ diff /usr/lib/libc++.1.dylib projects/libcxx/build/lib/libc++.1.0.dylib
Binary files /usr/lib/libc++.1.dylib and projects/libcxx/build/lib/libc++.1.0.dylib differ
$ ls -la /usr/lib/libc++.1.dylib projects/libcxx/build/lib/libc++.1.0.dylib
-rwxr-xr-x 1 root wheel 1405296 Mar 17 2014 /usr/lib/libc++.1.dylib
-rwxr-xr-x 1 steven staff 1688180 Sep 18 15:55 projects/libcxx/build/lib/libc++.1.0.dylib
I hope someone can shed a little light on this.