trace: use STAP_SDT_V2 to work around symbol visibility
PATCH v2 1/1 trace: use STAP_SDT_V2 to work around symbol visibility
QEMU binaries no longer launch successfully with recent SystemTap releases. This is because modular QEMU builds link the sdt semaphores into the main binary instead of into the shared objects where they are used. The symbol visibility of semaphores is 'hidden' and the dynamic linker prints an error during module loading:
$ ./configure --enable-trace-backends=dtrace --enable-modules ... ... Failed to open module: /builddir/build/BUILD/qemu-4.2.0/s390x-softmmu/../block-curl.so: undefined symbol: qemu_curl_close_semaphore
The long-term solution is to generate per-module dtrace .o files and link them into the module instead of the main binary.
In the short term we can define STAP_SDT_V2 so dtrace(1) produces a .o file with 'default' symbol visibility instead of 'hidden'. This workaround is small and easier to merge for QEMU 5.2.
---
v2:
* Define STAP_SDT_V2 everywhere [danpb]
--- configure | 1 + trace/meson.build | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
configure +1 -0
@@ -4832,6 +4832,7 @@ if have_backend "dtrace"; then trace_backend_stap="no" if has 'stap' ; then trace_backend_stap="yes" + QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2" fi fi
trace/meson.build +2 -2
@@ -38,13 +38,13 @@ foreach dir : [ '.' ] + trace_events_subdirs trace_dtrace_h = custom_target(fmt.format('trace-dtrace', 'h'), output: fmt.format('trace-dtrace', 'h'), input: trace_dtrace, - command: [ 'dtrace', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ]) + command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ]) trace_ss.add(trace_dtrace_h) if host_machine.system() != 'darwin' trace_dtrace_o = custom_target(fmt.format('trace-dtrace', 'o'), output: fmt.format('trace-dtrace', 'o'), input: trace_dtrace, - command: [ 'dtrace', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ]) + command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ]) trace_ss.add(trace_dtrace_o) endif
Signature · 1 line
2.28.0
Quoted 10 lines · Stefan Hajnoczi
QEMU binaries no longer launch successfully with recent SystemTap releases. This is because modular QEMU builds link the sdt semaphores into the main binary instead of into the shared objects where they are used. The symbol visibility of semaphores is 'hidden' and the dynamic linker prints an error during module loading:
$ ./configure --enable-trace-backends=dtrace --enable-modules ... ... Failed to open module: /builddir/build/BUILD/qemu-4.2.0/s390x-softmmu/../block-curl.so: undefined symbol: qemu_curl_close_semaphore
Quoted 6 lines
The long-term solution is to generate per-module dtrace .o files and link them into the module instead of the main binary.
In the short term we can define
STAP_SDT_V2so dtrace(1) produces a .o file with 'default' symbol visibility instead of 'hidden'. This workaround is small and easier to merge for QEMU 5.2.
And nice for distros to backport too.
Quoted 9 lines
Cc Daniel P. Berrangé <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 7 lines
---
v2:
* DefineSTAP_SDT_V2everywhere [danpb]--- configure | 1 + trace/meson.build | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 38 lines · Stefan Hajnoczi
QEMU binaries no longer launch successfully with recent SystemTap releases. This is because modular QEMU builds link the sdt semaphores into the main binary instead of into the shared objects where they are used. The symbol visibility of semaphores is 'hidden' and the dynamic linker prints an error during module loading:
$ ./configure --enable-trace-backends=dtrace --enable-modules ... ... Failed to open module: /builddir/build/BUILD/qemu-4.2.0/s390x-softmmu/../block-curl.so: undefined symbol: qemu_curl_close_semaphoreThe long-term solution is to generate per-module dtrace .o files and link them into the module instead of the main binary.
In the short term we can define
STAP_SDT_V2so dtrace(1) produces a .o file with 'default' symbol visibility instead of 'hidden'. This workaround is small and easier to merge for QEMU 5.2.Cc Daniel P. Berrangé <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>---
v2:
* DefineSTAP_SDT_V2everywhere [danpb]--- configure | 1 + trace/meson.build | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)configure +0
-0
configure if have_backend "dtrace"; then · line 4834
Quoted 3 lines
configure +0
-0@@ -4832,6 +4832,7 @@ if have_backend "dtrace"; then trace_backend_stap="no" if has 'stap' ; then trace_backend_stap="yes"
Maybe add a comment? (no need to repost if you agree):
# Workaround to avoid dtrace(1) produces file with 'hidden' # symbol visibility, define STAP_SDT_V2 to produce 'default' # symbol visibility instead.
configure if have_backend "dtrace"; then · line 4835
Quoted 1 line
configure +1
-0+ QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
Quoted 24 lines
configure +0
-0fi fitrace/meson.build +2
-2@@ -38,13 +38,13 @@ foreach dir : [ '.' ] + trace_events_subdirs trace_dtrace_h = custom_target(fmt.format('trace-dtrace', 'h'), output: fmt.format('trace-dtrace', 'h'), input: trace_dtrace, - command: [ 'dtrace', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ]) + command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ]) trace_ss.add(trace_dtrace_h) if host_machine.system() != 'darwin' trace_dtrace_o = custom_target(fmt.format('trace-dtrace', 'o'), output: fmt.format('trace-dtrace', 'o'), input: trace_dtrace, - command: [ 'dtrace', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ]) + command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ]) trace_ss.add(trace_dtrace_o) endif
Quoted 12 lines · Philippe Mathieu-Daudé
configure if have_backend "dtrace"; then · line 4834
Quoted 8 lines · Stefan Hajnoczi
configure +0
-0@@ -4832,6 +4832,7 @@ if have_backend "dtrace"; then trace_backend_stap="no" if has 'stap' ; then trace_backend_stap="yes"Maybe add a comment? (no need to repost if you agree):
Quoted 5 lines
# Workaround to avoid dtrace(1) produces file with 'hidden' # symbol visibility, define
STAP_SDT_V2to produce 'default' # symbol visibility instead.Quoted 1 line
configure +1
-0+ QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
Yes, that would be helpful.
Stefan
Hi -
Quoted 7 lines
Quoted 7 lines
Maybe add a comment? (no need to repost if you agree):
# Workaround to avoid dtrace(1) produces file with 'hidden' # symbol visibility, define
STAP_SDT_V2to produce 'default' # symbol visibility instead.Quoted 1 line
+ QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
Please note that we don't know how long this behavior will persist. You are relying on an accident. :-)
Much of the systemtap code doesn't support real STAP_SDT_V2 format, and /usr/include/sys/sdt.h cannot generate it at all. That macro tricks only the dtrace-header-generator to suppress the "hidden" visibility attribute, but doesn't change probe metadata format to the old V2 (in .probes sections rather than .note.* ELF notes).
We'll try not to break it, but please move toward the more proper per-solib or per-executable hidden copies of the semaphore objects.
- FChE
Quoted 14 lines · Frank Ch. Eigler
Hi -
Quoted 7 lines
Quoted 7 lines
Maybe add a comment? (no need to repost if you agree):
# Workaround to avoid dtrace(1) produces file with 'hidden' # symbol visibility, define
STAP_SDT_V2to produce 'default' # symbol visibility instead.Quoted 1 line
+ QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
Please note that we don't know how long this behavior will persist. You are relying on an accident. :-)
Quoted 8 lines
Much of the systemtap code doesn't support real
STAP_SDT_V2format, and/usr/include/sys/sdt.hcannot generate it at all. That macro tricks only the dtrace-header-generator to suppress the "hidden" visibility attribute, but doesn't change probe metadata format to the old V2 (in .probes sections rather than .note.* ELF notes).We'll try not to break it, but please move toward the more proper per-solib or per-executable hidden copies of the semaphore objects.
Yes, thanks. Gerd Hoffmann has started working on per-solib semaphore linking and this workaround will be replaced by it.
Stefan
----- Original Message -----
Quoted 20 lines
From: "Stefan Hajnoczi" <[email protected]>
To: [email protected]
Cc: "Peter Maydell" <[email protected]>, "Stefan Hajnoczi" <[email protected]>, "Daniel P . Berrangé" <[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Sent: Thursday, November 19, 2020 12:27:04 PM
Subject: [PATCH v2] trace: useSTAP_SDT_V2to work around symbol visibilityQEMU binaries no longer launch successfully with recent SystemTap releases. This is because modular QEMU builds link the sdt semaphores into the main binary instead of into the shared objects where they are used. The symbol visibility of semaphores is 'hidden' and the dynamic linker prints an error during module loading:
$ ./configure --enable-trace-backends=dtrace --enable-modules ... ... Failed to open module: /builddir/build/BUILD/qemu-4.2.0/s390x-softmmu/../block-curl.so: undefined symbol: qemu_curl_close_semaphore
Quoted 7 lines
The long-term solution is to generate per-module dtrace .o files and link them into the module instead of the main binary.
In the short term we can define
STAP_SDT_V2so dtrace(1) produces a .o file with 'default' symbol visibility instead of 'hidden'. This workaround is small and easier to merge for QEMU 5.2.
Thanks for this fix.
Quoted 57 lines
Cc Daniel P. Berrangé <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>---
v2:
* DefineSTAP_SDT_V2everywhere [danpb]--- configure | 1 + trace/meson.build | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)configure +1
-0@@ -4832,6 +4832,7 @@ if have_backend "dtrace"; then trace_backend_stap="no" if has 'stap' ; then trace_backend_stap="yes" + QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2" fi fitrace/meson.build +1
-2@@ -38,13 +38,13 @@ foreach dir : [ '.' ] + trace_events_subdirs trace_dtrace_h = custom_target(fmt.format('trace-dtrace', 'h'), output: fmt.format('trace-dtrace', 'h'), input: trace_dtrace, - command: [ 'dtrace', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ]) + command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ]) trace_ss.add(trace_dtrace_h) if host_machine.system() != 'darwin' trace_dtrace_o = custom_target(fmt.format('trace-dtrace', 'o'), output: fmt.format('trace-dtrace', 'o'), input: trace_dtrace, - command: [ 'dtrace', '-o', '@OUTPUT@','-G', '-s', '@INPUT@' ])
+ command: [ 'dtrace', '-DSTAP_SDT_V2',
'-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ])
trace_ss.add(trace_dtrace_o)
endif--
2.28.0
Signature · 2 lines
Miroslav Rezanina Software Engineer - Virtualization Team Maintainer