From 7423e43ec2cd27d52650a1caeb7c0576350e0a78 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 20 Sep 2018 12:59:44 +0100
Subject: [PATCH] tools: Ensure CFLAGS and LDFLAGS are passed to all OCaml
binaries (RHBZ#1624130).
After this commit, all annocheck errors are fixed except for:
Hardened: virt-get-kernel: MAYB: Gaps were detected in the annobin coverage. Run with -v to list.
After discussion with the annocheck maintainers this gap in coverage
(which corresponds to the OCaml runtime) seems to be caused either by
the runtime not being linked with the right flags, or might be a bug
in annocheck itself. In any case it's not something that can be
resolved within the scope of libguestfs.
(cherry picked from commit 34c23403c51a4d59d826c8045e06f9aabc2ceb16)
---
builder/Makefile.am | 2 +-
common/mlaugeas/Makefile.am | 2 +-
common/mlgettext/Makefile.am | 2 +-
common/mlpcre/Makefile.am | 2 +-
common/mlprogress/Makefile.am | 2 +-
common/mlstdutils/Makefile.am | 2 +-
common/mltools/Makefile.am | 2 +-
common/mlutils/Makefile.am | 2 +-
common/mlvisit/Makefile.am | 2 +-
common/mlxml/Makefile.am | 2 +-
customize/Makefile.am | 2 +-
daemon/Makefile.am | 2 +-
dib/Makefile.am | 2 +-
generator/Makefile.am | 2 +-
get-kernel/Makefile.am | 2 +-
ocaml-link.sh.in | 2 +-
ocaml/Makefile.am | 2 +-
resize/Makefile.am | 2 +-
sparsify/Makefile.am | 2 +-
sysprep/Makefile.am | 2 +-
v2v/Makefile.am | 2 +-
v2v/test-harness/Makefile.am | 2 +-
22 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/builder/Makefile.am b/builder/Makefile.am
index c7b50778a..a30a229b2 100644
--- a/builder/Makefile.am
+++ b/builder/Makefile.am
@@ -215,7 +215,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlaugeas/Makefile.am b/common/mlaugeas/Makefile.am
index 8aa15b80e..2c1a6e0fd 100644
--- a/common/mlaugeas/Makefile.am
+++ b/common/mlaugeas/Makefile.am
@@ -61,7 +61,7 @@ BOBJECTS = $(SOURCES_ML:.ml=.cmo)
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
OCAMLPACKAGES =
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlgettext/Makefile.am b/common/mlgettext/Makefile.am
index cdcea33ec..b918f90c3 100644
--- a/common/mlgettext/Makefile.am
+++ b/common/mlgettext/Makefile.am
@@ -60,7 +60,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlpcre/Makefile.am b/common/mlpcre/Makefile.am
index f9699f592..6f04256da 100644
--- a/common/mlpcre/Makefile.am
+++ b/common/mlpcre/Makefile.am
@@ -70,7 +70,7 @@ OCAMLPACKAGES = \
-I $(builddir)
OCAMLPACKAGES_TESTS = $(MLPCRE_CMA)
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlprogress/Makefile.am b/common/mlprogress/Makefile.am
index be88ef2de..af006d228 100644
--- a/common/mlprogress/Makefile.am
+++ b/common/mlprogress/Makefile.am
@@ -76,7 +76,7 @@ OCAMLPACKAGES = \
-I $(top_builddir)/ocaml \
-I $(builddir)
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlstdutils/Makefile.am b/common/mlstdutils/Makefile.am
index e38230db8..75252eb46 100644
--- a/common/mlstdutils/Makefile.am
+++ b/common/mlstdutils/Makefile.am
@@ -79,7 +79,7 @@ if HAVE_OCAML_PKG_OUNIT
OCAMLPACKAGES_TESTS += -package oUnit
endif
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mltools/Makefile.am b/common/mltools/Makefile.am
index 66b18f5de..b326cf56a 100644
--- a/common/mltools/Makefile.am
+++ b/common/mltools/Makefile.am
@@ -131,7 +131,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlutils/Makefile.am b/common/mlutils/Makefile.am
index 8627e5b10..77feafa56 100644
--- a/common/mlutils/Makefile.am
+++ b/common/mlutils/Makefile.am
@@ -74,7 +74,7 @@ OCAMLPACKAGES = \
-I $(top_builddir)/common/mlstdutils \
-I $(builddir)
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlvisit/Makefile.am b/common/mlvisit/Makefile.am
index add1fe56e..7230415e7 100644
--- a/common/mlvisit/Makefile.am
+++ b/common/mlvisit/Makefile.am
@@ -80,7 +80,7 @@ OCAMLPACKAGES = \
-I $(builddir)
OCAMLPACKAGES_TESTS = $(MLVISIT_CMA)
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/common/mlxml/Makefile.am b/common/mlxml/Makefile.am
index eab036b82..7f36b743a 100644
--- a/common/mlxml/Makefile.am
+++ b/common/mlxml/Makefile.am
@@ -72,7 +72,7 @@ OCAMLPACKAGES = \
-I $(top_builddir)/gnulib/lib/.libs \
-I $(builddir)
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/customize/Makefile.am b/customize/Makefile.am
index efdd27227..69cf6c13f 100644
--- a/customize/Makefile.am
+++ b/customize/Makefile.am
@@ -173,7 +173,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
virt_customize_DEPENDENCIES = \
$(top_srcdir)/ocaml-link.sh \
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index d9ed5625e..dcae1a66c 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -347,7 +347,7 @@ OCAMLPACKAGES = \
-I $(top_builddir)/common/mlpcre/.libs \
-I $(top_builddir)/gnulib/lib/.libs
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/dib/Makefile.am b/dib/Makefile.am
index 316f49903..7c2ab09d6 100644
--- a/dib/Makefile.am
+++ b/dib/Makefile.am
@@ -99,7 +99,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/generator/Makefile.am b/generator/Makefile.am
index c2d10966a..056d01346 100644
--- a/generator/Makefile.am
+++ b/generator/Makefile.am
@@ -175,7 +175,7 @@ OCAMLPACKAGES = \
-I . \
-I $(top_srcdir)/common/mlstdutils \
-I $(top_builddir)/common/mlstdutils
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
noinst_PROGRAM = generator
diff --git a/get-kernel/Makefile.am b/get-kernel/Makefile.am
index 81dfb48b4..75379e21f 100644
--- a/get-kernel/Makefile.am
+++ b/get-kernel/Makefile.am
@@ -82,7 +82,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/ocaml-link.sh.in b/ocaml-link.sh.in
index fbcc07951..6819c641e 100755
--- a/ocaml-link.sh.in
+++ b/ocaml-link.sh.in
@@ -47,4 +47,4 @@ done
exec "$@" \
@OCAML_RUNTIME_VARIANT_PIC_OPTION@ \
-linkpkg \
- -cclib "${cclib}"
+ -cclib "@LDFLAGS@ $cclib"
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index b0f2900f2..752fc109c 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -37,7 +37,7 @@ CLEANFILES += t/*.annot t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
if HAVE_OCAML
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
noinst_DATA = mlguestfs.cma META
if HAVE_OCAMLOPT
diff --git a/resize/Makefile.am b/resize/Makefile.am
index 847fb313a..7a4367023 100644
--- a/resize/Makefile.am
+++ b/resize/Makefile.am
@@ -80,7 +80,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
index 2ab357a68..2dce5e582 100644
--- a/sparsify/Makefile.am
+++ b/sparsify/Makefile.am
@@ -88,7 +88,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 0cc9da80a..6ed4ac713 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -136,7 +136,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 7de050b06..7a1ac329e 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -201,7 +201,7 @@ OCAMLCLIBS = \
$(LIBINTL) \
-lgnu
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/v2v/test-harness/Makefile.am b/v2v/test-harness/Makefile.am
index d69188969..22c3b8c49 100644
--- a/v2v/test-harness/Makefile.am
+++ b/v2v/test-harness/Makefile.am
@@ -47,7 +47,7 @@ OCAMLPACKAGES = \
-I $(top_builddir)/common/mltools \
-I $(top_builddir)/v2v
-OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
BOBJECTS = \
$(SOURCES_ML:.ml=.cmo) \
--
2.21.0