Bug 19176 - [4.0/4.1/4.2/4.3 Regression] static gcc cannot be build (libgcc_eh.a required for static gcc)
Summary: [4.0/4.1/4.2/4.3 Regression] static gcc cannot be build (libgcc_eh.a required...
Status: RESOLVED DUPLICATE of bug 26510
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.4
Assignee: Not yet assigned to anyone
URL:
Keywords: link-failure
Depends on:
Blocks: 26510
  Show dependency treegraph
 
Reported: 2004-12-28 14:34 UTC by Hidenori Ishikawa
Modified: 2006-12-24 06:21 UTC (History)
4 users (show)

See Also:
Host:
Target: powerpc-apple-darwin7.7.0
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-23 15:26:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hidenori Ishikawa 2004-12-28 14:34:07 UTC
gcc 4.0.0 cannot be bootstrap-ed if ./configure was run with --enable-static
--disable-shared.

This is due to the bug in "gcc/config/darwin.h".

     317 /* -dynamiclib implies -shared-libgcc just like -shared would on linux.  */
     318 #define REAL_LIBGCC_SPEC \
     319    "%{static|static-libgcc:-lgcc}\
     320     %{!static:%{!static-libgcc:\
     321       %{!Zdynamiclib:%{!shared-libgcc:-lgcc}\
     322       %{shared-libgcc:-lgcc_s -lgcc}} %{Zdynamiclib:-lgcc_s -lgcc}}}"

The REAL_LIBGCC_SPEC states that libgcc.a AND libgcc_eh.a are required for
static gcc.
(Probably copied from linux or i386 or any other spec files.)

However, in powerpc-apple-darwin7.7.0 (and possibly any of powerpc*-*-darwin*)
this "libgcc_eh.a" is not build during the bootstrap procedure (and also not
required).
So, after the first xgcc is build, bootstarp fails at stage1 by the following error:

/usr/lib/ld: can't locate file for: -lgcc_eh

To fix, simply sed -e 's/ -lgcc_eh//' the gcc/config/darwin.h file.
Comment 1 Hidenori Ishikawa 2004-12-28 14:37:57 UTC
(In reply to comment #0)
> This is due to the bug in "gcc/config/darwin.h".
> 
>      317 /* -dynamiclib implies -shared-libgcc just like -shared would on
linux.  */
>      318 #define REAL_LIBGCC_SPEC \
>      319    "%{static|static-libgcc:-lgcc}\
>      320     %{!static:%{!static-libgcc:\
>      321       %{!Zdynamiclib:%{!shared-libgcc:-lgcc}\
>      322       %{shared-libgcc:-lgcc_s -lgcc}} %{Zdynamiclib:-lgcc_s -lgcc}}}"

I'm sorry. I attached my "EDITED" version of "gcc/config/darwin.h".
The original one can be viewed at
http://sources.redhat.com/cgi-bin/cvsweb.cgi/gcc/gcc/config/darwin.h?cvsroot=gcc&only_with_tag=MAIN

     317 /* -dynamiclib implies -shared-libgcc just like -shared would on linux.  */
     318 #define REAL_LIBGCC_SPEC \
     319    "%{static|static-libgcc:-lgcc -lgcc_eh}\
     320     %{!static:%{!static-libgcc:\
     321       %{!Zdynamiclib:%{!shared-libgcc:-lgcc -lgcc_eh}\
     322       %{shared-libgcc:-lgcc_s -lgcc}} %{Zdynamiclib:-lgcc_s -lgcc}}}"
 
Comment 2 Andrew Pinski 2004-12-28 14:39:15 UTC
Really only building static is not supported on darwin.  I will look into the problem but only after a week 
if no one else has looked into this.
Comment 3 Hidenori Ishikawa 2004-12-28 15:04:52 UTC
(In reply to comment #2)
> Really only building static is not supported on darwin.  I will look into the
problem but only after a week 
> if no one else has looked into this.

Yes, I totally agree to your comment.
It is not possible to create a "completely static gcc binary" on darwin.
However, if gcc is built with gcc's shared libraries (i.e. --enable-shared), g++
and gfortran produces binaries that require libgcc_s.dylib for runtime.
In order to distribute gfortran compiled binaries, it is troublesome to handle
with libgcc_s.dylib.
So, what I mean by static gcc is "gcc which produces binaries free of
shared-gcc-libraries".
Comment 4 Andrew Pinski 2004-12-28 15:16:53 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Really only building static is not supported on darwin.  I will look into the
> problem but only after a week 
> > if no one else has looked into this.
> So, what I mean by static gcc is "gcc which produces binaries free of
> shared-gcc-libraries".

And that is a problem, libgcc_s is required for correct running in terms of exceptions.
Also it is not hard to cp libgcc_s with libgfortran and such.
Also telling people to set DYLD_LIBRARY_PATH is not hard, people do it all the time on linux and almost 
all other unix OS's.
Comment 5 Andrew Pinski 2006-10-23 15:26:54 UTC
Caused by:
2004-11-03  Andrew Pinski  <pinskia@physics.uc.edu>

        * config/darwin.h (REAL_LIBGCC_SPEC): Define to use shared
        libgcc for shared libraries.
Comment 6 Andrew Pinski 2006-12-24 06:21:12 UTC

*** This bug has been marked as a duplicate of 26510 ***