[SERVER-85763] Build failure with Xcode 15 Created: 25/Jan/24  Updated: 30/Jan/24

Status: Needs Scheduling
Project: Core Server
Component/s: None
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ryan Schmidt Assignee: Thomas Langston
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-85779 Build failure with C++20 due to use o... Needs Scheduling
Assigned Teams:
Build
Operating System: ALL
Steps To Reproduce:

% tar xzf mongodb-src-r7.0.5.tar.gz
% cd mongodb-src-r7.0.5
% python3.11 -m venv venv
% venv/bin/python3.11 -m pip install -r etc/pip/compile-requirements.txt
...
% venv/bin/python3.11 buildscripts/scons.py install-mongod
Checking required python packages...
Requirements list:
...
Resolved to these distributions:
...
scons: Reading SConscript files ...
scons: running with args /Users/me/mongodb-src-r7.0.5/venv/bin/python3.11 buildscripts/scons.py install-mongod
WARNING: The build_metrics tool might not work as intended due to a failed import:
No module named 'jsonschema'
Mkdir("build/scons")
scons version: 3.1.2
python version: 3 11 7 'final' 0
Mkdir("build/tmp_test_data")
CC is gcc
gcc found in $PATH at /usr/bin/gcc
CXX is g++
g++ found in $PATH at /usr/bin/g++
Checking if dev env is valid... skipped
Checking if C++ compiler "g++" is GCC... no
Checking if C++ compiler "g++" is clang... yes
Checking if C compiler "gcc" is clang... yes
Detected a aarch64 processor
Checking if target OS macOS is supported by the toolchain... yes
Checking if C compiler is clang 12.0 (or Apple XCode 13.0) or newer...yes
Checking if C++ compiler is clang 12.0 (or Apple XCode 13.0) or newer...yes
Checking for sufficient macOS target version minimum... yes
Checking whether the C compiler works... yes
Checking whether the C++ compiler works... yes
Checking that the C++ compiler can link a C++ program... no
C++ compiler g++ can't link C++ programs
See /Users/me/mongodb-src-r7.0.5/build/scons/config.log for details
% tail -n18 build/scons/config.log
scons: Configure: Checking that the C++ compiler can link a C++ program... 
build/scons/opt/sconf_temp/conftest_ac30bfea77045c1c67c4f51773b51414_0.cpp <-
  |
  |#include <iostream>
  |#include <cstdlib>
  |
  |int main() {
  |    std::cout << "Hello, World" << std::endl;
  |    return EXIT_SUCCESS;
  |}
  |
g++ -o build/scons/opt/sconf_temp/conftest_ac30bfea77045c1c67c4f51773b51414_0.o -c -Werror=unused-result -Woverloaded-virtual -Werror -ffp-contract=off -fasynchronous-unwind-tables -g2 -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -fno-omit-frame-pointer -fno-strict-aliasing -O2 -DNDEBUG build/scons/opt/sconf_temp/conftest_ac30bfea77045c1c67c4f51773b51414_0.cpp
g++ -o build/scons/opt/sconf_temp/conftest_ac30bfea77045c1c67c4f51773b51414_0_427bedf0569bb40c3d25829f0e6a3199 -Wl,-fatal_warnings -Wl,-bind_at_load build/scons/opt/sconf_temp/conftest_ac30bfea77045c1c67c4f51773b51414_0.o -lresolv
ld: warning: -bind_at_load is deprecated on macOS
ld: fatal warning(s) induced error (-fatal_warnings)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: Configure: no

docs/building.md mentioned that I could instead run:

% venv/bin/python3.11 buildscripts/scons.py install-mongod --disable-warnings-as-errors

but that doesn't change the situation (and you should not be enabling warnings as errors by default).

Participants:

 Description   

mongodb 7.0.5 does not build with the toolchain included with Xcode 15.2 on macOS 14.2.1. This is due to the new linker included in Xcode 15 and later.

This problem was originally reported to MacPorts: https://trac.macports.org/ticket/69186



 Comments   
Comment by Ryan Schmidt [ 26/Jan/24 ]

Please reopen. Daniel's suggestion works around the bug, but it is not a fix for the bug.

The changes I would like to see are:

  1. Make "--disable-warnings-as-errors=configure --disable-warnings-as-errors=source" the default. It is a worthy goal to make your build pass without warnings, but please don't expect the same of your users, who may be using a different toolchain than you which may have warnings that you were not expecting.
  2. Don't use "-bind_at_load" when using the Xcode 15 linker or newer. I'm assuming the new linker has some different way to achieve this feature but I don't know what it is. Alternately, when using Xcode 15, use the legacy linker, though I'm sure it will be removed in a future version of Xcode so that would only be a temporary measure.
Comment by Noopur Gupta [ 26/Jan/24 ]

Closing this ticket, since it seems like the suggestion by Daniel in the earlier comment worked.
Feel free to re-open this ticket if you have further questions on this issue.

Comment by Ryan Schmidt [ 26/Jan/24 ]

Thank you, using those two flags does work around the problem.

Comment by Daniel Moody [ 26/Jan/24 ]

ryandesign the configure checks do not disable warnings by default even with the disable-warnings-as-error flag, in this case you could get past the warning in the mean time by specifying disabling warnings as error for both source and configure check actions via adding this to the scons command line:

--disable-warnings-as-errors=configure --disable-warnings-as-errors=source

Notice the option for --disable-warnings-as-errors accepts choices:

add_option(
    "disable-warnings-as-errors",
    action="append",
    choices=["configure", "source"],
    const="source",
    default=build_profile.disable_warnings_as_errors,
    help=
    "Don't add a warnings-as-errors flag to compiler command lines in selected contexts; defaults to 'source' if no argument is provided",
    nargs="?",
    type="choice",
)

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