Bug#976795: gdal: Please build with -fno-guess-branch-probability on sh4 to prevent compiler segfault

John Paul Adrian Glaubitz <[email protected]>
Newsgroups gmane.linux.debian.ports.superh
Message-ID <160738680404.2418916.15787175541196645502.reportbug__25996.0438053653$1607387064$gmane$org@epyc.physik.fu-berlin.de>
Source: gdal
Severity: normal
Tags: patch
User: [email protected]
Usertags: sh3 sh4
X-Debbugs-Cc: [email protected]

Hello!

Due to a bug in gcc, the compiler currently segfaults on sh4 with -O2 unless
-fno-guess-branch-probability is passed as well [1]:

during RTL pass: mach
pcrasterutil.cpp: In function 'void castValuesToBooleanRange(void*, size_t, CSF_CR)':
pcrasterutil.cpp:674:1: internal compiler error: Segmentation fault
  674 | }
      | ^
mmap: Permission denied
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.

The attached patch for debian/rules works around this problem by passing the necessary
-fno-guess-branch-probability through DEB_CXXFLAGS_APPEND on sh4 (and sh3):

--- debian/rules.orig   2020-12-06 12:57:44.000000000 +0100
+++ debian/rules        2020-12-08 01:13:56.978960446 +0100
@@ -45,6 +45,11 @@
   WITH_HDF5:=
 endif
 
+# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98189
+ifneq (,$(filter $(DEB_HOST_ARCH),sh3 sh4))
+  export DEB_CXXFLAGS_APPEND=-fno-guess-branch-probability
+endif
+
 ifneq (,$(filter $(DEB_HOST_ARCH),amd64 i386))
   WITH_SSE=yes
   WITH_SSSE3=yes

Could you include that change in the next upload?

Thanks,
Adrian

> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98189

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
sh4-disable-guess-branch-probability.patch (text/plain, 409 B)
--- debian/rules.orig	2020-12-06 12:57:44.000000000 +0100
+++ debian/rules	2020-12-08 01:13:56.978960446 +0100
@@ -45,6 +45,11 @@
   WITH_HDF5:=
 endif
 
+# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98189
+ifneq (,$(filter $(DEB_HOST_ARCH),sh3 sh4))
+  export DEB_CXXFLAGS_APPEND=-fno-guess-branch-probability
+endif
+
 ifneq (,$(filter $(DEB_HOST_ARCH),amd64 i386))
   WITH_SSE=yes
   WITH_SSSE3=yes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.