From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24499 invoked by alias); 21 Jan 2010 05:01:08 -0000 Received: (qmail 24146 invoked by uid 48); 21 Jan 2010 05:00:55 -0000 Date: Thu, 21 Jan 2010 05:01:00 -0000 Message-ID: <20100121050055.24145.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/42818] Static C++ linking breakage "undefined reference to ___real__Znwj" and others in libcygwin.a(_cygwin_crt0_common.o) In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "davek at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-01/txt/msg02480.txt.bz2 ------- Comment #6 from davek at gcc dot gnu dot org 2010-01-21 05:00 ------- So, the optimal solution would be to avoid using the redirection wrappers when we're statically linking. That's still possible: those undefined references without relocs don't cause problems in and of themselves, but only because they turn the weak undefs that *do* have relocs strong. The obvious solution, since we're not using the redirection wrapper functions, is to also not include the array of weak function pointers. That would be trival to do by building two different versions of the CRT startup code in Cygwin itself, one for shared linking that contains the array, one for static linking that doesn't, and selecting the appropriate one at link time using a spec in the backend. That would work fine for --static, but as things stand now, it will still fail when just --static-libstdc++ is in use. This is because of the situation described in the two dependency PRs (Bug 41594 and Bug 41596): you can't test for --static-libstdc++ in a spec, because the code in g++spec.c removes it from the command-line. So, I'm going to leave this bug open and suspend it now I've committed the simple fix. Then, next stage 1, we'll get the situation with --static-libstdc++ resolved one way or another, and by that time I'll have added the alternative startup CRT object to the Cygwin runtime, and then I'll revert this fix and adjust the linker spec to select the correct startup variant. -- davek at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |SUSPENDED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42818