diff mbox series

[v2] systemtap: add option for readline

Message ID 20260413102839.4126045-1-ross.burton@arm.com
State New
Headers show
Series [v2] systemtap: add option for readline | expand

Commit Message

Ross Burton April 13, 2026, 10:28 a.m. UTC
systemtap will try and use libreadline if it's available which isn't
good for determinism. Add an option, and disable it by default.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../systemtap/systemtap/readline.patch        | 93 +++++++++++++++++++
 .../recipes-kernel/systemtap/systemtap_5.4.bb |  1 +
 .../systemtap/systemtap_git.inc               |  1 +
 3 files changed, 95 insertions(+)
 create mode 100644 meta/recipes-kernel/systemtap/systemtap/readline.patch
diff mbox series

Patch

diff --git a/meta/recipes-kernel/systemtap/systemtap/readline.patch b/meta/recipes-kernel/systemtap/systemtap/readline.patch
new file mode 100644
index 00000000000..d7afc800cd7
--- /dev/null
+++ b/meta/recipes-kernel/systemtap/systemtap/readline.patch
@@ -0,0 +1,93 @@ 
+configure: add option to enable/disable readline
+
+Add an option to control explicitly whether systemtap will look for and
+use readline, for reproducible builds.
+
+If not specified the behaviour is as before: look for readline and if it
+is found, use it.  However if --with-readline is passed then readline
+must be present, and if --without-readline is passed then readline will
+not be used.
+
+Upstream-Status: Submitted [https://sourceware.org/pipermail/systemtap/2026q2/028333.html]
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+diff --git i/configure.ac w/configure.ac
+index 6fb99da40..01457bafb 100644
+--- i/configure.ac
++++ w/configure.ac
+@@ -525,38 +525,47 @@ AC_CHECK_HEADERS([rpm/rpmcrypto.h], [
+                       have_rpmcrypto_h=yes
+ 		      AC_MSG_NOTICE([separate rpm/rpmcrypto.h])])
+ 
+-dnl Look for readline.
+-dnl
+-dnl First save the orignal value of LIBS.
+-LIBS_no_readline=$LIBS
+ 
+-dnl Check how for readline presence and how to link with it. On some
+-dnl systems you need to add a termcap compatible library.
+-have_libreadline="no"
+-AC_MSG_CHECKING([how to link readline libs])
+-for libtermcap in "" tinfo ncursesw ncurses curses termcap; do
+-  if test -z "$libtermcap"; then
+-    READLINE_LIBS="-lreadline"
++AC_ARG_WITH([readline],
++  AS_HELP_STRING([--without-readline],[disable use of readline]), [], [with_readline="check"])
++
++if test "$with_readline" != no; then
++  dnl Look for readline.
++  dnl
++  dnl First save the orignal value of LIBS.
++  LIBS_no_readline=$LIBS
++
++  have_libreadline="no"
++  dnl Check how for readline presence and how to link with it. On some
++  dnl systems you need to add a termcap compatible library.
++  AC_MSG_CHECKING([how to link readline libs])
++  for libtermcap in "" tinfo ncursesw ncurses curses termcap; do
++    if test -z "$libtermcap"; then
++      READLINE_LIBS="-lreadline"
++    else
++      READLINE_LIBS="-lreadline -l$libtermcap"
++    fi
++    LIBS="$READLINE_LIBS $LIBS_no_readline"
++    AC_LINK_IFELSE(
++      [AC_LANG_CALL([],[readline])],
++      [have_libreadline="yes"])
++    if test "$have_libreadline" = "yes"; then
++      break
++    fi
++  done
++
++  if test "$have_libreadline" = "no" -a "$with_readline" = "yes"; then
++    AC_MSG_ERROR([cannot find libreadline])
++  elif test "$have_libreadline" = "no" -a "$with_readline" = "check"; then
++    AC_MSG_RESULT([libreadline not found])
++    READLINE_LIBS=""
+   else
+-    READLINE_LIBS="-lreadline -l$libtermcap"
++    AC_MSG_RESULT([$READLINE_LIBS])
++    AC_DEFINE(HAVE_LIBREADLINE, [1],
++        [Define if you have the readline library (-lreadline).])
+   fi
+-  LIBS="$READLINE_LIBS $LIBS_no_readline"
+-  AC_LINK_IFELSE(
+-    [AC_LANG_CALL([],[readline])],
+-    [have_libreadline="yes"])
+-  if test "$have_libreadline" = "yes"; then
+-    break
+-  fi
+-done
+-if test "$have_libreadline" = "no"; then
+-  AC_MSG_RESULT([none])
+-  READLINE_LIBS=""
+-else
+-  AC_MSG_RESULT([$READLINE_LIBS])
+-  AC_DEFINE(HAVE_LIBREADLINE, [1],
+-	    [Define if you have the readline library (-lreadline).])
++  AC_SUBST([READLINE_LIBS])
+ fi
+-AC_SUBST([READLINE_LIBS])
+ AM_CONDITIONAL([HAVE_LIBREADLINE], [test "$have_libreadline" = "yes"])
+ 
+ dnl End of readline checks: restore LIBS
diff --git a/meta/recipes-kernel/systemtap/systemtap_5.4.bb b/meta/recipes-kernel/systemtap/systemtap_5.4.bb
index 254bac4d6f9..22dd76bbffd 100644
--- a/meta/recipes-kernel/systemtap/systemtap_5.4.bb
+++ b/meta/recipes-kernel/systemtap/systemtap_5.4.bb
@@ -32,6 +32,7 @@  PACKAGECONFIG[sqlite] = "--enable-sqlite,--disable-sqlite,sqlite3"
 PACKAGECONFIG[monitor] = "--enable-monitor,--disable-monitor,ncurses json-c"
 PACKAGECONFIG[python3-probes] = "--with-python3-probes,--without-python3-probes,python3-setuptools-native"
 PACKAGECONFIG[debuginfod] = "--with-debuginfod, --without-debuginfod"
+PACKAGECONFIG[readline] = "--with-readline,--without-readline,readline"
 
 inherit autotools gettext pkgconfig systemd
 inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python3-probes', 'setuptools3-base', '', d)}
diff --git a/meta/recipes-kernel/systemtap/systemtap_git.inc b/meta/recipes-kernel/systemtap/systemtap_git.inc
index 24b6f0ae029..a18381a56de 100644
--- a/meta/recipes-kernel/systemtap/systemtap_git.inc
+++ b/meta/recipes-kernel/systemtap/systemtap_git.inc
@@ -6,6 +6,7 @@  SRC_URI = "git://sourceware.org/git/systemtap.git;protocol=https;branch=master;t
            file://0001-Install-python-modules-to-correct-library-dir.patch \
            file://0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch \
            file://0001-elaborate.cxx-fix-32-bit-build.patch \
+           file://readline.patch \
            "
 
 SRCREV = "911a1354aac264651fda932061e7f20d2ecc2471"