* [Buildroot] [PATCH] package/procps-ng: fix build without __NR_pidfd_open and pidfd_open() found
@ 2024-10-29 5:33 Scott Fan
2024-10-29 11:20 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 4+ messages in thread
From: Scott Fan @ 2024-10-29 5:33 UTC (permalink / raw)
To: buildroot; +Cc: Scott Fan
Backport patch from upstream:
https://gitlab.com/procps-ng/procps/-/commit/2507bc475782ff5e0541d37c780dff1e293c9553
Add new configure option, allow disable build pidwait explicitly to avoid errors.
Signed-off-by: Scott Fan <fancp2007@gmail.com>
---
...03-build-sys-Fix-pidfd_open-checking.patch | 99 +++++++++++++++++++
package/procps-ng/Config.in | 8 ++
package/procps-ng/procps-ng.mk | 5 +
3 files changed, 112 insertions(+)
create mode 100644 package/procps-ng/0003-build-sys-Fix-pidfd_open-checking.patch
diff --git a/package/procps-ng/0003-build-sys-Fix-pidfd_open-checking.patch b/package/procps-ng/0003-build-sys-Fix-pidfd_open-checking.patch
new file mode 100644
index 0000000000..bf89a07a20
--- /dev/null
+++ b/package/procps-ng/0003-build-sys-Fix-pidfd_open-checking.patch
@@ -0,0 +1,99 @@
+From ae7b0eb069f4add363e8c4d01833a06c3f5ee842 Mon Sep 17 00:00:00 2001
+From: Craig Small <csmall@dropbear.xyz>
+Date: Mon, 30 Sep 2024 17:26:01 +1000
+Subject: [PATCH] build-sys: Fix pidfd_open checking
+
+The previous build setup would check for pidfd_open using
+AC_CHECK_FUNC and would be incorrectly reported as true.
+
+Also, if pidfd_open() and __NR_pidfd_open were not present,
+pidwait would silently not be built.
+
+So, changes:
+ compile a small programin using pidfd_open to test it properly
+ conditionally try to find NR_pidfd_open if the function fails
+ complain if neither are present
+ have --disable-pidwait configure option so you are explicit in
+ not wanting and knowing you wont get pidwait
+
+References:
+ #352
+ commit d9c3e3676d86094abaa239b3218f57bf49d70b4f
+ commit 17f94796a9b3c4f1ff28829107a82107dcb362b4
+
+Signed-off-by: Craig Small <csmall@dropbear.xyz>
+
+Upstream: https://gitlab.com/procps-ng/procps/-/commit/2507bc475782ff5e0541d37c780dff1e293c9553
+
+Signed-off-by: Scott Fan <fancp2007@gmail.com>
+[Scott: backported to version 4.0.4]
+---
+ configure.ac | 45 ++++++++++++++++++++++++++++++---------------
+ 1 file changed, 30 insertions(+), 15 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index fec27e3f..0719fcd1 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -170,21 +170,6 @@ AC_TRY_COMPILE([#include <errno.h>],
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no))
+
+-AC_CHECK_FUNC([pidfd_open], [enable_pidwait=yes], [
+- AC_MSG_CHECKING([for __NR_pidfd_open])
+- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+-#include <sys/syscall.h>
+-#ifndef __NR_pidfd_open
+-#error __NR_pidfd_open not defined
+-#endif
+- ])], [enable_pidwait=yes], [enable_pidwait=no])
+- AC_MSG_RESULT([$enable_pidwait])
+-])
+-if test "$enable_pidwait" = yes; then
+- AC_DEFINE([ENABLE_PIDWAIT], [1], [Enable pidwait])
+-fi
+-AM_CONDITIONAL([BUILD_PIDWAIT], [test x$enable_pidwait = xyes])
+-
+ dnl watch8bit must be before the AC_ARG_WITH set as it sets up ncurses
+ AC_SUBST([WITH_WATCH8BIT])
+ AC_ARG_ENABLE([watch8bit],
+@@ -321,6 +306,36 @@ AC_ARG_ENABLE([pidof],
+ )
+ AM_CONDITIONAL(BUILD_PIDOF, test "x$enable_pidof" = xyes)
+
++# If pidwait is enabled, we need either pidfd_open() or __NR_pidfd_open need to be defined
++# Cannot use AC_CHECK_FUNC as it (incorrectly) passes with pidfd_open missing
++AC_ARG_ENABLE([pidwait],
++ AS_HELP_STRING([--disable-pidwait], [do not build pidwait]),
++ [], [
++ enable_pidwait=yes
++ AC_DEFINE(ENABLE_PIDWAIT, 1, [enable pidwait])
++ ]
++)
++AM_CONDITIONAL(BUILD_PIDWAIT, test "x$enable_pidwait" = xyes)
++AC_MSG_CHECKING([for pidfd_open()])
++AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ [pidfd_open(1,1)]]])],
++ have_pidfd_open=yes; AC_MSG_RESULT([yes]) ,
++ have_pidfd_open=no; AC_MSG_RESULT([no])
++ )
++
++AS_IF([[test "x$enable_pidwait" = xyes -a "x$have_pidfd_open" = xno]],
++ AC_MSG_CHECKING([for __NR_pidfd_open])
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
++#include <sys/syscall.h>
++#ifndef __NR_pidfd_open
++#error __NR_pidfd_open not defined
++#endif
++ ])],
++ AC_MSG_RESULT([yes]),
++ AC_MSG_RESULT([no])
++ AC_MSG_ERROR([Neither pidfd_open or __NR_pidfd_open found. Disable pidwait with configure option --disable-pidwait])
++ )
++ ,[])
++
+ AC_ARG_ENABLE([kill],
+ AS_HELP_STRING([--disable-kill], [do not build kill]),
+ [], [enable_kill=yes]
+--
+2.43.0
+
diff --git a/package/procps-ng/Config.in b/package/procps-ng/Config.in
index 7af0e97fb4..17bc437fff 100644
--- a/package/procps-ng/Config.in
+++ b/package/procps-ng/Config.in
@@ -17,4 +17,12 @@ config BR2_PACKAGE_PROCPS_NG_ORIGINAL_TOP
Disable modern top layout, return to original top with
detailed cpu usage.
+config BR2_PACKAGE_PROCPS_NG_DISABLE_PIDWAIT
+ bool "Do not build pidwait"
+ help
+ Disable pidwait with configure option --disable-pidwait
+ explicitly. If pidwait is enabled, we need either pidfd_open()
+ or __NR_pidfd_open need to be defined, the option can avoid
+ errors when the condition is not met.
+
endif
diff --git a/package/procps-ng/procps-ng.mk b/package/procps-ng/procps-ng.mk
index c5185c2c8a..2db638c508 100644
--- a/package/procps-ng/procps-ng.mk
+++ b/package/procps-ng/procps-ng.mk
@@ -16,6 +16,7 @@ PROCPS_NG_CONF_OPTS = LIBS=$(TARGET_NLS_LIBS)
# Applying 0001-build-sys-Add-systemd-elogind-to-w.patch touches Makefile.am
# Applying 0002-fix-ncurses-h-include.patch touches configure.ac
+# Applying 0003-build-sys-Fix-pidfd_open-checking.patch touches configure.ac
PROCPS_NG_AUTORECONF = YES
ifeq ($(BR2_PACKAGE_SYSTEMD),y)
@@ -60,6 +61,10 @@ ifeq ($(BR2_PACKAGE_PROCPS_NG_ORIGINAL_TOP),y)
PROCPS_NG_CONF_OPTS += --disable-modern-top
endif
+ifeq ($(BR2_PACKAGE_PROCPS_NG_DISABLE_PIDWAIT),y)
+PROCPS_NG_CONF_OPTS += --disable-pidwait
+endif
+
# Avoid installing S02sysctl, since openrc provides /etc/init.d/sysctl.
define PROCPS_NG_INSTALL_INIT_OPENRC
@:
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH] package/procps-ng: fix build without __NR_pidfd_open and pidfd_open() found
2024-10-29 5:33 [Buildroot] [PATCH] package/procps-ng: fix build without __NR_pidfd_open and pidfd_open() found Scott Fan
@ 2024-10-29 11:20 ` Thomas Petazzoni via buildroot
2024-10-29 13:25 ` Scott Fan
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-10-29 11:20 UTC (permalink / raw)
To: Scott Fan; +Cc: buildroot
Hello,
On Tue, 29 Oct 2024 13:33:36 +0800
Scott Fan <fancp2007@gmail.com> wrote:
> Backport patch from upstream:
> https://gitlab.com/procps-ng/procps/-/commit/2507bc475782ff5e0541d37c780dff1e293c9553
>
> Add new configure option, allow disable build pidwait explicitly to avoid errors.
Why isn't this auto-detected? It is really silly to use configure.ac
and not detect such things automatically.
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH] package/procps-ng: fix build without __NR_pidfd_open and pidfd_open() found
2024-10-29 11:20 ` Thomas Petazzoni via buildroot
@ 2024-10-29 13:25 ` Scott Fan
2024-10-29 13:39 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 4+ messages in thread
From: Scott Fan @ 2024-10-29 13:25 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot
Hi Thomas,
Patch from upstream define the next line:
AC_MSG_ERROR([Neither pidfd_open or __NR_pidfd_open found. Disable
pidwait with configure option --disable-pidwait])
It will report an error message while neither pidfd_open or
__NR_pidfd_open found.
I can not build it with kernel 4.19.x, so add an option to allow
explicit disable pidwait.
Scott Fan
On Tue, Oct 29, 2024 at 7:20 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Tue, 29 Oct 2024 13:33:36 +0800
> Scott Fan <fancp2007@gmail.com> wrote:
>
> > Backport patch from upstream:
> > https://gitlab.com/procps-ng/procps/-/commit/2507bc475782ff5e0541d37c780dff1e293c9553
> >
> > Add new configure option, allow disable build pidwait explicitly to avoid errors.
>
> Why isn't this auto-detected? It is really silly to use configure.ac
> and not detect such things automatically.
>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH] package/procps-ng: fix build without __NR_pidfd_open and pidfd_open() found
2024-10-29 13:25 ` Scott Fan
@ 2024-10-29 13:39 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-10-29 13:39 UTC (permalink / raw)
To: Scott Fan; +Cc: buildroot
On Tue, 29 Oct 2024 21:25:58 +0800
Scott Fan <fancp2007@gmail.com> wrote:
> Patch from upstream define the next line:
> AC_MSG_ERROR([Neither pidfd_open or __NR_pidfd_open found. Disable
> pidwait with configure option --disable-pidwait])
Then it makes no sense, it (the configure script) should simply disable
this automatically.
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-29 13:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 5:33 [Buildroot] [PATCH] package/procps-ng: fix build without __NR_pidfd_open and pidfd_open() found Scott Fan
2024-10-29 11:20 ` Thomas Petazzoni via buildroot
2024-10-29 13:25 ` Scott Fan
2024-10-29 13:39 ` Thomas Petazzoni via buildroot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.