Skip to content

Conversation

@kevinAlbs
Copy link
Collaborator

@kevinAlbs kevinAlbs commented Sep 10, 2025

Summary

Append detected C++ compiler to handshake.

Verified with this patch build: https://spruce.mongodb.com/version/68c08e74190e6700073c344b

Background & Motivation

See CDRIVER-6091. Knowing if a C++ compiler was detected may help inform future decisions.

Example from the handshake before:

{
    "driver": {
        "name": "mongoc",
        "version": "2.2.0-pre"
    },
    "os": {
        "type": "Linux",
        "name": "Ubuntu",
        "version": "22.04",
        "architecture": "x86_64"
    },
    "platform": "cfg=0x06235e88e9 posix=200809 stdc=199901 CC=GCC 11.4.0 CFLAGS=\"\" LDFLAGS=\"\""
}

This PR adds CXX to the platform string of the MongoDB Handshake:

                                                        vvvvvvvvvvvvvv
cfg=0x06235e88e9 posix=200809 stdc=199901 CC=GCC 11.4.0 CXX=GNU 11.4.0 CFLAGS=\"\" LDFLAGS=\"\"
                                                        ^^^^^^^^^^^^^^

If a C++ compiler is not found, CXX=Unknown is included. Alternatively: CXX could be omitted if not detected. But I expect it may help with analysis to easily distinguish between: "driver too old to check" and "checked and did not find".

@kevinAlbs kevinAlbs marked this pull request as ready for review September 10, 2025 17:53
@kevinAlbs kevinAlbs requested a review from a team as a code owner September 10, 2025 17:53
Copy link
Collaborator

@connorsmacd connorsmacd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevinAlbs kevinAlbs requested review from eramongodb and removed request for vector-of-bool September 11, 2025 19:17
Comment on lines +758 to +764
if(DEFINED CMAKE_CXX_COMPILER_ID)
set(MONGOC_CXX_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}")
endif()

if(DEFINED CMAKE_CXX_COMPILER_VERSION)
set(MONGOC_CXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding a comment to the check_language (CXX) -> enable_language (CXX) in the root CMakeLists.txt documenting that these optional compiler ID + version handshake metadata is dependent on them (no longer just for "some C++-specific tests"):

# Optionally enable C++ to do some C++-specific tests
include (CheckLanguage)
check_language (CXX)
if (CMAKE_CXX_COMPILER)
enable_language (CXX)
if (NOT CMAKE_CXX_STANDARD)
# Default to C++11 for purposes of testing.
set (CMAKE_CXX_STANDARD 11)
endif ()
else ()
message (STATUS "No CXX support")
endif ()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Comment updated.

@kevinAlbs kevinAlbs merged commit 9af0467 into mongodb:master Sep 12, 2025
1 of 2 checks passed
Julia-Garland pushed a commit to Julia-Garland/mongo-c-driver that referenced this pull request Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants