mchehab / rasdaemon

Rasdaemon is a RAS (Reliability, Availability and Serviceability) logging tool. It records memory errors, using the EDAC tracing events. EDAC is a Linux kernel subsystem with handles detection of ECC errors from memory controllers for most chipsets on i386 and x86_64 architectures. EDAC drivers for other architectures like arm also exists.
GNU General Public License v2.0
173 stars 79 forks source link

Linker errors when compiling with gcc 10+ #15

Closed ashleybone closed 4 years ago

ashleybone commented 4 years ago

Hi,

GCC 10 and above defaults to -fno-common, which prevents the merging of globals declared in multiple compilation units. This is causing linker problems with the declaration of:

struct ras_events *ras;

on line 30 of ras-record.h. It needs to be declared extern and defined in a single complation unit, or -fcommon needs to be added to the CFLAGS.

I'm using gcc 10.1.0 on arch linux. I configured and built ras with:

./configure \
>     --prefix=/usr           \
>     --sbindir=/usr/bin      \
>     --sysconfdir=/etc       \
>     --localstatedir=/var    \
>     --enable-aer            \
>     --enable-arm            \
>     --enable-extlog         \
>     --enable-hisi-ns-decode \
>     --enable-mce            \
>     --enable-non-standard   \
>     --enable-devlink        \
>     --enable-diskerror      \
>     --enable-abrt-report    \
>     --enable-sqlite3        \
>     ;
make

and the output of make is:

make  all-recursive
make[1]: Entering directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5'
Making all in libtrace
make[2]: Entering directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/libtrace'
  CC       event-parse.o
  CC       parse-filter.o
  CC       kbuffer-parse.o
  CC       parse-utils.o
  CC       trace-seq.o
  AR       libtrace.a
ar: `u' modifier ignored since `D' is the default (see `U')
make[2]: Leaving directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/libtrace'
Making all in util
make[2]: Entering directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/util'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/util'
Making all in man
make[2]: Entering directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/man'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/man'
make[2]: Entering directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5'
  CC       rasdaemon.o
  CC       ras-events.o
  CC       ras-mc-handler.o
  CC       bitfield.o
  CC       ras-record.o
  CC       ras-aer-handler.o
  CC       ras-non-standard-handler.o
  CC       ras-arm-handler.o
  CC       ras-mce-handler.o
  CC       mce-intel.o
  CC       mce-amd.o
  CC       mce-intel-p4-p6.o
  CC       mce-intel-nehalem.o
  CC       mce-intel-dunnington.o
  CC       mce-intel-tulsa.o
  CC       mce-intel-sb.o
  CC       mce-intel-ivb.o
  CC       mce-intel-haswell.o
  CC       mce-intel-knl.o
  CC       mce-intel-broadwell-de.o
  CC       mce-intel-broadwell-epex.o
  CC       mce-intel-skylake-xeon.o
  CC       mce-amd-k8.o
  CC       mce-amd-smca.o
  CC       ras-extlog-handler.o
  CC       ras-devlink-handler.o
  CC       ras-diskerror-handler.o
  CC       ras-report.o
  CC       non-standard-hisi_hip07.o
  CC       non-standard-hisi_hip08.o
  CCLD     rasdaemon
/usr/bin/ld: ras-events.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-mc-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: bitfield.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-record.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-aer-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-non-standard-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-arm-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-mce-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-amd.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-p4-p6.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-nehalem.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-dunnington.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-tulsa.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-sb.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-ivb.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-haswell.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-knl.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-broadwell-de.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-broadwell-epex.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-intel-skylake-xeon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-amd-k8.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: mce-amd-smca.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-extlog-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-devlink-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-diskerror-handler.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: ras-report.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: non-standard-hisi_hip07.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
/usr/bin/ld: non-standard-hisi_hip08.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: multiple definition of `ras'; rasdaemon.o:/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5/ras-record.h:30: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:621: rasdaemon] Error 1
make[2]: Leaving directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5'
make[1]: *** [Makefile:724: all-recursive] Error 1
make[1]: Leaving directory '/home/ashley/Development/ArchLinux/rasdaemon/rasdaemon-0.6.5'
make: *** [Makefile:515: all] Error 2
mchehab commented 4 years ago

This seems to have been solved by commit 1a3448616b3208883133227243b2a1faef198fa0.

As I'm able to compile it with gcc 10.1.1 without issues, I'm closing this issue. If this is still happening, feel free to re-open, and to submit a fixup patch.