[SERVER-14184] Unused preprocessor macros from s2 conflict on OS X Yosemite Created: 06/Jun/14  Updated: 11/Mar/15  Resolved: 19/Sep/14

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 2.6.1
Fix Version/s: 2.6.6, 2.7.7

Type: Bug Priority: Minor - P4
Reporter: Marc Bachmann Assignee: Matt Kangas
Resolution: Done Votes: 0
Labels: community-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Yosemite Developer Preview 1 (14A238x)


Issue Links:
Related
is related to SERVER-14204 Add support to build from source on O... Closed
Backwards Compatibility: Fully Compatible
Operating System: OS X
Backport Completed:
Steps To Reproduce:

1. Install OSX Yosemite
2. Install brew & scons
3. Build mongodb from source

I did an upgrade from Mavericks. So I'm sorry if you can't reproduce this bug. It's probably my mistake.

Sprint: Server 2.7.4, Server 2.7.5, Server 2.7.6
Participants:

 Description   

The file "src/third_party/s2/util/endian/endian.h" is not compatible with the c compiler on Yosemite.

This is the build error I got.

In file included from src/third_party/s2/s2cellid.cc:24:
In file included from src/third_party/s2/strings/strutil.h:62:
src/third_party/s2/util/endian/endian.h:182:9: error: 'htonll' macro redefined [-Werror]
#define htonll(x) ghtonll(x)
        ^
/usr/include/sys/_endian.h:141:9: note: previous definition is here
#define htonll(x)       __DARWIN_OSSwapInt64(x)
        ^
In file included from src/third_party/s2/s2cellid.cc:24:
In file included from src/third_party/s2/strings/strutil.h:62:
src/third_party/s2/util/endian/endian.h:189:9: error: 'ntohll' macro redefined [-Werror]
#define ntohll(x) htonll(x)
        ^
/usr/include/sys/_endian.h:140:9: note: previous definition is here
#define ntohll(x)       __DARWIN_OSSwapInt64(x)
        ^
2 errors generated.
scons: *** [build/darwin/normal/third_party/s2/s2cellid.o] Error 1
scons: building terminated because of errors.

Somehow the last lines (118-189) are the problem. The compilation worked after I’ve removed them. (I couldn’t find a location where those were used anyways)

Here is the version of the compiler I used:

$ g++ --version
Configured with: --prefix=/Applications/Xcode6-Beta.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.34.4) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

How does mongodb handle bugs in third party libraries?
Certainly there is a better solution to this problem.



 Comments   
Comment by Githook User [ 27/Oct/14 ]

Author:

{u'username': u'kangas', u'name': u'Matt Kangas', u'email': u'matt.kangas@mongodb.com'}

Message: SERVER-14184 Remove unused S2 macros that conflict on OS X Yosemite

(cherry picked from commit 759b6e8cabfb745b712b5ffd0748561129c3b421)
Branch: v2.6
https://github.com/mongodb/mongo/commit/8ffd49eda26de47acb766b4094f7aba4ddb7a25d

Comment by Githook User [ 19/Sep/14 ]

Author:

{u'username': u'kangas', u'name': u'Matt Kangas', u'email': u'matt.kangas@mongodb.com'}

Message: SERVER-14184 Remove unused S2 macros that conflict on OS X Yosemite
Branch: master
https://github.com/mongodb/mongo/commit/759b6e8cabfb745b712b5ffd0748561129c3b421

Comment by Adrian Petrescu [ 19/Jun/14 ]

Just for reference, here is what those macros are defined as, in /usr/include/sys/_endian.h in the latest Yosemite/Xcode beta:

#define ntohll(x)       ((__uint64_t)(x))
#define htonll(x)       ((__uint64_t)(x))

Comment by Eric Milkie [ 06/Jun/14 ]

Yes, we can definitely remove those unused macros from endian.h. An easy fix!

Comment by Matt Kangas [ 06/Jun/14 ]

Apparently Yosemite added htonll/ntohll? Mavericks doesn't have the "ll" variants.

"man 3 byteorder" on Mavericks shows
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/htonl.3.html

$ man htonll
No manual entry for htonll

Generated at Thu Feb 08 03:34:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.