-
Notifications
You must be signed in to change notification settings - Fork 92
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
MONGOCRYPT-685 update libbson to 1.27.1 #818
Conversation
If a `BUILD_VERSION` is specified for libmongocrypt, do not apply the same value for the embedded C driver.
libmongoc is not required to build libmongocrypt.
removes open TODO comments
It is now defined in libbson
The removed code adds a runtime requirement of libbson 1.16.0 or newer. Add a check to ensure libbson 1.16.0 or newer is used at compile-time. This may prevent use of an older system install of libbson.
VERSION_CURRENT is now committed into the C driver
Will be used to patch libbson
To resolve build error on GCC 4.4.7 on RHEL 6.2
To resolve build error on RHEL 6.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cmake/ImportBSON.cmake
Outdated
if (BUILD_VERSION) | ||
# Both libmongocrypt and C driver support setting a `BUILD_VERSION`. Do not reuse the `BUILD_VERSION` for libmongocrypt when building the C driver. | ||
# Set the `BUILD_VERSION` in this file to only apply to the C driver subproject. | ||
set (BUILD_VERSION ${MONGOC_FETCH_TAG_FOR_LIBBSON}) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to only set the build version if its already defined for the parent project? This could also be unset(BUILD_VERSION)
to clear the value from the scope and let the sub-project infer its own value, or alternatively it can unconditionally set BUILD_VERSION
to the fetch tag value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Updated to unconditionally set BUILD_VERSION
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is moved to a separate module, I'd prefer it more module-like so that it doesn't peek at variables in the includer's scope and behave different when included multiple times. For example:
find_program(GIT_EXECUTABLE git)
find_program(PATCH_EXECUTABLE patch)
#[[
Form a new Patch-applying command for the given inputs
make_patch_command(
<outvar>
[DIRECTORY <dir>]
[STRIP_COMPONENTS <N>]
PATCHES [<file> ...]
)
]]
function(make_patch_command out)
cmake_parse_arguments(PARSE_ARGV 1 patch "" "DIRECTORY;STRIP_COMPONENTS" "PATCHES")
if(GIT_COMMAND)
# git ...
set(cmd ${GIT_EXECUTABLE})
if(patch_DIRECTORY)
# git --work-tree=...
list(APPEND cmd --work-tree=${patch_DIRECTORY})
endif()
# git ... apply ...
list(APPEND cmd apply)
# git ... apply -pN ...
if(patch_STRIP_COMPONENTS)
list(APPEND cmd -p${patch_STRIP_COMPONENTS})
endif()
# git ... apply ...
foreach(p IN LISTS patch_PATCHES)
# git ... apply ... <file>
list(APPEND cmd ${p})
endforeach()
else()
# patch ...
set(cmd ${PATCH_EXECUTABLE})
if(patch_DIRECTORY)
# patch --dir=...
list(APPEND cmd --dir=${patch_DIRECTORY})
endif()
# patch ... -pN ...
if(patch_STRIP_COMPONENTS)
list(APPEND cmd -p${patch_STRIP_COMPONENTS})
endif()
foreach(p IN LISTS patch_PATCHES)
# patch ... ---input=<file>
list(APPEND cmd --input=${p})
endforeach()
endif()
set("${out}" "${cmd}" PARENT_SCOPE)
endfunction()
and then callers can use it via make_patch_command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. Thank you for the suggestion! Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I discovered two simplifications to the patch command function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: vector-of-bool <[email protected]>
* update bundled libbson to 1.27.1 * override `BUILD_VERSION` for C driver If a `BUILD_VERSION` is specified for libmongocrypt, do not apply the same value for the embedded C driver. * Clarify `ENABLE_ONLINE_TESTS` requires libmongoc. libmongoc is not required to build libmongocrypt. * use the now-available `BSON_CONCAT` and remove TODOs * remove `BSON_SUBTYPE_ENCRYPTED` (now defined in libbson) * remove workaround for CDRIVER-3340 The removed code adds a runtime requirement of libbson 1.16.0 or newer. Add a check to ensure libbson 1.16.0 or newer is used at compile-time. This may prevent use of an older system install of libbson. * disable building tests and counters in C driver * update version in `prep_c_driver_source.sh` * remove unnecessary VERSION_CURRENT VERSION_CURRENT is now committed into the C driver * add a `make_patch_command` CMake helper use for libbson and IntelDFP * patch libbson to remove GCC diagnostic pragma To resolve build error on GCC 4.4.7 on RHEL 6.2 * define `__STDC_LIMIT_MACROS` To resolve build error on RHEL 6.2 * apply patch in linker tests * reference ticket to drop RHEL 6.2 --------- Co-authored-by: vector-of-bool <[email protected]>
Summary
Update bundled libbson to 1.27.1
Apply workarounds to resolve errors on RHEL 6.2 with gcc 4.4.7:
__STDC_LIMIT_MACROS
when compiling with C++.Remove workarounds for older libbson:
CONCAT
macro withBSON_CONCAT
.BSON_SUBTYPE_ENCRYPTED
(now defined in libbson).Verified with this patch build: https://spruce.mongodb.com/version/6650b53f05094a0007522646
Background
Motivation
Updating bundled libbson is to address an issue reported in Skyk that was fixed in libbson 1.25.0: https://security.snyk.io/vuln/SNYK-UNMANAGED-MONGODBMONGOCDRIVER-6156642
Workaround: define
__STDC_LIMIT_MACROS
for C++ targetsDefining
__STDC_LIMIT_MACROS
resolves an error on this patch when compiling a C++ test target:bson-cmp.h:144: error: 'INT8_MIN' was not declared in this scope
. The stdint.h header on a spawned RHEL 6.2 host includes:Workaround: remove diagnostic pragma on old GCC
Removing the
GCC diagnostic
pragma resolves an error on this patch:mongoc-aggregate.c:97: error: #pragma GCC diagnostic not allowed inside functions
. I expect this is unavailable on GCC 4.6 and older. GCC 4.6 changelog notes:Due to the workarounds, MONGOCRYPT-688 was filed to propose dropping RHEL 6.2 support for libmongocrypt.
Adding a runtime check
Removing the workaround of CDRIVER-3340 motivated adding a compile-time check to ensure libbson is newer than 1.16.0 (to include fix of CDRIVER-3340). The check for 1.16.0 is a precaution to ensure using a system install of libbson is 1.16.0 or newer. When libbson is loaded from the system, a version check is not performed.