qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] build contrib/plugins using meson
@ 2024-09-25 20:48 Pierrick Bouvier
  2024-09-25 20:48 ` [PATCH v2 1/2] meson: build contrib/plugins with meson Pierrick Bouvier
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2024-09-25 20:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Daniel P. Berrangé, Pierrick Bouvier,
	Alexandre Iooss, Paolo Bonzini, Alex Bennée, Thomas Huth,
	Philippe Mathieu-Daudé, Mahmoud Mandour

Contrib plugins have been built out of tree so far, thanks to a Makefile.
However, it is quite inconvenient for maintenance, as we may break them,
especially for specific architectures.

First patches are fixing warnings for existing plugins, then we add meson
support, and finally, we remove Makefile for contrib/plugins.

Based on the proposal of Anton Kochkov on associated gitlab issue.
Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710

Plugins are now deactivated by default on 32-bits hosts (since cf2a78), so we
can enable with meson without worrying of warnings when building plugins for 32
bits.

v2
--

- removed warnings fix for 32 bits as they were incorrect. They are not needed
  anymore as plugins are deprecated for 32 bits hosts.

Removed patches for individual plugins.

Pierrick Bouvier (2):
  meson: build contrib/plugins with meson
  contrib/plugins: remove Makefile for contrib/plugins

 configure                   | 18 --------
 Makefile                    | 10 -----
 meson.build                 |  4 ++
 contrib/plugins/Makefile    | 87 -------------------------------------
 contrib/plugins/meson.build | 23 ++++++++++
 5 files changed, 27 insertions(+), 115 deletions(-)
 delete mode 100644 contrib/plugins/Makefile
 create mode 100644 contrib/plugins/meson.build

-- 
2.39.5



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

* [PATCH v2 1/2] meson: build contrib/plugins with meson
  2024-09-25 20:48 [PATCH v2 0/2] build contrib/plugins using meson Pierrick Bouvier
@ 2024-09-25 20:48 ` Pierrick Bouvier
  2024-10-21  9:38   ` Alex Bennée
  2024-09-25 20:48 ` [PATCH v2 2/2] contrib/plugins: remove Makefile for contrib/plugins Pierrick Bouvier
  2024-10-09 22:13 ` [PATCH v2 0/2] build contrib/plugins using meson Pierrick Bouvier
  2 siblings, 1 reply; 7+ messages in thread
From: Pierrick Bouvier @ 2024-09-25 20:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Daniel P. Berrangé, Pierrick Bouvier,
	Alexandre Iooss, Paolo Bonzini, Alex Bennée, Thomas Huth,
	Philippe Mathieu-Daudé, Mahmoud Mandour

Tried to unify this meson.build with tests/tcg/plugins/meson.build but
the resulting modules are not output in the right directory.

Originally proposed by Anton Kochkov, thank you!

Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build                 |  4 ++++
 contrib/plugins/meson.build | 23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 contrib/plugins/meson.build

diff --git a/meson.build b/meson.build
index ceee6b22c8d..b18c2a54ab5 100644
--- a/meson.build
+++ b/meson.build
@@ -3655,6 +3655,10 @@ subdir('accel')
 subdir('plugins')
 subdir('ebpf')
 
+if 'CONFIG_TCG' in config_all_accel
+  subdir('contrib/plugins')
+endif
+
 common_user_inc = []
 
 subdir('common-user')
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
new file mode 100644
index 00000000000..a0e026d25e2
--- /dev/null
+++ b/contrib/plugins/meson.build
@@ -0,0 +1,23 @@
+t = []
+if get_option('plugins')
+  foreach i : ['cache', 'drcov', 'execlog', 'hotblocks', 'hotpages', 'howvec',
+               'hwprofile', 'ips', 'lockstep', 'stoptrigger']
+    if host_os == 'windows'
+      t += shared_module(i, files(i + '.c') + 'win32_linker.c',
+                        include_directories: '../../include/qemu',
+                        link_depends: [win32_qemu_plugin_api_lib],
+                        link_args: ['-Lplugins', '-lqemu_plugin_api'],
+                        dependencies: glib)
+
+    else
+      t += shared_module(i, files(i + '.c'),
+                        include_directories: '../../include/qemu',
+                        dependencies: glib)
+    endif
+  endforeach
+endif
+if t.length() > 0
+  alias_target('contrib-plugins', t)
+else
+  run_target('contrib-plugins', command: find_program('true'))
+endif
-- 
2.39.5



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

* [PATCH v2 2/2] contrib/plugins: remove Makefile for contrib/plugins
  2024-09-25 20:48 [PATCH v2 0/2] build contrib/plugins using meson Pierrick Bouvier
  2024-09-25 20:48 ` [PATCH v2 1/2] meson: build contrib/plugins with meson Pierrick Bouvier
