Skip to content

CXX-3088 fix build with GCC 4.8.5 #1194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 3, 2024

Conversation

kevinAlbs
Copy link
Collaborator

Summary

Fix build with GCC 4.8.5.

Verified with this patch build.

Description

Supporting build with GCC 4.8.5 is motivated by a request to build on a customer RHEL 7.9 system. See slack thread.

This PR resolves errors observed when building with RHEL 7 with GCC 4.8.5.

Error: redeclaration differs in 'constexpr'

/root/mongo-cxx-driver/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp:571:45: error: redeclaration 'bsoncxx::v_noabi::stdx::basic_string_view<Char, Traits>::npos' differs in 'constexpr'
const std::size_t basic_string_view<C, Tr>::npos;
                                            ^
/root/mongo-cxx-driver/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp:136:32: error: from previous declaration 'bsoncxx::v_noabi::stdx::basic_string_view<Char, Traits>::npos'
    static constexpr size_type npos = static_cast<size_type>(-1);

I expect this is a quirk in old GCC. See: https://stackoverflow.com/a/17074539/774658. This PR adds constexpr to match.

Error: missing space

/root/mongo-cxx-driver/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp:83:42: error: missing space between '""' and suffix identifier
BSONCXX_API document::value BSONCXX_CALL operator""_bson(const char* json, size_t len);

This PR adds a space for C++11 compliance.

C++11 user-defined literals note a space is required:

float operator ""E(const char*);                    // error: ""E (with no intervening space)
                                                    // is a single token

C++14 user-defined literals permit no space:

float operator ""_e(const char*);                   // OK

Ignoring unused parameters

Building the C driver resulted in errors due to unused-parameter warnings:

../../_deps/mongo-c-driver-src/src/libbson/src/bson/bson-atomic.h:202:28: error: unused parameter 'order' [-Werror=unused-parameter]
    static BSON_INLINE Type bson_atomic_##NamePart##_fetch (      

This was addressed in CDRIVER-5673. However, trying to upgrade the C driver to include the fix resulted in test failures in In-Use Encryption tests due to "rangePreview" being removed. I expect the In-Use Encryption test updates will be addressed in CXX-3014. To limit scope of this PR, -Wno-unused-parameter is added to compile flags on RHEL 7 as a temporary workaround until the C driver is upgraded to include CDRIVER-5673.

Cloud User and others added 5 commits August 21, 2024 11:42
Resolves error: "redeclaration [...] differs in 'constexpr'"
Resolves error: "missing space between '""' and suffix identifier"
Resolves warnings (causing errors) addressed in CDRIVER-5673. Upgrading C driver to get fix results in test failures due to removal of "rangePreview" algorithm.
@eramongodb
Copy link
Contributor

eramongodb commented Aug 21, 2024

Building the C driver resulted in errors due to unused-parameter warnings: [...]

Shouldn't FetchMongoC.cmake be preventing warnings-as-errors when building the C Driver from source?

C driver is already built with `-Werror` removed.
Copy link
Collaborator Author

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

Building the C driver resulted in errors due to unused-parameter warnings: [...]

Shouldn't FetchMongoC.cmake be preventing warnings-as-errors when building the C Driver from source?

Good spot. The errors were from the C++ driver building C driver headers. I reverted changes to cc_flags, but kept the cxx_flags.

Verified with this patch: https://spruce.mongodb.com/version/66c63bc0968aff00077889c3

@kevinAlbs kevinAlbs requested a review from eramongodb August 21, 2024 19:54
@kevinAlbs kevinAlbs merged commit ac24564 into mongodb:master Sep 3, 2024
69 of 79 checks passed
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