diff mbox series

[meta-networking,v2,24/26] openipmi: fix the perl bindings

Message ID 20261201015526.1956497-25-tim.orling@konsulko.com
State Under Review
Headers show
Series perl recipes: add missing base, DynaLoader and other perl-module RDEPENDS | expand

Commit Message

Tim Orling Dec. 1, 2026, 1:54 a.m. UTC
The perl bindings in openipmi-perl cannot be used:

- They are installed in ${libdir}/perl/vendor_perl, which is not in
  perl's @INC. Install them in ${libdir}/perl5/vendor_perl instead, and
  drop the do_install code that moved ${libdir}/perl5 to
  ${libdir}/perl. cpan-base adds ${libdir}/perl5 to FILES:${PN}, so
  put ${PN}-perl and ${PN}-python before ${PN} in PACKAGES.
- OpenIPMI.so is not linked against the OpenIPMI libraries, and its
  SONAME libOpenIPMI.so.0 hides the real libOpenIPMI.so.0 from the
  dynamic loader, so it fails with undefined symbols. Add a patch that
  links it like the python binding and builds it as a module, and update
  PRIVATE_LIBS to the new SONAME.
- OpenIPMI.pm uses base, DynaLoader and Exporter, but openipmi-perl has
  no RDEPENDS on them or on perl. Found by the perl-rdeps QA check.

Tested on qemux86-64: "use OpenIPMI" works and OpenIPMI::init_posix()
returns 0.

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 ...penIPMI.so-against-the-OpenIPMI-libr.patch | 33 +++++++++++++++++++
 .../openipmi/openipmi_2.0.38.bb               | 23 ++++++-------
 2 files changed, 43 insertions(+), 13 deletions(-)
 create mode 100644 meta-networking/recipes-support/openipmi/files/0003-swig-perl-link-OpenIPMI.so-against-the-OpenIPMI-libr.patch
diff mbox series

Patch

diff --git a/meta-networking/recipes-support/openipmi/files/0003-swig-perl-link-OpenIPMI.so-against-the-OpenIPMI-libr.patch b/meta-networking/recipes-support/openipmi/files/0003-swig-perl-link-OpenIPMI.so-against-the-OpenIPMI-libr.patch
new file mode 100644
index 0000000000..11b7c62b4a
--- /dev/null
+++ b/meta-networking/recipes-support/openipmi/files/0003-swig-perl-link-OpenIPMI.so-against-the-OpenIPMI-libr.patch
@@ -0,0 +1,33 @@ 
+From: Tim Orling <tim.orling@konsulko.com>
+Subject: [PATCH] swig/perl: build OpenIPMI.so as a module linked against
+ the OpenIPMI libraries
+
+The perl binding is built from libOpenIPMI.la without any LIBADD, so
+OpenIPMI.so has no NEEDED entries for libOpenIPMI and friends and fails
+to load:
+
+  OpenIPMI.so: undefined symbol: i__ipmi_debug_malloc
+
+Link it against the same libraries as the python binding, using the
+perl POSIX OS handler library. Also build it with -module
+-avoid-version like the python binding: otherwise it gets the SONAME
+libOpenIPMI.so.0, so the dynamic loader takes it for the real
+libOpenIPMI.so.0 and never loads that, and libOpenIPMIcmdlang.so.0
+fails with undefined symbols.
+
+Upstream-Status: Pending
+AI-Generated: Uses Claude Code (Claude Opus 5.5)
+Signed-off-by: Tim Orling <tim.orling@konsulko.com>
+---
+--- a/swig/perl/Makefile.am
++++ b/swig/perl/Makefile.am
+@@ -17,7 +17,8 @@
+ 
+ nodist_libOpenIPMI_la_SOURCES = OpenIPMI_wrap.c
+ libOpenIPMI_la_SOURCES = OpenIPMI_perl.c
+-libOpenIPMI_la_LDFLAGS = -rpath /nowhere -no-undefined
++libOpenIPMI_la_LDFLAGS = -module -avoid-version -rpath /nowhere -no-undefined
++libOpenIPMI_la_LIBADD = $(OPENIPMI_SWIG_LIBS) $(PERL_POSIX_LIB)
+ 
+ OpenIPMI_wrap.c OpenIPMI.pm: $(top_srcdir)/swig/OpenIPMI.i OpenIPMI_lang.i
+ 	$(SWIG) $(DEFS) -perl5 -o OpenIPMI_wrap.c -I$(top_srcdir)/swig/perl $<
diff --git a/meta-networking/recipes-support/openipmi/openipmi_2.0.38.bb b/meta-networking/recipes-support/openipmi/openipmi_2.0.38.bb
index a637b19d20..93bd0745ca 100644
--- a/meta-networking/recipes-support/openipmi/openipmi_2.0.38.bb
+++ b/meta-networking/recipes-support/openipmi/openipmi_2.0.38.bb
@@ -30,6 +30,7 @@  SRC_URI = "${SOURCEFORGE_MIRROR}/openipmi/OpenIPMI-${PV}.tar.gz \
            file://include_sys_types.patch \
            file://0001-Makefile.am-Pass-BUILD_CFLAGS-to-BUILD_CC.patch \
            file://0002-swig-python-OpenIPMI_lang.i-add-py2-py3-C-API-compa.patch \
+           file://0003-swig-perl-link-OpenIPMI.so-against-the-OpenIPMI-libr.patch \
            file://openipmi-helper \
            file://ipmi.service \
            "
