[PATCH v2 3/3] system/main.c: compile only once

Pierrick Bouvier posted 3 patches 2 months, 2 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>
[PATCH v2 3/3] system/main.c: compile only once
Posted by Pierrick Bouvier 2 months, 2 weeks ago
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build        | 4 ++--
 system/meson.build | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index f94209bb301..b72d4ce8618 100644
--- a/meson.build
+++ b/meson.build
@@ -4420,14 +4420,14 @@ foreach target : target_dirs
     execs = [{
       'name': 'qemu-system-' + target_name,
       'win_subsystem': 'console',
-      'sources': files('system/main.c'),
+      'sources': [],
       'dependencies': [sdl]
     }]
     if host_os == 'windows' and (sdl.found() or gtk.found())
       execs += [{
         'name': 'qemu-system-' + target_name + 'w',
         'win_subsystem': 'windows',
-        'sources': files('system/main.c'),
+        'sources': [],
         'dependencies': [sdl]
       }]
     endif
diff --git a/system/meson.build b/system/meson.build
index 6d21ff9faa7..f358c2c446d 100644
--- a/system/meson.build
+++ b/system/meson.build
@@ -18,6 +18,7 @@ system_ss.add(files(
   'globals.c',
   'ioport.c',
   'ram-block-attributes.c',
+  'main.c',
   'memory_mapping.c',
   'memory.c',
   'physmem.c',
-- 
2.47.2
Re: [PATCH v2 3/3] system/main.c: compile only once
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
Hi,

On 31/7/25 00:05, Pierrick Bouvier wrote:
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   meson.build        | 4 ++--
>   system/meson.build | 1 +
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index f94209bb301..b72d4ce8618 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -4420,14 +4420,14 @@ foreach target : target_dirs
>       execs = [{
>         'name': 'qemu-system-' + target_name,
>         'win_subsystem': 'console',
> -      'sources': files('system/main.c'),
> +      'sources': [],
>         'dependencies': [sdl]
>       }]
>       if host_os == 'windows' and (sdl.found() or gtk.found())
>         execs += [{
>           'name': 'qemu-system-' + target_name + 'w',
>           'win_subsystem': 'windows',
> -        'sources': files('system/main.c'),
> +        'sources': [],
>           'dependencies': [sdl]
>         }]
>       endif
> diff --git a/system/meson.build b/system/meson.build
> index 6d21ff9faa7..f358c2c446d 100644
> --- a/system/meson.build
> +++ b/system/meson.build
> @@ -18,6 +18,7 @@ system_ss.add(files(
>     'globals.c',
>     'ioport.c',
>     'ram-block-attributes.c',
> +  'main.c',
>     'memory_mapping.c',
>     'memory.c',
>     'physmem.c',

This makes the build-oss-fuzz job to fail:

FAILED: qemu-fuzz-i386
clang -m64 @qemu-fuzz-i386.rsp
/usr/bin/ld: libsystem.a.p/system_main.c.o: in function `main':
/builds/philmd/qemu/build-oss-fuzz/../system/main.c:70: multiple 
definition of `main'; 
/usr/bin/../lib/clang/18/lib/x86_64-redhat-linux-gnu/libclang_rt.fuzzer.a(FuzzerMain.cpp.o):(.text+0x0): 
first defined here
/usr/bin/ld: qemu-fuzz-i386.p/tests_qtest_fuzz_fuzz.c.o:(.bss+0x0): 
multiple definition of `__odr_asan_gen_qemu_main'; 
libsystem.a.p/system_main.c.o:(.bss+0x0): first defined here
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:168: run-ninja] Error 1
Error : Build failed. Please specify a compiler with fuzzing support 
using the $CC and $CXX environment variables \nFor example: CC=clang 
CXX=clang++ ./scripts/oss-fuzz/build.sh, exiting.

https://gitlab.com/philmd/qemu/-/jobs/11205571060
Re: [PATCH v2 3/3] system/main.c: compile only once
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
On 1/9/25 17:07, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> On 31/7/25 00:05, Pierrick Bouvier wrote:
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   meson.build        | 4 ++--
>>   system/meson.build | 1 +
>>   2 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/meson.build b/meson.build
>> index f94209bb301..b72d4ce8618 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -4420,14 +4420,14 @@ foreach target : target_dirs
>>       execs = [{
>>         'name': 'qemu-system-' + target_name,
>>         'win_subsystem': 'console',
>> -      'sources': files('system/main.c'),
>> +      'sources': [],
>>         'dependencies': [sdl]
>>       }]
>>       if host_os == 'windows' and (sdl.found() or gtk.found())
>>         execs += [{
>>           'name': 'qemu-system-' + target_name + 'w',
>>           'win_subsystem': 'windows',
>> -        'sources': files('system/main.c'),
>> +        'sources': [],
>>           'dependencies': [sdl]
>>         }]
>>       endif
>> diff --git a/system/meson.build b/system/meson.build
>> index 6d21ff9faa7..f358c2c446d 100644
>> --- a/system/meson.build
>> +++ b/system/meson.build
>> @@ -18,6 +18,7 @@ system_ss.add(files(
>>     'globals.c',
>>     'ioport.c',
>>     'ram-block-attributes.c',
>> +  'main.c',
>>     'memory_mapping.c',
>>     'memory.c',
>>     'physmem.c',
> 
> This makes the build-oss-fuzz job to fail:
> 
> FAILED: qemu-fuzz-i386
> clang -m64 @qemu-fuzz-i386.rsp
> /usr/bin/ld: libsystem.a.p/system_main.c.o: in function `main':
> /builds/philmd/qemu/build-oss-fuzz/../system/main.c:70: multiple 
> definition of `main'; /usr/bin/../lib/clang/18/lib/x86_64-redhat-linux- 
> gnu/libclang_rt.fuzzer.a(FuzzerMain.cpp.o):(.text+0x0): first defined here
> /usr/bin/ld: qemu-fuzz-i386.p/tests_qtest_fuzz_fuzz.c.o:(.bss+0x0): 
> multiple definition of `__odr_asan_gen_qemu_main'; libsystem.a.p/ 
> system_main.c.o:(.bss+0x0): first defined here
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> ninja: build stopped: subcommand failed.
> make: *** [Makefile:168: run-ninja] Error 1
> Error : Build failed. Please specify a compiler with fuzzing support 
> using the $CC and $CXX environment variables \nFor example: CC=clang 
> CXX=clang++ ./scripts/oss-fuzz/build.sh, exiting.
> 
> https://gitlab.com/philmd/qemu/-/jobs/11205571060

FYI I'm dropping this single patch from my queue (but keeping the
other two).


Re: [PATCH v2 3/3] system/main.c: compile only once
Posted by Pierrick Bouvier 1 month, 1 week ago
On 2025-09-01 22:51, Philippe Mathieu-Daudé wrote:
> On 1/9/25 17:07, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> On 31/7/25 00:05, Pierrick Bouvier wrote:
>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> ---
>>>    meson.build        | 4 ++--
>>>    system/meson.build | 1 +
>>>    2 files changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/meson.build b/meson.build
>>> index f94209bb301..b72d4ce8618 100644
>>> --- a/meson.build
>>> +++ b/meson.build
>>> @@ -4420,14 +4420,14 @@ foreach target : target_dirs
>>>        execs = [{
>>>          'name': 'qemu-system-' + target_name,
>>>          'win_subsystem': 'console',
>>> -      'sources': files('system/main.c'),
>>> +      'sources': [],
>>>          'dependencies': [sdl]
>>>        }]
>>>        if host_os == 'windows' and (sdl.found() or gtk.found())
>>>          execs += [{
>>>            'name': 'qemu-system-' + target_name + 'w',
>>>            'win_subsystem': 'windows',
>>> -        'sources': files('system/main.c'),
>>> +        'sources': [],
>>>            'dependencies': [sdl]
>>>          }]
>>>        endif
>>> diff --git a/system/meson.build b/system/meson.build
>>> index 6d21ff9faa7..f358c2c446d 100644
>>> --- a/system/meson.build
>>> +++ b/system/meson.build
>>> @@ -18,6 +18,7 @@ system_ss.add(files(
>>>      'globals.c',
>>>      'ioport.c',
>>>      'ram-block-attributes.c',
>>> +  'main.c',
>>>      'memory_mapping.c',
>>>      'memory.c',
>>>      'physmem.c',
>>
>> This makes the build-oss-fuzz job to fail:
>>
>> FAILED: qemu-fuzz-i386
>> clang -m64 @qemu-fuzz-i386.rsp
>> /usr/bin/ld: libsystem.a.p/system_main.c.o: in function `main':
>> /builds/philmd/qemu/build-oss-fuzz/../system/main.c:70: multiple
>> definition of `main'; /usr/bin/../lib/clang/18/lib/x86_64-redhat-linux-
>> gnu/libclang_rt.fuzzer.a(FuzzerMain.cpp.o):(.text+0x0): first defined here
>> /usr/bin/ld: qemu-fuzz-i386.p/tests_qtest_fuzz_fuzz.c.o:(.bss+0x0):
>> multiple definition of `__odr_asan_gen_qemu_main'; libsystem.a.p/
>> system_main.c.o:(.bss+0x0): first defined here
>> clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)
>> ninja: build stopped: subcommand failed.
>> make: *** [Makefile:168: run-ninja] Error 1
>> Error : Build failed. Please specify a compiler with fuzzing support
>> using the $CC and $CXX environment variables \nFor example: CC=clang
>> CXX=clang++ ./scripts/oss-fuzz/build.sh, exiting.
>>
>> https://gitlab.com/philmd/qemu/-/jobs/11205571060
> 
> FYI I'm dropping this single patch from my queue (but keeping the
> other two).
> 

Thanks, you did well.
Nothing critical on this specific patch.