]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Darwin] Some TLC for older Darwin versions.
authorIain Sandoe <iain@sandoe.co.uk>
Wed, 30 Oct 2019 20:38:47 +0000 (20:38 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Wed, 30 Oct 2019 20:38:47 +0000 (20:38 +0000)
This is part 3 of build fixes for older Darwin versions (and will also
fix testsuite complaints about linkage with objects that are built for
an newer OS version than is being built, when used with a modern linker).

The library handling and some of the options for creating the crts for
the older PPC Darwin versions had bit-rotted somewhat. This adjusts the
build criteria for the crts to avoid newer ld64 versions warnings about
mismatches in build and object versions.

Added to some of the comments that it is documented why the specs are as
they are.

gcc/

2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>

Backport from mainline
2019-07-03  Iain Sandoe  <iain@sandoe.co.uk>

* config/darwin.h (REAL_LIBGCC_SPEC): Adjust for earlier Darwin.
(STARTFILE_SPEC): Split crt3 into a separate spec.
(DARWIN_EXTRA_SPECS): Add crt2 and crt3 spec.
(DARWIN_CRT2_SPEC): New.
(DARWIN_CRT3_SPEC): New.
(MIN_LD64_OMIT_STUBS): Revise to 62.1.
* config/rs6000/darwin.h (DARWIN_CRT2_SPEC): Revise conditions.
(DARWIN_CRT3_SPEC): New.

libgcc/

2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>

Backport from mainline.
2019-07-03  Iain Sandoe  <iain@sandoe.co.uk>

* config.host (powerpc-*-darwin*,powerpc64-*-darwin*): Revise crt
list.
* config/rs6000/t-darwin: Build crt3_2 for older systems.  Revise
mmacosx-version-min for crts to run across all system versions.
* config/rs6000/t-darwin64 (LIB2ADD): Remove.
* config/t-darwin: Revise mmacosx-version-min for crts to run across
system versions >= 10.4.

From-SVN: r277644

gcc/ChangeLog
gcc/config/darwin.h
gcc/config/rs6000/darwin.h
libgcc/ChangeLog
libgcc/config.host
libgcc/config/rs6000/t-darwin
libgcc/config/rs6000/t-darwin64
libgcc/config/t-darwin

index 1873defbe083e469b7a8b0101f148afe169b4453..aac74ed389418cadcde7a0f3259d6ed2860aa833 100644 (file)
@@ -1,3 +1,17 @@
+2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
+
+       Backport from mainline
+       2019-07-03  Iain Sandoe  <iain@sandoe.co.uk>
+
+       * config/darwin.h (REAL_LIBGCC_SPEC): Adjust for earlier Darwin.
+       (STARTFILE_SPEC): Split crt3 into a separate spec.
+       (DARWIN_EXTRA_SPECS): Add crt2 and crt3 spec.
+       (DARWIN_CRT2_SPEC): New.
+       (DARWIN_CRT3_SPEC): New.
+       (MIN_LD64_OMIT_STUBS): Revise to 62.1.
+       * config/rs6000/darwin.h (DARWIN_CRT2_SPEC): Revise conditions.
+       (DARWIN_CRT3_SPEC): New.
+
 2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline
index a8046d000e3ea2d8dd928f8a71c410c544115222..be261e73a7b4a119b5de62e43e0ad7281f064348 100644 (file)
@@ -184,8 +184,15 @@ extern GTY(()) int darwin_ms_struct;
 #define DARWIN_NOCOMPACT_UNWIND \
 " %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) "
 
-/* This is mostly a clone of the standard LINK_COMMAND_SPEC, plus
-   precomp, libtool, and fat build additions.
+/* In Darwin linker specs we can put -lcrt0.o and ld will search the library
+   path for crt0.o or -lcrtx.a and it will search for for libcrtx.a.  As for
+   other ports, we can also put xxx.{o,a}%s and get the appropriate complete
+   startfile absolute directory.  This latter point is important when we want
+   to override ld's rule of .dylib being found ahead of .a and the user wants
+   the convenience library to be linked.  */
+
+/* The LINK_COMMAND spec is mostly a clone of the standard LINK_COMMAND_SPEC,
+   plus precomp, libtool, and fat build additions.
 
    In general, random Darwin linker flags should go into LINK_SPEC
    instead of LINK_COMMAND_SPEC.  The command spec is better for
@@ -350,43 +357,42 @@ extern GTY(()) int darwin_ms_struct;
 
 /* Support -mmacosx-version-min by supplying different (stub) libgcc_s.dylib
    libraries to link against, and by not linking against libgcc_s on
-   earlier-than-10.3.9.
+   earlier-than-10.3.9.  If we need exceptions, prior to 10.3.9, then we have
+   to link the static eh lib, since there's no shared version on the system.
+
+   Note that by default, except as above, -lgcc_eh is not linked against.
+   This is because,in general, we need to unwind through system libraries that
+   are linked with the shared unwinder in libunwind (or libgcc_s for 10.4/5).
 
-   Note that by default, -lgcc_eh is not linked against!  This is
-   because in a future version of Darwin the EH frame information may
-   be in a new format, or the fallback routine might be changed; if
-   you want to explicitly link against the static version of those
-   routines, because you know you don't need to unwind through system
-   libraries, you need to explicitly say -static-libgcc.
+   The static version of the current libgcc unwinder (which differs from the
+   implementation in libunwind.dylib on systems Darwin10 [10.6]+) can be used
+   by specifying -static-libgcc.
 
-   If it is linked against, it has to be before -lgcc, because it may
+   If libgcc_eh is linked against, it has to be before -lgcc, because it might
    need symbols from -lgcc.  */
+
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC                                                  \
    "%{static-libgcc|static: -lgcc_eh -lgcc;                               \
-      shared-libgcc|fexceptions|fgnu-runtime:                             \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)       \
+      shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime:            \
+       %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh)         \
+       %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
        %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)     \
+       %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_ext.10.4) \
        %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)     \
        -lgcc ;                                                            \
       :%:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
        %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)     \
+       %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_ext.10.4) \
        %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)     \
        -lgcc }"
 
-/* We specify crt0.o as -lcrt0.o so that ld will search the library path.
-
-   crt3.o provides __cxa_atexit on systems that don't have it.  Since
-   it's only used with C++, which requires passing -shared-libgcc, key
-   off that to avoid unnecessarily adding a destructor to every
-   powerpc program built.  */
+/* We specify crt0.o as -lcrt0.o so that ld will search the library path.  */
 
 #undef  STARTFILE_SPEC
 #define STARTFILE_SPEC                                                     \
-  "%{Zdynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}}                 \
  %{!Zdynamiclib:%{Zbundle:%{!static:                                     \
+"%{Zdynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}}                   \
%{!Zdynamiclib:%{Zbundle:%{!static:                                       \
        %:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o)          \
        %{fgnu-tm: -lcrttms.o}}}                                            \
      %{!Zbundle:%{pg:%{static:-lgcrt0.o}                                   \
@@ -400,7 +406,7 @@ extern GTY(()) int darwin_ms_struct;
                                 %{!object:%{preload:-lcrt0.o}              \
                                   %{!preload: %(darwin_crt1)               \
                                              %(darwin_crt2)}}}}}}          \
 %{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
%(darwin_crt3)"
 
 /* We want a destructor last in the list.  */
 #define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
@@ -408,18 +414,30 @@ extern GTY(()) int darwin_ms_struct;
 
 #define DARWIN_EXTRA_SPECS                                             \
   { "darwin_crt1", DARWIN_CRT1_SPEC },                                 \
+  { "darwin_crt2", DARWIN_CRT2_SPEC },                                 \
+  { "darwin_crt3", DARWIN_CRT3_SPEC },                                 \
   { "darwin_dylib1", DARWIN_DYLIB1_SPEC },
 
-#define DARWIN_DYLIB1_SPEC                                             \
-  "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o)          \
-   %:version-compare(>< 10.5 10.6 mmacosx-version-min= -ldylib1.10.5.o)"
-
 #define DARWIN_CRT1_SPEC                                               \
   "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o)            \
    %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lcrt1.10.5.o)  \
    %:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o)  \
    %{fgnu-tm: -lcrttms.o}"
 
+#define DARWIN_CRT2_SPEC ""
+
+/* crt3.o provides __cxa_atexit on systems that don't have it (and a fix
+   up for faulty versions on 10.4).  Since it's only used with C++, which
+   requires passing -shared-libgcc, key off that to avoid unnecessarily
+   adding a destructor to every program built for 10.4 or earlier.  */
+
+#define DARWIN_CRT3_SPEC \
+"%{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
+
+#define DARWIN_DYLIB1_SPEC                                             \
+  "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o)          \
+   %:version-compare(>< 10.5 10.6 mmacosx-version-min= -ldylib1.10.5.o)"
+
 #ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION
 /* Emit macosx version (but only major).  */
 #define ASM_MMACOSX_VERSION_MIN_SPEC \
index 0f458f8bec5063208eaef0a2480dc497e449f48c..e36de59ca2509d09766337d6334a5557068b12fc 100644 (file)
    %:version-compare(>< 10.5 10.7 mmacosx-version-min= -lcrt1.10.5.o)  \
    %{fgnu-tm: -lcrttms.o}"
 
-/* crt2.o is at least partially required for 10.3.x and earlier.  */
+/* crt2.o is at least partially required for 10.3.x and earlier.
+   It deals with registration of the unwind frames, where this is not
+   automatically provided by the system.  So we need it for any case that
+   might use exceptions.  */
+#undef DARWIN_CRT2_SPEC
 #define DARWIN_CRT2_SPEC \
-  "%{!m64:%:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s)}"
+"%{!m64:%{shared-libgcc|static-libstdc++|fexceptions|fobjc-exceptions|fgnu-runtime: \
+   %:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s) \
+  }}"
+
+/* crt3 deals with providing cxa_atexit on earlier systems (or fixing it up,
+   for broken versions).  It's only needed for c++ code, so we can make it
+   conditional on shared-libgcc since that's forced on for c++.  */
+#undef DARWIN_CRT3_SPEC
+#define DARWIN_CRT3_SPEC \
+"%{!m64:%{shared-libgcc|static-libstdc++:                                                      \
+   %:version-compare(>< 10.4 10.5 mmacosx-version-min= crt3.o%s) \
+   %:version-compare(!> 10.4 mmacosx-version-min= crt3_2.o%s) \
+  }}"
 
 /* The PPC regs save/restore functions are leaves and could, conceivably
    be used by the tm destructor.  */
index dde643b1b05eba7b1109fe2b1cbe29fc0f766722..ca2819f0e45a508bce87fa2f9449d9e78c0e6a90 100644 (file)
@@ -1,3 +1,16 @@
+2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
+
+       Backport from mainline.
+       2019-07-03  Iain Sandoe  <iain@sandoe.co.uk>
+
+       * config.host (powerpc-*-darwin*,powerpc64-*-darwin*): Revise crt
+       list.
+       * config/rs6000/t-darwin: Build crt3_2 for older systems.  Revise
+       mmacosx-version-min for crts to run across all system versions.
+       * config/rs6000/t-darwin64 (LIB2ADD): Remove.
+       * config/t-darwin: Revise mmacosx-version-min for crts to run across
+       system versions >= 10.4.
+
 2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline.
index d32c8b98dda4f801526381fad3746519a5c0f242..0f15fda36120bfacd5625a742f3ddf11d1d6846f 100644 (file)
@@ -1072,12 +1072,12 @@ powerpc-*-darwin*)
          md_unwind_header=rs6000/darwin-unwind.h
          ;;
        esac
