package/qemu: fix build with glibc >= 2.41

When host or target qemu is built with glibc >= 2.41 and Linux
user-land emulation (BR2_PACKAGE_QEMU_LINUX_USER=y or
BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE=y), compilation fails with
output:

    ../linux-user/syscall.c:362:8: error: redefinition of ‘struct sched_attr’
      362 | struct sched_attr {
          |        ^~~~~~~~~~
    In file included from /usr/include/bits/sched.h:63,
                     from /usr/include/sched.h:43,
                     from /usr/include/pthread.h:22,
                     from /home/buildroot/buildroot/output/per-package/host-qemu/host/include/glib-2.0/glib/deprecated/gthread.h:126,
                     from /home/buildroot/buildroot/output/per-package/host-qemu/host/include/glib-2.0/glib.h:115,
                     from /home/buildroot/buildroot/output/build/host-qemu-9.2.0/include/glib-compat.h:32,
                     from /home/buildroot/buildroot/output/build/host-qemu-9.2.0/include/qemu/osdep.h:161,
                     from ../linux-user/syscall.c:20:
    /usr/include/linux/sched/types.h:98:8: note: originally defined here
       98 | struct sched_attr {
          |        ^~~~~~~~~~

For information, the Buildroot glibc package has been bumped in
commit [1]. Also, major distributions are starting to publish updates
to glibc 2.41. See for example Arch Linux update [2].

This commit adds a package patch to solve this issue.

Fixes:
- https://autobuild.buildroot.org/results/e8733bdf78d8e9448988c3d300c43a47f62375d8/
- and many others...

[1] 6ecab31fad
[2] 7cebc14490

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
[Julien: reworded the commit log]
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
James Hilliard
2025-02-06 10:33:28 -07:00
committed by Julien Olivain
parent 5f5e351043
commit 912a8458a9

View File

@@ -0,0 +1,49 @@
From 66b1926d72ef51d4d59d0f97061f26a75651e265 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 11 Oct 2024 12:31:40 -0700
Subject: [PATCH] sched_attr: Do not define for glibc >= 2.41
glibc 2.41+ has added [1] definitions for sched_setattr and sched_getattr functions
and struct sched_attr. Therefore, it needs to be checked for here as well before
defining sched_attr
Define sched_attr conditionally on SCHED_ATTR_SIZE_VER0
Fixes builds with glibc/trunk
[1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=21571ca0d70302909cf72707b2a7736cf12190a0;hp=298bc488fdc047da37482f4003023cb9adef78f8
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Upstream: https://patchwork.kernel.org/project/qemu-devel/patch/20241011193140.1047648-1-raj.khem@gmail.com/
---
linux-user/syscall.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1ce4c79784..a407d4a023 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -358,7 +358,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
#define __NR_sys_sched_setaffinity __NR_sched_setaffinity
_syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len,
unsigned long *, user_mask_ptr);
-/* sched_attr is not defined in glibc */
+/* sched_attr is not defined in glibc < 2.41 */
+#ifndef SCHED_ATTR_SIZE_VER0
struct sched_attr {
uint32_t size;
uint32_t sched_policy;
@@ -371,6 +372,7 @@ struct sched_attr {
uint32_t sched_util_min;
uint32_t sched_util_max;
};
+#endif
#define __NR_sys_sched_getattr __NR_sched_getattr
_syscall4(int, sys_sched_getattr, pid_t, pid, struct sched_attr *, attr,
unsigned int, size, unsigned int, flags);
--
2.34.1