RSS/Atom feed Twitter
Site is read-only, email is disabled

[PATCH] configure: add runtime test for gcc-7.2 bug

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

[PATCH] configure: add runtime test for gcc-7.2 bug Kir Kolyshkin 08 Jan 00:18
  [PATCH] configure: add runtime test for gcc-7.2 bug Tobias Ellinghaus 08 Jan 22:58
Kir Kolyshkin
2018-01-08 00:18:23 UTC (over 6 years ago)

[PATCH] configure: add runtime test for gcc-7.2 bug

Commit 9b4382614be ("Bug 787222 - Can't convert from 16 bit to 16 bit floating point.") introduced a GCC version check to configure, and a warning that GCC 7.2.0 should not be used.

While earlier release of GCC 7.2 had this bug, it was fixed in 7.2 branch later. It looks like Ubuntu and Debian took the fix (included in 7.2.0-6, 20 Sep 2017) while Fedora did not (although gcc has version 7.2.1 in Fedora). This means we can not rely on gcc version to detect whether the bug is present.

From the other side, the bug only manifests itself when -O3 (or greater) is used for compilation, so the result depends on CFLAGS being used.

Having this in mind, let's - remove the check for gcc version, - add a run time check for the bug, and - make a warning a fatal error as we know the resulting binary is buggy - add a hint to use different CC and/or CFLAGS

Results: - no warnings on Ubuntu Artful or Debian Buster - no warnings on Fedora 27
- error on Fedora 27 when -O3 is used:

checking for gcc bug PR tree-optimization/82108... bad configure: error:
This build of GCC has a serious bug affecting GEGL/GIMP. We advise
against using this version of the compiler (previous and further versions are fine).
See https://bugzilla.gnome.org/show_bug.cgi?id=787222 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82108

A workaround is to NOT use -O3 in CFLAGS, or switch to a different compiler (e.g. CC=gcc-6 ./configure). [root@2575fb510525 gimp]# gcc --version gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)

Signed-off-by: Kir Kolyshkin
---
configure.ac | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac index 156085a85f..0999f14ed4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -534,14 +534,71 @@ if test "x$os_win32" = xyes; then fi

if test "x$GCC" = xyes; then
- gcc_version=`$CC -v 2>&1|grep 'gcc version'|sed -e 's/.*gcc version \([[0-9.]]\+\)[[^0-9.]].*/\1/'` - if test "x$gcc_version" = "x7.2.0" ; then - warning_gcc="
-WARNING: GCC 7.2.0 has a serious bug affecting GEGL/GIMP. We advise - against using this version of the compiler (previous and - further versions are fine). - See https://bugzilla.gnome.org/show_bug.cgi?id=787222" - fi
+ AC_MSG_CHECKING([for gcc bug PR tree-optimization/82108]) + AC_RUN_IFELSE(
+ [
+ AC_LANG_SOURCE(
+ [[
+ void downscale_2(const float* src, int src_n, float* dst); + void __attribute__((noinline,noclone)) downscale_2(const float* src, int src_n, float* dst) + {
+ int i;
+
+ for (i = 0; i < src_n; i += 2) { + const float* a = src; + const float* b = src + 4; +
+ dst[0] = (a[0] + b[0]) / 2; + dst[1] = (a[1] + b[1]) / 2; + dst[2] = (a[2] + b[2]) / 2; + dst[3] = (a[3] + b[3]) / 2; +
+ src += 2 * 4;
+ dst += 4;
+ }
+ }
+
+ int main ()
+ {
+ const float in[4 * 4] = { + 1, 2, 3, 4,
+ 5, 6, 7, 8,
+
+ 1, 2, 3, 4,
+ 5, 6, 7, 8
+ };
+ float out[2 * 4];
+
+ downscale_2 (in, 4, out); +
+ if (out[0] != 3 || out[1] != 4 || out[2] != 5 || out[3] != 6 + || out[4] != 3 || out[5] != 4 || out[6] != 5 || out[7] != 6) + return 1;
+
+ return 0;
+ }]]
+ )
+ ],
+ [
+ AC_MSG_RESULT([good (no bug)]) + ],
+ [
+ AC_MSG_RESULT([bad])
+ AC_MSG_ERROR([
+ This build of GCC has a serious bug affecting GEGL/GIMP. We advise + against using this version of the compiler (previous and + further versions are fine).
+ See https://bugzilla.gnome.org/show_bug.cgi?id=787222 + and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82108 +
+ A workaround is to NOT use -O3 in CFLAGS, or switch to + a different compiler (e.g. CC=gcc-6 ./configure).]) + ],
+ [
+ AC_MSG_RESULT([skip (cross-compiling)]) + ]
+ )
+
# For GCC, use -v which has more information than --version. CC_VERSION="\\\\t`$CC -v 2>&1 | sed -e 's/$/\\\\n\\\\t/g' | tr -d '\n'`" else
@@ -2766,7 +2823,7 @@ Optional Modules: Tests:
Use xvfb-run $have_xvfb_run Test appdata $have_appstream_util -$have_recommended_xgettext$have_recommended_fontconfig$have_recommended_gtk$warning_vector_icons_windows$warning_glib_networking$warning_gcc" +$have_recommended_xgettext$have_recommended_fontconfig$have_recommended_gtk$warning_vector_icons_windows$warning_glib_networking"
if test "x$required_deps" = "x"; then AC_OUTPUT

2.14.1
Tobias Ellinghaus
2018-01-08 22:58:56 UTC (over 6 years ago)

[PATCH] configure: add runtime test for gcc-7.2 bug

Am Montag, 8. Januar 2018, 01:18:23 CET schrieb Kir Kolyshkin:

[GIMP compiled with GCC 7.2 has/had a problem with converting 16bit images]

- make a warning a fatal error as we know the resulting binary is buggy

That's a terrible idea. There are many people who don't care at all about 16bit images. Why break GIMP for them?

Tobias

[...]