Gentoo Archives: gentoo-dev

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] CFLAGS=-fno-common related breakage is incoming
Date: Sun, 19 Jan 2020 22:37:06
Message-Id: 20200119223651.3b6aa2fc@sf
> What is happening?
gcc-10 is coming soon. It will be more disruptive than gcc-9. One of the major changes is the switch from C{,XX}FLAGS=-fcommon to C{,XX}FLAGS=-fno-common by default: https://gcc.gnu.org/PR85678 It's a planned change and not a gcc regression. It will expose some warts on old code and unblock minor optimisations accessing globals. The change has already happened in gcc trunk.
> Is my package affected? Should I do anything?
You can check proactively if your packages are affected. Add -fno-common to your make.conf's C{,XX}FLAGS and see if things still build. The typical symptom is a linker failure on multiple definitions for some global variable: ld: a.o:(.bss+0x0): multiple definition of `a'; main.o:(.data+0x0): first defined here
> How to fix it?
https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common contains some examples. Ideally code will need a few 'extern' additions and maybe moving variable definitions. Example of proposed openrc fix: https://github.com/OpenRC/openrc/pull/348 Adding 'append-flags -fcommon' might work as a temporary workaround.
> Can I help?
Glad you asked! We will need to gather failed packages and fix them upstream and downstream. Here is what you can do: 1. Add -fno-common to your make.conf's C{,XX}FLAGS 2. Build packages you maintain 3. Fix a bug upstream (or report a failure). 4. Pull a fix downstream (or file a bug and add it to the tracker).
> What is already known to be broken? Can I look at example fixes?
See https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common for an artificial example. Gentoo tracker bug of known issues: https://bugs.gentoo.org/705764 15 bugs so far. SUSE tracker bug of known issues: https://bugzilla.suse.com/show_bug.cgi?id=1160244 95 bugs so far. A good source of packages to check against the ones you care about.
> What does -fcommon do?
Look up -fcommon in https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html
> I have no idea why my package broke. The error does not make sense.
Feel free to CC toolchain@ on a bug you observe and we'll try to sort it out. -- Sergei

Replies

Subject Author
Re: [gentoo-dev] CFLAGS=-fno-common related breakage is incoming Sergei Trofimovich <slyfox@g.o>