Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 29 additions & 26 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2221,28 +2221,6 @@ AC_MSG_RESULT([$BOLT_APPLY_FLAGS])
# compiler and platform. BASECFLAGS tweaks need to be made even if the
# user set OPT.

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([[]], [[]])],
[ac_cv_cc_supports_fstrict_overflow=yes],
[ac_cv_cc_supports_fstrict_overflow=no]
)
)
_RESTORE_VAR([CFLAGS])

AS_VAR_IF([ac_cv_cc_supports_fstrict_overflow], [yes],
[STRICT_OVERFLOW_CFLAGS="-fstrict-overflow"
NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"],
[STRICT_OVERFLOW_CFLAGS=""
NO_STRICT_OVERFLOW_CFLAGS=""])

AC_MSG_CHECKING([for --with-strict-overflow])
AC_ARG_WITH([strict-overflow],
AS_HELP_STRING(
Expand All @@ -2251,12 +2229,37 @@ AC_ARG_WITH([strict-overflow],
),
[
AS_VAR_IF(
[ac_cv_cc_supports_fstrict_overflow], [no],
[AC_MSG_WARN([--with-strict-overflow=yes requires a compiler that supports -fstrict-overflow])],
[]
[with_strict_overflow], [yes],
[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([[]], [[]])],
[ac_cv_cc_supports_fstrict_overflow=yes],
[ac_cv_cc_supports_fstrict_overflow=no]
)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should be fine with using AX_CHECK_COMPILE_FLAG here. (I don't remember why I did not recommend that when we added this code.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Are you suggesting we just check -fstrict-overflow? Currently it checks both -fstrict-overflow and -fno-strict-overflow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using AX_CHECK_COMPILE_FLAG makes it more complicated to follow IMO, but I pushed the change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I should've been more specific. Currently, we check for the compile flag first, then we check for the configure flag. Now, you've embedded the compile check into the configure flag check. I suggest keeping the original structure. We should be able to use AX_CHECK_COMPILE_FLAG to check for the compile flag(s), and then use those results when we check for the configure flag.

_RESTORE_VAR([CFLAGS])

AS_VAR_IF([ac_cv_cc_supports_fstrict_overflow], [yes],
[STRICT_OVERFLOW_CFLAGS="-fstrict-overflow"
NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"],
[AC_MSG_WARN([--with-strict-overflow=yes requires a compiler that supports -fstrict-overflow])
STRICT_OVERFLOW_CFLAGS=""
NO_STRICT_OVERFLOW_CFLAGS=""])
],
[STRICT_OVERFLOW_CFLAGS=""
NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"]
)
],
[with_strict_overflow=no]
[with_strict_overflow=no
STRICT_OVERFLOW_CFLAGS=""
NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"]
)
AC_MSG_RESULT([$with_strict_overflow])

Expand Down
Loading