Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 726560 - app-emulation/qemu-5.0.0 fails to compile: machine-init-done.c:(.text+0x0): multiple definition of `qemu_add_machine_init_done_notifier'
Summary: app-emulation/qemu-5.0.0 fails to compile: machine-init-done.c:(.text+0x0): m...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Matthias Maier
URL: https://github.com/qemu/qemu/commit/6...
Whiteboard:
Keywords:
Depends on:
Blocks: -fno-common
  Show dependency tree
 
Reported: 2020-06-01 06:32 UTC by Agostino Sarubbo
Modified: 2021-03-29 22:55 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log.bz2 (build.log.bz2,35.23 KB, application/x-bzip2)
2020-06-01 06:32 UTC, Agostino Sarubbo
Details
fcommon.log (app-emulation:qemu-5.2.0-r3-fcommon.log.bz2,79.37 KB, application/x-bzip)
2021-03-29 01:41 UTC, gordon
Details
no-fcommon.log (app-emulation:qemu-5.2.0-r3-no-fcommon.log.bz2,142.02 KB, application/x-bzip)
2021-03-29 01:41 UTC, gordon
Details
emerge-info (emerge-info.log,10.89 KB, text/x-log)
2021-03-29 01:42 UTC, gordon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2020-06-01 06:32:25 UTC
This is an auto-filed bug because app-emulation/qemu fails to compile.
The issue was originally discovered on amd64, but it may be reproducible on other arches as well.
If you think that a different summary clarifies the issue better, feel free to change it.
Attached build log and emerge --info.

NOTE:
If you need further logs, feel free to ask.
Comment 1 Agostino Sarubbo gentoo-dev 2020-06-01 06:32:31 UTC
Created attachment 642960 [details]
build.log.bz2

build log and emerge --info
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2020-06-01 07:32:39 UTC
Probably related to -fno-common failure on one of configurations:

"""
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../libqemuutil.a(machine-init-done.o): in function `qemu_add
_machine_init_done_notifier':
machine-init-done.c:(.text+0x0): multiple definition of `qemu_add_machine_init_done_notifier'; softmmu/vl.o:vl.c:(.text+0x24a0): first defin
ed here
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../libqemuutil.a(machine-init-done.o): warning: definition o
f `machine_init_done' overriding common from softmmu/vl.o
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:208: qemu-system-x86_64] Error 1
"""
Comment 3 Agostino Sarubbo gentoo-dev 2020-06-01 07:59:01 UTC
Note that I'm using -fcommon to overwrite gcc10 behavior.
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2020-06-01 22:38:50 UTC
Oh, i completely missed that! That's unusual and might explain why I don't see it locally. I'll try with -fcommon.
Comment 5 gordon 2020-09-21 09:04:32 UTC
Tried it with gcc10 and -fcommon in CFLAGS, I have the same error.
Comment 6 Sven Eden 2021-01-26 09:11:03 UTC
I have this issue with qemu-5.2.0 and gcc-9.3.0:

--------
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: libqemuutil.a(stubs_machine-init-done.c.o): in function `qemu_add_machine_init_done_notifier':
/data/portage/portage/app-emulation/qemu-5.2.0-r1/work/qemu-5.2.0/softmmu-build/../stubs/machine-init-done.c:8: multiple definition of `qemu_add_machine_init_done_notifier'; libqemu-x86_64-softmmu.fa.p/softmmu_vl.c.o:/data/portage/portage/app-emulation/qemu-5.2.0-r1/work/qemu-5.2.0/softmmu-build/../softmmu/vl.c:2381: first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: libqemuutil.a(stubs_machine-init-done.c.o): warning: definition of `machine_init_done' overriding common from libqemu-x86_64-softmmu.fa.p/softmmu_vl.c.o
collect2: error: ld returned 1 exit status
--------

Linker is /usr/x86_64-pc-linux-gnu/binutils-bin/2.35.1/ld
Comment 7 gordon 2021-03-28 14:30:34 UTC
It looks like -fcommon in CFLAGS breaks the build.
I am able to compile qemu-5.2.0 without -fcommon in CFLAGS, but it fails with reported error if I have -fcommon in CFLAGS.
Tried with gcc-10.2.0-r5.
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2021-03-28 20:20:58 UTC
(In reply to gordon from comment #7)
> It looks like -fcommon in CFLAGS breaks the build.
> I am able to compile qemu-5.2.0 without -fcommon in CFLAGS, but it fails
> with reported error if I have -fcommon in CFLAGS.
> Tried with gcc-10.2.0-r5.

Can you attach your build.log? Last time I tried I did not see -fcommon failures.
Comment 9 gordon 2021-03-29 01:41:01 UTC
Created attachment 695739 [details]
fcommon.log
Comment 10 gordon 2021-03-29 01:41:45 UTC
Created attachment 695742 [details]
no-fcommon.log

Same everything except no -fcommon in CFLAGS
Comment 11 gordon 2021-03-29 01:42:21 UTC
Created attachment 695745 [details]
emerge-info
Comment 12 gordon 2021-03-29 01:43:18 UTC
Comment on attachment 695739 [details]
fcommon.log

With CFLAGS+=-fcommon
Comment 13 Sergei Trofimovich (RETIRED) gentoo-dev 2021-03-29 08:33:11 UTC
Reproduced locally as well. Thank you!

Looking at it now.
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2021-03-29 08:50:42 UTC
`machine_init_done` has a slight mismatch in section types defined: .common vs .data.

$ nm libqemuutil.a.p/stubs_machine-init-done.c.o | fgrep machine_init
0000000000000000 D machine_init_done
0000000000000000 T qemu_add_machine_init_done_notifier

$ nm libqemu-x86_64-softmmu.fa.p/softmmu_vl.c.o | fgrep machine_init
0000000000000001 C machine_init_done
0000000000000230 b machine_init_done_notifiers
                 U qdev_machine_init
00000000000024d0 T qemu_add_machine_init_done_notifier
0000000000002510 T qemu_remove_machine_init_done_notifier

They either should both be common definitions or one of them should be declaraion.
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2021-03-29 08:53:53 UTC
Conflisting definitions are:

$ git grep -P '[^a-z_]machine_init_done[^a-z_]' | cat
chardev/char-mux.c:    if (!machine_init_done) {
chardev/char-mux.c:    *be_opened = machine_init_done;
include/sysemu/sysemu.h:extern bool machine_init_done;
softmmu/vl.c:bool machine_init_done;
softmmu/vl.c:    if (machine_init_done) {
softmmu/vl.c:    machine_init_done = true;
stubs/machine-init-done.c:bool machine_init_done = true;
Comment 16 Sergei Trofimovich (RETIRED) gentoo-dev 2021-03-29 22:44:47 UTC
`machine_init_dome` conflicts were solved upstream: https://github.com/qemu/qemu/commit/6b21670cfda76e47a827810eea5eb3b518cb6521

Unfortunately I can't easily backport fixes as is as they move too much code dependent on other commits. As a very crude workaround I suggest do a 'filter-flags -fcommon' in the ebuild itself (and drop it for next qemu release.
Comment 17 Larry the Git Cow gentoo-dev 2021-03-29 22:55:16 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0837524b145743820a05177f77a6d7c05f677df4

commit 0837524b145743820a05177f77a6d7c05f677df4
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2021-03-29 22:55:01 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2021-03-29 22:55:13 +0000

    app-emulation/qemu: filter out -fcommon
    
    Next qemu release should have a proper fix for symbol collision:
      $ git grep -P '[^a-z_]machine_init_done[^a-z_]' | cat
      softmmu/vl.c:bool machine_init_done;
      stubs/machine-init-done.c:bool machine_init_done = true;
    
    I'm not comfortable backporting the change and only
    filtering out -fcommon as a workaround. We'll remove
    a workaround in next release.
    
    Reported-by: Agostino Sarubbo
    Reported-by: gordon@niflheim.info
    Closes: https://bugs.gentoo.org/726560
    Package-Manager: Portage-3.0.17, Repoman-3.0.2
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 app-emulation/qemu/qemu-5.2.0-r3.ebuild | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)