Subject: bug#73793: closed (Re: [PATCH v3] gnu: gcc-9: Add libsanitizer fsconfig command patch)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 15 Oct 2024 15:58:04 +0000

Your bug report

#73793: [PATCH] gnu: gcc-9: Fix name conflict for newer glibc versions

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
73793: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73793
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [PATCH v3] gnu: gcc-9: Add libsanitizer fsconfig command patch
From: Ludovic Courtès <[email-masked]>
To: Rutherther <[email-masked]>
Cc: [email-masked]
Date: Tue, 15 Oct 2024 17:45:46 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Rutherther <[email-masked]> skribis:

> Since newer glibc version there is a conflict in names
> between kernel module and glibc module.
> This uses a patch that was used upstream in llvm to bypass it.
> Without this, the build fails with a redefinition error.
>
> * gnu/packages/gcc.scm: Add gcc-7-libsanitizer-fsconfig-command.patch.
>
> Change-Id: Ibb8446b7bba52f72d82fcf69804cae09215daeed

I tweaked the commit log to clarify which entities are changed.

Applied, thanks!

Ludo’.

Subject: [PATCH] gnu: gcc-9: Fix name conflict for newer glibc versions
From: Rutherther <[email-masked]>
To: [email-masked]
Cc: Rutherther <[email-masked]>
Date: Sun, 13 Oct 2024 17:22:36 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Note: not tested yet, I am currently building it locally.

Since newer glibc version there is a conflict in names.
This uses a patch that was used upstream in llvm to bypass it.

* gnu/packages/patches/gcc-9-glibc-name-conflict.patch: Add gcc 9 glibc patch.
* gnu/local.mk: Register it.
* gnu/packages/gcc.scm (gcc-9)[source]: Use it.

Change-Id: Ibb8446b7bba52f72d82fcf69804cae09215daeed
---
 gnu/local.mk                                  |  1 +
 gnu/packages/gcc.scm                          |  3 +-
 .../patches/gcc-9-glibc-name-conflict.patch   | 54 +++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/gcc-9-glibc-name-conflict.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3a35bbca37..c1e878587a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1349,6 +1349,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gcc-8-sort-libtool-find-output.patch	\
   %D%/packages/patches/gcc-8-strmov-store-file-names.patch	\
   %D%/packages/patches/gcc-9-asan-fix-limits-include.patch	\
+  %D%/packages/patches/gcc-9-glibc-name-conflict.patch	        \
   %D%/packages/patches/gcc-9-strmov-store-file-names.patch	\
   %D%/packages/patches/gcc-12-strmov-store-file-names.patch	\
   %D%/packages/patches/gcc-10-cross-environment-variables.patch \
diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index c6c7730ad1..b014cee6c1 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -724,7 +724,8 @@ (define-public gcc-10
             (sha256
              (base32
               "1h87lcfaga0ydsf4pkhwlnjr8mky5ix8npbv6iy3jvzlzm1ra415"))
-            (patches (search-patches "gcc-9-strmov-store-file-names.patch"
+            (patches (search-patches "gcc-9-glibc-name-conflict.patch"
+                                     "gcc-9-strmov-store-file-names.patch"
                                      "gcc-5.0-libvtv-runpath.patch"
                                      "gcc-10-libsanitizer-no-crypt.patch"))
             (modules '((guix build utils)))
diff --git a/gnu/packages/patches/gcc-9-glibc-name-conflict.patch b/gnu/packages/patches/gcc-9-glibc-name-conflict.patch
new file mode 100644
index 0000000000..3796e86c52
--- /dev/null
+++ b/gnu/packages/patches/gcc-9-glibc-name-conflict.patch
@@ -0,0 +1,54 @@
+From b379129c4beb3f26223288627a1291739f33af02 Mon Sep 17 00:00:00 2001
+From: Fangrui Song <[email-masked]>
+Date: Mon, 11 Jul 2022 11:38:28 -0700
+Subject: [PATCH] [sanitizer] Remove #include <linux/fs.h> to resolve
+ fsconfig_command/mount_attr conflict with glibc 2.36
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It is generally not a good idea to mix usage of glibc headers and Linux UAPI
+headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
+since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
+defines `fsconfig_command` which conflicts with linux/mount.h:
+
+    .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’
+
+Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.
+
+Fix https://github.com/llvm/llvm-project/issues/56421
+
+Reviewed By: #sanitizers, vitalybuka, zatrazz
+
+Differential Revision: https://reviews.llvm.org/D129471
+---
+ .../sanitizer_common/sanitizer_platform_limits_posix.cpp | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+index 4bd425435d56d9..81740bf4ab3948 100644
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -73,7 +73,6 @@
+ #include <sys/vt.h>
+ #include <linux/cdrom.h>
+ #include <linux/fd.h>
+-#include <linux/fs.h>
+ #include <linux/hdreg.h>
+ #include <linux/input.h>
+ #include <linux/ioctl.h>
+@@ -876,10 +875,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
+   unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
+ #endif
+-  unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
+-  unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
+-  unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
+-  unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
++  unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
++  unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
++  unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
++  unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
+   unsigned IOCTL_GIO_CMAP = GIO_CMAP;
+   unsigned IOCTL_GIO_FONT = GIO_FONT;
+   unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;

base-commit: 8f0d76152a4496960f4c2ec219839c5a48b0568e
-- 
2.46.0