qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix duplicate symbol error on MacOS build
@ 2025-03-19  2:30 Tanish Desai
  2025-03-19 13:44 ` Peter Maydell
  2025-03-19 13:52 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 8+ messages in thread
From: Tanish Desai @ 2025-03-19  2:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Tanish Desai

The issue started after commit https://github.com/qemu/qemu/commit/59f4d65584bd3372070e2484876436c8d02505e4

Reproduction:
  1. In the build directory on MacOS (haven't tried on other OS), run:
       ../configure --enable-rust --target-list=aarch64-softmmu
  2. Then run either:
       ninja -C .
       OR
       make
  3. At the end, you will encounter the error:
       duplicate symbol '_pl011_create' in:
           /Users/tanishdesai37/Downloads/qemu-master/build/libcommon.a.p/hw_char_pl011.c.o
           librust_aarch64_softmmu.a[5](pl011.pl011.390d424367e209af-cgu.1.rcgu.o)
       ld: 1 duplicate symbols

Root cause:
  Both CONFIG_PL011 and X_PL011_RUST are selected, causing C++ and Rust to produce the same object.
  This is due to the commit above where 'select PL011' forces a true condition instead of checking if HAVE_RUST is true.
  If HAVE_RUST is true, X_PL011_RUST should be selected instead of CONFIG_PL011.

Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
---
 hw/vmapple/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
index 2382b297672..01bcbf40e00 100644
--- a/hw/vmapple/Kconfig
+++ b/hw/vmapple/Kconfig
@@ -22,7 +22,8 @@ config VMAPPLE
     select PLATFORM_BUS
     select PCI_EXPRESS
     select PCI_EXPRESS_GENERIC_BRIDGE
-    select PL011 # UART
+    select PL011 if !HAVE_RUST # UART
+    select X_PL011_RUST if HAVE_RUST # UART
     select PL031 # RTC
     select PL061 # GPIO
     select GPIO_PWR
-- 
2.48.1



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

* Re: [PATCH] Fix duplicate symbol error on MacOS build
  2025-03-19  2:30 [PATCH] Fix duplicate symbol error on MacOS build Tanish Desai
@ 2025-03-19 13:44 ` Peter Maydell
  2025-03-19 13:49   ` Philippe Mathieu-Daudé
  2025-03-19 14:36   ` Paolo Bonzini
  2025-03-19 13:52 ` Philippe Mathieu-Daudé
  1 sibling, 2 replies; 8+ messages in thread
From: Peter Maydell @ 2025-03-19 13:44 UTC (permalink / raw)
  To: Tanish Desai; +Cc: qemu-devel, Paolo Bonzini

On Wed, 19 Mar 2025 at 12:53, Tanish Desai <tanishdesai37@gmail.com> wrote:
>
> The issue started after commit https://github.com/qemu/qemu/commit/59f4d65584bd3372070e2484876436c8d02505e4
>
> Reproduction:
>   1. In the build directory on MacOS (haven't tried on other OS), run:
>        ../configure --enable-rust --target-list=aarch64-softmmu
>   2. Then run either:
>        ninja -C .
>        OR
>        make
>   3. At the end, you will encounter the error:
>        duplicate symbol '_pl011_create' in:
>            /Users/tanishdesai37/Downloads/qemu-master/build/libcommon.a.p/hw_char_pl011.c.o
>            librust_aarch64_softmmu.a[5](pl011.pl011.390d424367e209af-cgu.1.rcgu.o)
>        ld: 1 duplicate symbols
>
> Root cause:
>   Both CONFIG_PL011 and X_PL011_RUST are selected, causing C++ and Rust to produce the same object.
>   This is due to the commit above where 'select PL011' forces a true condition instead of checking if HAVE_RUST is true.
>   If HAVE_RUST is true, X_PL011_RUST should be selected instead of CONFIG_PL011.
>
> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
> ---
>  hw/vmapple/Kconfig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
> index 2382b297672..01bcbf40e00 100644
> --- a/hw/vmapple/Kconfig
> +++ b/hw/vmapple/Kconfig
> @@ -22,7 +22,8 @@ config VMAPPLE
>      select PLATFORM_BUS
>      select PCI_EXPRESS
>      select PCI_EXPRESS_GENERIC_BRIDGE
> -    select PL011 # UART
> +    select PL011 if !HAVE_RUST # UART
> +    select X_PL011_RUST if HAVE_RUST # UART
>      select PL031 # RTC
>      select PL061 # GPIO
>      select GPIO_PWR

Paolo: we seem to have quite a lot of this

    select PL011 if !HAVE_RUST # UART
    select X_PL011_RUST if HAVE_RUST # UART

duplicated for every PL011-using machine. Can we factor this out
in Kconfig? e.g.

config PL011
    select X_PL011_RUST if HAVE_RUST
    select PL011_C if !HAVE_RUST

(and update hw/char/meson.build to use CONFIG_PL011_C for pl011.c).
Then all the machines can go back to plain "select PL011" and
don't need to care whether it's the Rust or C version.

Or does that not work?

thanks
-- PMM


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

* Re: [PATCH] Fix duplicate symbol error on MacOS build
  2025-03-19 13:44 ` Peter Maydell
