[gcc r16-5605] [PATCH] libgomp: Fix GCC build after glibc@cd748a6
Jeff Law
law@gcc.gnu.org
Tue Nov 25 23:58:57 GMT 2025
https://gcc.gnu.org/g:9c9d3aef2f66625d9cb03ef4baee10ed6648e681
commit r16-5605-g9c9d3aef2f66625d9cb03ef4baee10ed6648e681
Author: Frank Scheiner <frank.scheiner@web.de>
Date: Tue Nov 25 16:58:23 2025 -0700
[PATCH] libgomp: Fix GCC build after glibc@cd748a6
The toolchain autobuilds for ia64 failed ([1]) yesterday with:
```
libtool: compile: /usr/src/t2-src/src.gcc.ia64-toolchain.251121.040147.278918/gcc-16-20251116/objs/gcc/xgcc-wrapper /usr/src/t2-src/src.gcc.ia64-toolchain.251121.040147.278918/gcc-16-20251116/objs/./gcc/xgcc -B/usr/src/t2-src/src.gcc.ia64-toolchain.251121.040147.278918/gcc-16-20251116/objs/./gcc/ -B/usr/src/t2-src/build/ia64-toolchain-24-svn-generic-ia64-itanium2-cross-linux/TOOLCHAIN/cross/usr/ia64-t2-linux-gnu/bin/ -B/usr/src/t2-src/build/ia64-toolchain-24-svn-generic-ia64-itanium2-cross-linux/TOOLCHAIN/cross/usr/ia64-t2-linux-gnu/lib/ -isystem /usr/src/t2-src/build/ia64-toolchain-24-svn-generic-ia64-itanium2-cross-linux/TOOLCHAIN/cross/usr/ia64-t2-linux-gnu/include -isystem /usr/src/t2-src/build/ia64-toolchain-24-svn-generic-ia64-itanium2-cross-linux/TOOLCHAIN/cross/usr/ia64-t2-linux-gnu/sys-include --sysroot=/usr/src/t2-src/build/ia64-toolchain-24-svn-generic-ia64-itanium2-cross-linux -DHAVE_CONFIG_H -I. -I../../../libgomp -I../../../libgomp/config/linux/ia64 -I../../../libgomp/config/linux -I../../../libgomp/config/posix -I../../../libgomp -I../../../libgomp/../include -Wall -Werror -ftls-model=initial-exec -pthread -DUSING_INITIAL_EXEC_TLS -g -O2 -MT oacc-cuda.lo -MD -MP -MF .deps/oacc-cuda.Tpo -c ../../../libgomp/oacc-cuda.c -o oacc-cuda.o >/dev/null 2>&1
../../../libgomp/affinity-fmt.c: In function 'gomp_display_affinity':
../../../libgomp/affinity-fmt.c:330:25: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
330 | char *q = strchr (p + 1, '}');
| ^~~~~~
```
[1]: https://github.com/johnny-mnemonic/toolchain-autobuilds/actions/runs/19559235881
This is not ia64-specific but due to the changes in the recent glibc
commit "Implement C23 const-preserving standard library macros" (i.e.
[2]) now requiring "char *q" to be a pointer to a const char to compile
w/o error because of the return value of strchr() .
[2]: https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Also see the related discussion at [3] for details.
[3]: https://sourceware.org/pipermail/libc-alpha/2025-November/172809.html
The GCC build is fixed by the attached patch, see [4] for a successful
build with the then latest snapshots of binutils, glibc and GCC.
[4]: https://github.com/johnny-mnemonic/toolchain-autobuilds/actions/runs/19585045571
Idea from Tomas, attached patch from me.
Cheers,
Frank
0001-libgomp-Fix-GCC-build-after-glibc-cd748a6.patch
From 80af9c233c694904174b54a59404d311378f41f8 Mon Sep 17 00:00:00 2001
From: Frank Scheiner <frank.scheiner@web.de>
Date: Sat, 22 Nov 2025 14:58:10 +0100
Subject: [PATCH] libgomp: Fix GCC build after glibc@cd748a6
char *q needs to be a pointer to a const char for the return value of
strchr() with glibc after "Implement C23 const-preserving standard library
macros".
[glibc@cd748a6]: https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
libgomp/ChangeLog:
* affinity-fmt.c: Make char *q a pointer to a const char.
Diff:
---
libgomp/affinity-fmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgomp/affinity-fmt.c b/libgomp/affinity-fmt.c
index 1fae893cbaca..8d3df5f1cd55 100644
--- a/libgomp/affinity-fmt.c
+++ b/libgomp/affinity-fmt.c
@@ -327,7 +327,7 @@ gomp_display_affinity (char *buffer, size_t size,
}
if (c == '{')
{
- char *q = strchr (p + 1, '}');
+ const char *q = strchr (p + 1, '}');
if (q)
gomp_fatal ("unsupported long type name '%.*s' in affinity "
"format", (int) (q - (p + 1)), p + 1);
More information about the Gcc-cvs
mailing list