-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-96821: Add config option --with-strict-overflow
#96823
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
Changes from 31 commits
8863e74
0598ea9
50cbb61
f4f3b83
8015da0
d2a2c82
25b15bf
86d01d6
ca2d023
43baf35
2b6ade9
9d402a8
e5cff7b
2118727
a2bb1e9
89ba064
8d50ae4
71ca2a5
8538fe6
26956f3
88a2c76
4f95dba
506d77e
d45d6ae
f6d3113
d6423c7
0f2f931
3b4046f
3995eb6
2714d61
6236fb9
ca6e6ba
fa14763
6b09fa7
9f34477
7116f84
e526f6e
db665ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Explicitly mark C extension modules that need defined signed integer overflow, | ||
| and add a configure option ``--with-strict-overflow``. | ||
|
matthiasgoergens marked this conversation as resolved.
Outdated
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2082,6 +2082,35 @@ case $CC in | |
| fi | ||
| esac | ||
|
|
||
| dnl Historically, some of our code assumed that signed integer overflow | ||
| dnl is defined behaviour via twos-complement. | ||
| dnl Set STRICT_OVERFLOW_CFLAGS and NO_STRICT_OVERFLOW_CFLAGS depending on compiler support. | ||
| dnl Pass the latter to modules that depend on such behaviour. | ||
| _SAVE_VAR([CFLAGS]) | ||
| CFLAGS="-fstrict-overflow -fno-strict-overflow" | ||
| AC_CACHE_CHECK([if $CC supports -fstrict-overflow and -fno-strict-overflow], | ||
| [ac_cv_cc_supports_fstrict_overflow], | ||
| AC_COMPILE_IFELSE( | ||
| [ | ||
| AC_LANG_PROGRAM([[]], [[]]) | ||
| ],[ | ||
| STRICT_OVERFLOW_CFLAGS="-fstrict-overflow" | ||
| NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow" | ||
| ],[ | ||
| STRICT_OVERFLOW_CFLAGS="" | ||
| NO_STRICT_OVERFLOW_CFLAGS="" | ||
| ]) | ||
| ) | ||
| _RESTORE_VAR([CFLAGS]) | ||
|
|
||
| AC_MSG_CHECKING([for --with-strict-overflow]) | ||
| AC_ARG_WITH([strict-overflow], | ||
| AS_HELP_STRING( | ||
| [--with-strict-overflow], | ||
| [choose between -fstrict-overflow or -fno-strict-overflow (default is no)]),[], | ||
| [with_strict_overflow=no]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to pick on this further. I would like two more changes before merging:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. Don't worry about picking on this, I'm just glad you care enough to make the effort!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, just ping me when you've made the changes, and I'll get this merged. |
||
| AC_MSG_RESULT([$with_strict_overflow]) | ||
|
|
||
| # Check if CC supports -Og optimization level | ||
| _SAVE_VAR([CFLAGS]) | ||
| CFLAGS="-Og" | ||
|
|
@@ -2112,15 +2141,8 @@ if test "${OPT-unset}" = "unset" | |
| then | ||
| case $GCC in | ||
| yes) | ||
| # For gcc 4.x we need to use -fwrapv so lets check if its supported | ||
| if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then | ||
| WRAP="-fwrapv" | ||
| fi | ||
|
|
||
| if test -n "${cc_is_clang}" | ||
| then | ||
| # Clang also needs -fwrapv | ||
| WRAP="-fwrapv" | ||
| # bpo-30104: disable strict aliasing to compile correctly dtoa.c, | ||
| # see Makefile.pre.in for more information | ||
| CFLAGS_ALIASING="-fno-strict-aliasing" | ||
|
|
@@ -2131,7 +2153,7 @@ then | |
| if test "$Py_DEBUG" = 'true' ; then | ||
| OPT="-g $PYDEBUG_CFLAGS -Wall" | ||
| else | ||
| OPT="-g $WRAP -O3 -Wall" | ||
| OPT="-g -O3 -Wall" | ||
| fi | ||
| ;; | ||
| *) | ||
|
|
@@ -2246,6 +2268,10 @@ AC_DEFUN([PY_CHECK_CC_WARNING], [ | |
| ]) | ||
|
|
||
| # tweak BASECFLAGS based on compiler and platform | ||
| AS_VAR_IF([with_strict_overflow], [yes], | ||
| [BASECFLAGS="$BASECFLAGS $STRICT_OVERFLOW_CFLAGS"], | ||
| [BASECFLAGS="$BASECFLAGS $NO_STRICT_OVERFLOW_CFLAGS"]) | ||
|
|
||
| case $GCC in | ||
| yes) | ||
| CFLAGS_NODIST="$CFLAGS_NODIST -std=c11" | ||
|
|
@@ -7307,7 +7333,7 @@ PY_STDLIB_MOD([_crypt], | |
| [$LIBCRYPT_CFLAGS], [$LIBCRYPT_LIBS]) | ||
| PY_STDLIB_MOD([_ctypes], | ||
| [], [test "$have_libffi" = yes], | ||
| [$LIBFFI_CFLAGS], [$LIBFFI_LIBS]) | ||
| [$NO_STRICT_OVERFLOW_CFLAGS $LIBFFI_CFLAGS], [$LIBFFI_LIBS]) | ||
| PY_STDLIB_MOD([_curses], | ||
| [], [test "$have_curses" != "no"], | ||
| [$CURSES_CFLAGS], [$CURSES_LIBS] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.