-
Notifications
You must be signed in to change notification settings - Fork 455
Reducing Warnings - Compile with C99 on Evergreen by default #1067
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
Conversation
@@ -28,6 +29,7 @@ set -o errexit # Exit the script with error if any of the commands fail | |||
# ZSTD Build against system zstd. | |||
|
|||
# Options for this script. | |||
C_STD_VERSION=${CSTD_VERSION:-99} |
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.
+1 for a dedicated env var
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. The comments in CMakeLists.txt look helpful for future readers.
If you have not already, I suggest running a full patch build to check compile tasks on all platforms. |
@kevinAlbs Latest patch builds are noisy due to unrelated server compat issues, but compile tasks were verified here: https://spruce.mongodb.com/version/62cc9a6557e85a7ecf6b16f2/tasks |
@@ -28,6 +29,7 @@ set -o errexit # Exit the script with error if any of the commands fail | |||
# ZSTD Build against system zstd. | |||
|
|||
# Options for this script. | |||
C_STD_VERSION=${CSTD_VERSION:-99} |
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.
@eramongodb: I think this was a typo, but it appears to have been fixed in a subsequent commit: f4a83c0#diff-5621bd7804f10985a5f14a01ee66b14439494aa0a6cdfa6c6debd151e7c90d7aR10
Likewise for compile-windows.sh
.
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.
Correct. This mistake was in part what motivated the addition of the check_var_opt
/check_var_req
functions in the referenced commit.
Description
This PR is a followup to #920 and is related to CDRIVER-4136.
This PR ensures that all builds of the C Driver on Evergreen are able to be compiled with
-std=c99
(or equivalent) by default to ensure strict conformance with the C99 standard across all platforms and configurations. This addresses all C89/C90 compatibility related warnings emitted due to use of C99 features.In the spirit of minimizing platform-specific configuration flags, the C standard is specified via CMake's
CMAKE_C_STANDARD
andCMAKE_C_STANDARD_REQUIRED
on both Linux and Windows.CMAKE_C_EXTENSIONS
is set toOFF
to ensure strict C99 conformance and that any extensions being depended on are explicitly opted into.Setting
CMAKE_C_EXTENSIONS
toOFF
exposed a configuration bug on RHEL 6.2 and RHEL 7.0, which provides glibc versions 2.12 and 2.17 respectively. #920 proposed removing_BSD_SOURCE
in favor of_DEFAULT_SOURCE
due to the former being deprecated; however,_DEFAULT_SOURCE
is only supported given glibc version 2.19 and newer. To support glibc version 2.19 and earlier while also supporting strict C99 conformance, this PR partially reverts the changes in #920.Therefore, the full set of compile definitions to explicitly opt into POSIX features and non-standard extensions currently being used by the C driver include:
_XOPEN_SOURCE=700
: required to enable use ofstrnlen
(>=700) in addition to other features in the X/Open namespace (i.e.pthread_rwlock_*
(>=500)) as required by the POSIX specification._DEFAULT_SOURCE
: required to enable use ofgetpagesize
,h_errno
, and other BSD-derived definitions._BSD_SOURCE
: required for compatibility with glibc 2.19 and earlier._DARWIN_C_SOURCE
: required to enable use of_SC_NPROCESSORS_ONLN
and other non-POSIX extensions on MacOS that are otherwise disabled by_POSIX_C_SOURCE
(set to200112L
by_XOPEN_SOURCE=700
)._BSD_SOURCE
could be removed once all platforms with glibc version 2.19 or earlier are no longer supported.The
debug-compile-c99
task is removed due to redundancy.