public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53570] New: Unused symbols are not removed for fully static targets (avr-gcc)
@ 2012-06-04 7:06 jwatte at gmail dot com
2012-06-04 7:08 ` [Bug c++/53570] " jwatte at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: jwatte at gmail dot com @ 2012-06-04 7:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53570
Bug #: 53570
Summary: Unused symbols are not removed for fully static
targets (avr-gcc)
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jwatte@gmail.com
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.7.0/lto-wrapper
Target: avr
Configured with: /build/src/gcc-4.7.0/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,c++ --disable-libssp --disable-nls --target=avr
--with-as=/usr/bin/avr-as --with-ld=/usr/bin/avr-ld --with-gnu-as --with-gnu-ld
Thread model: single
gcc version 4.7.0 (GCC)
This is a problem report for how the linker is not smart enough
to remove unused functions, even with -Os. This makes it very
hard to create libraries of functions where only some functions
may be used in any particular binary. Note: "r" option to ar is
passed in, so the linker should have all the symbol information
it needs to make the determination.
See the attached test program, especially the "lib.cpp" file.
There is nothing in the C++ standard that requires the compiler
or linker to include the not_called symbol, or the
some_large_function symbol, when they are not used. On a small
target like the AVR, including those symbols is too wasteful.
To reproduce:
- untar this archive
- run ./make.sh
- avr-objdump --disassemble main, and find the unused symbols
still included
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53570] Unused symbols are not removed for fully static targets (avr-gcc)
2012-06-04 7:06 [Bug c++/53570] New: Unused symbols are not removed for fully static targets (avr-gcc) jwatte at gmail dot com
@ 2012-06-04 7:08 ` jwatte at gmail dot com
2012-06-04 8:33 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jwatte at gmail dot com @ 2012-06-04 7:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53570
--- Comment #1 from jwatte at gmail dot com 2012-06-04 07:08:03 UTC ---
Created attachment 27551
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27551
Reproduction case (gzipped tar archive)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53570] Unused symbols are not removed for fully static targets (avr-gcc)
2012-06-04 7:06 [Bug c++/53570] New: Unused symbols are not removed for fully static targets (avr-gcc) jwatte at gmail dot com
2012-06-04 7:08 ` [Bug c++/53570] " jwatte at gmail dot com
@ 2012-06-04 8:33 ` pinskia at gcc dot gnu.org
2012-06-04 8:37 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-06-04 8:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53570
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |normal
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53570] Unused symbols are not removed for fully static targets (avr-gcc)
2012-06-04 7:06 [Bug c++/53570] New: Unused symbols are not removed for fully static targets (avr-gcc) jwatte at gmail dot com
2012-06-04 7:08 ` [Bug c++/53570] " jwatte at gmail dot com
2012-06-04 8:33 ` pinskia at gcc dot gnu.org
@ 2012-06-04 8:37 ` pinskia at gcc dot gnu.org
2012-06-04 18:07 ` jwatte at gmail dot com
2012-06-09 16:50 ` ebotcazou at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-06-04 8:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53570
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-06-04 08:36:53 UTC ---
This is expected as there is only one section in the object file.
If you use -ffunction-sections -fdata-sections and link with -Wl,--gc-sections.
The unused functions/data will be removed.
Another way is to use the link time optimizer (-flto on both the compile
command line and the link command line; note you need to have the optimization
options passed to the link command line also).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53570] Unused symbols are not removed for fully static targets (avr-gcc)
2012-06-04 7:06 [Bug c++/53570] New: Unused symbols are not removed for fully static targets (avr-gcc) jwatte at gmail dot com
` (2 preceding siblings ...)
2012-06-04 8:37 ` pinskia at gcc dot gnu.org
@ 2012-06-04 18:07 ` jwatte at gmail dot com
2012-06-09 16:50 ` ebotcazou at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jwatte at gmail dot com @ 2012-06-04 18:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53570
--- Comment #3 from jwatte at gmail dot com 2012-06-04 18:07:04 UTC ---
I will try -flto and report back. Thanks!
Btw: I think "that's expected" is in the eye of the beholder. If all you've
ever done is VAX/GCC-style UNIX, then it's expected. If you've worked with
other toolchains, like AIX, CodeWarrior, Microsoft, etc, then you'd actually
expect function-level linking by default.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53570] Unused symbols are not removed for fully static targets (avr-gcc)
2012-06-04 7:06 [Bug c++/53570] New: Unused symbols are not removed for fully static targets (avr-gcc) jwatte at gmail dot com
` (3 preceding siblings ...)
2012-06-04 18:07 ` jwatte at gmail dot com
@ 2012-06-09 16:50 ` ebotcazou at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-06-09 16:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53570
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |ebotcazou at gcc dot
| |gnu.org
Resolution| |WORKSFORME
--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-06-09 16:49:59 UTC ---
> Btw: I think "that's expected" is in the eye of the beholder. If all you've
> ever done is VAX/GCC-style UNIX, then it's expected. If you've worked with
> other toolchains, like AIX, CodeWarrior, Microsoft, etc, then you'd actually
> expect function-level linking by default.
Not sure what VAX/GCC-style UNIX means... it's the default ELF behavior. And
what you call function-level linking is achieved by means of
-ffunction-sections -fdata-sections -Wl,--gc-sections. -flto is something
else.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-06-09 16:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-04 7:06 [Bug c++/53570] New: Unused symbols are not removed for fully static targets (avr-gcc) jwatte at gmail dot com
2012-06-04 7:08 ` [Bug c++/53570] " jwatte at gmail dot com
2012-06-04 8:33 ` pinskia at gcc dot gnu.org
2012-06-04 8:37 ` pinskia at gcc dot gnu.org
2012-06-04 18:07 ` jwatte at gmail dot com
2012-06-09 16:50 ` ebotcazou at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).