Blame SOURCES/kvm-trace-use-STAP_SDT_V2-to-work-around-symbol-visibili.patch

a19a21
From ba3068eb1a349ec4ed8b7ccdae76450f0c315be9 Mon Sep 17 00:00:00 2001
a19a21
From: Stefan Hajnoczi <stefanha@redhat.com>
a19a21
Date: Thu, 19 Nov 2020 17:23:11 -0500
a19a21
Subject: [PATCH 18/18] trace: use STAP_SDT_V2 to work around symbol visibility
a19a21
MIME-Version: 1.0
a19a21
Content-Type: text/plain; charset=UTF-8
a19a21
Content-Transfer-Encoding: 8bit
a19a21
a19a21
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
a19a21
Message-id: <20201119172311.942629-2-stefanha@redhat.com>
a19a21
Patchwork-id: 99779
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] trace: use STAP_SDT_V2 to work around symbol visibility
a19a21
Bugzilla: 1898700
a19a21
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
a19a21
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
a19a21
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
a19a21
a19a21
QEMU binaries no longer launch successfully with recent SystemTap
a19a21
releases. This is because modular QEMU builds link the sdt semaphores
a19a21
into the main binary instead of into the shared objects where they are
a19a21
used. The symbol visibility of semaphores is 'hidden' and the dynamic
a19a21
linker prints an error during module loading:
a19a21
a19a21
  $ ./configure --enable-trace-backends=dtrace --enable-modules ...
a19a21
  ...
a19a21
  Failed to open module: /builddir/build/BUILD/qemu-4.2.0/s390x-softmmu/../block-curl.so: undefined symbol: qemu_curl_close_semaphore
a19a21
a19a21
The long-term solution is to generate per-module dtrace .o files and
a19a21
link them into the module instead of the main binary.
a19a21
a19a21
In the short term we can define STAP_SDT_V2 so dtrace(1) produces a .o
a19a21
file with 'default' symbol visibility instead of 'hidden'. This
a19a21
workaround is small and easier to merge for QEMU 5.2 and downstream
a19a21
backports.
a19a21
a19a21
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1898700
a19a21
Cc: wcohen@redhat.com
a19a21
Cc: fche@redhat.com
a19a21
Cc: kraxel@redhat.com
a19a21
Cc: rjones@redhat.com
a19a21
Cc: ddepaula@redhat.com
a19a21
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
a19a21
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
a19a21
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
a19a21
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
a19a21
a19a21
(cherry picked from commit 4b265c79a85bb35abe19aacea6954c1616521639)
a19a21
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
a19a21
a19a21
Conflicts:
a19a21
  trace/meson.build
a19a21
  Downstream uses makefiles, so move the dtrace invocation changes to
a19a21
  rules.mak and Makefile.
a19a21
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a19a21
---
a19a21
 Makefile  | 4 ++--
a19a21
 configure | 7 +++++++
a19a21
 rules.mak | 2 +-
a19a21
 3 files changed, 10 insertions(+), 3 deletions(-)
a19a21
a19a21
diff --git a/Makefile b/Makefile
a19a21
index ff05c309497..29b01a13ee3 100644
a19a21
--- a/Makefile
a19a21
+++ b/Makefile
a19a21
@@ -198,7 +198,7 @@ tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
a19a21
 		$< > $@,"GEN","$(@:%-timestamp=%)")
a19a21
 
a19a21
 %/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
a19a21
-	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
a19a21
+	$(call quiet-command,dtrace -o $@ -DSTAP_SDT_V2 -h -s $<, "GEN","$@")
a19a21
 
a19a21
 %/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
a19a21
 
a19a21
@@ -258,7 +258,7 @@ trace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config
a19a21
 		$< > $@,"GEN","$(@:%-timestamp=%)")
a19a21
 
a19a21
 trace-dtrace-root.h: trace-dtrace-root.dtrace
a19a21
-	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
a19a21
+	$(call quiet-command,dtrace -o $@ -DSTAP_SDT_V2 -h -s $<, "GEN","$@")
a19a21
 
a19a21
 trace-dtrace-root.o: trace-dtrace-root.dtrace
a19a21
 
a19a21
diff --git a/configure b/configure
a19a21
index 5120c1409a7..c62b61403f6 100755
a19a21
--- a/configure
a19a21
+++ b/configure
a19a21
@@ -5275,6 +5275,13 @@ if have_backend "dtrace"; then
a19a21
   trace_backend_stap="no"
a19a21
   if has 'stap' ; then
a19a21
     trace_backend_stap="yes"
a19a21
+
a19a21
+    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
a19a21
+    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
a19a21
+    # instead. QEMU --enable-modules depends on this because the SystemTap
a19a21
+    # semaphores are linked into the main binary and not the module's shared
a19a21
+    # object.
a19a21
+    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
a19a21
   fi
a19a21
 fi
a19a21
 
a19a21
diff --git a/rules.mak b/rules.mak
a19a21
index 967295dd2b6..bdfc223a5a1 100644
a19a21
--- a/rules.mak
a19a21
+++ b/rules.mak
a19a21
@@ -101,7 +101,7 @@ LINK = $(call quiet-command, $(LINKPROG) $(QEMU_LDFLAGS) $(QEMU_CFLAGS) $(CFLAGS
a19a21
 	       -c -o $@ $<,"OBJC","$(TARGET_DIR)$@")
a19a21
 
a19a21
 %.o: %.dtrace
a19a21
-	$(call quiet-command,dtrace -o $@ -G -s $<,"GEN","$(TARGET_DIR)$@")
a19a21
+	$(call quiet-command,dtrace -o $@ -DSTAP_SDT_V2 -G -s $<,"GEN","$(TARGET_DIR)$@")
a19a21
 
a19a21
 DSO_OBJ_CFLAGS := -fPIC -DBUILD_DSO
a19a21
 module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS)
a19a21
-- 
a19a21
2.27.0
a19a21