This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/42818] New: Static C++ linking breakage "undefined reference to ___real__Znwj" and others in libcygwin.a(_cygwin_crt0_common.o)
- From: "davek at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jan 2010 03:08:55 -0000
- Subject: [Bug target/42818] New: Static C++ linking breakage "undefined reference to ___real__Znwj" and others in libcygwin.a(_cygwin_crt0_common.o)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[ Don't Panic. There is already a fix for this bug, in fact two, one that is
suitable for our current Stage 3(4?) status but slightly suboptimal, another
that is better but blocked by an existing PR that won't be fixed until next
Stage1. I just figured I should say that first of all. ]
There's a problematic interaction between the parts of cygwin backend's linker
specs, the cygwin libc CRT startup code, and the backend's support for N2800
#17.6.4.6 [replacement.functions]. When linking C++ executables statically,
this leads to symptoms such as those reported here:
http://cygwin.com/ml/cygwin/2009-12/msg00583.html
/tmp/winsup/i686-pc-cygwin/winsup/cygwin/libcygwin.a(_cygwin_crt0_common.o):_cyg
> win_crt0_common.cc:(.data+0x0): undefined reference to `___real__Znwj'
> /tmp/winsup/i686-pc-cygwin/winsup/cygwin/libcygwin.a(_cygwin_crt0_common.o):_cyg
> win_crt0_common.cc:(.data+0x4): undefined reference to `___real__Znaj'
> /tmp/winsup/i686-pc-cygwin/winsup/cygwin/libcygwin.a(_cygwin_crt0_common.o):_cyg
> win_crt0_common.cc:(.data+0x8): undefined reference to `___real__ZdlPv'
> collect2: ld returned 1 exit status
> make[1]: *** [cygserver.exe] Error 1
The particular functions reported as undefined will be whatever subset of the
replaceable new/delete operators are referenced in the executable and drawn
into the final link.
I'll post analysis, patches and test results as separate comments. I've not
set the severity of this bug any higher than "normal" because it's
already/about-to-be fixed, but I'm going to leave it open after applying the
stage3-suitable fix to remind me to apply the more optimal one when we return
to stage 1 and Bug 41594 and/or Bug 41596 get fixed.
--
Summary: Static C++ linking breakage "undefined reference to
___real__Znwj" and others in
libcygwin.a(_cygwin_crt0_common.o)
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: missed-optimization, link-failure
Severity: normal
Priority: P3
Component: target
AssignedTo: davek at gcc dot gnu dot org
ReportedBy: davek at gcc dot gnu dot org
GCC build triplet: i686-pc-cygwin
GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin
BugsThisDependsOn: 41594,41596
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42818