-       tmake_file="$tmake_file rs6000/t-ibm-ldouble"
-       extra_parts="$extra_parts crt2.o libef_ppc.a"
+       tmake_file="$tmake_file rs6000/t-ppc64-fp rs6000/t-ibm-ldouble"
+       extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o"
        ;;
 powerpc64-*-darwin*)
        tmake_file="$tmake_file rs6000/t-darwin64 rs6000/t-ibm-ldouble"
-       extra_parts="$extra_parts crt2.o libef_ppc.a"
+       extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o"
        ;;
 powerpc*-*-freebsd*)
        tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff rs6000/t-freebsd t-softfp-sfdf t-softfp-excl t-softfp"
index 0c238b7a7e83c3c8291295e2139e6ea203f036e4..8b513bdb1d78b606d44b3f6da56527aea412fdbe 100644 (file)
@@ -1,7 +1,11 @@
-DARWIN_EXTRA_CRT_BUILD_CFLAGS = -mlongcall -mmacosx-version-min=10.4
 
 crt2.o: $(srcdir)/config/rs6000/darwin-crt2.c
-       $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -c $<
+       $(crt_compile) -mmacosx-version-min=10.1 -c $<
+
+# The sources for this indicate that there are some parts that
+# don't apply >= 10.4
+crt3_2.o: $(srcdir)/config/darwin-crt3.c
+       $(crt_compile) -mmacosx-version-min=10.1 -c $<
 
 # The outlined register save/restore functions need to run anywhere, and
 # they must be leaf functions suitable for use in an endfile.
