Add upstream patches to fix cc plugin.

This commit is contained in:
Richard W.M. Jones 2020-06-04 14:31:33 +01:00
parent 5e53df9dbc
commit 18f635cb34
3 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From 1271945aa9144090f9c74c1915c4c1d431344df3 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 4 Jun 2020 14:13:46 +0100
Subject: [PATCH 1/2] cc: Add -fPIC -shared to -DCFLAGS rather than in the
plugin.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes the output of nbdkit cc --dump-plugin so it matches the
documentation, and it's slightly cleaner than doing this munging in
the cc plugin source code.
Fixes: commit a4339e3c3c17d8b95ddf0b20cf015de5078620ec
---
plugins/cc/Makefile.am | 2 +-
plugins/cc/cc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/cc/Makefile.am b/plugins/cc/Makefile.am
index 6b02e891..d7e709f8 100644
--- a/plugins/cc/Makefile.am
+++ b/plugins/cc/Makefile.am
@@ -42,7 +42,7 @@ nbdkit_cc_plugin_la_SOURCES = \
nbdkit_cc_plugin_la_CPPFLAGS = \
-DCC="\"$(CC)\"" \
- -DCFLAGS="\"$(CFLAGS)\"" \
+ -DCFLAGS="\"$(CFLAGS) -fPIC -shared\"" \
-I$(top_srcdir)/common/utils \
-I$(top_srcdir)/include \
-I. \
diff --git a/plugins/cc/cc.c b/plugins/cc/cc.c
index 2139cf62..e55c5e76 100644
--- a/plugins/cc/cc.c
+++ b/plugins/cc/cc.c
@@ -53,7 +53,7 @@ static bool unlink_on_exit = false;
/* C compiler and flags. */
static const char *cc = CC;
-static const char *cflags = CFLAGS " -fPIC -shared";
+static const char *cflags = CFLAGS;
static const char *extra_cflags;
/* List of parameters for the subplugin. */
--
2.25.0

View File

@ -0,0 +1,49 @@
From 28e66a6f4999ed7edf51ca268d6831f3d11dcb2e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 4 Jun 2020 14:28:51 +0100
Subject: [PATCH 2/2] cc: Run test against local <nbdkit-plugin.h>, not
installed.
The problem was revealed when trying to compile nbdkit 1.21.7 in
Fedora Koji.
Fixes: commit a4339e3c3c17d8b95ddf0b20cf015de5078620ec
---
plugins/cc/nbdkit-cc-plugin.pod | 5 +++--
tests/test-shebang-cc.sh | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/plugins/cc/nbdkit-cc-plugin.pod b/plugins/cc/nbdkit-cc-plugin.pod
index c8ef3950..ecd7a81e 100644
--- a/plugins/cc/nbdkit-cc-plugin.pod
+++ b/plugins/cc/nbdkit-cc-plugin.pod
@@ -27,11 +27,12 @@ L<nbdkit-plugin(3)>.
Simple plugins from the nbdkit source tree can be compiled and run
directly using commands such as:
- $ nbdkit cc plugins/example1/example1.c EXTRA_CFLAGS="-I."
+ $ nbdkit cc plugins/example1/example1.c EXTRA_CFLAGS="-I. -Iinclude"
You can also read the source from stdin using C<->:
- $ nbdkit cc - EXTRA_CFLAGS="-I." < plugins/example1/example1.c
+ $ nbdkit cc - EXTRA_CFLAGS="-I. -Iinclude" \
+ < plugins/example1/example1.c
To replace the compiler flags:
diff --git a/tests/test-shebang-cc.sh b/tests/test-shebang-cc.sh
index 7f15ebff..83d9815e 100755
--- a/tests/test-shebang-cc.sh
+++ b/tests/test-shebang-cc.sh
@@ -45,6 +45,7 @@ fi
requires guestfish --version
$script -fv -U - \
+ EXTRA_CFLAGS="-I$SRCDIR/../include" \
--run '
guestfish \
add "" protocol:nbd server:unix:$unixsocket : \
--
2.25.0

View File

@ -38,7 +38,7 @@ ExclusiveArch: x86_64
%global verify_tarball_signature 1
# If there are patches which touch autotools files, set this to 1.
%global patches_touch_autotools %{nil}
%global patches_touch_autotools 1
# The source directory.
%global source_directory 1.21-development
@ -58,6 +58,10 @@ Source1: http://libguestfs.org/download/nbdkit/%{source_directory}/%{name
Source2: libguestfs.keyring
%endif
# Upstream patches that fix the cc plugin.
Patch1: 0001-cc-Add-fPIC-shared-to-DCFLAGS-rather-than-in-the-plu.patch
Patch2: 0002-cc-Run-test-against-local-nbdkit-plugin.h-not-instal.patch
%if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool
%endif