[BUG] PCem V15 does not compile with GCC >= 10.x

Discussion of development and patch submission.
Post Reply
ConiKost
Posts: 2
Joined: Sat 21 Sep, 2019 3:40 pm

[BUG] PCem V15 does not compile with GCC >= 10.x

Post by ConiKost »

Starting with GCC >= 10.x, -fno-common is used instead of -fcommon. Compilation of PCem V15 fails.

Following output is an example, since it affects more places.
See full log: https://pastebin.com/D1diRPJY

Code: Select all

usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0x750): multiple definition of `cpu_state'; pcem-386.o:(.bss+0x690): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0xd0): multiple definition of `bios_high_mapping'; pcem-386.o:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0x410): multiple definition of `bios_mapping'; pcem-386.o:(.bss+0x340): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0x8f0): multiple definition of `hdc'; pcem-386.o:(.bss+0x830): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0x998): multiple definition of `pic2'; pcem-386.o:(.bss+0x8d8): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0x9b0): multiple definition of `pic'; pcem-386.o:(.bss+0x8f0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0x9c8): multiple definition of `ppi'; pcem-386.o:(.bss+0x908): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_common.o:(.bss+0x9d0): multiple definition of `ram'; pcem-386.o:(.bss+0x910): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x6c0): multiple definition of `cpu_state'; pcem-386.o:(.bss+0x690): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x6b8): multiple definition of `x87_pc_off'; pcem-386.o:(.bss+0x688): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x6b2): multiple definition of `x87_pc_seg'; pcem-386.o:(.bss+0x682): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x6b4): multiple definition of `x87_op_off'; pcem-386.o:(.bss+0x684): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x6b0): multiple definition of `x87_op_seg'; pcem-386.o:(.bss+0x680): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x940): multiple definition of `ram'; pcem-386.o:(.bss+0x910): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x30): multiple definition of `bios_high_mapping'; pcem-386.o:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x370): multiple definition of `bios_mapping'; pcem-386.o:(.bss+0x340): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x860): multiple definition of `hdc'; pcem-386.o:(.bss+0x830): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x908): multiple definition of `pic2'; pcem-386.o:(.bss+0x8d8): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x920): multiple definition of `pic'; pcem-386.o:(.bss+0x8f0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec.o:(.bss+0x938): multiple definition of `ppi'; pcem-386.o:(.bss+0x908): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x690): multiple definition of `cpu_state'; pcem-386.o:(.bss+0x690): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x688): multiple definition of `x87_pc_off'; pcem-386.o:(.bss+0x688): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x682): multiple definition of `x87_pc_seg'; pcem-386.o:(.bss+0x682): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x684): multiple definition of `x87_op_off'; pcem-386.o:(.bss+0x684): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x680): multiple definition of `x87_op_seg'; pcem-386.o:(.bss+0x680): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x0): multiple definition of `bios_high_mapping'; pcem-386.o:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x340): multiple definition of `bios_mapping'; pcem-386.o:(.bss+0x340): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x830): multiple definition of `hdc'; pcem-386.o:(.bss+0x830): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x8d8): multiple definition of `pic2'; pcem-386.o:(.bss+0x8d8): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x8f0): multiple definition of `pic'; pcem-386.o:(.bss+0x8f0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x908): multiple definition of `ppi'; pcem-386.o:(.bss+0x908): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: pcem-386_dynarec_ops.o:(.bss+0x910): multiple definition of `ram'; pcem-386.o:(.bss+0x910): first defined here
jasaldivara
Posts: 2
Joined: Wed 08 Jan, 2020 11:12 pm

Re: [BUG] PCem V15 does not compile with GCC >= 10.x

Post by jasaldivara »

I have the same problem, both whith PCem v15 and v16.

What's the best solution? Where should I change that flag? Or should I install an older version of GCC?
davefiddes
Posts: 4
Joined: Wed 06 May, 2020 7:21 pm

Re: [BUG] PCem V15 does not compile with GCC >= 10.x

Post by davefiddes »

This just bit me when trying out PCem on Fedora 32 which uses gcc 10.0.1 20200430 (Red Hat 10.0.1-0.13) and will probably update to the final GCC 10.1 release shortly.

A hack fix can be achieved by adding "-fcommon" to the CFLAGS settings in configure.ac (circa line 33) and re-building the configure script by running autoconf.

Seems like the -fcommon option has existed in gcc for a long time (at least as far back as gcc 4.2.4) so should be safe to add in to the default CFLAGS.
JosepMa
Posts: 163
Joined: Tue 20 Jun, 2017 6:25 pm

Re: [BUG] PCem V15 does not compile with GCC >= 10.x

Post by JosepMa »

https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common

It seems it could be complicated to rearrange the code in some places .

Basically, ".h" files should not have variable instantiations ( like, for example bios_high_mapping in mem.h ).
Instead, they should be defined on one .c file, and use the "extern x" keyword on .h files that would need to refer to it.
User avatar
SarahWalker
Site Admin
Posts: 1884
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [BUG] PCem V15 does not compile with GCC >= 10.x

Post by SarahWalker »

Added -fcommon in commit 1f63723. I should probably actually fix the issue at some point...
Post Reply