Bug 37989 - PR37528 fix broke --disable-shared on mingw32
Summary: PR37528 fix broke --disable-shared on mingw32
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Danny Smith
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-01 18:02 UTC by Mikael Pettersson
Modified: 2008-11-04 02:21 UTC (History)
1 user (show)

See Also:
Host: i686-pc-cygwin
Target: x86_64-pc-mingw32
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed: 2008-11-03 06:09:24


Attachments
patch to unbreak --disable-shared on mingw32 (375 bytes, patch)
2008-11-01 18:10 UTC, Mikael Pettersson
Details | Diff
revised patch to quard with ENABLE_SHARED_LIBGCC (424 bytes, patch)
2008-11-03 07:45 UTC, Danny Smith
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikael Pettersson 2008-11-01 18:02:43 UTC
gcc-4.4-20081003 and later configured with --disable-shared for mingw32 attempt to link with libgcc_eh.a even though it never built libgcc_eh.a (those object files are included in libgcc.a):

/home/mikpe/gcc-4.4-20081031/configure --target=x86_64-pc-mingw32 --prefix=/tmp/cross-mingw64 --disable-nls --disable-shared --enable-threads=win32 --enable-languages=c --with-gmp=/opt/local/gmp-4.2.4 --with-mpfr=/opt/local/mpfr-2.3.2 --disable-win32-registry --enable-sjlj-exceptions
make
make install
echo "int main(void) { return 0; }" > trivial.c
/tmp/cross-mingw64/bin/x86_64-pc-mingw32-gcc trivial.c
/tmp/cross-mingw64/lib/gcc/x86_64-pc-mingw32/4.4.0/../../../../x86_64-pc-mingw32/bin/ld: cannot find -lgcc_eh
collect2: ld returned 1 exit status

The fix for PR37528 changed mingw32.h to #define REAL_LIBGCC_SPEC, and it also
changed it to unconditionally link with -lgcc_eh for !shared-libgcc.
That only works if libgcc_eh.a actually was built, which isn't the case when
gcc was configured with --disable-shared.
Comment 1 Mikael Pettersson 2008-11-01 18:10:18 UTC
Created attachment 16610 [details]
patch to unbreak --disable-shared on mingw32

Proposed patch to unbreak --disable-shared on mingw32. When PR37528 changed mingw32.h to #define REAL_LIBGCC_SPEC it also bypassed gcc/gcc.c's logic to only link with -lgcc_eh when ENABLE_SHARED_LIBGCC is defined. So my proposed fix adds that logic to mingw32.h's definition of REAL_LIBGCC_SPEC.

Tested on WinXP64 under cygwin both with and without --disable-shared.
Comment 2 Danny Smith 2008-11-03 07:45:58 UTC
Created attachment 16614 [details]
revised patch to quard with ENABLE_SHARED_LIBGCC

Hi Mikael,

I have modified your patch slightly and added a ChangeLog entry.  It works for me with host=build=target=mingw32.  Does attached it work for you.
Danny
Comment 3 Mikael Pettersson 2008-11-03 13:49:11 UTC
(In reply to comment #2)
Danny, I've tested the revised patch both with and without --disable-shared, and both configs build and work fine.
Comment 4 dannysmith@gcc.gnu.org 2008-11-04 02:17:35 UTC
Subject: Bug 37989

Author: dannysmith
Date: Tue Nov  4 02:16:07 2008
New Revision: 141575

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141575
Log:
2008-11-03  Mikael Pettersson  <mikpe@it.uu.se>

        PR target/37989
	* config/i386/mingw32.h (REAL_LIBGCC_SPEC): Only add libgcc_s.a
	or libgcc_eh.a to spec if ENABLE_SHARED_LIBGCC.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/mingw32.h

Comment 5 Danny Smith 2008-11-04 02:21:38 UTC
Fixed by Mikael's patch