[SERVER-45922] Build failure in overflow_arithmetic.h: constexpr function never produces a constant expression Created: 02/Feb/20 Updated: 29/Oct/23 Resolved: 06/Feb/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Build |
| Affects Version/s: | 4.2.3 |
| Fix Version/s: | 4.2.4, 4.3.4 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ralph Seichter | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Operating System: | ALL | ||||
| Backport Requested: |
v4.2
|
||||
| Steps To Reproduce: |
|
||||
| Sprint: | Dev Platform 2020-02-10 | ||||
| Participants: | |||||
| Description |
|
The attempt to build MongoDB 4.2.3 on macOS 10.14 (High Sierra) fails:
Please also see attached build log and MacPorts ticket 60032 |
| Comments |
| Comment by Githook User [ 06/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Andrew Morrow', 'username': 'acmorrow', 'email': 'acm@mongodb.com'}Message: (cherry picked from commit 98159f8798a3d73878beab634e9ce81784848e8f) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 06/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
mongodb.com@seichter.de - Not a problem. As it turns out, there was a real bug in our build system. We will fix up the minimum so others don't get burned by this too. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ralph Seichter [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for taking the time to explain things to me, and for addressing the underlying issue. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ryan Schmidt [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
And in case my comment earlier caused confusion, when I mentioned blacklisting a compiler I was referring to a feature of MacPorts by which a portfile author can specify Xcode clang versions with which that port will not work. We had been blacklisting clang < 1000 for mongodb. After what we've learned in this ticket, I've updated it to blacklist clang < 1001. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
For all versions of MongoDB, across all the compilers (gcc, clang, Xcode, MSVC) relevant on each of our various platforms, we define in the build system official compiler minima which (should!) match our CI compilers for the branch/platform combination. For the v4.2 branch, that minimum on macOS was originally set at Xcode 10.0. However, at some point we apparently upgraded our CI macOS compilers to Xcode 10.2 but failed to upgrade the enforced compiler minimum to match. Since we were building with Xcode 10.2 we never noticed that v4.2 was broken with Xcode 10.1. I don't happen to have Xcode 10.0 handy to test, but it is also possible that this was a regression in Xcode 10.1 and that Xcode 10.0 would be fine, or it is possible that Xcode 10 is also broken. If you have Xcode 10.0 installed you could easily test it out using my repro above. We set these minima so that users building MongoDB from source don't find themselves building with a toolchain that is definitely not going to work, encountering a build break, and then filing tickets to us that we end up closing as "use a newer compiler". However, we do offer the --disable-minimum-compiler-version-enforcement flag to allow these minima to be ignored in situations where it is warranted. We really don't recommend that though. I'm not sure how good C++17 support is in Xcode 9, and we do no testing of the v4.2 database with it. It is possible that an Xcode 9 build of v4.2 will compile and link but have erroneous runtime behavior. We don't currently have the ability to blacklist specific versions. We just set a minimum. Usually these minima are upgraded in lockstep across all platforms when we do a C++ language standard upgrade which requires a new toolchain to support. MongoDB v4.2 was the first build to require C++17, and we upgraded the compiler minima for MSVC, GCC, clang, and Xcode simultaneously. Adding support for a blacklist would be tacitly claiming support for older compiler versions, but without explicitly testing them, it would be risky. And explicitly testing them would massively expand the amount of testing we need to perform. Regarding clang 9, Xcode 10 appears to be more or less clang 7, not clang 9. To somewhat prove this, the -fsanitize=implicit-integer-sign-change is new in clang 8: https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#undefined-behavior-sanitizer-ubsan Using homebrew clang 7 and clang 8, we can see that clang 7 doesn't know about this flag, but clang 8 does:
If we try this with various Xcode, we get interesting results:
Now what is interesting here is that they both errored out, but Xcode 11 is at least aware of the flag and knows it isn't OK on this target. So, if you consider this experiment valid, Xcode 10 cannot be newer than clang 7 (or, is definitely older than clang 8), and Xcode 11 is at least clang 8, but could be newer. It is incredibly unfortunate that Apple makes it so obscure what the relationship is between Xcode versions and clang versions, but the Xcode versions definitely do not imply the matching clang version. MongoDB definitely does build with clang 9, but it is actually newer than our toolchain of record (clang 7), so we do no testing there either. We will probably upgrade to clang 9 or clang 10 as the minimum sometime during MongoDB 4.6 development. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ralph Seichter [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Andrew, to make sure I understand this approach: Even though MongoDB 4.2.x can be successfully built using clang 9, which I believe to be bundled with Xcode 9, you are planning to change your build checks to actively block any Xcode version < 10.2 ? Why not just exclude the affected Xcode 10.1 ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We will disable support for building with Xcode < 10.2, as it appears that Xcode 10.1 cannot actually build the v4.2 branch. It is not clear whether this is also true on the current master branch, as the code in question has been refactored there. However, it would be somewhat odd to have the master branch compiler minimum be lower than v4.2. So we will land this on master first and backport it to the v4.2 branch. The v4.0 branch only requires Xcode 8, so is not affected. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
OK, I was able to log into one of our macOS 10.14 developer machines that fortunately has both Xcode 10.1 and Xcode 10.2 installed. I can reproduce the error when I build a slightly reduced version of that file with Xcode 10.1, but not with Xcode 10.2:
However, Xcode 10.2 has no problem with it:
Xcode 11.3 is also happy with it:
This suggests that the v4.2 codebase really requires Xcode 10.2, and we should upgrade our check for _apple_build_version_:
However, the current SConscript checks look only to be at or newer than 10001044, which was presumably Xcode 10.0.0. Unfortunately, if we make this change it does mean that MongoDB v4.2 will not be buildable with Xcode on macOS 10.13 or older, since Apple dropped 10.13 support in the minor version bump from Xcode 10.1 to 10.2. Builds for macOS 10.12 are still possible by building with the appropriate -mmacosx-version-min flag, but they will need to be run on a macOS 10.14+ machine using Xcode 10.2+. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ryan Schmidt [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The reporter didn't say. The log attached to the MacPorts ticket says Xcode is not installed. (Presumably, only the command line tools are installed, or else MacPorts is unable to detect the Xcode version for some reason.) Xcode 10.1 is the last version that is compatible with High Sierra. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Do you know what minor and patch version Xcode is failing? Our macOS nightlies use Xcode 10.2.0 and we do not see this error. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ryan Schmidt [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
No, using the MacPorts clang 9 compiler with a working linker works, both on my system and on our buildbot. Using Xcode 10's clang 1000.10.44.4 does not work, per the user's log. I don't believe questions about the linker are relevant here; the error comes from the compiler. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I don't think it is? There was one issue in the linked macports thing where the wrong linker was in play. That was resolved. Then there was an issue where if you didn't get Xcode as your compiler, it didn't work. But once you do get Xcode as your compiler, the problems with the overflow_arithmetic.h header go away. So I'm not sure what else there is to do? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ryan Schmidt [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I don't understand how the linker is involved in the compiler generating a constexpr error message. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ryandesign - OK, so it sounds to me like everything works when the compiler and linker are the right versions? In that case, I'm inclined to close this ticket. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ryan Schmidt [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The MacPorts clang that successfully built the port for me (on High Sierra with Xcode 9) was:
I'm the mongodb maintainer for MacPorts, so you can email me if there's anything I should know about, otherwise I'm sure I'll find out when I try to update our port to 4.4. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ryandesign - FYI, I tried building v4.2 HEAD with homebrew {{clang}}s of various versions newer than or equal to the required clang minimum of 7, and I was unable to reproduce those errors. I built as follows:
Also tried with the llvm@8 and llvm@9 versions of the compiler, and the test always built OK. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ryandesign - Also, on a wholly different topic, what is the best way for me to flag upcoming build system changes to the macports developers responsible for MongoDB. We have some major build system interface changes coming in v4.4. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Another interesting data point: this file was substantially overhauled since v4.2:
I'm going to checkout v4.2 locally and build it with my newer (linux) clang and see if anything shakes out. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oh that is interesting. It suggests that this newer clang is seeing something that is perhaps really erroneous in our code and flagging it. Do you happen to know what version of clang is actually getting used? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ryan Schmidt [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ah! I forgot. We are not disabling minimum compiler version enforcement. We are blacklisting Xcode clangs less than version 1000, so with Xcode 9, a newer MacPorts clang would indeed be used. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The MongoDB build system should, on the v4.2 branch, be requiring Xcode 10 or newer: https://github.com/mongodb/mongo/blob/68ed6c33387eb9111568d9ebd7d20fdd3dfc1530/SConstruct#L2039-L2058, so I'm confused how it could be building with Xcode 9, unless our check is erroneous. Or are you building with --disable-minimum-comiler-version-enforcement? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ryan Schmidt [ 05/Feb/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just to clarify: from the log attached to the MacPorts ticket, it is confirmed that the user is using macOS 10.13 (which is High Sierra), not macOS 10.14 (which is Mojave). The user is also using Xcode 10. This version of mongodb built successfully on macOS 10.13 (High Sierra) on my machine and on the MacPorts automated build system, both using Xcode 9. |