All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] trace: use STAP_SDT_V2 to work around symbol visibility
@ 2020-11-18 17:48 Stefan Hajnoczi
  2020-11-18 17:51 ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2020-11-18 17:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Daniel P . Berrangé,
	rjones, fche, kraxel, Stefan Hajnoczi, wcohen, mrezanin,
	ddepaula

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 /usr/bin/dtrace produces
an .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é <berrange@redhat.com>
Cc: wcohen@redhat.com
Cc: fche@redhat.com
Cc: kraxel@redhat.com
Cc: rjones@redhat.com
Cc: mrezanin@redhat.com
Cc: ddepaula@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 trace/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/trace/meson.build b/trace/meson.build
index d5fc45c628..52be7c5b2c 100644
--- a/trace/meson.build
+++ b/trace/meson.build
@@ -44,7 +44,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
       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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] trace: use STAP_SDT_V2 to work around symbol visibility
  2020-11-18 17:48 [PATCH] trace: use STAP_SDT_V2 to work around symbol visibility Stefan Hajnoczi
@ 2020-11-18 17:51 ` Daniel P. Berrangé
  2020-11-19  9:44   ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrangé @ 2020-11-18 17:51 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Peter Maydell, qemu-devel, rjones, fche, kraxel, wcohen,
	mrezanin, ddepaula

On Wed, Nov 18, 2020 at 05:48:09PM +0000, Stefan Hajnoczi wrote:
> 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 /usr/bin/dtrace produces
> an .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é <berrange@redhat.com>
> Cc: wcohen@redhat.com
> Cc: fche@redhat.com
> Cc: kraxel@redhat.com
> Cc: rjones@redhat.com
> Cc: mrezanin@redhat.com
> Cc: ddepaula@redhat.com
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  trace/meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/trace/meson.build b/trace/meson.build
> index d5fc45c628..52be7c5b2c 100644
> --- a/trace/meson.build
> +++ b/trace/meson.build
> @@ -44,7 +44,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
>        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@' ])

I'm a little concerned that we're not also setting this macro before
including the generated trace.h headers, because those headers do
check this STAP_SDT_V1 symbol.

Currently the generated headers have same code for V2 and V3 (the default),
so we won't break, but I'm concerned we could break if they introduce a
future V4 and that impacts the generated headers.

So I think the safe thing todo is set -DSTAP_SDT_V2 as a global compile
arg for QEMU too, so all trace.h files see the symbol that matches the
trace.o files


Regards,
Daniel
-- 
|: 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 :|



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] trace: use STAP_SDT_V2 to work around symbol visibility
  2020-11-18 17:51 ` Daniel P. Berrangé
@ 2020-11-19  9:44   ` Stefan Hajnoczi
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2020-11-19  9:44 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Peter Maydell, qemu-devel, rjones, fche, kraxel, wcohen,
	mrezanin, ddepaula

[-- Attachment #1: Type: text/plain, Size: 2969 bytes --]

On Wed, Nov 18, 2020 at 05:51:28PM +0000, Daniel P. Berrangé wrote:
> On Wed, Nov 18, 2020 at 05:48:09PM +0000, Stefan Hajnoczi wrote:
> > 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 /usr/bin/dtrace produces
> > an .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é <berrange@redhat.com>
> > Cc: wcohen@redhat.com
> > Cc: fche@redhat.com
> > Cc: kraxel@redhat.com
> > Cc: rjones@redhat.com
> > Cc: mrezanin@redhat.com
> > Cc: ddepaula@redhat.com
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  trace/meson.build | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/trace/meson.build b/trace/meson.build
> > index d5fc45c628..52be7c5b2c 100644
> > --- a/trace/meson.build
> > +++ b/trace/meson.build
> > @@ -44,7 +44,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
> >        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@' ])
> 
> I'm a little concerned that we're not also setting this macro before
> including the generated trace.h headers, because those headers do
> check this STAP_SDT_V1 symbol.
> 
> Currently the generated headers have same code for V2 and V3 (the default),
> so we won't break, but I'm concerned we could break if they introduce a
> future V4 and that impacts the generated headers.
> 
> So I think the safe thing todo is set -DSTAP_SDT_V2 as a global compile
> arg for QEMU too, so all trace.h files see the symbol that matches the
> trace.o files

I have grepped systemtap.git and setting STAP_SDT_V2 globally seems
fine. Originally I wasn't sure of its side-effects, but I'm more
confident about using it after checking the SystemTap code. Will send a
v2.

Input from Frank or William would be appreciated though!

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-19  9:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18 17:48 [PATCH] trace: use STAP_SDT_V2 to work around symbol visibility Stefan Hajnoczi
2020-11-18 17:51 ` Daniel P. Berrangé
2020-11-19  9:44   ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.