@@ -32,10 +36,12 @@ libef_ppc.a: $(PPC_ENDFILE_OBJS)
        $(AR_CREATE_FOR_TARGET) $@ $(PPC_ENDFILE_OBJS)
        $(RANLIB_FOR_TARGET) $@
 
+dw_ppc.o: $(srcdir)/config/rs6000/darwin-world.S
+       $(crt_compile) -mmacosx-version-min=10.1 -c $<
+
 LIB2ADD = $(srcdir)/config/rs6000/darwin-tramp.S \
          $(srcdir)/config/darwin-64.c \
-         $(srcdir)/config/rs6000/darwin-world.S \
-         $(srcdir)/config/rs6000/ppc64-fp.c
+         $(srcdir)/config/rs6000/darwin-world.S
 
 # The .S files above are designed to run on all processors, even though
 # they use AltiVec instructions.
index 50f09d6de1aa8244220eaee64dc19a93e724b57c..999679fc3cbf9d1fcb62bbb8205b27749b0eac69 100644 (file)
@@ -1,7 +1 @@
 LIB2_SIDITI_CONV_FUNCS = yes
-
-LIB2ADD = $(srcdir)/config/rs6000/darwin-tramp.S \
-         $(srcdir)/config/darwin-64.c \
-         $(srcdir)/config/rs6000/darwin-fpsave.S \
-         $(srcdir)/config/rs6000/darwin-gpsave.S \
-         $(srcdir)/config/rs6000/darwin-world.S
index 2fcb712a060248cd218d2510367f8f73e2fb6872..3b5e342895815ba95caef0e77faec6934da5f852 100644 (file)
@@ -3,19 +3,13 @@
 HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.4
 
 crt3.o: $(srcdir)/config/darwin-crt3.c
-       $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -c $<
+       $(crt_compile) -mmacosx-version-min=10.4 -c $<
 
 crttms.o: $(srcdir)/config/darwin-crt-tm.c
-       $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -DSTART -c $<
+       $(crt_compile) -mmacosx-version-min=10.4 -DSTART -c $<
 
 crttme.o: $(srcdir)/config/darwin-crt-tm.c
-       $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -DEND -c $<
-
-# -pipe because there's an assembler bug, 4077127, which causes
-# it to not properly process the first # directive, causing temporary
-# file names to appear in stabs, causing the bootstrap to fail.  Using -pipe
-# works around this by not having any temporary file names.
-HOST_LIBGCC2_CFLAGS += -pipe
+       $(crt_compile) -mmacosx-version-min=10.4 -DEND -c $<
 
 # Use unwind-dw2-fde-darwin
 LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/config/unwind-dw2-fde-darwin.c \
@@ -23,4 +17,4 @@ LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/config/unwind-dw2-fde-darwin.c \
 
 # Patch to __Unwind_Find_Enclosing_Function for Darwin10.
 d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c
-       $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -mmacosx-version-min=10.6 -c $<
+       $(crt_compile) -mmacosx-version-min=10.6 -c $<