@ 2024-09-25 20:48 ` Pierrick Bouvier
  2024-10-09 22:13 ` [PATCH v2 0/2] build contrib/plugins using meson Pierrick Bouvier
  2 siblings, 0 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2024-09-25 20:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Daniel P. Berrangé, Pierrick Bouvier,
	Alexandre Iooss, Paolo Bonzini, Alex Bennée, Thomas Huth,
	Philippe Mathieu-Daudé, Mahmoud Mandour

Now replaced by meson build.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 configure                | 18 ---------
 Makefile                 | 10 -----
 contrib/plugins/Makefile | 87 ----------------------------------------
 3 files changed, 115 deletions(-)
 delete mode 100644 contrib/plugins/Makefile

diff --git a/configure b/configure
index aa7aae70fa1..934336e5286 100755
--- a/configure
+++ b/configure
@@ -1055,7 +1055,6 @@ if test "$plugins" != "no" && test $host_bits -eq 64; then
         plugins="no"
     else
         plugins=yes
-        subdirs="$subdirs contrib/plugins"
     fi
 fi
 
@@ -1555,7 +1554,6 @@ LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
 LINKS="$LINKS tests/avocado tests/data"
 LINKS="$LINKS tests/qemu-iotests/check tests/qemu-iotests/Makefile"
 LINKS="$LINKS python"
-LINKS="$LINKS contrib/plugins/Makefile "
 for f in $LINKS ; do
     if [ -e "$source_path/$f" ]; then
         symlink "$source_path/$f" "$f"
@@ -1638,22 +1636,6 @@ if test "$default_targets" = "yes"; then
   echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
 fi
 
-# contrib/plugins configuration
-echo "# Automatically generated by configure - do not modify" > contrib/plugins/$config_host_mak
-echo "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak
-echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak
-echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak
-echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak
-if test "$host_os" = windows; then
-  echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak
-fi
-if test "$host_os" = darwin; then
-  echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak
-fi
-if test "$host_os" = windows; then
-  echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak
-fi
-
 # tests/tcg configuration
 mkdir -p tests/tcg
 echo "# Automatically generated by configure - do not modify" > tests/tcg/$config_host_mak
diff --git a/Makefile b/Makefile
index 917c9a34d1c..b65b0bd41a8 100644
--- a/Makefile
+++ b/Makefile
@@ -187,11 +187,6 @@ SUBDIR_RULES=$(foreach t, all clean distclean, $(addsuffix /$(t), $(SUBDIRS)))
 $(SUBDIR_RULES):
 	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
 
-ifneq ($(filter contrib/plugins, $(SUBDIRS)),)
-.PHONY: plugins
-plugins: contrib/plugins/all
-endif
-
 .PHONY: recurse-all recurse-clean
 recurse-all: $(addsuffix /all, $(SUBDIRS))
 recurse-clean: $(addsuffix /clean, $(SUBDIRS))
@@ -307,11 +302,6 @@ help:
 	$(call print-help,cscope,Generate cscope index)
 	$(call print-help,sparse,Run sparse on the QEMU source)
 	@echo  ''
-ifneq ($(filter contrib/plugins, $(SUBDIRS)),)
-	@echo  'Plugin targets:'
-	$(call print-help,plugins,Build the example TCG plugins)
-	@echo  ''
-endif
 	@echo  'Cleaning targets:'
 	$(call print-help,clean,Remove most generated files but keep the config)
 	$(call print-help,distclean,Remove all generated files)
diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile
deleted file mode 100644
index bbddd4800ff..00000000000
--- a/contrib/plugins/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-# -*- Mode: makefile -*-
-#
-# This Makefile example is fairly independent from the main makefile
-# so users can take and adapt it for their build. We only really
-# include config-host.mak so we don't have to repeat probing for
-# programs that the main configure has already done for us.
-#
-
-include config-host.mak
-
-TOP_SRC_PATH = $(SRC_PATH)/../..
-
-VPATH += $(SRC_PATH)
-
-NAMES :=
-NAMES += bbv
-NAMES += execlog
-NAMES += hotblocks
-NAMES += hotpages
-NAMES += howvec
-
-# The lockstep example communicates using unix sockets,
-# and can't be easily made to work on windows.
-ifneq ($(CONFIG_WIN32),y)
-NAMES += lockstep
-endif
-
-NAMES += hwprofile
-NAMES += cache
-NAMES += drcov
-NAMES += ips
-NAMES += stoptrigger
-NAMES += cflow
-
-ifeq ($(CONFIG_WIN32),y)
-SO_SUFFIX := .dll
-LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0)
-else
-SO_SUFFIX := .so
-endif
-
-SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES)))
-
-# The main QEMU uses Glib extensively so it is perfectly fine to use it
-# in plugins (which many example do).
-PLUGIN_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0)
-PLUGIN_CFLAGS += -fPIC -Wall
-PLUGIN_CFLAGS += -I$(TOP_SRC_PATH)/include/qemu
-
-# Helper that honours V=1 so we get some output when compiling
-quiet-@ = $(if $(V),,@$(if $1,printf "  %-7s %s\n" "$(strip $1)" "$(strip $2)" && ))
-quiet-command = $(call quiet-@,$2,$3)$1
-
-# for including , in command strings
-COMMA := ,
-
-all: $(SONAMES)
-
-%.o: %.c
-	$(call quiet-command, \
-		$(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $<, \
-	        BUILD, plugin $@)
-
-ifeq ($(CONFIG_WIN32),y)
-lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/libqemu_plugin_api.a
-	$(call quiet-command, \
-		$(CC) -shared -o $@ $^ $(LDLIBS), \
-		LINK, plugin $@)
-else ifeq ($(CONFIG_DARWIN),y)
-lib%$(SO_SUFFIX): %.o
-	$(call quiet-command, \
-		$(CC) -bundle -Wl$(COMMA)-undefined$(COMMA)dynamic_lookup -o $@ $^ $(LDLIBS), \
-		LINK, plugin $@)
-else
-lib%$(SO_SUFFIX): %.o
-	$(call quiet-command, \
-		$(CC) -shared -o $@ $^ $(LDLIBS), \
-		LINK, plugin $@)
-endif
-
-
-clean distclean:
-	rm -f *.o *$(SO_SUFFIX) *.d
-	rm -Rf .libs
-
-.PHONY: all clean
-.SECONDARY:
-- 
2.39.5



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

* Re: [PATCH v2 0/2] build contrib/plugins using meson
  2024-09-25 20:48 [PATCH v2 0/2] build contrib/plugins using meson Pierrick Bouvier
  2024-09-25 20:48 ` [PATCH v2 1/2] meson: build contrib/plugins with meson Pierrick Bouvier
  2024-09-25 20:48 ` [PATCH v2 2/2] contrib/plugins: remove Makefile for contrib/plugins Pierrick Bouvier
@ 2024-10-09 22:13 ` Pierrick Bouvier
  2 siblings, 0 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2024-10-09 22:13 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Daniel P. Berrangé, Alexandre Iooss,
	Paolo Bonzini, Alex Bennée, Thomas Huth,
	Philippe Mathieu-Daudé, Mahmoud Mandour

On 9/25/24 13:48, Pierrick Bouvier wrote:
> Contrib plugins have been built out of tree so far, thanks to a Makefile.
> However, it is quite inconvenient for maintenance, as we may break them,
> especially for specific architectures.
> 
> First patches are fixing warnings for existing plugins, then we add meson
> support, and finally, we remove Makefile for contrib/plugins.
> 
> Based on the proposal of Anton Kochkov on associated gitlab issue.
> Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710
> 
> Plugins are now deactivated by default on 32-bits hosts (since cf2a78), so we
> can enable with meson without worrying of warnings when building plugins for 32
> bits.
> 
> v2
> --
> 
> - removed warnings fix for 32 bits as they were incorrect. They are not needed
>    anymore as plugins are deprecated for 32 bits hosts.
> 
> Removed patches for individual plugins.
> 
> Pierrick Bouvier (2):
>    meson: build contrib/plugins with meson
>    contrib/plugins: remove Makefile for contrib/plugins
> 
>   configure                   | 18 --------
>   Makefile                    | 10 -----
>   meson.build                 |  4 ++
>   contrib/plugins/Makefile    | 87 -------------------------------------
>   contrib/plugins/meson.build | 23 ++++++++++
>   5 files changed, 27 insertions(+), 115 deletions(-)
>   delete mode 100644 contrib/plugins/Makefile
>   create mode 100644 contrib/plugins/meson.build
> 

Gentle ping on this series, to know if people are interested by this change.

Thanks,
Pierrick


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

* Re: [PATCH v2 1/2] meson: build contrib/plugins with meson
  2024-09-25 20:48 ` [PATCH v2 1/2] meson: build contrib/plugins with meson Pierrick Bouvier
@ 2024-10-21  9:38   ` Alex Bennée
  2024-10-21 15:45     ` Pierrick Bouvier
  2024-10-21 15:53     ` Pierrick Bouvier
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Bennée @ 2024-10-21  9:38 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: qemu-devel, Marc-André Lureau, Daniel P. Berrangé,
	Alexandre Iooss, Paolo Bonzini, Thomas Huth,
	Philippe Mathieu-Daudé, Mahmoud Mandour, Brad Smith

Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> Tried to unify this meson.build with tests/tcg/plugins/meson.build but
> the resulting modules are not output in the right directory.
>
> Originally proposed by Anton Kochkov, thank you!
>
> Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>  meson.build                 |  4 ++++
>  contrib/plugins/meson.build | 23 +++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
>  create mode 100644 contrib/plugins/meson.build
>
> diff --git a/meson.build b/meson.build
> index ceee6b22c8d..b18c2a54ab5 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3655,6 +3655,10 @@ subdir('accel')
>  subdir('plugins')
>  subdir('ebpf')
>  
> +if 'CONFIG_TCG' in config_all_accel
> +  subdir('contrib/plugins')
> +endif
> +
>  common_user_inc = []
>  
>  subdir('common-user')
> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
> new file mode 100644
> index 00000000000..a0e026d25e2
> --- /dev/null
> +++ b/contrib/plugins/meson.build
> @@ -0,0 +1,23 @@
> +t = []
> +if get_option('plugins')
> +  foreach i : ['cache', 'drcov', 'execlog', 'hotblocks', 'hotpages', 'howvec',
> +               'hwprofile', 'ips', 'lockstep', 'stoptrigger']
> +    if host_os == 'windows'
> +      t += shared_module(i, files(i + '.c') + 'win32_linker.c',
> +                        include_directories: '../../include/qemu',
> +                        link_depends: [win32_qemu_plugin_api_lib],
> +                        link_args: ['-Lplugins', '-lqemu_plugin_api'],
> +                        dependencies: glib)
> +
> +    else
> +      t += shared_module(i, files(i + '.c'),
> +                        include_directories: '../../include/qemu',
> +                        dependencies: glib)

I was trying to work out where the include dirs come from to make sure
Brad's fix (see Zu4063fjfHC5hHUl@humpty.home.comstyle.com) also applies.
It does but:

  ➜  make contrib/plugins/libexeclog.so V=1
  /usr/bin/ninja -v   -j1 -d keepdepfile contrib/plugins/libexeclog.so | cat
  [1/2] cc -m64 -Icontrib/plugins/libexeclog.so.p -Icontrib/plugins -I../../contrib/plugins -I../../include/qemu -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home/alex/lsrc/qemu.git/linux-headers -isystem linux-headers -iquote . -iquote /home/alex/lsrc/qemu.git -iquote /home/alex/lsrc/qemu.git/include -iquote /home/alex/lsrc/qemu.git/host/include/x86_64 -iquote /home/alex/lsrc/qemu.git/host/include/generic -iquote /home/alex/lsrc/qemu.git/tcg/i386 -pthread -mcx16 -mpopcnt -mneeded -mmovbe -mabm -mbmi -mbmi2 -mfma -mf16c -mavx2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -fPIC -MD -MQ contrib/plugins/libexeclog.so.p/execlog.c.o -MF contrib/plugins/libexeclog.so.p/execlog.c.o.d -o contrib/plugins/libexeclog.so.p/execlog.c.o -c ../../contrib/plugins/execlog.c
  [2/2] cc -m64  -o contrib/plugins/libexeclog.so contrib/plugins/libexeclog.so.p/execlog.c.o -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group /usr/lib/x86_64-linux-gnu/libglib-2.0.so /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so -Wl,--end-group -pthread

I'm not sure why we see "-Icontrib/plugins -I../../contrib/plugins".
It's probably a harmless redundancy but I'm curious as to where the path
comes from, any idea?

> +    endif
> +  endforeach
> +endif
> +if t.length() > 0
> +  alias_target('contrib-plugins', t)
> +else
> +  run_target('contrib-plugins', command: find_program('true'))
> +endif

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


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

* Re: [PATCH v2 1/2] meson: build contrib/plugins with meson
  2024-10-21  9:38   ` Alex Bennée
@ 2024-10-21 15:45     ` Pierrick Bouvier
  2024-10-21 15:53     ` Pierrick Bouvier
  1 sibling, 0 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2024-10-21 15:45 UTC (permalink / raw)
  To: Alex Bennée
  Cc: qemu-devel, Marc-André Lureau, Daniel P. Berrangé,
	Alexandre Iooss, Paolo Bonzini, Thomas Huth,
	Philippe Mathieu-Daudé, Mahmoud Mandour, Brad Smith

On 10/21/24 02:38, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> 
>> Tried to unify this meson.build with tests/tcg/plugins/meson.build but
>> the resulting modules are not output in the right directory.
>>
>> Originally proposed by Anton Kochkov, thank you!
>>
>> Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   meson.build                 |  4 ++++
>>   contrib/plugins/meson.build | 23 +++++++++++++++++++++++
>>   2 files changed, 27 insertions(+)
>>   create mode 100644 contrib/plugins/meson.build
>>
>> diff --git a/meson.build b/meson.build
>> index ceee6b22c8d..b18c2a54ab5 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -3655,6 +3655,10 @@ subdir('accel')
>>   subdir('plugins')
>>   subdir('ebpf')
>>   
>> +if 'CONFIG_TCG' in config_all_accel
>> +  subdir('contrib/plugins')
>> +endif
>> +
>>   common_user_inc = []
>>   
>>   subdir('common-user')
>> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
>> new file mode 100644
>> index 00000000000..a0e026d25e2
>> --- /dev/null
>> +++ b/contrib/plugins/meson.build
>> @@ -0,0 +1,23 @@
>> +t = []
>> +if get_option('plugins')
>> +  foreach i : ['cache', 'drcov', 'execlog', 'hotblocks', 'hotpages', 'howvec',
>> +               'hwprofile', 'ips', 'lockstep', 'stoptrigger']
>> +    if host_os == 'windows'
>> +      t += shared_module(i, files(i + '.c') + 'win32_linker.c',
>> +                        include_directories: '../../include/qemu',
>> +                        link_depends: [win32_qemu_plugin_api_lib],
>> +                        link_args: ['-Lplugins', '-lqemu_plugin_api'],
>> +                        dependencies: glib)
>> +
>> +    else
>> +      t += shared_module(i, files(i + '.c'),
>> +                        include_directories: '../../include/qemu',
>> +                        dependencies: glib)
> 
> I was trying to work out where the include dirs come from to make sure
> Brad's fix (see Zu4063fjfHC5hHUl@humpty.home.comstyle.com) also applies.
> It does but:
> 
>    ➜  make contrib/plugins/libexeclog.so V=1
>    /usr/bin/ninja -v   -j1 -d keepdepfile contrib/plugins/libexeclog.so | cat
>    [1/2] cc -m64 -Icontrib/plugins/libexeclog.so.p -Icontrib/plugins -I../../contrib/plugins -I../../include/qemu -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home/alex/lsrc/qemu.git/linux-headers -isystem linux-headers -iquote . -iquote /home/alex/lsrc/qemu.git -iquote /home/alex/lsrc/qemu.git/include -iquote /home/alex/lsrc/qemu.git/host/include/x86_64 -iquote /home/alex/lsrc/qemu.git/host/include/generic -iquote /home/alex/lsrc/qemu.git/tcg/i386 -pthread -mcx16 -mpopcnt -mneeded -mmovbe -mabm -mbmi -mbmi2 -mfma -mf16c -mavx2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -fPIC -MD -MQ contrib/plugins/libexeclog.so.p/execlog.c.o -MF contrib/plugins/libexeclog.so.p/execlog.c.o.d -o contrib/plugins/libexeclog.so.p/execlog.c.o -c ../../contrib/plugins/execlog.c
>    [2/2] cc -m64  -o contrib/plugins/libexeclog.so contrib/plugins/libexeclog.so.p/execlog.c.o -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group /usr/lib/x86_64-linux-gnu/libglib-2.0.so /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so -Wl,--end-group -pthread
> 
> I'm not sure why we see "-Icontrib/plugins -I../../contrib/plugins".
> It's probably a harmless redundancy but I'm curious as to where the path
> comes from, any idea?
> 

It comes from meson itself.
You can see the same kind of include scheme is used for any source file 
in the QEMU tree.
I guess the rationale is to provide include directory either from root 
tree, or from build directory (in case a generated source depends on it?).

It's harmless indeed, because as you noticed, QEMU never had any build 
failure related to this since meson was introduced.

>> +    endif
>> +  endforeach
>> +endif
>> +if t.length() > 0
>> +  alias_target('contrib-plugins', t)
>> +else
>> +  run_target('contrib-plugins', command: find_program('true'))
>> +endif
> 

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

* Re: [PATCH v2 1/2] meson: build contrib/plugins with meson
  2024-10-21  9:38   ` Alex Bennée
  2024-10-21 15:45     ` Pierrick Bouvier
@ 2024-10-21 15:53     ` Pierrick Bouvier
  1 sibling, 0 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2024-10-21 15:53 UTC (permalink / raw)
  To: Alex Bennée
  Cc: qemu-devel, Marc-André Lureau, Daniel P. Berrangé,
	Alexandre Iooss, Paolo Bonzini, Thomas Huth,
	Philippe Mathieu-Daudé, Mahmoud Mandour, Brad Smith

On 10/21/24 02:38, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> 
>> Tried to unify this meson.build with tests/tcg/plugins/meson.build but
>> the resulting modules are not output in the right directory.
>>
>> Originally proposed by Anton Kochkov, thank you!
>>
>> Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   meson.build                 |  4 ++++
>>   contrib/plugins/meson.build | 23 +++++++++++++++++++++++
>>   2 files changed, 27 insertions(+)
>>   create mode 100644 contrib/plugins/meson.build
>>
>> diff --git a/meson.build b/meson.build
>> index ceee6b22c8d..b18c2a54ab5 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -3655,6 +3655,10 @@ subdir('accel')
>>   subdir('plugins')
>>   subdir('ebpf')
>>   
>> +if 'CONFIG_TCG' in config_all_accel
>> +  subdir('contrib/plugins')
>> +endif
>> +
>>   common_user_inc = []
>>   
>>   subdir('common-user')
>> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
>> new file mode 100644
>> index 00000000000..a0e026d25e2
>> --- /dev/null
>> +++ b/contrib/plugins/meson.build
>> @@ -0,0 +1,23 @@
>> +t = []
>> +if get_option('plugins')
>> +  foreach i : ['cache', 'drcov', 'execlog', 'hotblocks', 'hotpages', 'howvec',
>> +               'hwprofile', 'ips', 'lockstep', 'stoptrigger']
>> +    if host_os == 'windows'
>> +      t += shared_module(i, files(i + '.c') + 'win32_linker.c',
>> +                        include_directories: '../../include/qemu',
>> +                        link_depends: [win32_qemu_plugin_api_lib],
>> +                        link_args: ['-Lplugins', '-lqemu_plugin_api'],
>> +                        dependencies: glib)
>> +
>> +    else
>> +      t += shared_module(i, files(i + '.c'),
>> +                        include_directories: '../../include/qemu',
>> +                        dependencies: glib)
> 
> I was trying to work out where the include dirs come from to make sure
> Brad's fix (see Zu4063fjfHC5hHUl@humpty.home.comstyle.com) also applies.

In the meson.build, I don't think we need such a fix, as it does the 
right thing out of the box.
Ideally, we should remove the Makefile to avoid having to maintain it 
when we'll introduce other deps/plugins in the future.

Users who want to compile out of tree can still get the compilation 
command from ninja, and adapt it to their needs.

> It does but:
> 
>    ➜  make contrib/plugins/libexeclog.so V=1
>    /usr/bin/ninja -v   -j1 -d keepdepfile contrib/plugins/libexeclog.so | cat
>    [1/2] cc -m64 -Icontrib/plugins/libexeclog.so.p -Icontrib/plugins -I../../contrib/plugins -I../../include/qemu -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home/alex/lsrc/qemu.git/linux-headers -isystem linux-headers -iquote . -iquote /home/alex/lsrc/qemu.git -iquote /home/alex/lsrc/qemu.git/include -iquote /home/alex/lsrc/qemu.git/host/include/x86_64 -iquote /home/alex/lsrc/qemu.git/host/include/generic -iquote /home/alex/lsrc/qemu.git/tcg/i386 -pthread -mcx16 -mpopcnt -mneeded -mmovbe -mabm -mbmi -mbmi2 -mfma -mf16c -mavx2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -fPIC -MD -MQ contrib/plugins/libexeclog.so.p/execlog.c.o -MF contrib/plugins/libexeclog.so.p/execlog.c.o.d -o contrib/plugins/libexeclog.so.p/execlog.c.o -c ../../contrib/plugins/execlog.c
>    [2/2] cc -m64  -o contrib/plugins/libexeclog.so contrib/plugins/libexeclog.so.p/execlog.c.o -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group /usr/lib/x86_64-linux-gnu/libglib-2.0.so /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so -Wl,--end-group -pthread
> 
> I'm not sure why we see "-Icontrib/plugins -I../../contrib/plugins".
> It's probably a harmless redundancy but I'm curious as to where the path
> comes from, any idea?
> 
>> +    endif
>> +  endforeach
>> +endif
>> +if t.length() > 0
>> +  alias_target('contrib-plugins', t)
>> +else
>> +  run_target('contrib-plugins', command: find_program('true'))
>> +endif
> 

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

end of thread, other threads:[~2024-10-21 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 20:48 [PATCH v2 0/2] build contrib/plugins using meson Pierrick Bouvier
2024-09-25 20:48 ` [PATCH v2 1/2] meson: build contrib/plugins with meson Pierrick Bouvier
2024-10-21  9:38   ` Alex Bennée
2024-10-21 15:45     ` Pierrick Bouvier
2024-10-21 15:53     ` Pierrick Bouvier
2024-09-25 20:48 ` [PATCH v2 2/2] contrib/plugins: remove Makefile for contrib/plugins Pierrick Bouvier
2024-10-09 22:13 ` [PATCH v2 0/2] build contrib/plugins using meson Pierrick Bouvier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).