From 912a8458a96a7ee3fb391a507244a9084b03fb72 Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Thu, 6 Feb 2025 10:33:28 -0700 Subject: [PATCH] package/qemu: fix build with glibc >= 2.41 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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] https://gitlab.com/buildroot.org/buildroot/-/commit/6ecab31fad12a494ec0d2a3767c736a55c80a769 [2] https://gitlab.archlinux.org/archlinux/packaging/packages/glibc/-/commit/7cebc144906a0fb68a5f6e75985b386c722ffbd9 Signed-off-by: James Hilliard [Julien: reworded the commit log] Signed-off-by: Julien Olivain --- ...ed_attr-Do-not-define-for-glibc-2.41.patch | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 package/qemu/0003-sched_attr-Do-not-define-for-glibc-2.41.patch diff --git a/package/qemu/0003-sched_attr-Do-not-define-for-glibc-2.41.patch b/package/qemu/0003-sched_attr-Do-not-define-for-glibc-2.41.patch new file mode 100644 index 0000000000..11edc27c2f --- /dev/null +++ b/package/qemu/0003-sched_attr-Do-not-define-for-glibc-2.41.patch @@ -0,0 +1,49 @@ +From 66b1926d72ef51d4d59d0f97061f26a75651e265 Mon Sep 17 00:00:00 2001 +From: Khem Raj +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 +Cc: Laurent Vivier +Cc: Paolo Bonzini +Signed-off-by: James Hilliard +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 +