diff options
author | David Kaspar [Dee'Kej] <dkaspar@redhat.com> | 2018-02-26 15:48:45 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2018-03-07 10:07:50 +0000 |
commit | 8c206ceeeac12b048aeafc9ea51080b624750ff4 (patch) | |
tree | 1818cf03e13387390b449648a9c2dc1d0223cc72 | |
parent | 39686173fd26eb6e5eee91202433f5e5f307f61c (diff) | |
download | ghostpdl-8c206ceeeac12b048aeafc9ea51080b624750ff4.tar.gz |
Bug 699068: configure.ac: forcibly disable strict aliasing via CFLAGS
In case user specifies their own CFLAGS that contains -O2, -O3, -Os or
-fstrict-aliasing, the default behaviour to disable the strict
aliasing will be overriden and enabled, which is not correct...
This commit will append the -fno-strict-aliasing option to CFLAGS set
by user, which will effectively force the disabling of strict aliasing.
NOTE: originally the patch issued a warning when appending -fno-strict-aliasing
and I've changed it to a normal checking/result message pattern - it seems less
likely to cause end user confusion/panic
-rw-r--r-- | configure.ac | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 68850fd85..9341930b8 100644 --- a/configure.ac +++ b/configure.ac @@ -329,7 +329,7 @@ AC_SUBST(SET_DT_SONAME) if test $ac_cv_prog_gcc = yes; then cflags_to_try="-Wall -Wstrict-prototypes -Wundef \ -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings \ --Wno-strict-aliasing -Werror=declaration-after-statement \ +-fno-strict-aliasing -Werror=declaration-after-statement \ -fno-builtin -fno-common -Werror=return-type" optflags_to_try="$CC_OPT_FLAGS_TO_TRY" dbgflags_to_try="$CC_DBG_FLAGS_TO_TRY" @@ -372,6 +372,8 @@ AC_SUBST(ARCH_CONF_HEADER) # CFLAGS="-DDEBUG $CFLAGS" #fi +# NOTE: To correctly disable GCC's strict aliasing with '-fno-strict-aliasing' +# option, the 'cflags_to_try' have to checked after 'optflags_to_try'. AC_MSG_CHECKING([supported compiler flags]) old_cflags=$CFLAGS @@ -2795,6 +2797,24 @@ fi AC_SUBST(VERSIONED_PATH) # -------------------------------------------------- +# Check if we are using GCC, and disable strict +# aliasing optimization if GCC supports it... +# +# NOTE: Strict aliasing can cause some parts +# of Ghostscript to malfunction. +# -------------------------------------------------- +if test $ac_cv_prog_gcc = yes; then + AC_MSG_CHECKING([whether to explicitly disable strict aliasing]) + CFLAGS_backup="$CFLAGS" + CFLAGS="$CFLAGS -fno-strict-aliasing" + AC_TRY_COMPILE(, [return 0;], [ + AC_MSG_RESULT([yes]) + CFLAGS_backup="$CFLAGS" + ]) + CFLAGS="$CFLAGS_backup" +fi + +# -------------------------------------------------- # Modify build for internal cluster testing. # DO NOT USE THIS OPTION OUTSIDE OF ARTIFEX! # -------------------------------------------------- |