https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121535

            Bug ID: 121535
           Summary: ia64: with cryptsetup 2.8.0 - internal compiler error:
                    in int_mode_for_mode, at stor-layout.cc:408
           Product: gcc
           Version: 15.2.0
               URL: http://epic-slack.org/#!index.md#2025-07-11
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frank.scheiner at web dot de
                CC: rene at exactcode dot de
  Target Milestone: ---
              Host: ia64-slackware-linux
            Target: ia64-slackware-linux
             Build: ia64-slackware-linux

Created attachment 62114
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62114&action=edit
preprocessed source

Detected when trying to build a/cryptsetup 2.8.0 for EPIC Slack (unofficial
Slackware port to ia64). Present in all GCC versions I have available 14.1,
14.2, 14.3, 15.1 and 15.2 just tested today.

```
root@rx2800-i2:/srv/slackware/tmp/cryptsetup-2.8.0# /bin/sh ./libtool  --tag=CC
  --mode=compile gcc -v -save-temps -DHAVE_CONFIG_H -I.  -include config.h
-I./lib -DDATADIR=\""/usr/share"\" -DLOCALEDIR=\""/usr/share/locale"\"
-DLIBDIR=\""/usr/lib"\" -DPREFIX=\""/usr"\" -DSYSCONFDIR=\""/etc"\"
-DVERSION=\""2.8.0"\" -DEXTERNAL_LUKS2_TOKENS_PATH=\"/usr/lib/cryptsetup\" 
-Wall   -O2 -MT lib/crypto_backend/libcrypto_backend_la-memutils.lo -MD -MP -MF
lib/crypto_backend/.deps/libcrypto_backend_la-memutils.Tpo -c -o
lib/crypto_backend/libcrypto_backend_la-memutils.lo `test -f
'lib/crypto_backend/memutils.c' || echo './'`lib/crypto_backend/memutils.c
libtool: compile:  gcc -v -save-temps -DHAVE_CONFIG_H -I. -include config.h
-I./lib -DDATADIR=\"/usr/share\" -DLOCALEDIR=\"/usr/share/locale\"
-DLIBDIR=\"/usr/lib\" -DPREFIX=\"/usr\" -DSYSCONFDIR=\"/etc\"
-DVERSION=\"2.8.0\" -DEXTERNAL_LUKS2_TOKENS_PATH=\"/usr/lib/cryptsetup\" -Wall
-O2 -MT lib/crypto_backend/libcrypto_backend_la-memutils.lo -MD -MP -MF
lib/crypto_backend/.deps/libcrypto_backend_la-memutils.Tpo -c
lib/crypto_backend/memutils.c  -fPIC -DPIC -o
lib/crypto_backend/.libs/libcrypto_backend_la-memutils.o
Reading specs from /usr/lib/gcc/ia64-slackware-linux/15.2.0/specs
COLLECT_GCC=gcc
Target: ia64-slackware-linux
Configured with: ../configure --prefix=/usr --libdir=/usr/lib --mandir=/usr/man
--infodir=/usr/info --enable-shared --enable-bootstrap
--enable-languages=c,c++,fortran --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-libstdcxx-dual-abi
--with-default-libstdcxx-abi=new --disable-libstdcxx-pch
--disable-libunwind-exceptions --enable-__cxa_atexit --disable-libssp
--enable-gnu-indirect-function --enable-gnu-unique-object --enable-plugin
--disable-lto --disable-install-libiberty --disable-werror --with-gnu-ld
--with-isl --verbose --with-arch-directory=ia64 --disable-gtktest
--enable-clocale=gnu --disable-multilib --target=ia64-slackware-linux
--build=ia64-slackware-linux --host=ia64-slackware-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'HAVE_CONFIG_H' '-I' '.' '-include'
'config.h' '-I' './lib' '-D' 'DATADIR="/usr/share"' '-D'
'LOCALEDIR="/usr/share/locale"' '-D' 'LIBDIR="/usr/lib"' '-D' 'PREFIX="/usr"'
'-D' 'SYSCONFDIR="/etc"' '-D' 'VERSION="2.8.0"' '-D'
'EXTERNAL_LUKS2_TOKENS_PATH="/usr/lib/cryptsetup"' '-Wall' '-O2' '-MT'
'lib/crypto_backend/libcrypto_backend_la-memutils.lo' '-MD' '-MP' '-MF'
'lib/crypto_backend/.deps/libcrypto_backend_la-memutils.Tpo' '-c' '-fPIC' '-D'
'PIC' '-o' 'lib/crypto_backend/.libs/libcrypto_backend_la-memutils.o'
'-dumpdir' 'lib/crypto_backend/.libs/'
 /usr/libexec/gcc/ia64-slackware-linux/15.2.0/cc1 -E -quiet -v -I . -I ./lib
-MD lib/crypto_backend/.libs/libcrypto_backend_la-memutils.d -MF
lib/crypto_backend/.deps/libcrypto_backend_la-memutils.Tpo -MP -MT
lib/crypto_backend/libcrypto_backend_la-memutils.lo -D HAVE_CONFIG_H -D
DATADIR="/usr/share" -D LOCALEDIR="/usr/share/locale" -D LIBDIR="/usr/lib" -D
PREFIX="/usr" -D SYSCONFDIR="/etc" -D VERSION="2.8.0" -D
EXTERNAL_LUKS2_TOKENS_PATH="/usr/lib/cryptsetup" -D PIC -include config.h
lib/crypto_backend/memutils.c -Wall -fPIC -O2 -fpch-preprocess -o
lib/crypto_backend/.libs/libcrypto_backend_la-memutils.i
ignoring nonexistent directory
"/usr/lib/gcc/ia64-slackware-linux/15.2.0/../../../../ia64-slackware-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 .
 ./lib
 /usr/lib/gcc/ia64-slackware-linux/15.2.0/include
 /usr/local/include
 /usr/lib/gcc/ia64-slackware-linux/15.2.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'HAVE_CONFIG_H' '-I' '.' '-include'
'config.h' '-I' './lib' '-D' 'DATADIR="/usr/share"' '-D'
'LOCALEDIR="/usr/share/locale"' '-D' 'LIBDIR="/usr/lib"' '-D' 'PREFIX="/usr"'
'-D' 'SYSCONFDIR="/etc"' '-D' 'VERSION="2.8.0"' '-D'
'EXTERNAL_LUKS2_TOKENS_PATH="/usr/lib/cryptsetup"' '-Wall' '-O2' '-MT'
'lib/crypto_backend/libcrypto_backend_la-memutils.lo' '-MD' '-MP' '-MF'
'lib/crypto_backend/.deps/libcrypto_backend_la-memutils.Tpo' '-c' '-fPIC' '-D'
'PIC' '-o' 'lib/crypto_backend/.libs/libcrypto_backend_la-memutils.o'
'-dumpdir' 'lib/crypto_backend/.libs/'
 /usr/libexec/gcc/ia64-slackware-linux/15.2.0/cc1 -fpreprocessed
lib/crypto_backend/.libs/libcrypto_backend_la-memutils.i -quiet -dumpdir
lib/crypto_backend/.libs/ -dumpbase libcrypto_backend_la-memutils.c
-dumpbase-ext .c -O2 -Wall -version -fPIC -o
lib/crypto_backend/.libs/libcrypto_backend_la-memutils.s
GNU C23 (GCC) version 15.2.0 (ia64-slackware-linux)
        compiled by GNU C version 15.2.0, GMP version 6.3.0, MPFR version
4.2.2, MPC version 1.3.1, isl version isl-0.27-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 117b9eee970a18c07b4b633b9f7c0bc2
during RTL pass: zero_call_used_regs
lib/crypto_backend/memutils.c: In function 'crypt_backend_memcpy':
lib/crypto_backend/memutils.c:48:1: internal compiler error: in
int_mode_for_mode, at stor-layout.cc:408
   48 | }
      | ^
linux-gate.so.1: Bad address
0x40000000031bac2f diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, void**,
diagnostic_t)
        ???:0
0x40000000031e649f internal_error(char const*, ...)
        ???:0
0x400000000024789f fancy_abort(char const*, int, char const*)
        ???:0
0x4000000001379eaf int_mode_for_mode(machine_mode)
        ???:0
0x40000000009495ef emit_move_insn_1(rtx_def*, rtx_def*)
        ???:0
0x4000000000949def emit_move_insn(rtx_def*, rtx_def*)
        ???:0
0x400000000139a1af default_zero_call_used_regs(HARD_REG_SET)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

For whatever reason this reaches gcc_unreachable() in [1].

[1]:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/stor-layout.cc;h=63e830a4d2e2db6e891a6bb5ecc08e8d095ad3c3;hb=HEAD#l408.

This change ([2], specifically line 5 below) in cryptsetup triggers this issue:

```
+#define ATTR_NOINLINE __attribute__ ((noinline))
+#define ATTR_ZERO_REGS
+#if defined __has_attribute
+#  if __has_attribute (zero_call_used_regs)
+#    undef ATTR_ZERO_REGS
+#    define ATTR_ZERO_REGS __attribute__ ((zero_call_used_regs("used")))
+#  endif
+#endif
```

...released with 2.8.0.

[2]:
https://github.com/mbroz/cryptsetup/commit/c5d4b845dfcd0514564c08f19d76c5da3162ed4d#diff-40bc8f4f3a8d7a09424c918181476ef8dbe36cfd55e89eb7a19ffe308220b2b1R28

This is also happens when using a cross-compiler on T2. I asked René if any
other architecture in T2 also shows this problem, but he didn't see that for
any other architecture in T2, so it might be a sole problem of ia64.

T2 works it around with [3]. EPIC Slack stays on 2.7.5 for the time being.

[3]:
https://github.com/rxrbln/t2sde/blob/main/package/security/cryptsetup/hotfix-zero-regs.patch.ia64

I'm unsure about the selected component for the bug.

Reply via email to