Blame 0001-trace-use-STAP_SDT_V2-to-work-around-symbol-visibili.patch

Daniel P. Berrangé e83749
From 0e330ca9023487b3635cdcee1b7ef03266ea9068 Mon Sep 17 00:00:00 2001
Daniel P. Berrangé e83749
From: Stefan Hajnoczi <stefanha@redhat.com>
Daniel P. Berrangé e83749
Date: Thu, 19 Nov 2020 11:27:04 +0000
Daniel P. Berrangé e83749
Subject: [PATCH] trace: use STAP_SDT_V2 to work around symbol visibility
Daniel P. Berrangé e83749
MIME-Version: 1.0
Daniel P. Berrangé e83749
Content-Type: text/plain; charset=UTF-8
Daniel P. Berrangé e83749
Content-Transfer-Encoding: 8bit
Daniel P. Berrangé e83749
Daniel P. Berrangé e83749
QEMU binaries no longer launch successfully with recent SystemTap
Daniel P. Berrangé e83749
releases. This is because modular QEMU builds link the sdt semaphores
Daniel P. Berrangé e83749
into the main binary instead of into the shared objects where they are
Daniel P. Berrangé e83749
used. The symbol visibility of semaphores is 'hidden' and the dynamic
Daniel P. Berrangé e83749
linker prints an error during module loading:
Daniel P. Berrangé e83749
Daniel P. Berrangé e83749
  $ ./configure --enable-trace-backends=dtrace --enable-modules ...
Daniel P. Berrangé e83749
  ...
Daniel P. Berrangé e83749
  Failed to open module: /builddir/build/BUILD/qemu-4.2.0/s390x-softmmu/../block-curl.so: undefined symbol: qemu_curl_close_semaphore
Daniel P. Berrangé e83749
Daniel P. Berrangé e83749
The long-term solution is to generate per-module dtrace .o files and
Daniel P. Berrangé e83749
link them into the module instead of the main binary.
Daniel P. Berrangé e83749
Daniel P. Berrangé e83749
In the short term we can define STAP_SDT_V2 so dtrace(1) produces a .o
Daniel P. Berrangé e83749
file with 'default' symbol visibility instead of 'hidden'. This
Daniel P. Berrangé e83749
workaround is small and easier to merge for QEMU 5.2.
Daniel P. Berrangé e83749
Daniel P. Berrangé e83749
Cc: Daniel P. Berrangé <berrange@redhat.com>
Daniel P. Berrangé e83749
Cc: wcohen@redhat.com
Daniel P. Berrangé e83749
Cc: fche@redhat.com
Daniel P. Berrangé e83749
Cc: kraxel@redhat.com
Daniel P. Berrangé e83749
Cc: rjones@redhat.com
Daniel P. Berrangé e83749
Cc: mrezanin@redhat.com
Daniel P. Berrangé e83749
Cc: ddepaula@redhat.com
Daniel P. Berrangé e83749
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Daniel P. Berrangé e83749
---
Daniel P. Berrangé e83749
 configure         | 1 +
Daniel P. Berrangé e83749
 trace/meson.build | 4 ++--
Daniel P. Berrangé e83749
 2 files changed, 3 insertions(+), 2 deletions(-)
Daniel P. Berrangé e83749
Daniel P. Berrangé e83749
diff --git a/configure b/configure
Daniel P. Berrangé e83749
index 714e75b5d8..5d91d49c7b 100755
Daniel P. Berrangé e83749
--- a/configure
Daniel P. Berrangé e83749
+++ b/configure
Daniel P. Berrangé e83749
@@ -4832,6 +4832,7 @@ if have_backend "dtrace"; then
Daniel P. Berrangé e83749
   trace_backend_stap="no"
Daniel P. Berrangé e83749
   if has 'stap' ; then
Daniel P. Berrangé e83749
     trace_backend_stap="yes"
Daniel P. Berrangé e83749
+    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
Daniel P. Berrangé e83749
   fi
Daniel P. Berrangé e83749
 fi
Daniel P. Berrangé e83749
 
Daniel P. Berrangé e83749
diff --git a/trace/meson.build b/trace/meson.build
Daniel P. Berrangé e83749
index d5fc45c628..843ea14495 100644
Daniel P. Berrangé e83749
--- a/trace/meson.build
Daniel P. Berrangé e83749
+++ b/trace/meson.build
Daniel P. Berrangé e83749
@@ -38,13 +38,13 @@ foreach dir : [ '.' ] + trace_events_subdirs
Daniel P. Berrangé e83749
     trace_dtrace_h = custom_target(fmt.format('trace-dtrace', 'h'),
Daniel P. Berrangé e83749
                                    output: fmt.format('trace-dtrace', 'h'),
Daniel P. Berrangé e83749
                                    input: trace_dtrace,
Daniel P. Berrangé e83749
-                                   command: [ 'dtrace', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ])
Daniel P. Berrangé e83749
+                                   command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ])
Daniel P. Berrangé e83749
     trace_ss.add(trace_dtrace_h)
Daniel P. Berrangé e83749
     if host_machine.system() != 'darwin'
Daniel P. Berrangé e83749
       trace_dtrace_o = custom_target(fmt.format('trace-dtrace', 'o'),
Daniel P. Berrangé e83749
                                      output: fmt.format('trace-dtrace', 'o'),
Daniel P. Berrangé e83749
                                      input: trace_dtrace,
Daniel P. Berrangé e83749
-                                     command: [ 'dtrace', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ])
Daniel P. Berrangé e83749
+                                     command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ])
Daniel P. Berrangé e83749
       trace_ss.add(trace_dtrace_o)
Daniel P. Berrangé e83749
     endif
Daniel P. Berrangé e83749
 
Daniel P. Berrangé e83749
-- 
Daniel P. Berrangé e83749
2.28.0
Daniel P. Berrangé e83749