Page MenuHome GnuPG

libgcrypt build-error with gcc-15 on powerpc and alpha
Closed, ResolvedPublic

Description

On some archs libgcrypt fails to build from source with gcc-15. Helmut Grohne writes:

libgcrypt20 fails to build from source with gcc-15 for some
architectures. The cause may be found in mpi/longlong.h. In several
lines such as 193, 499 and 1409, there are function prototypes without
arguments. This trips up the updated language standard by gcc-15 and
building libcrypt20 now complains about excess arguments. For example:

In file included from ../../mpi/mpih-div.c:32:
../../mpi/mpih-div.c: In function ‘_gcry_mpih_mod_1’:
../../mpi/longlong.h:190:11: error: too many arguments to function ‘__udiv_qrnnd’; expected 0, have 4
  190 |     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                         \
      |           ^~~~~~~~~~~~  ~~~~
../../mpi/mpih-div.c:84:17: note: in expansion of macro ‘udiv_qrnnd’
   84 |                 udiv_qrnnd(divisor_limb_inverted, dummy,
      |                 ^~~~~~~~~~
../../mpi/longlong.h:193:16: note: declared here

This does not seem to affect amd64 as Matthias would have otherwise
reported this problem already. It does affect at least alpha.

I do not see this on arm64, powerpc64le shows a different issue:

libtool: link: ( cd ".libs" && rm -f "libgcrypt.la" && ln -s "../libgcrypt.la" "libgcrypt.la" )
/bin/bash ../libtool  --tag=CC   --mode=link gcc-15  -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/ametzler/GCR/libgcrypt20-1.11.1=. -fstack-protector-strong -Wformat -Werror=format-security -fvisibility=hidden -fno-delete-null-pointer-checks -Wall  -Wl,-z,relro -Wl,-z,now -o mpicalc mpicalc-mpicalc.o libgcrypt.la -L/usr/lib/powerpc64le-linux-gnu -lgpg-error
libtool: link: gcc-15 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/ametzler/GCR/libgcrypt20-1.11.1=. -fstack-protector-strong -Wformat -Werror=format-security -fvisibility=hidden -fno-delete-null-pointer-checks -Wall -Wl,-z -Wl,relro -Wl,-z -Wl,now -o .libs/mpicalc mpicalc-mpicalc.o  ./.libs/libgcrypt.so -L/usr/lib/powerpc64le-linux-gnu -lgpg-error
/usr/bin/ld: ./.libs/libgcrypt.so: undefined reference to `gcry_poly1305_p10le_4blocks'
/usr/bin/ld: ./.libs/libgcrypt.so: undefined reference to `_gcry_chacha20_p10le_8x'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:662: mpicalc] Error 1
make[3]: Leaving directory '/home/ametzler/GCR/libgcrypt20-1.11.1/build/src'

Comparing the buildlogs for gcc14 and 15 on this arch shows no errors/warnings, I was surprised that support for "checking whether GCC inline assembler supports PowerISA 3.00 instructions." stopped succeeding with gcc-15.

Details

External Link
https://bugs.debian.org/1109071
Version
1.11.0

Event Timeline

Sure that this is about 1.11.0 ? We released 1.11.1 with at least one fix for gcc regression (T7166). In master we had some more fixes for gcc 15 bugs (or what ever you will call such regression in a compiler)

Sure that this is about 1.11.0 ? We released 1.11.1 with at least one fix for gcc regression (T7166). In master we had some more fixes for gcc 15 bugs (or what ever you will call such regression in a compiler)

Helmut tested on 1.11.0, the powerpc64le issue was reproduced by me on 1.11.1.
I have asked Helmut on which archs except alpha (I have no access there) I should be able to reproduce the original issue.

werner renamed this task from libgcrypt build-error with gcc-15 to libgcrypt build-error with gcc-15 on powerpc and alpha.Jul 14 2025, 4:54 PM

The powerpc64le issue (undefined reference to `gcry_poly1305_p10le_4blocks') also applies to GIT master.

gniibe triaged this task as Normal priority.
gniibe added a subscriber: gniibe.

For PowerISA 3.00 Instructions issue, following patch may help:

diff --git a/configure.ac b/configure.ac
index 6cc1e189..70d632af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2448,10 +2448,11 @@ AC_CACHE_CHECK([whether GCC inline assembler supports PowerISA 3.00 instructions
         else
           gcry_cv_gcc_inline_asm_ppc_arch_3_00=no
           AC_LINK_IFELSE([AC_LANG_PROGRAM(
-          [[__asm__(".text\n\t"
+          [[__asm__(".machine        \"any\"\n"
+                    ".text\n\t"
                     ".globl testfn;\n"
                     "testfn:\n"
-                    "stxvb16x %r1,%v12,%v30;\n"
+                    "stxvb16x 47,0,9;\n"
                   );
             void testfn(void);
             ]], [ testfn(); ])],

I figured out that .machine "any" is needed with GCC 15.

For Alpha (hppa, and sparc), IIUC, following patch may help:

diff --git a/mpi/longlong.h b/mpi/longlong.h
index 7dc67591..9e60592a 100644
--- a/mpi/longlong.h
+++ b/mpi/longlong.h
@@ -192,7 +192,7 @@ SPDX-License-Identifier: LGPL-2.1-or-later
     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); 			\
     (r) = __r;								\
   } while (0)
-extern UDItype __udiv_qrnnd ();
+extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
 #  define UDIV_TIME 220
 # endif /* !LONGLONG_STANDALONE */
 #endif /* __alpha */
@@ -448,7 +448,7 @@ extern UDItype __udiv_qrnnd ();
     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); 			\
     (r) = __r;								\
   } while (0)
-extern USItype __udiv_qrnnd ();
+extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
 # endif /* !LONGLONG_STANDALONE && !ASM_DISABLED */
 # define count_leading_zeros(count, x) \
   do {								       \
@@ -1408,7 +1408,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); 			\
     (r) = __r;								\
   } while (0)
-extern USItype __udiv_qrnnd ();
+extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
 #   define UDIV_TIME 140
 #  endif /* LONGLONG_STANDALONE */
 # endif /* udiv_qrnnd */

I checked GCC for longlong.h. It's gone for hppa and sparc (C implementation is enough). For Alpha, we see adding the function prototype.

I figured out that .machine "any" is needed with GCC 15.

Perhaps, cipher/poly1305-p10le.s would also need this. (I only tested for the check of stxvb16x instruction.)

For PowerISA 3.00 Instructions issue, following patch may help:

diff --git a/configure.ac b/configure.ac
index 6cc1e189..70d632af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2448,10 +2448,11 @@ AC_CACHE_CHECK([whether GCC inline assembler supports PowerISA 3.00 instructions
         else
           gcry_cv_gcc_inline_asm_ppc_arch_3_00=no
           AC_LINK_IFELSE([AC_LANG_PROGRAM(
-          [[__asm__(".text\n\t"
+          [[__asm__(".machine        \"any\"\n"
+                    ".text\n\t"
                     ".globl testfn;\n"
                     "testfn:\n"
-                    "stxvb16x %r1,%v12,%v30;\n"
+                    "stxvb16x 47,0,9;\n"
                   );
             void testfn(void);
             ]], [ testfn(); ])],

I figured out that .machine "any" is needed with GCC 15.

With this patch we get

checking whether GCC inline assembler supports PowerISA 3.00 instructions... yes

again, but the build fails with

/bin/bash ../libtool    --mode=compile gcc-15 -Wa,--noexecstack -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/ametzler/GCR/libgcrypt20-1.11.1=. -fstack-protector-strong -Wformat -Werror=format-security -c -o poly1305-p10le.lo ../../cipher/poly1305-p10le.s
libtool: compile:  gcc-15 -Wa,--noexecstack -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/ametzler/GCR/libgcrypt20-1.11.1=. -fstack-protector-strong -Wformat -Werror=format-security -c ../../cipher/poly1305-p10le.s  -fPIC -DPIC -o .libs/poly1305-p10le.o
../../cipher/poly1305-p10le.s: Assembler messages:
../../cipher/poly1305-p10le.s:381: Error: unrecognized opcode: `lxv'
../../cipher/poly1305-p10le.s:382: Error: unrecognized opcode: `lxv'
../../cipher/poly1305-p10le.s:395: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:397: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:399: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:401: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:402: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:406: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:514: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:518: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:520: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:522: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:524: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:525: Error: unrecognized opcode: `mtvsrdd'
../../cipher/poly1305-p10le.s:772: Error: unrecognized opcode: `mfvsrld'
../../cipher/poly1305-p10le.s:776: Error: unrecognized opcode: `mfvsrld'
../../cipher/poly1305-p10le.s:777: Error: unrecognized opcode: `mfvsrld'
make[3]: *** [Makefile:983: poly1305-p10le.lo] Error 1
make[3]: Leaving directory '/home/ametzler/GCR/libgcrypt20-1.11.1/build/cipher'

I tested Ubuntu's version of GCC-15 (powerpc64le cross-compiler) and did not see this build failure:

$ powerpc64le-linux-gnu-gcc-15 --version
powerpc64le-linux-gnu-gcc-15 (Ubuntu 15-20250404-0ubuntu1) 15.0.1 20250404 (experimental) [master r15-9193-g08e803aa9be]
checking whether compiler supports PowerPC AltiVec/VSX/crypto intrinsics... yes
checking whether GCC inline assembler supports PowerPC AltiVec/VSX/crypto instructions... yes
checking whether GCC inline assembler supports PowerISA 3.00 instructions... yes

Build also succeeds with my setup.

Here's patches which might help... at least they do not break my build:

IIUC, it's actually binutils version dependency (instead of GCC 15), perhaps.

Well, let me apply the patch of longlong firstly.

Then, please apply PowerPC patches of yours, @jukivili .

gniibe mentioned this in Unknown Object (Maniphest Task).Jul 28 2025, 8:00 AM

Ok, thanks. I pushed the powerpc patches to master.

gniibe mentioned this in Unknown Object (Maniphest Task).Aug 4 2025, 8:02 AM
gniibe changed the task status from Open to Testing.Aug 5 2025, 7:57 AM

Hello,
thank you all. I can confirm that 1.11.2 builds successfully on ppc64el with gcc-15 (Debian sid + experimental). Lacking access I have not be able to check alpha. I would suggest closing this report as fixed.
cu Andreas

Thanks for testing.