Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/procps-ng: fix build with missing pidfd_open
@ 2025-02-25 15:50 Michael Nosthoff via buildroot
  2025-02-25 19:59 ` Julien Olivain
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Nosthoff via buildroot @ 2025-02-25 15:50 UTC (permalink / raw)
  To: buildroot

port back patch introduced shortly after the 4.0.5 release.

Fixes:
  checking for __NR_pidfd_open... no
  configure: error: Neither pidfd_open or __NR_pidfd_open found. Disable pidwait with configure option --disable-pidwait

happening with this defconfig:

BR2_arm=y
BR2_cortex_a15_a7=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_SYSTEMD=y
BR2_PACKAGE_PROCPS_NG=y

Signed-off-by: Michael Nosthoff <buildroot@heine.tech>
---
 ...provide-definition-for-nr-pidfd_open.patch | 57 +++++++++++++++++++
 package/procps-ng/procps-ng.mk                |  3 +
 2 files changed, 60 insertions(+)
 create mode 100644 package/procps-ng/0001-pgrep-provide-definition-for-nr-pidfd_open.patch

diff --git a/package/procps-ng/0001-pgrep-provide-definition-for-nr-pidfd_open.patch b/package/procps-ng/0001-pgrep-provide-definition-for-nr-pidfd_open.patch
new file mode 100644
index 0000000000..9c83124311
--- /dev/null
+++ b/package/procps-ng/0001-pgrep-provide-definition-for-nr-pidfd_open.patch
@@ -0,0 +1,57 @@
+From 90a0ddcd64c2d43dc2c2c856b1b42b5cae6b8a44 Mon Sep 17 00:00:00 2001
+From: Markus Mayer <mmayer@broadcom.com>
+Date: Wed, 11 Dec 2024 14:53:33 -0800
+Subject: [PATCH] pgrep: provide definition for __NR_pidfd_open if needed
+
+We already implement pidfd_open() ourselves if libc doesn't provide it.
+Let's also provide our own definition of __NR_pidfd_open in case the
+kernel headers don't contain it.
+
+This way, pgrep can provide its full capabilities after being built
+against older kernel headers (for increased compatibility) but being run
+on systems with newer kernels.
+
+Signed-off-by: Markus Mayer <mmayer@broadcom.com>
+Upstream: https://gitlab.com/procps-ng/procps/-/commit/90a0ddcd64c2d43dc2c2c856b1b42b5cae6b8a44
+Signed-off: Michael Nosthoff <buildroot@heine.tech>
+---
+ configure.ac | 2 +-
+ src/pgrep.c  | 9 +++++++++
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 1e984b12..14ba3ad7 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -325,7 +325,7 @@ AS_IF([[test "x$enable_pidwait" = xyes -a "x$have_pidfd_open" = xno]],
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ #include <sys/syscall.h>
+ #ifndef __NR_pidfd_open
+-#error __NR_pidfd_open not defined
++#warning __NR_pidfd_open not defined; using our definition
+ #endif
+       ])],
+       AC_MSG_RESULT([yes]),
+diff --git a/src/pgrep.c b/src/pgrep.c
+index 2c6b06b8..6fc25dd4 100644
+--- a/src/pgrep.c
++++ b/src/pgrep.c
+@@ -874,6 +874,15 @@ static int signal_option(int *argc, char **argv)
+ }
+
+ #if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
++
++#ifndef __NR_pidfd_open
++#ifdef __alpha__
++#define __NR_pidfd_open 544
++#else
++#define __NR_pidfd_open 434
++#endif
++#endif
++
+ static int pidfd_open (pid_t pid, unsigned int flags)
+ {
+ 	return syscall(__NR_pidfd_open, pid, flags);
+--
+GitLab
+
diff --git a/package/procps-ng/procps-ng.mk b/package/procps-ng/procps-ng.mk
index f4eadcb547..56fe1790c3 100644
--- a/package/procps-ng/procps-ng.mk
+++ b/package/procps-ng/procps-ng.mk
@@ -14,6 +14,9 @@ PROCPS_NG_INSTALL_STAGING = YES
 PROCPS_NG_DEPENDENCIES = ncurses host-pkgconf $(TARGET_NLS_DEPENDENCIES)
 PROCPS_NG_CONF_OPTS = LIBS=$(TARGET_NLS_LIBS)
 
+# Applying 0001-pgrep-provide-definition-for-nr-pidfd_open.patch touches configure.ac
+PROCPS_NG_AUTORECONF = YES
+
 ifeq ($(BR2_PACKAGE_SYSTEMD),y)
 PROCPS_NG_DEPENDENCIES += systemd
 PROCPS_NG_CONF_OPTS += --with-systemd
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-25 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25 15:50 [Buildroot] [PATCH] package/procps-ng: fix build with missing pidfd_open Michael Nosthoff via buildroot
2025-02-25 19:59 ` Julien Olivain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox