qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins


From: Roman Bolshakov
Subject: Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins
Date: Thu, 29 Nov 2018 12:57:16 +0300
User-agent: NeoMutt/20180716

On Wed, Nov 28, 2018 at 12:23:32PM -0500, Emilio G. Cota wrote:
> On Wed, Nov 28, 2018 at 13:43:30 +0300, Roman Bolshakov wrote:
> > qemu-ga fails to link because it doesn't have symbols declared in
> > qemu-plugins-ld64.symbols. Perhaps "-Wl,-exported_symbols_list" should
> > be applied only to qemu-system?
> 
> I just pushed to the same github branch the appended fixup.
> The idea is to only add the linker flags when the output
> binary links plugin.o.
> 
> Can you please test?
> 
> Thanks,
> 
>               Emilio
> 
> ---
> commit 8f45416b79765b66e5ce0fca7db93b97bbcfcfbb
> Author: Emilio G. Cota <address@hidden>
> Date:   Wed Nov 28 12:11:23 2018 -0500
> 
>     configure: ld64 fixup
>     
>     And copy the file to the build dir also for !ld64.
>     
>     Signed-off-by: Emilio G. Cota <address@hidden>
> 
> diff --git a/Makefile.target b/Makefile.target
> index 719699696d..7ea17d71cb 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -107,7 +107,23 @@ obj-y += target/$(TARGET_BASE_ARCH)/
>  obj-y += disas.o
>  obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
>  
> -obj-$(CONFIG_PLUGINS) += plugin.o
> +ifdef CONFIG_PLUGINS
> +obj-y += plugin.o
> +# Abuse -libs suffix to only link with --dynamic-list/-exported_symbols_list
> +# when the final binary includes the plugin object.
> +#
> +# Note that simply setting LDFLAGS is not enough: we build binaries that
> +# never link plugin.o, and the linker might fail (at least ld64 does)
> +# if the symbols in the list are not in the output binary.
> + ifdef CONFIG_HAS_LD_DYNAMIC_LIST
> + plugin.o-libs := -Wl,--dynamic-list=$(BUILD_DIR)/qemu-plugins-ld.symbols
> + else
> +  ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST
> +  plugin.o-libs := \
> +     -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols
> +  endif
> + endif
> +endif
>  
>  #########################################################
>  # Linux user emulator target
> diff --git a/configure b/configure
> index 3dc9c9697b..395acf831e 100755
> --- a/configure
> +++ b/configure
> @@ -5185,7 +5185,7 @@ fi
>  # See if -exported_symbols_list is supported by the linker
>  
>  cat > $TMPTXT <<EOF
> -  foo
> +  _foo
>  EOF
>  
>  ld_exported_symbols_list="no"
> @@ -6843,13 +6843,17 @@ fi
>  if test "$plugins" = "yes" ; then
>      echo "CONFIG_PLUGINS=y" >> $config_host_mak
>      LIBS="-ldl $LIBS"
> +    # Copy the export object list to the build dir
>      if test "$ld_dynamic_list" = "yes" ; then
> -     LDFLAGS="-Wl,--dynamic-list=\$(SRC_PATH)/qemu-plugins.symbols $LDFLAGS"
> +     echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
> +     ld_symbols=qemu-plugins-ld.symbols
> +     cp "$source_path/qemu-plugins.symbols" $ld_symbols
>      elif test "$ld_exported_symbols_list" = "yes" ; then
> +     echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
>       ld64_symbols=qemu-plugins-ld64.symbols
>       echo "# Automatically generated by configure - do not modify" > 
> $ld64_symbols
> -     cat "$source_path/qemu-plugins.symbols" | grep qemu_ | sed 's/;//g' >> 
> $ld64_symbols
> -     LDFLAGS="-Wl,-exported_symbols_list,\$(BUILD_DIR)/$ld64_symbols 
> $LDFLAGS"
> +     grep 'qemu_' "$source_path/qemu-plugins.symbols" | sed 's/;//g' | \
> +         sed -E 's/^\s*(.*)/_\1/' >> $ld64_symbols
>      else
>       error_exit \
>           "If \$plugins=yes, either \$ld_dynamic_list or " \
> 
Hi Emilio,

I think there's an issue with "\s" character class, it's not recognized
by macOS sed  and I'm getting incorrect lines in
qemu-plugins-ld64.symbols:
_  qemu_xxx
_  qemu_xyz

After I replaced "\s" with "[[:space:]]", linking proceeds further, but
doesn't succeed because of an unresolved reference for qemu-system cris,
lm32, m68k, microblaze, microblazeel, moxie, nios2, or1k, riscv32,
riscv64, sparc, unicore32, tricore, xtensa, xtensaeb:

Undefined symbols for architecture x86_64:
  "_pci_register_bar", referenced from:
      _plugin_chan_realize in plugin-chan.o

It probably has nothing to do with macOS per-se and shouldn't link on
Linux as well. If I disable the aforementioned targets the build
succeeds and I can see the symbols from qemu-plugins-ld64.symbols in
compiled qemu-system binaries.

Best regards,
Roman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]