diff mbox series

[bug#62307,core-updates,01/15] gnu: glibc/fix-for-hurd-cross: Add new variant.

Message ID 6a027350c8639d0c52cdda781abb9f7d304f64ed.1679349992.git.dev@jpoiret.xyz
State New
Headers show
Series Update Hurd and fix build failures | expand

Commit Message

Josselin Poiret March 20, 2023, 10:10 p.m. UTC
* gnu/packages/base.scm (glibc/fix-for-hurd-cross): New variable.
(glibc/hurd-headers): Inherit it.
* gnu/packages/patches/glibc-hurd-add-freestanding-for-configure.patch:
* gnu/packages/patches/glibc-hurd-add-freestanding-to-cppflags.patch: New files
* gnu/local.mk (dist_patch_DATA): Register patches.
---
 gnu/local.mk                                  |  2 +
 gnu/packages/base.scm                         | 13 ++-
 ...-hurd-add-freestanding-for-configure.patch | 87 +++++++++++++++++++
 ...bc-hurd-add-freestanding-to-cppflags.patch | 72 +++++++++++++++
 4 files changed, 173 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/glibc-hurd-add-freestanding-for-configure.patch
 create mode 100644 gnu/packages/patches/glibc-hurd-add-freestanding-to-cppflags.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index c7a37814d9..0b2c8538c4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1226,6 +1226,8 @@  dist_patch_DATA =						\
   %D%/packages/patches/glibc-cross-objdump.patch		\
   %D%/packages/patches/glibc-dl-cache.patch			\
   %D%/packages/patches/glibc-hidden-visibility-ldconfig.patch	\
+  %D%/packages/patches/glibc-hurd-add-freestanding-to-cppflags.patch \
+  %D%/packages/patches/glibc-hurd-add-freestanding-for-configure.patch \
   %D%/packages/patches/glibc-hurd-clock_gettime_monotonic.patch	\
   %D%/packages/patches/glibc-2.31-hurd-clock_gettime_monotonic.patch	\
   %D%/packages/patches/glibc-hurd-clock_t_centiseconds.patch	\
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 041f16b4fc..ffb3f8ac52 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -1376,8 +1376,19 @@  (define-public which
 command.")
     (license gpl3+))) ; some files are under GPLv2+
 
