Skip to content

Commit d71e614

Browse files
committed
Add Glibc patches for building with GCC 14
1 parent b1678dd commit d71e614

8 files changed

+195
-5
lines changed

bootstrap/Glibc/build_tarballs.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ fi
4949
# Always use `/lib`, no more `/lib64`
5050
GLIBC_CONFIGURE_OVERRIDES+=( libc_cv_slibdir=/lib libdir="/lib" )
5151
52+
# Our newer compilers balk at some of this old glibc code.
53+
# `-Wno-implicit-int` is to fix `__start()` not having `int` before it breaking configure tests.
54+
# `-fcommon` is to enable the old default behavior of GCC <= 10 merging `__cache_line_size`
55+
GLIBC_CONFIGURE_OVERRIDES+=( CFLAGS="-g -O2 -fcommon -Wno-implicit-int -Wno-implicit-function-declaration -Wno-builtin-declaration-mismatch -Wno-array-parameter -Wno-int-conversion" )
56+
5257
rm -rf ${WORKSPACE}/srcdir/glibc_build
5358
mkdir -p ${WORKSPACE}/srcdir/glibc_build
5459
cd ${WORKSPACE}/srcdir/glibc_build
@@ -58,7 +63,7 @@ ${WORKSPACE}/srcdir/glibc-*/configure \
5863
--host=${target} \
5964
--disable-multilib \
6065
--disable-werror \
61-
${GLIBC_CONFIGURE_OVERRIDES[@]}
66+
"${GLIBC_CONFIGURE_OVERRIDES[@]}"
6267
6368
make -j${nproc}
6469
make install install_root="${prefix}"
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
commit d6af8dfa32b42c9956ddbe557d3bfecbd92c0462
2+
Author: Elliot Saba <[email protected]>
3+
Date: Sun May 18 18:43:48 2025 +0000
4+
5+
Backport removal of no-whole-archive
6+
7+
This configure check was removed in cf09d0b052cbbfbcabc3c3d78d485876b9b81f9c
8+
and fails for newer GCC versions (Such as GCC 14) with the following error:
9+
```
10+
conftest.c:1:1: error: return type defaults to 'int' [-Wimplicit-int]
11+
1 | _start () {}
12+
| ^~~~~~
13+
conftest.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
14+
3 | __throw () {}
15+
| ^~~~~~~
16+
```
17+
We backport its removal here.
18+
19+
diff --git a/configure b/configure
20+
index 8c9413b14c..b14ebb63a1 100755
21+
--- a/configure
22+
+++ b/configure
23+
@@ -7219,36 +7219,6 @@ _ACEOF
24+
25+
fi
26+
27+
-{ $as_echo "$as_me:$LINENO: checking for ld --no-whole-archive" >&5
28+
-$as_echo_n "checking for ld --no-whole-archive... " >&6; }
29+
-if test "${libc_cv_ld_no_whole_archive+set}" = set; then
30+
- $as_echo_n "(cached) " >&6
31+
-else
32+
- cat > conftest.c <<\EOF
33+
-_start () {}
34+
-int __eh_pc;
35+
-__throw () {}
36+
-EOF
37+
-if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
38+
- -nostdlib -nostartfiles -Wl,--no-whole-archive
39+
- -o conftest conftest.c 1>&5'
40+
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
41+
- (eval $ac_try) 2>&5
42+
- ac_status=$?
43+
- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
44+
- (exit $ac_status); }; }; then
45+
- libc_cv_ld_no_whole_archive=yes
46+
-else
47+
- libc_cv_ld_no_whole_archive=no
48+
-fi
49+
-rm -f conftest*
50+
-fi
51+
-{ $as_echo "$as_me:$LINENO: result: $libc_cv_ld_no_whole_archive" >&5
52+
-$as_echo "$libc_cv_ld_no_whole_archive" >&6; }
53+
-if test $libc_cv_ld_no_whole_archive = yes; then
54+
- no_whole_archive=-Wl,--no-whole-archive
55+
-fi
56+
-
57+
{ $as_echo "$as_me:$LINENO: checking for gcc -fexceptions" >&5
58+
$as_echo_n "checking for gcc -fexceptions... " >&6; }
59+
if test "${libc_cv_gcc_exceptions+set}" = set; then
60+
diff --git a/configure.in b/configure.in
61+
index 098adf4d35..f2c8491590 100644
62+
--- a/configure.in
63+
+++ b/configure.in
64+
@@ -1945,26 +1945,6 @@ if test $libc_cv_asm_cfi_directives = yes; then
65+
AC_DEFINE(HAVE_ASM_CFI_DIRECTIVES)
66+
fi
67+
68+
-AC_CACHE_CHECK(for ld --no-whole-archive, libc_cv_ld_no_whole_archive, [dnl
69+
-cat > conftest.c <<\EOF
70+
-_start () {}
71+
-int __eh_pc;
72+
-__throw () {}
73+
-EOF
74+
-dnl No \ in command here because it ends up inside ''.
75+
-if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
76+
- -nostdlib -nostartfiles -Wl,--no-whole-archive
77+
- -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
78+
- libc_cv_ld_no_whole_archive=yes
79+
-else
80+
- libc_cv_ld_no_whole_archive=no
81+
-fi
82+
-rm -f conftest*])
83+
-if test $libc_cv_ld_no_whole_archive = yes; then
84+
- no_whole_archive=-Wl,--no-whole-archive
85+
-fi
86+
-AC_SUBST(no_whole_archive)dnl
87+
-
88+
AC_CACHE_CHECK(for gcc -fexceptions, libc_cv_gcc_exceptions, [dnl
89+
cat > conftest.c <<\EOF
90+
_start () {}

bootstrap/Glibc/patches-v2.17.0/glibc-000-gcc_version_217.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
AC_CHECK_TOOL_PREFIX
66
AC_CHECK_PROG_VER(CC, ${ac_tool_prefix}gcc ${ac_tool_prefix}cc, -v,
77
- [version \([egcygnustpi-]*[0-9.]*\)], [4.[3-9].* | 4.[1-9][0-9].* | [5-9].* ],
8-
+ [version \([egcygnustpi-]*[0-9.]*\)], [4.[3-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-1].* ],
8+
+ [version \([egcygnustpi-]*[0-9.]*\)], [4.[3-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-4].* ],
99
critic_missing="$critic_missing gcc")
1010
AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
1111
[GNU Make[^0-9]*\([0-9][0-9.]*\)],
@@ -16,7 +16,7 @@
1616
case $ac_prog_version in
1717
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
1818
- 4.[3-9].* | 4.[1-9][0-9].* | [5-9].* )
19-
+ 4.[3-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-1].* )
19+
+ 4.[3-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-4].* )
2020
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
2121
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
2222

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From e812eaa1ce27f2a7d07f75b2306c263b53d35816 Mon Sep 17 00:00:00 2001
2+
From: Artem Panfilov <[email protected]>
3+
Date: Wed, 31 Jan 2024 16:02:06 +0200
4+
Subject: [PATCH] x86_64: Correct THREAD_SETMEM/THREAD_SETMEM_NC for movq [BZ
5+
#27591]
6+
7+
config/i386/constraints.md in GCC has
8+
9+
(define_constraint "e"
10+
"32-bit signed integer constant, or a symbolic reference known
11+
to fit that range (for immediate operands in sign-extending x86-64
12+
instructions)."
13+
(match_operand 0 "x86_64_immediate_operand"))
14+
15+
Since movq takes a signed 32-bit immediate or a register source operand,
16+
use "er", instead of "nr"/"ir", constraint for 32-bit signed integer
17+
constant or register on movq.
18+
19+
Note: this patch is backported from:
20+
https://github.com/bminor/glibc/commit/b1ec623ed50bb8c7b9b6333fa350c3866dbde87f
21+
22+
Reviewed-by: Carlos O'Donell <[email protected]>
23+
Signed-off-by: Artem Panfilov <[email protected]>
24+
---
25+
nptl/sysdeps/x86_64/tls.h | 10 ++++++++--
26+
1 file changed, 8 insertions(+), 2 deletions(-)
27+
28+
diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
29+
index f3b76495b3..ec14b70b6f 100644
30+
--- a/nptl/sysdeps/x86_64/tls.h
31+
+++ b/nptl/sysdeps/x86_64/tls.h
32+
@@ -263,8 +263,11 @@ typedef struct
33+
4 or 8. */ \
34+
abort (); \
35+
\
36+
+ /* Since movq takes a signed 32-bit immediate or a register source \
37+
+ operand, use "er" constraint for 32-bit signed integer constant \
38+
+ or register. */ \
39+
asm volatile ("movq %q0,%%fs:%P1" : \
40+
- : IMM_MODE ((uint64_t) cast_to_integer (value)), \
41+
+ : "er" ((uint64_t) cast_to_integer (value)), \
42+
"i" (offsetof (struct pthread, member))); \
43+
}})
44+
45+
@@ -288,8 +291,11 @@ typedef struct
46+
4 or 8. */ \
47+
abort (); \
48+
\
49+
+ /* Since movq takes a signed 32-bit immediate or a register source \
50+
+ operand, use "er" constraint for 32-bit signed integer constant \
51+
+ or register. */ \
52+
asm volatile ("movq %q0,%%fs:%P1(,%q2,8)" : \
53+
- : IMM_MODE ((uint64_t) cast_to_integer (value)), \
54+
+ : "er" ((uint64_t) cast_to_integer (value)), \
55+
"i" (offsetof (struct pthread, member[0])), \
56+
"r" (idx)); \
57+
}})
58+
--
59+
2.39.2
60+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
glibc-151-old-gcc-cflags.patchcommit c961c54984c90b0e2f58247c1eafc826ac86ccc9
2+
Author: Elliot Saba <[email protected]>
3+
Date: Wed May 21 04:06:16 2025 +0000
4+
5+
Force old GCC behavior
6+
7+
These CFLAGS force newer GCCs to behave like older GCCs, which allows
8+
the build to actually go through.
9+
10+
diff --git a/configure b/configure
11+
index 8799b7de78..305acfada3 100755
12+
--- a/configure
13+
+++ b/configure
14+
@@ -2915,15 +2915,15 @@ if test "$ac_test_CFLAGS" = set; then
15+
CFLAGS=$ac_save_CFLAGS
16+
elif test $ac_cv_prog_cc_g = yes; then
17+
if test "$GCC" = yes; then
18+
- CFLAGS="-g -O2"
19+
+ CFLAGS="-g -O2 -Wno-implicit-int -fcommon"
20+
else
21+
- CFLAGS="-g"
22+
+ CFLAGS="-g -Wno-implicit-int -fcommon"
23+
fi
24+
else
25+
if test "$GCC" = yes; then
26+
- CFLAGS="-O2"
27+
+ CFLAGS="-O2 -Wno-implicit-int -fcommon"
28+
else
29+
- CFLAGS=
30+
+ CFLAGS="-Wno-implicit-int -fcommon"
31+
fi
32+
fi
33+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5

bootstrap/Glibc/patches-v2.19.0/glibc-000-gcc_version_219.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
AC_CHECK_TOOL_PREFIX
66
AC_CHECK_PROG_VER(CC, ${ac_tool_prefix}gcc ${ac_tool_prefix}cc, -v,
77
- [version \([egcygnustpi-]*[0-9.]*\)], [4.[4-9].* | 4.[1-9][0-9].* | [5-9].* ],
8-
+ [version \([egcygnustpi-]*[0-9.]*\)], [4.[4-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-1].* ],
8+
+ [version \([egcygnustpi-]*[0-9.]*\)], [4.[4-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-4].* ],
99
critic_missing="$critic_missing gcc")
1010
AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
1111
[GNU Make[^0-9]*\([0-9][0-9.]*\)],
@@ -16,7 +16,7 @@
1616
case $ac_prog_version in
1717
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
1818
- 4.[4-9].* | 4.[1-9][0-9].* | [5-9].* )
19-
+ 4.[4-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-1].* )
19+
+ 4.[4-9].* | 4.[1-9][0-9].* | [5-9].* | 1[0-4].* )
2020
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
2121
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
2222

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../patches-v2.17.0/glibc-150-movq-register.patch
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../patches-v2.17.0/glibc-151-old-gcc-cflags.patch

0 commit comments

Comments
 (0)