Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
gcc10 compiling/linking problems
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6171
Location: Dallas area

PostPosted: Thu May 14, 2020 12:30 pm    Post subject: gcc10 compiling/linking problems Reply with quote

There seem to be several programs that won't compile without errors with the gcc-10 compiler, and the key is complaining during the linking phase about multiple definitions. These are mostly caused by default behavior of the compile changing, specifically the "common" flag.

From the release notes
Code:
GCC now defaults to -fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking.


What this means is that if you have multiple definitions in your code, and the common flag is set, you'll get a linking error.

Two ways to get things to compile.
1. add the common flag to your CFLAGS, the makes the behavior similar to pre-gcc10 compilers OR use an "env" override of "common" per package.
2. fix the code to get rid of multiple definitions.

Note: There are other problems with some packages (who thought that the gcc version would be over a single digit :roll: ) that need a code change.

Edit to add: changed no-common to common, *doh*
_________________
UM780, 6.1 zen kernel, gcc 13, profile 17.0 (custom bare multilib), openrc, wayland


Last edited by Anon-E-moose on Thu May 28, 2020 10:40 am; edited 2 times in total
Back to top
View user's profile Send private message
thumper
Guru
Guru


Joined: 06 Dec 2002
Posts: 554
Location: Venice FL

PostPosted: Thu May 28, 2020 1:55 am    Post subject: Reply with quote

Don't you mean
Code:
-fcommon
makes the behavior similar to pre-gcc10 compilers.
And
Code:
-fno-common
gives linker errors for unfixed code, which is now the default.

???
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6171
Location: Dallas area

PostPosted: Thu May 28, 2020 10:38 am    Post subject: Reply with quote

Indeed, I wrote it backwards. :roll:
_________________
UM780, 6.1 zen kernel, gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2739
Location: Here and Away Again

PostPosted: Thu May 28, 2020 10:47 am    Post subject: ><)))°€ Reply with quote

See also: wiki.gentoo.org - Gcc 10 porting notes/fno common
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum