Add upstream patch to fix linking the daemon with OCaml 5.1

This commit is contained in:
Richard W.M. Jones 2023-10-06 11:36:54 +01:00
parent b81ea517da
commit 6414c52e4d
2 changed files with 118 additions and 2 deletions

View File

@ -0,0 +1,108 @@
From f8cbd7140095279e40b36415d5b6fc5c36e96a40 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 6 Oct 2023 11:15:55 +0100
Subject: [PATCH] daemon: Find -lcamlstr{nat,byt} and -lunix{nat,byt}, and
require -lzstd
OCaml 5.1 changes the names of these libraries for some reason.
Also in OCaml 5.1, if using those libraries you must link with -lzstd.
Since zstd was already described as "required" (although we only used
it in the appliance), there is no official change to the requirements,
but I have added a configure time check for the library.
Thanks: Jerry James <loganjerry@gmail.com>
---
daemon/Makefile.am | 8 +++++---
m4/guestfs-libraries.m4 | 3 +++
m4/guestfs-ocaml.m4 | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 01c0f6416c..b44d7712f8 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -376,9 +376,11 @@ OCAML_LIBS = \
-lmlstdutils \
-lmlaugeas \
-lmlhivex \
- -lcamlstr \
- -lunix \
- -l$(CAMLRUN) -ldl -lm
+ -l$(CAMLSTR) \
+ -l$(CAMLUNIX) \
+ -l$(CAMLRUN) \
+ $(LIBZSTD_LIBS) \
+ -ldl -lm
CLEANFILES += camldaemon.o
diff --git a/m4/guestfs-libraries.m4 b/m4/guestfs-libraries.m4
index 29d012a378..18c4cd3074 100644
--- a/m4/guestfs-libraries.m4
+++ b/m4/guestfs-libraries.m4
@@ -248,6 +248,9 @@ PKG_CHECK_MODULES([PCRE2], [libpcre2-8], [], [
PCRE_LIBS=`$PCRE2_CONFIG --libs8`
])
+dnl Check for zstd (required since OCaml 5.1)
+PKG_CHECK_MODULES([LIBZSTD], [libzstd])
+
dnl Check for Augeas >= 1.2.0 (required).
PKG_CHECK_MODULES([AUGEAS],[augeas >= 1.2.0])
diff --git a/m4/guestfs-ocaml.m4 b/m4/guestfs-ocaml.m4
index 39a8346f3e..25b06408c1 100644
--- a/m4/guestfs-ocaml.m4
+++ b/m4/guestfs-ocaml.m4
@@ -122,6 +122,47 @@ if test "x$enable_daemon" = "xyes"; then
AC_MSG_ERROR([could not find or link to libasmrun or libcamlrun])
fi
AC_SUBST([CAMLRUN])
+
+ dnl OCaml 5.1 changed -lcamlstr to -lcamlstrnat / -lcamlstrbyt
+ dnl and -lunix to -lunixnat / -lunixbyt so we need to detect
+ dnl the new or old libraries. As above we cannot use AC_CHECK_LIB.
+ AC_MSG_CHECKING([how to link the daemon with -lcamlstr*])
+ if test "x$OCAMLOPT" != "xno"; then
+ choices="camlstrnat camlstr"
+ else
+ choices="camlstrbyt camlstr"
+ fi
+ for f in $choices; do
+ if test -f "$OCAMLLIB/lib$f.a"; then
+ CAMLSTR=$f
+ break
+ fi
+ done
+ if test "x$CAMLSTR" != "x"; then
+ AC_MSG_RESULT([$CAMLSTR])
+ else
+ AC_MSG_ERROR([could not find or link to -lcamlstr*])
+ fi
+ AC_SUBST([CAMLSTR])
+
+ AC_MSG_CHECKING([how to link the daemon with -lunix*])
+ if test "x$OCAMLOPT" != "xno"; then
+ choices="unixnat unix"
+ else
+ choices="unixbyt unix"
+ fi
+ for f in $choices; do
+ if test -f "$OCAMLLIB/lib$f.a"; then
+ CAMLUNIX=$f
+ break
+ fi
+ done
+ if test "x$CAMLUNIX" != "x"; then
+ AC_MSG_RESULT([$CAMLUNIX])
+ else
+ AC_MSG_ERROR([could not find or link to -lunix*])
+ fi
+ AC_SUBST([CAMLUNIX])
fi
dnl Define HIVEX_OPEN_UNSAFE_FLAG based on test above.
--
2.41.0

View File

@ -31,7 +31,7 @@ ExcludeArch: %{ix86}
# If there are patches which touch autotools files, set this to 1. # If there are patches which touch autotools files, set this to 1.
%if !0%{?rhel} %if !0%{?rhel}
%global patches_touch_autotools %{nil} %global patches_touch_autotools 1
%else %else
# On RHEL the downstream patches always touch autotools files. # On RHEL the downstream patches always touch autotools files.
%global patches_touch_autotools 1 %global patches_touch_autotools 1
@ -50,7 +50,7 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs Name: libguestfs
Epoch: 1 Epoch: 1
Version: 1.51.7 Version: 1.51.7
Release: 3%{?dist} Release: 4%{?dist}
License: LGPL-2.1-or-later License: LGPL-2.1-or-later
# Build only for architectures that have a kernel # Build only for architectures that have a kernel
@ -84,6 +84,10 @@ Source7: libguestfs.keyring
# Maintainer script which helps with handling patches. # Maintainer script which helps with handling patches.
Source8: copy-patches.sh Source8: copy-patches.sh
# Fix linking the daemon on OCaml 5.1
# Upstream in >= 1.51.8
Patch: 0001-daemon-Find-lcamlstr-nat-byt-and-lunix-nat-byt-and-r.patch
%if 0%{patches_touch_autotools} %if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool, gettext-devel BuildRequires: autoconf, automake, libtool, gettext-devel
%endif %endif
@ -143,6 +147,7 @@ BuildRequires: /usr/bin/ping
BuildRequires: /usr/bin/wget BuildRequires: /usr/bin/wget
BuildRequires: xz BuildRequires: xz
BuildRequires: zstd BuildRequires: zstd
BuildRequires: zstd-devel
BuildRequires: /usr/bin/qemu-img BuildRequires: /usr/bin/qemu-img
%if 0%{verify_tarball_signature} %if 0%{verify_tarball_signature}
@ -1093,6 +1098,9 @@ rm ocaml/html/.gitignore
%changelog %changelog
* Fri Oct 06 2023 Richard W.M. Jones <rjones@redhat.com> - 1:1.51.7-4
- Add upstream patch to fix linking the daemon with OCaml 5.1
* Thu Oct 05 2023 Richard W.M. Jones <rjones@redhat.com> - 1:1.51.7-3 * Thu Oct 05 2023 Richard W.M. Jones <rjones@redhat.com> - 1:1.51.7-3
- OCaml 5.1 rebuild for Fedora 40 - OCaml 5.1 rebuild for Fedora 40