public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/3400] New: gcc -Wl,--gc-sections -static build doesn't flush stdout
@ 2006-10-19 18:10 vda dot linux at googlemail dot com
2006-10-19 20:20 ` [Bug libc/3400] " drepper at redhat dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: vda dot linux at googlemail dot com @ 2006-10-19 18:10 UTC (permalink / raw)
To: glibc-bugs
t.c:
#include <stdio.h>
int main() {
printf("Hello world\n");
}
# gcc -O2 t.c -o shared
# gcc -O2 t.c -static -o static
# gcc -O2 t.c -Wl,--gc-sections -static -o gc-sect
# ./shared | cat
Hello world
# ./static | cat
Hello world
# ./gc-sect | cat
The last command outputs nothing.
Adding fflush(stdout) after printf makes it work.
(Pipe is needed to make stdout buffered).
IOW: static link with section garbage collection desn't work correctly,
which is a pity because it is such a handy optimization.
This is why:
Makerules:
PROVIDE(__start___libc_atexit = .);\
__libc_atexit : { *(__libc_atexit) }\
PROVIDE(__stop___libc_atexit = .);\
libio/genops.c:
#ifdef text_set_element
text_set_element(__libc_atexit, _IO_cleanup);
#endif
include/libc-symbols.h:
#ifdef HAVE_ELF
/* Make SYMBOL, which is in the text segment, an element of SET. */
# define text_set_element(set, symbol) _elf_set_element(set, symbol)
/* These are all done the same way in ELF.
There is a new section created for each set. */
# ifdef SHARED
/* When building a shared library, make the set section writable,
because it will need to be relocated at run time anyway. */
# define _elf_set_element(set, symbol) \
static const void *__elf_set_##set##_element_##symbol##__ \
__attribute__ ((used, section (#set))) = &(symbol)
# else
And of course:
void
exit (int status)
{
...
RUN_HOOK (__libc_atexit, ());
_exit (status);
}
You have to explain to ld that it should never drop __libc_atexit sections...
--
Summary: gcc -Wl,--gc-sections -static build doesn't flush stdout
Product: glibc
Version: 2.4
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: vda dot linux at googlemail dot com
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=3400
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/3400] gcc -Wl,--gc-sections -static build doesn't flush stdout
2006-10-19 18:10 [Bug libc/3400] New: gcc -Wl,--gc-sections -static build doesn't flush stdout vda dot linux at googlemail dot com
@ 2006-10-19 20:20 ` drepper at redhat dot com
2007-01-27 10:51 ` vapier at gentoo dot org
2010-01-07 13:37 ` hjl dot tools at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: drepper at redhat dot com @ 2006-10-19 20:20 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2006-10-19 20:20 -------
You simply cannot use that option. Period. Static linking is not really
supported. I'm not closing the bug outright so that somebody with interest can
think of a clean and non-intrusive way to handle this. But I sure as hell won't
spend a second thinking about static linking.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
http://sourceware.org/bugzilla/show_bug.cgi?id=3400
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/3400] gcc -Wl,--gc-sections -static build doesn't flush stdout
2006-10-19 18:10 [Bug libc/3400] New: gcc -Wl,--gc-sections -static build doesn't flush stdout vda dot linux at googlemail dot com
2006-10-19 20:20 ` [Bug libc/3400] " drepper at redhat dot com
@ 2007-01-27 10:51 ` vapier at gentoo dot org
2010-01-07 13:37 ` hjl dot tools at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: vapier at gentoo dot org @ 2007-01-27 10:51 UTC (permalink / raw)
To: glibc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |toolchain at gentoo dot org
http://sourceware.org/bugzilla/show_bug.cgi?id=3400
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/3400] gcc -Wl,--gc-sections -static build doesn't flush stdout
2006-10-19 18:10 [Bug libc/3400] New: gcc -Wl,--gc-sections -static build doesn't flush stdout vda dot linux at googlemail dot com
2006-10-19 20:20 ` [Bug libc/3400] " drepper at redhat dot com
2007-01-27 10:51 ` vapier at gentoo dot org
@ 2010-01-07 13:37 ` hjl dot tools at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-01-07 13:37 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From hjl dot tools at gmail dot com 2010-01-07 13:36 -------
It is a linker bug.
*** This bug has been marked as a duplicate of 11133 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|SUSPENDED |RESOLVED
Resolution| |DUPLICATE
http://sourceware.org/bugzilla/show_bug.cgi?id=3400
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-01-07 13:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-19 18:10 [Bug libc/3400] New: gcc -Wl,--gc-sections -static build doesn't flush stdout vda dot linux at googlemail dot com
2006-10-19 20:20 ` [Bug libc/3400] " drepper at redhat dot com
2007-01-27 10:51 ` vapier at gentoo dot org
2010-01-07 13:37 ` hjl dot tools at gmail dot com
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).