[libvirt PATCH 1/2] meson: Fix cross-building of dtrace probes

Andrea Bolognani abologna at redhat.com
Wed Jan 20 16:54:04 UTC 2021


From: Helmut Grohne <helmut at subdivi.de>

dtrace invokes the C compiler, so when cross-building we need
to make sure that $CC is set in the environment and that it
points to the cross-compiler rather than the native one.

Until https://github.com/mesonbuild/meson/issues/266
is addressed, the workaround is to call dtrace via env(1).

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980334

Signed-off-by: Helmut Grohne <helmut at subdivi.de>
Reviewed-by: Andrea Bolognani <abologna at redhat.com>
---
 meson.build          | 1 +
 src/meson.build      | 4 ++--
 src/qemu/meson.build | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index d8a63baac9..1c36b10390 100644
--- a/meson.build
+++ b/meson.build
@@ -2022,6 +2022,7 @@ if host_machine.system() == 'linux'
   if dtrace_prog.found()
     conf.set('WITH_DTRACE_PROBES', 1)
   endif
+  dtrace_command = [ 'env', 'CC=' + ' '.join(meson.get_compiler('c').cmd_array()), dtrace_prog ]
 endif
 
 if not get_option('host_validate').disabled() and host_machine.system() != 'windows'
diff --git a/src/meson.build b/src/meson.build
index 7c478219d6..56e71f4456 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -60,14 +60,14 @@ if conf.has('WITH_DTRACE_PROBES')
     out_h,
     input: infile,
     output: out_h,
-    command: [ dtrace_prog, '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ],
+    command: dtrace_command + [ '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ],
   )
 
   dtrace_gen_objects += custom_target(
     out_o,
     input: infile,
     output: out_o,
-    command: [ dtrace_prog, '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ],
+    command: dtrace_command + [ '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ],
   )
 
   custom_target(
diff --git a/src/qemu/meson.build b/src/qemu/meson.build
index 90640b03c6..e3065c3507 100644
--- a/src/qemu/meson.build
+++ b/src/qemu/meson.build
@@ -56,14 +56,14 @@ if conf.has('WITH_DTRACE_PROBES')
     out_h,
     input: infile,
     output: out_h,
-    command: [ dtrace_prog, '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ],
+    command: dtrace_command + [ '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ],
   )
 
   qemu_dtrace_gen_objects += custom_target(
     out_o,
     input: infile,
     output: out_o,
-    command: [ dtrace_prog, '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ],
+    command: dtrace_command + [ '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ],
   )
 
   qemu_dtrace_gen_stp = custom_target(
-- 
2.26.2




More information about the libvir-list mailing list