+;; We need this for now because otherwise the configure phase fails.  This
+;; will be fixed with glibc 2.37.
+(define-public glibc/fix-for-hurd-cross
+  (package/inherit glibc
+    (source
+     (origin
+       (inherit (package-source glibc))
+       (patches (append (origin-patches (package-source glibc))
+                        (search-patches "glibc-hurd-add-freestanding-for-configure.patch"
+                                        "glibc-hurd-add-freestanding-to-cppflags.patch")))))))
+
 (define-public glibc/hurd-headers
-  (package (inherit glibc)
+  (package (inherit glibc/fix-for-hurd-cross)
     (name "glibc-hurd-headers")
     (outputs '("out"))
     (propagated-inputs (list gnumach-headers hurd-headers))
diff --git a/gnu/packages/patches/glibc-hurd-add-freestanding-for-configure.patch b/gnu/packages/patches/glibc-hurd-add-freestanding-for-configure.patch
new file mode 100644
index 0000000000..4b5346f012
--- /dev/null
+++ b/gnu/packages/patches/glibc-hurd-add-freestanding-for-configure.patch
@@ -0,0 +1,87 @@ 
+From 8b8c768e3c701ed1993789bb46acb8a12c7a93df Mon Sep 17 00:00:00 2001
+From: Flavio Cruz <flaviocruz@gmail.com>
+Date: Sun, 18 Dec 2022 19:46:15 -0500
+Subject: [PATCH] Force use of -ffreestanding when checking for gnumach headers
+
+Without this ./configure assumes that we are in a fully hosted
+environment, which might not be the case. After this patch, we can rely on
+the freestanding header files provided by GCC such as stdint.h.
+Message-Id: <Y5+0V9osFc/zXMq0@mars>
+---
+ sysdeps/mach/configure    | 8 +++++++-
+ sysdeps/mach/configure.ac | 6 ++++++
+ 2 files changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/sysdeps/mach/configure b/sysdeps/mach/configure
+index 739f1028a46..36f556a6639 100644
+--- a/sysdeps/mach/configure
++++ b/sysdeps/mach/configure
+@@ -133,6 +133,8 @@ if test -n "$sysheaders"; then
+ fi
+ 
+ ### Sanity checks for Mach header installation
++old_CFLAGS=$CFLAGS
++CFLAGS="$CFLAGS -ffreestanding"
+ 
+ 
+ ac_fn_c_check_header_preproc "$LINENO" "mach/mach_types.h" "ac_cv_header_mach_mach_types_h"
+@@ -143,6 +145,7 @@ else
+ fi
+ 
+ 
++CFLAGS=$old_CFLAGS
+ ac_fn_c_check_header_preproc "$LINENO" "mach/mach_types.defs" "ac_cv_header_mach_mach_types_defs"
+ if test "x$ac_cv_header_mach_mach_types_defs" = xyes; then :
+ 
+@@ -216,7 +219,9 @@ $as_echo_n "checking for creation_time in task_basic_info... " >&6; }
+ if ${libc_cv_mach_task_creation_time+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++  old_CFLAGS=$CFLAGS
++CFLAGS="$CFLAGS -ffreestanding"
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ #include <mach/task_info.h>
+ int
+@@ -242,6 +247,7 @@ $as_echo "$libc_cv_mach_task_creation_time" >&6; }
+ if test $libc_cv_mach_task_creation_time = no; then
+   as_fn_error $? "you need Mach headers supporting task_info.creation_time" "$LINENO" 5
+ fi
++CFLAGS=$old_CFLAGS
+ 
+ mach_interface_list=
+ for ifc in mach mach4 gnumach \
+diff --git a/sysdeps/mach/configure.ac b/sysdeps/mach/configure.ac
+index 61b00d66b10..5816c3d4ad4 100644
+--- a/sysdeps/mach/configure.ac
++++ b/sysdeps/mach/configure.ac
+@@ -12,8 +12,11 @@ if test -n "$sysheaders"; then
+ fi
+ 
+ ### Sanity checks for Mach header installation
++old_CFLAGS=$CFLAGS
++CFLAGS="$CFLAGS -ffreestanding"
+ AC_CHECK_HEADER(mach/mach_types.h,,
+                 [AC_MSG_ERROR([cannot find Mach headers])], -)
++CFLAGS=$old_CFLAGS
+ AC_CHECK_HEADER(mach/mach_types.defs,, [dnl
+ AC_MSG_ERROR([cannot find Mach .defs files])], -)
+ 
+@@ -42,6 +45,8 @@ dnl The creation_time field is a GNU Mach addition the other variants lack.
+ dnl
+ AC_CACHE_CHECK(for creation_time in task_basic_info,
+ 	       libc_cv_mach_task_creation_time, [dnl
++old_CFLAGS=$CFLAGS
++CFLAGS="$CFLAGS -ffreestanding"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach/task_info.h>]], [[
+ extern struct task_basic_info *i;
+ long s = i->creation_time.seconds;
+@@ -49,6 +54,7 @@ long s = i->creation_time.seconds;
+ if test $libc_cv_mach_task_creation_time = no; then
+   AC_MSG_ERROR([you need Mach headers supporting task_info.creation_time])
+ fi
++CFLAGS=$old_CFLAGS
+ 
+ dnl
+ dnl The Darwin variant no longer has <mach/mach.defs>
diff --git a/gnu/packages/patches/glibc-hurd-add-freestanding-to-cppflags.patch b/gnu/packages/patches/glibc-hurd-add-freestanding-to-cppflags.patch
new file mode 100644
index 0000000000..14ed3f2a78
--- /dev/null
+++ b/gnu/packages/patches/glibc-hurd-add-freestanding-to-cppflags.patch
@@ -0,0 +1,72 @@ 
+From 7685630b98ca2a3f5de86eadf130993e6cf998a0 Mon Sep 17 00:00:00 2001
+From: Samuel Thibault <samuel.thibault@ens-lyon.org>
+Date: Mon, 19 Dec 2022 02:34:55 +0100
+Subject: [PATCH] mach: Fix passing -ffreestanding when checking for gnumach
+ headers
+
+8b8c768e3c70 ("Force use of -ffreestanding when checking for gnumach
+headers") was passing -ffreestanding to CFLAGS only, but headers checks are
+performed with the preprocessor, so we rather need to pass it to CPPFLAGS.
+---
+ sysdeps/mach/configure    | 9 +++------
+ sysdeps/mach/configure.ac | 9 +++------
+ 2 files changed, 6 insertions(+), 12 deletions(-)
+
+diff --git a/sysdeps/mach/configure b/sysdeps/mach/configure
+index 36f556a663..ba6371cd3f 100644
+--- a/sysdeps/mach/configure
++++ b/sysdeps/mach/configure
+@@ -127,14 +127,13 @@ fi
+ config_vars="$config_vars
+ MIG = $MIG"
+ 
++OLD_CPPFLAGS=$CPPFLAGS
+ if test -n "$sysheaders"; then
+-  OLD_CPPFLAGS=$CPPFLAGS
+   CPPFLAGS="$CPPFLAGS $SYSINCLUDES"
+ fi
+ 
+ ### Sanity checks for Mach header installation
+-old_CFLAGS=$CFLAGS
+-CFLAGS="$CFLAGS -ffreestanding"
++CPPFLAGS="$CPPFLAGS -ffreestanding"
+ 
+ 
+ ac_fn_c_check_header_preproc "$LINENO" "mach/mach_types.h" "ac_cv_header_mach_mach_types_h"
+@@ -527,6 +526,4 @@ if test $hurd_cv_mig_retcode = yes; then
+ 
+ fi
+ 
+-if test -n "$sysheaders"; then
+-  CPPFLAGS=$OLD_CPPFLAGS
+-fi
++CPPFLAGS=$OLD_CPPFLAGS
+diff --git a/sysdeps/mach/configure.ac b/sysdeps/mach/configure.ac
+index 5816c3d4ad..900e5445c5 100644
+--- a/sysdeps/mach/configure.ac
++++ b/sysdeps/mach/configure.ac
+@@ -6,14 +6,13 @@ if test "x$MIG" = xMISSING; then
+ fi
+ LIBC_CONFIG_VAR([MIG], [$MIG])
+ 
++OLD_CPPFLAGS=$CPPFLAGS
+ if test -n "$sysheaders"; then
+-  OLD_CPPFLAGS=$CPPFLAGS
+   CPPFLAGS="$CPPFLAGS $SYSINCLUDES"
+ fi
+ 
+ ### Sanity checks for Mach header installation
+-old_CFLAGS=$CFLAGS
+-CFLAGS="$CFLAGS -ffreestanding"
++CPPFLAGS="$CPPFLAGS -ffreestanding"
+ AC_CHECK_HEADER(mach/mach_types.h,,
+                 [AC_MSG_ERROR([cannot find Mach headers])], -)
+ CFLAGS=$old_CFLAGS
+@@ -136,6 +135,4 @@ fi])
+ 
+ hurd_MIG_RETCODE
+ 
+-if test -n "$sysheaders"; then
+-  CPPFLAGS=$OLD_CPPFLAGS
+-fi
++CPPFLAGS=$OLD_CPPFLAGS