@ 2025-03-19 13:49   ` Philippe Mathieu-Daudé
  2025-03-19 14:02     ` Tanish Desai
  2025-03-19 14:36   ` Paolo Bonzini
  1 sibling, 1 reply; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-19 13:49 UTC (permalink / raw)
  To: Peter Maydell, Tanish Desai; +Cc: qemu-devel, Paolo Bonzini

On 19/3/25 14:44, Peter Maydell wrote:
> On Wed, 19 Mar 2025 at 12:53, Tanish Desai <tanishdesai37@gmail.com> wrote:
>>
>> The issue started after commit https://github.com/qemu/qemu/commit/59f4d65584bd3372070e2484876436c8d02505e4
>>
>> Reproduction:
>>    1. In the build directory on MacOS (haven't tried on other OS), run:
>>         ../configure --enable-rust --target-list=aarch64-softmmu
>>    2. Then run either:
>>         ninja -C .
>>         OR
>>         make
>>    3. At the end, you will encounter the error:
>>         duplicate symbol '_pl011_create' in:
>>             /Users/tanishdesai37/Downloads/qemu-master/build/libcommon.a.p/hw_char_pl011.c.o
>>             librust_aarch64_softmmu.a[5](pl011.pl011.390d424367e209af-cgu.1.rcgu.o)
>>         ld: 1 duplicate symbols
>>
>> Root cause:
>>    Both CONFIG_PL011 and X_PL011_RUST are selected, causing C++ and Rust to produce the same object.
>>    This is due to the commit above where 'select PL011' forces a true condition instead of checking if HAVE_RUST is true.
>>    If HAVE_RUST is true, X_PL011_RUST should be selected instead of CONFIG_PL011.
>>
>> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
>> ---
>>   hw/vmapple/Kconfig | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
>> index 2382b297672..01bcbf40e00 100644
>> --- a/hw/vmapple/Kconfig
>> +++ b/hw/vmapple/Kconfig
>> @@ -22,7 +22,8 @@ config VMAPPLE
>>       select PLATFORM_BUS
>>       select PCI_EXPRESS
>>       select PCI_EXPRESS_GENERIC_BRIDGE
>> -    select PL011 # UART
>> +    select PL011 if !HAVE_RUST # UART
>> +    select X_PL011_RUST if HAVE_RUST # UART
>>       select PL031 # RTC
>>       select PL061 # GPIO
>>       select GPIO_PWR
> 
> Paolo: we seem to have quite a lot of this
> 
>      select PL011 if !HAVE_RUST # UART
>      select X_PL011_RUST if HAVE_RUST # UART
> 
> duplicated for every PL011-using machine. Can we factor this out
> in Kconfig? e.g.
> 
> config PL011
>      select X_PL011_RUST if HAVE_RUST
>      select PL011_C if !HAVE_RUST
> 
> (and update hw/char/meson.build to use CONFIG_PL011_C for pl011.c).
> Then all the machines can go back to plain "select PL011" and
> don't need to care whether it's the Rust or C version.
> 
> Or does that not work?

This should work.



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

* Re: [PATCH] Fix duplicate symbol error on MacOS build
  2025-03-19  2:30 [PATCH] Fix duplicate symbol error on MacOS build Tanish Desai
  2025-03-19 13:44 ` Peter Maydell
@ 2025-03-19 13:52 ` Philippe Mathieu-Daudé
  2025-03-19 14:26   ` Daniel P. Berrangé
  1 sibling, 1 reply; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-19 13:52 UTC (permalink / raw)
  To: Tanish Desai, qemu-devel
  Cc: Thomas Huth, Daniel P. Berrangé, Alex Bennée,
	Paolo Bonzini

Cc'ing CI maintainers.

