[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug c++/104712] -fkeep-inline-functions causing link errors (debian but not godbolt?)
From: ajrh at ajrh dot net via Gcc-bugs <gcc-bugs () gcc ! gnu ! org>
Date: 2022-02-28 15:42:52
Message-ID: bug-104712-4-U95oOIW3ZS () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104712
ajrh at ajrh dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ajrh at ajrh dot net
--- Comment #6 from ajrh at ajrh dot net ---
Created attachment 52525
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52525&action=edit
mention -ffunction-sections -Wl,-gc-sections in gcov manual
On deeper investigation the original code had lots of unused inlined explicit
template specializations, and a few of these had constants missing the 'inline'
keyword. So gcc is behaving perfectly. Apologies for the misleading
testcase.
I understand better now: --keep-inline-functions is correctly generating
lots of otherwise dead code, and of course some of it might not link.
Though I only wanted to link it in order to run gcov to find and remove all the
dead code, an amusing catch-22.
Am I correct that a good way to fix this sometimes will be to use
-ffunction-sections -Wl,-gc-sections ? E.g. in the example below:
----
extern int i;
inline int f(const char *x)
{
return i;
}
int main(int argc, char *argv[])
{
return !!argc;
}
----
gcc -o x --coverage x.cpp && {x; gcov x}
File 'x.cpp'
Lines executed:100.00% of 2
gcc -o x --coverage -fkeep-inline-functions x.cpp && {x; gcov x}
x.cpp:(.text._Z1fPKc[_Z1fPKc]+0x1c): undefined reference to `i'
g++ -o x --coverage -fkeep-inline-functions -ffunction-sections
-Wl,-gc-sections x.cpp && {x; gcov x}
File 'x.cpp'
Lines executed:50.00% of 4
----
If that's right it might be useful to mention as a hint in the manual.
Attached a texi patch if so.
Thank you all for the help.=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic