diff mbox series

[4/4] qapi/meson: Restrict machine-specific objects to sysemu

Message ID 20220204152924.6253-5-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series buildsys: Avoid building unused objects | expand

Commit Message

Philippe Mathieu-Daudé Feb. 4, 2022, 3:29 p.m. UTC
machine/ and net/ are only useful to machines;
block/ and migration/ to machine or tools.

Note we need to keep building machine.json generated sources
on all targets because some want to access X86CPUFeatureWordInfo
from any architecture ¯\_(ツ)_/¯ Otherwise we get on all but
x86 targets:

  /usr/bin/ld: libqemu-i386-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_get_feature_words':
  ../target/i386/cpu.c:4587: undefined reference to `visit_type_X86CPUFeatureWordInfoList'
  collect2: error: ld returned 1 exit status

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 qapi/meson.build | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

Thomas Huth Feb. 4, 2022, 4:25 p.m. UTC | #1
On 04/02/2022 16.29, Philippe Mathieu-Daudé wrote:
> machine/ and net/ are only useful to machines;
> block/ and migration/ to machine or tools.
> 
> Note we need to keep building machine.json generated sources
> on all targets because some want to access X86CPUFeatureWordInfo
> from any architecture ¯\_(ツ)_/¯ Otherwise we get on all but
> x86 targets:
> 
>    /usr/bin/ld: libqemu-i386-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_get_feature_words':
>    ../target/i386/cpu.c:4587: undefined reference to `visit_type_X86CPUFeatureWordInfoList'
>    collect2: error: ld returned 1 exit status

Would it be possible to move the X86CPUFeatureWordInfo stuff into 
machine-target.json first, adding a proper 'if': 'TARGET_I386' there?

  Thomas


> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   qapi/meson.build | 20 ++++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/qapi/meson.build b/qapi/meson.build
> index 656ef0e039..38b01f3083 100644
> --- a/qapi/meson.build
> +++ b/qapi/meson.build
> @@ -23,10 +23,6 @@ endif
>   
>   qapi_all_modules = [
>     'authz',
> -  'block',
> -  'block-core',
> -  'block-export',
> -  'char',
>     'common',
>     'compat',
>     'control',
> @@ -35,26 +31,23 @@ qapi_all_modules = [
>     'error',
>     'introspect',
>     'job',
> -  'machine',
> -  'machine-target',
> +  'machine', # x86 is considered multiarch by some
>     'migration',
>     'misc',
>     'misc-target',
> -  'net',
>     'pragma',
> -  'qom',
>     'replay',
>     'run-state',
>     'sockets',
>     'trace',
> -  'transaction',
> -  'yank',
>   ]
>   if have_system
>     qapi_all_modules += [
>       'acpi',
>       'audio',
>       'qdev',
> +    'machine-target',
> +    'net',
>       'pci',
>       'rdma',
>       'rocker',
> @@ -63,7 +56,14 @@ if have_system
>   endif
>   if have_system or have_tools
>     qapi_all_modules += [
> +    'block',
> +    'block-core',
> +    'block-export',
> +    'char',
> +    'qom',
>       'ui',
> +    'transaction',
> +    'yank',
>     ]
>   endif
>
Paolo Bonzini Feb. 4, 2022, 5 p.m. UTC | #2
On 2/4/22 16:29, Philippe Mathieu-Daudé via wrote:
> machine/ and net/ are only useful to machines;
> block/ and migration/ to machine or tools.
> 
> Note we need to keep building machine.json generated sources
> on all targets because some want to access X86CPUFeatureWordInfo
> from any architecture ¯\_(ツ)_/¯ Otherwise we get on all but
> x86 targets:
> 
>    /usr/bin/ld: libqemu-i386-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_get_feature_words':
>    ../target/i386/cpu.c:4587: undefined reference to `visit_type_X86CPUFeatureWordInfoList'
>    collect2: error: ld returned 1 exit status

I suppose you mean "on all but x86 hosts", since it links 
libqemu-i386-linux-user.fa.p?  But I don't understand how that happens. 
  Is it related to

{ 'struct': 'DummyForceArrays',
   'data': { 'unused': ['X86CPUFeatureWordInfo'] } }

and if so can DummyForceArrays be moved to machine-target.json together 
with X86CPUFeatureWordInfo, and under 'if': 'TARGET_I386'?

Thanks,

Paolo

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   qapi/meson.build | 20 ++++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/qapi/meson.build b/qapi/meson.build
> index 656ef0e039..38b01f3083 100644
> --- a/qapi/meson.build
> +++ b/qapi/meson.build
> @@ -23,10 +23,6 @@ endif
>   
>   qapi_all_modules = [
>     'authz',
> -  'block',
> -  'block-core',
> -  'block-export',
> -  'char',
>     'common',
>     'compat',
>     'control',
> @@ -35,26 +31,23 @@ qapi_all_modules = [
>     'error',
>     'introspect',
>     'job',
> -  'machine',
> -  'machine-target',
> +  'machine', # x86 is considered multiarch by some
>     'migration',
>     'misc',
>     'misc-target',
> -  'net',
>     'pragma',
> -  'qom',
>     'replay',
>     'run-state',
>     'sockets',
>     'trace',
> -  'transaction',
> -  'yank',
>   ]
>   if have_system
>     qapi_all_modules += [
>       'acpi',
>       'audio',
>       'qdev',
> +    'machine-target',
> +    'net',
>       'pci',
>       'rdma',
>       'rocker',
> @@ -63,7 +56,14 @@ if have_system
>   endif
>   if have_system or have_tools
>     qapi_all_modules += [
> +    'block',
> +    'block-core',
> +    'block-export',
> +    'char',
> +    'qom',
>       'ui',
> +    'transaction',
> +    'yank',
>     ]
>   endif
>
Philippe Mathieu-Daudé Feb. 4, 2022, 11:40 p.m. UTC | #3
On 4/2/22 18:00, Paolo Bonzini wrote:
> On 2/4/22 16:29, Philippe Mathieu-Daudé via wrote:
>> machine/ and net/ are only useful to machines;
>> block/ and migration/ to machine or tools.
>>
>> Note we need to keep building machine.json generated sources
>> on all targets because some want to access X86CPUFeatureWordInfo
>> from any architecture ¯\_(ツ)_/¯ Otherwise we get on all but
>> x86 targets:
>>
>>    /usr/bin/ld: libqemu-i386-linux-user.fa.p/target_i386_cpu.c.o: in 
>> function `x86_cpu_get_feature_words':
>>    ../target/i386/cpu.c:4587: undefined reference to 
>> `visit_type_X86CPUFeatureWordInfoList'
>>    collect2: error: ld returned 1 exit status
> 
> I suppose you mean "on all but x86 hosts", since it links 
> libqemu-i386-linux-user.fa.p?  But I don't understand how that happens. 
>   Is it related to
> 
> { 'struct': 'DummyForceArrays',
>    'data': { 'unused': ['X86CPUFeatureWordInfo'] } }
> 
> and if so can DummyForceArrays be moved to machine-target.json together 
> with X86CPUFeatureWordInfo, and under 'if': 'TARGET_I386'?

Err this one is not an *arch* problem, but a user/system one (sorry I
got confused with another one). Here the problem is it is not trivial
to restrict visit_type_X86CPUFeatureWordInfoList() to sysemu.

So machine.json must be in qapi_all_modules[] even if !have_system.
diff mbox series

Patch

diff --git a/qapi/meson.build b/qapi/meson.build
index 656ef0e039..38b01f3083 100644
--- a/qapi/meson.build
+++ b/qapi/meson.build
@@ -23,10 +23,6 @@  endif
 
 qapi_all_modules = [
   'authz',
-  'block',
-  'block-core',
-  'block-export',
-  'char',
   'common',
   'compat',
   'control',
@@ -35,26 +31,23 @@  qapi_all_modules = [
   'error',
   'introspect',
   'job',
-  'machine',
-  'machine-target',
+  'machine', # x86 is considered multiarch by some
   'migration',
   'misc',
   'misc-target',
-  'net',
   'pragma',
-  'qom',
   'replay',
   'run-state',
   'sockets',
   'trace',
-  'transaction',
-  'yank',
 ]
 if have_system
   qapi_all_modules += [
     'acpi',
     'audio',
     'qdev',
+    'machine-target',
+    'net',
     'pci',
     'rdma',
     'rocker',
@@ -63,7 +56,14 @@  if have_system
 endif
 if have_system or have_tools
   qapi_all_modules += [
+    'block',
+    'block-core',
+    'block-export',
+    'char',
+    'qom',
     'ui',
+    'transaction',
+    'yank',
   ]
 endif