[SERVER-10644] MongoDB not able to build from source on OS X Mavericks due to missing Boost header file Created: 29/Aug/13 Updated: 10/Dec/14 Resolved: 05/Sep/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Build |
| Affects Version/s: | 2.4.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | George Thiruvathukal | Assignee: | Eric Milkie |
| Resolution: | Done | Votes: | 0 |
| Labels: | clang | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
$ uname -a |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Operating System: | OS X | ||||||||
| Steps To Reproduce: | Just run scons all |
||||||||
| Participants: | |||||||||
| Description |
|
During build, compilations fails due to the inability to find the <tr1/unordered_map> header file:
|
| Comments |
| Comment by Andrew Morrow (Inactive) [ 27/Oct/13 ] | ||||||||||||||||||||||||||
|
Slava A similar fix has been committed on the master branch: https://github.com/mongodb/mongo/commit/c70a72b151fcfab26d0db5e8ceeb7c04a96ce449 | ||||||||||||||||||||||||||
| Comment by Slava Bacherikov [X] [ 27/Oct/13 ] | ||||||||||||||||||||||||||
|
This patch solve an issue on OS X Mavericks. | ||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 07/Oct/13 ] | ||||||||||||||||||||||||||
|
mistydemeo Also, thanks for the suggestion on _LIBCPP_VERSION. I think we may use that to tackle | ||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 07/Oct/13 ] | ||||||||||||||||||||||||||
|
Hi Misty - The work to support libc++ and clang is complete, but it all took place on master after the 2.4 branch was created, and it is extremely unlikely that we would backport that work to the 2.4 branch. You may be right that some small targeted patches against 2.4 would get it working under XCode 5 (I suspect that asking it to use libstdc++ by adding --stdlib=libstdc++ to CXXFLAGS in the Sconstruct file is the easiest way), but those patches would need to be carried along in brew/macports. The other important changes were mostly related to suppressing certain clang warnings if I remember correctly. The expectation is that MongoDB 2.6 will work with clang and libc++ out of the box. As far as linking goes, it is true that linking with libstdc++ would make us ABI incompatible, but for the servers and tools this would not be an issue since nothing should be linking against those. The client driver is a separate issue, obviously. | ||||||||||||||||||||||||||
| Comment by Misty De Meo [ 07/Oct/13 ] | ||||||||||||||||||||||||||
|
To provide a little more detail here... clang supports two different C++ standard libraries - libstdc+, the GCC-based C+ stdlib that's traditionally been the default (also the same C++ stdlib used by Apple's GCC 4.2 and LLVM-GCC 4.2); and libc+, a newer C+ stdlib that originated in the LLVM project. The two stdlibs have been shipped with clang for a number of versions now, and are selectable using the `-stdlib=` switch, e.g. `-stdlib=libc++`. Starting with 10.9, the default C++ stdlib is now libc+. There are a few differences between them, which is the cause of the problem here. In this case, the issue is that libc+ doesn't include the tr1-prefixed parts of the C++ stdlib, only the C++11-standardized versions of those same additions. libc++ and libstdc++ aren't compatible, so I wouldn't recommend mixing headers from both like the proposed solution here is doing. Instead, the best solutions would be to:
| ||||||||||||||||||||||||||
| Comment by Eric Milkie [ 05/Sep/13 ] | ||||||||||||||||||||||||||
|
George, it looks like compiling with the Developer Preview version of XCode that comes with Mavericks works with MongoDB version 2.5.2. I don't think there's anything further for us to do here. | ||||||||||||||||||||||||||
| Comment by Eric Milkie [ 03/Sep/13 ] | ||||||||||||||||||||||||||
|
Ah that would be it. | ||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 03/Sep/13 ] | ||||||||||||||||||||||||||
|
On master we add -Wno-unused-private-fields if supported: https://github.com/mongodb/mongo/blob/master/SConstruct#L1063. | ||||||||||||||||||||||||||
| Comment by Eric Milkie [ 03/Sep/13 ] | ||||||||||||||||||||||||||
|
The unordered_map header does generate a lot of warnings, but my 2.4 build gets a lot further by using --cpppath=<etc>
I haven't determined why we don't have this problem on master branch. | ||||||||||||||||||||||||||
| Comment by Eric Milkie [ 03/Sep/13 ] | ||||||||||||||||||||||||||
|
I discovered that you can easily see which directories are being searched for the include path by using "-v":
So despite being configured with --with-gxx-include-dir=/usr/include/c++/4.2.1, you apparently must still manually tell the compiler to amend its include path. To diagnose why scons' config stage isn't finding a boost header, look in .scons/<platform>/config.log to see why the test file didn't compile. | ||||||||||||||||||||||||||
| Comment by George Thiruvathukal [ 30/Aug/13 ] | ||||||||||||||||||||||||||
|
Oh, yeah, this is very interesting. The executables are 'technically' different - but not very different:
And clang fails as well to compile the test code:
| ||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 29/Aug/13 ] | ||||||||||||||||||||||||||
|
Very interesting.
I'll need to sit down with a Mavericks + XCode 5 setup to explore further, but my quick analysis is that there is some sort of Apple side bug related to the 'fake' g++ not correctly searching for tr1 headers in the configured 'gxx-include-dir'. That example program you tested out really needs to work. That may need to be reported upstream. However, even if you were able to get past that issue, I think the bigger problem you face is that mongodb 2.4 offers incomplete support for clang, so I'd expect that you will run into other problems if you get past this. However, you should be able to build mongodb 2.4 on an older platform and run it on Mavericks, assuming the system dependencies are met. Please note that we are working on improved clang support in the 2.5 development release of mongodb. However, I'm not aware of Mavericks support currently being an explicit release goal for 2.6. | ||||||||||||||||||||||||||
| Comment by George Thiruvathukal [ 29/Aug/13 ] | ||||||||||||||||||||||||||
|
Sure. Here's clang:
| ||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 29/Aug/13 ] | ||||||||||||||||||||||||||
|
I think we are getting somewhere now. Your 'g++' isn't GCC: it is clang. Can you verify by seeing what the output of 'clang --version' is? I bet it is identical to what you get for 'g++ --version'. | ||||||||||||||||||||||||||
| Comment by George Thiruvathukal [ 29/Aug/13 ] | ||||||||||||||||||||||||||
|
Yes, g++ does compile the test code when specifying the include path:
Here's the version info:
And one additional fun fact:
| ||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 29/Aug/13 ] | ||||||||||||||||||||||||||
|
Can your g++ compile a simple test file containing:
Can you also provide the output of 'g++ --version'? | ||||||||||||||||||||||||||
| Comment by George Thiruvathukal [ 29/Aug/13 ] | ||||||||||||||||||||||||||
|
Sure can. Here you go, Andrew:
| ||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 29/Aug/13 ] | ||||||||||||||||||||||||||
|
On my Mountain Lion machine, I find GCC's tr1/unordered_map to exist as /usr/include/c++/4.2.1/tr1/unordered_map, provided by package com.apple.pkg.DevSDK:
Unfortunately I don't have a Mavericks machine handy to test with right now. Can you check what unordered_map files are available on your machine and post the list back here? Thanks, |