@@ -51,21 +52,23 @@  EXTRA_OECONF = "--disable-static \
 PACKAGECONFIG ??= "gdbm"
 PACKAGECONFIG[gdbm] = "ac_cv_header_gdbm_h=yes,ac_cv_header_gdbm_h=no,gdbm,"
 
-PACKAGES += "${PN}-perl ${PN}-python"
-PRIVATE_LIBS:${PN}-perl = "libOpenIPMI.so.0"
+PACKAGES =+ "${PN}-perl ${PN}-python"
+PRIVATE_LIBS:${PN}-perl = "libOpenIPMI.so"
 
 FILES:${PN}-perl = " \
-    ${libdir}/perl/vendor_perl/*/OpenIPMI.pm \
-    ${libdir}/perl/vendor_perl/*/auto/OpenIPMI/OpenIPMI.so \
+    ${libdir}/perl5/vendor_perl/*/OpenIPMI.pm \
+    ${libdir}/perl5/vendor_perl/*/auto/OpenIPMI/OpenIPMI.so \
     "
 
 FILES:${PN}-python = "${PYTHON_SITEPACKAGES_DIR}"
 
 FILES:${PN}-dbg += " \
-    ${libdir}/perl/vendor_perl/*/auto/OpenIPMI/.debug \
+    ${libdir}/perl5/vendor_perl/*/auto/OpenIPMI/.debug \
     ${PYTHON_SITEPACKAGES_DIR}/.debug \
     "
 
+RDEPENDS:${PN}-perl = "perl perl-module-base perl-module-dynaloader perl-module-exporter"
+
 do_configure () {
     # The release tarball lacks ChangeLog, which automake's gnu strictness requires
     touch ${S}/ChangeLog
@@ -83,7 +86,7 @@  do_configure () {
         echo "SAL: libdir = $libdir"
         sed -i -e "/^PERL_CFLAGS/s:-I/usr/local/include:-I${STAGING_INCDIR_NATIVE}:g" $i
         sed -i -e "/^PERL_CFLAGS/s:-I .* :-I ${STAGING_LIBDIR}${PERL_OWN_DIR}/perl5/${@get_perl_version(d)}/${@get_perl_arch(d)}/CORE :g" $i
-        sed -i -e "/^PERL_INSTALL_DIR/s:^PERL_INSTALL_DIR = .*:PERL_INSTALL_DIR = ${libdir}/perl/vendor_perl/$perl_ver:g" $i
+        sed -i -e "/^PERL_INSTALL_DIR/s:^PERL_INSTALL_DIR = .*:PERL_INSTALL_DIR = ${libdir}/perl5/vendor_perl/$perl_ver:g" $i
     done
 }
 
@@ -97,13 +100,7 @@  do_install:append () {
     install -m 0755 -d ${D}${sysconfdir}/sysconfig ${D}${sysconfdir}/init.d
     install -m 0755 ${S}/ipmi.init ${D}${sysconfdir}/init.d/ipmi
     install -m 0644 ${S}/ipmi.sysconf ${D}${sysconfdir}/sysconfig/ipmi
-    # SAL: mv: cannot stat `/localdisk/loadbuild/slittle1/workspace/cgts_test_build/bitbake_build/tmp/work/x86_64-wrs-linux/openipmi-2.0.19-r4/image/usr/lib64/perl5': No such file or directory
-    # SAL: real path to perl is /localdisk/loadbuild/slittle1/workspace/cgts_test_build/bitbake_build/tmp/work/x86_64-wrs-linux/perl-5.14.2-r8.3/package/usr/lib64/perl5 and it is a symlink to perl so no need to mv.
-    if [ -d ${D}${libdir}/perl5 ]
-    then
-        mv ${D}${libdir}/perl5 ${D}${libdir}/perl
-    fi
- 
+
     # for systemd
     install -d ${D}${systemd_unitdir}/system
     install -m 0664 ${UNPACKDIR}/ipmi.service ${D}${systemd_unitdir}/system