[libvirt PATCH v2] meson: Fix build with -Dtest_coverage=true

Jiri Denemark posted 1 patch 3 years, 3 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/88d9df7f3831c925abc97be29d161815e7929873.1611066700.git.jdenemar@redhat.com
tests/meson.build               | 8 ++++----
tools/nss/meson.build           | 2 ++
tools/wireshark/src/meson.build | 3 +++
3 files changed, 9 insertions(+), 4 deletions(-)
[libvirt PATCH v2] meson: Fix build with -Dtest_coverage=true
Posted by Jiri Denemark 3 years, 3 months ago
As can be seen in commit 8a62a1592ae00eab4eb153c02661e56b9d8d9032 (from
autoconf era), the coverage flags have to be used also when linking
objects. However, this was not reflected when we switched to meson.

Without this patch linking fails with undefined references to various
__gcov_* symbols.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 tests/meson.build               | 8 ++++----
 tools/nss/meson.build           | 2 ++
 tools/wireshark/src/meson.build | 3 +++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/meson.build b/tests/meson.build
index f1d91ca50d..23255dd62a 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -26,7 +26,10 @@ tests_dep = declare_dependency(
     top_inc_dir,
     util_inc_dir,
   ],
-  link_args: libvirt_export_dynamic,
+  link_args: (
+    libvirt_export_dynamic
+    + coverage_flags
+  ),
 )
 
 tests_env = [
@@ -228,9 +231,6 @@ executable(
   dependencies: [
     tests_dep,
   ],
-  link_args: [
-    coverage_flags,
-  ],
 )
 
 
diff --git a/tools/nss/meson.build b/tools/nss/meson.build
index cf3eec9b24..198936f3d4 100644
--- a/tools/nss/meson.build
+++ b/tools/nss/meson.build
@@ -66,6 +66,7 @@ nss_libvirt_lib = shared_module(
   link_args: [
     nss_libvirt_syms,
     libvirt_export_dynamic,
+    coverage_flags,
   ],
   link_whole: [
     nss_libvirt_impl,
@@ -81,6 +82,7 @@ nss_libvirt_guest_lib = shared_library(
   link_args: [
     nss_libvirt_guest_syms,
     libvirt_export_dynamic,
+    coverage_flags,
   ],
   link_whole: [
     nss_libvirt_guest_impl,
diff --git a/tools/wireshark/src/meson.build b/tools/wireshark/src/meson.build
index 49ccc9bb86..9b452dc5ca 100644
--- a/tools/wireshark/src/meson.build
+++ b/tools/wireshark/src/meson.build
@@ -12,6 +12,9 @@ shared_library(
     xdr_dep,
     tools_dep,
   ],
+  link_args: [
+    coverage_flags
+  ],
   install: true,
   install_dir: wireshark_plugindir,
 )
-- 
2.30.0

Re: [libvirt PATCH v2] meson: Fix build with -Dtest_coverage=true
Posted by Pavel Hrdina 3 years, 3 months ago
On Tue, Jan 19, 2021 at 03:31:56PM +0100, Jiri Denemark wrote:
> As can be seen in commit 8a62a1592ae00eab4eb153c02661e56b9d8d9032 (from
> autoconf era), the coverage flags have to be used also when linking
> objects. However, this was not reflected when we switched to meson.
> 
> Without this patch linking fails with undefined references to various
> __gcov_* symbols.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  tests/meson.build               | 8 ++++----
>  tools/nss/meson.build           | 2 ++
>  tools/wireshark/src/meson.build | 3 +++
>  3 files changed, 9 insertions(+), 4 deletions(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>