On 19/3/25 03:30, Tanish Desai wrote:
> The issue started after commit https://github.com/qemu/qemu/commit/59f4d65584bd3372070e2484876436c8d02505e4
> 
> Reproduction:
>    1. In the build directory on MacOS (haven't tried on other OS), run:
>         ../configure --enable-rust --target-list=aarch64-softmmu

This config isn't covered on our CI, we only test --enable-rust on
Linux. Should we also test it for all non-Linux hosts? I'd rather not...

>    2. Then run either:
>         ninja -C .
>         OR
>         make
>    3. At the end, you will encounter the error:
>         duplicate symbol '_pl011_create' in:
>             /Users/tanishdesai37/Downloads/qemu-master/build/libcommon.a.p/hw_char_pl011.c.o
>             librust_aarch64_softmmu.a[5](pl011.pl011.390d424367e209af-cgu.1.rcgu.o)
>         ld: 1 duplicate symbols
> 
> Root cause:
>    Both CONFIG_PL011 and X_PL011_RUST are selected, causing C++ and Rust to produce the same object.
>    This is due to the commit above where 'select PL011' forces a true condition instead of checking if HAVE_RUST is true.
>    If HAVE_RUST is true, X_PL011_RUST should be selected instead of CONFIG_PL011.
> 
> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
> ---
>   hw/vmapple/Kconfig | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
> index 2382b297672..01bcbf40e00 100644
> --- a/hw/vmapple/Kconfig
> +++ b/hw/vmapple/Kconfig
> @@ -22,7 +22,8 @@ config VMAPPLE
>       select PLATFORM_BUS
>       select PCI_EXPRESS
>       select PCI_EXPRESS_GENERIC_BRIDGE
> -    select PL011 # UART
> +    select PL011 if !HAVE_RUST # UART
> +    select X_PL011_RUST if HAVE_RUST # UART
>       select PL031 # RTC
>       select PL061 # GPIO
>       select GPIO_PWR



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

* Re: [PATCH] Fix duplicate symbol error on MacOS build
  2025-03-19 13:49   ` Philippe Mathieu-Daudé
@ 2025-03-19 14:02     ` Tanish Desai
  2025-03-19 16:43       ` Peter Maydell
  0 siblings, 1 reply; 8+ messages in thread
From: Tanish Desai @ 2025-03-19 14:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Peter Maydell, qemu-devel, Paolo Bonzini

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

It will work for PL011 but there are other devices using the same method
for selecting rust or c++ file like HPET in timer.
You can check this:-
https://github.com/qemu/qemu/blob/master/hw/timer/Kconfig
Wouldn’t it create inconsistencies in code if we change only for PL011?

On Wed, 19 Mar 2025 at 7:19 PM, Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> On 19/3/25 14:44, Peter Maydell wrote:
> > On Wed, 19 Mar 2025 at 12:53, Tanish Desai <tanishdesai37@gmail.com>
> wrote:
> >>
> >> The issue started after commit
> https://github.com/qemu/qemu/commit/59f4d65584bd3372070e2484876436c8d02505e4
> >>
> >> Reproduction:
> >>    1. In the build directory on MacOS (haven't tried on other OS), run:
> >>         ../configure --enable-rust --target-list=aarch64-softmmu
> >>    2. Then run either:
> >>         ninja -C .
> >>         OR
> >>         make
> >>    3. At the end, you will encounter the error:
> >>         duplicate symbol '_pl011_create' in:
> >>
>  /Users/tanishdesai37/Downloads/qemu-master/build/libcommon.a.p/hw_char_pl011.c.o
> >>
>  librust_aarch64_softmmu.a[5](pl011.pl011.390d424367e209af-cgu.1.rcgu.o)
> >>         ld: 1 duplicate symbols
> >>
> >> Root cause:
> >>    Both CONFIG_PL011 and X_PL011_RUST are selected, causing C++ and
> Rust to produce the same object.
> >>    This is due to the commit above where 'select PL011' forces a true
> condition instead of checking if HAVE_RUST is true.
> >>    If HAVE_RUST is true, X_PL011_RUST should be selected instead of
> CONFIG_PL011.
> >>
> >> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
> >> ---
> >>   hw/vmapple/Kconfig | 3 ++-
> >>   1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
> >> index 2382b297672..01bcbf40e00 100644
> >> --- a/hw/vmapple/Kconfig
> >> +++ b/hw/vmapple/Kconfig
> >> @@ -22,7 +22,8 @@ config VMAPPLE
> >>       select PLATFORM_BUS
> >>       select PCI_EXPRESS
> >>       select PCI_EXPRESS_GENERIC_BRIDGE
> >> -    select PL011 # UART
> >> +    select PL011 if !HAVE_RUST # UART
> >> +    select X_PL011_RUST if HAVE_RUST # UART
> >>       select PL031 # RTC
> >>       select PL061 # GPIO
> >>       select GPIO_PWR
> >
> > Paolo: we seem to have quite a lot of this
> >
> >      select PL011 if !HAVE_RUST # UART
> >      select X_PL011_RUST if HAVE_RUST # UART
> >
> > duplicated for every PL011-using machine. Can we factor this out
> > in Kconfig? e.g.
> >
> > config PL011
> >      select X_PL011_RUST if HAVE_RUST
> >      select PL011_C if !HAVE_RUST
> >
> > (and update hw/char/meson.build to use CONFIG_PL011_C for pl011.c).
> > Then all the machines can go back to plain "select PL011" and
> > don't need to care whether it's the Rust or C version.
> >
> > Or does that not work?
>
> This should work.
>
>

[-- Attachment #2: Type: text/html, Size: 4263 bytes --]

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

* Re: [PATCH] Fix duplicate symbol error on MacOS build
  2025-03-19 13:52 ` Philippe Mathieu-Daudé
@ 2025-03-19 14:26   ` Daniel P. Berrangé
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel P. Berrangé @ 2025-03-19 14:26 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Tanish Desai, qemu-devel, Thomas Huth, Alex Bennée,
	Paolo Bonzini

On Wed, Mar 19, 2025 at 02:52:43PM +0100, Philippe Mathieu-Daudé wrote:
> Cc'ing CI maintainers.
> 
> On 19/3/25 03:30, Tanish Desai wrote:
> > The issue started after commit https://github.com/qemu/qemu/commit/59f4d65584bd3372070e2484876436c8d02505e4
> > 
> > Reproduction:
> >    1. In the build directory on MacOS (haven't tried on other OS), run:
> >         ../configure --enable-rust --target-list=aarch64-softmmu
> 
> This config isn't covered on our CI, we only test --enable-rust on
> Linux. Should we also test it for all non-Linux hosts? I'd rather not...

Bear in mind that Rust is still an experimental feature. If it is
broken in some build scenarios & not exhaustively tested, so be it,
that's what it means to be "experimental".

When we make Rust an on-by-default feature, then we'll get
coverage across all CI scenarios automatically. Of course we then
have the reverse question of CI testing of "rust disabled" scenarios,
Ideally we make Rust mandatory and thus avoid those non-Rust scenarios.

So I agree we don't need to expand CI coverage currently, just
fix bugs when they're pointed out.

With 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] 8+ messages in thread

* Re: [PATCH] Fix duplicate symbol error on MacOS build
  2025-03-19 13:44 ` Peter Maydell
  2025-03-19 13:49   ` Philippe Mathieu-Daudé
@ 2025-03-19 14:36   ` Paolo Bonzini
  1 sibling, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2025-03-19 14:36 UTC (permalink / raw)
  To: Peter Maydell, Tanish Desai; +Cc: qemu-devel

On 3/19/25 14:44, Peter Maydell wrote:
>> -    select PL011 # UART
>> +    select PL011 if !HAVE_RUST # UART
>> +    select X_PL011_RUST if HAVE_RUST # UART
>>       select PL031 # RTC
>>       select PL061 # GPIO
>>       select GPIO_PWR
> 
> Paolo: we seem to have quite a lot of this
> 
>      select PL011 if !HAVE_RUST # UART
>      select X_PL011_RUST if HAVE_RUST # UART
> 
> duplicated for every PL011-using machine. Can we factor this out
> in Kconfig? e.g.
> 
> config PL011
>      select X_PL011_RUST if HAVE_RUST
>      select PL011_C if !HAVE_RUST
> 
> (and update hw/char/meson.build to use CONFIG_PL011_C for pl011.c).
> Then all the machines can go back to plain "select PL011" and
> don't need to care whether it's the Rust or C version.
> 
> Or does that not work?

Yes, it works.

Paolo



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

* Re: [PATCH] Fix duplicate symbol error on MacOS build
  2025-03-19 14:02     ` Tanish Desai
@ 2025-03-19 16:43       ` Peter Maydell
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2025-03-19 16:43 UTC (permalink / raw)
  To: Tanish Desai; +Cc: Philippe Mathieu-Daudé, qemu-devel, Paolo Bonzini

On Wed, 19 Mar 2025 at 14:02, Tanish Desai <tanishdesai37@gmail.com> wrote:
>
> It will work for PL011 but there are other devices using the same method for selecting rust or c++ file like HPET in timer.
> You can check this:-
> https://github.com/qemu/qemu/blob/master/hw/timer/Kconfig
> Wouldn’t it create inconsistencies in code if we change only for PL011?

Yes, we should do the same thing for all the devices we have
dual implementations of (currently only pl011 and hpet).
I have some patches which I'm just testing to do that.

thanks
-- PMM


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

end of thread, other threads:[~2025-03-19 16:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19  2:30 [PATCH] Fix duplicate symbol error on MacOS build Tanish Desai
2025-03-19 13:44 ` Peter Maydell
2025-03-19 13:49   ` Philippe Mathieu-Daudé
2025-03-19 14:02     ` Tanish Desai
2025-03-19 16:43       ` Peter Maydell
2025-03-19 14:36   ` Paolo Bonzini
2025-03-19 13:52 ` Philippe Mathieu-Daudé
2025-03-19 14:26   ` Daniel P. Berrangé

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).