This patch removes some duplication in rs6000/sysv4.h of macros found
in gnu-user.h that we want for linux.  Including gnu-user.h will mean
powerpc doesn't miss updates to that file.

Requires https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00917.html and
https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00919.html

Bootstrapped etc. powerpc-linux and powerpc64le-linux.

        * config.gcc (powerpc*-*-freebsd*, powerpc-*-netbsd*),
        (powerpc-*-eabisimaltivec*, powerpc-*-eabisim*, powerpc-*-elf*),
        (powerpc-*-eabialtivec*, powerpc-*-eabi*, powerpc-*-rtems*),
        (powerpc-wrs-vxworks*, powerpc-*-lynxos*, powerpcle-*-elf*),
        (powerpcle-*-eabisim*, powerpcle-*-eabi*): Add gnu-user.h to tm_file.
        * config/rs6000/freebsd.h (CPLUSPLUS_CPP_SPEC),
        (LINK_GCC_C_SEQUENCE_SPEC): Undef.
        (ASM_APP_ON, ASM_APP_OFF): Don't define.
        * config/rs6000/freebsd64.h (ASM_APP_ON, ASM_APP_OFF): Don't define.
        * config/rs6000/lynx.h (ASM_APP_ON, ASM_APP_OFF): Don't define.
        * config/rs6000/linux64.h (LINK_GCC_C_SEQUENCE_SPEC): Define.
        * config/rs6000/netbsd.h (CPLUSPLUS_CPP_SPEC),
        (LINK_GCC_C_SEQUENCE_SPEC): Undef.
        * config/rs6000/rtems.h (LINK_GCC_C_SEQUENCE_SPEC): Define.
        * config/rs6000/sysv4.h (GNU_USER_TARGET_CRTI): Redefine.
        (GNU_USER_TARGET_CRTN): Redefine.
        (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
        (LIB_LINUX_SPEC): Use GNU_USER_TARGET_LIB_SPEC.
        (CRTOFFLOADBEGIN, CRTOFFLOADEND): Don't define.
        (STARTFILE_LINUX_SPEC): Define as GNU_USER_TARGET_STARTFILE_SPEC.
        (ENDFILE_LINUX_SPEC): Define as GNU_USER_TARGET_ENDFILE_SPEC.
        (UCLIBC_DYNAMIC_LINKER, CHOOSE_DYNAMIC_LINKER): Don't define.
        (LINK_EH_SPEC): Don't define.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 75ff2f5658e..6aea55207ca 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2567,7 +2567,7 @@ powerpc64-*-darwin*)
        extra_headers=altivec.h
        ;;
 powerpc*-*-freebsd*)
-       tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file} rs6000/sysv4.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h ${fbsd_tm_file} 
rs6000/sysv4.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="rs6000/t-fprules rs6000/t-ppcos ${tmake_file} 
rs6000/t-ppccomm"
        case ${target} in
@@ -2582,7 +2582,7 @@ powerpc*-*-freebsd*)
        esac
        ;;
 powerpc-*-netbsd*)
-       tm_file="${tm_file} dbxelf.h elfos.h ${nbsd_tm_file} freebsd-spec.h 
rs6000/sysv4.h rs6000/netbsd.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h ${nbsd_tm_file} 
freebsd-spec.h rs6000/sysv4.h rs6000/netbsd.h"
        extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
        tmake_file="${tmake_file} rs6000/t-netbsd"
        extra_options="${extra_options} rs6000/sysv4.opt"
@@ -2594,30 +2594,30 @@ powerpc-*-eabispe*)
        use_gcc_stdint=wrap
        ;;
 powerpc-*-eabisimaltivec*)
-       tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h newlib-stdint.h 
rs6000/sysv4.h rs6000/eabi.h rs6000/eabisim.h rs6000/eabialtivec.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/eabisim.h 
rs6000/eabialtivec.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="rs6000/t-fprules rs6000/t-ppcendian rs6000/t-ppccomm"
        use_gcc_stdint=wrap
        ;;
 powerpc-*-eabisim*)
-       tm_file="${tm_file} dbxelf.h elfos.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/eabisim.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/eabisim.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
        use_gcc_stdint=wrap
        ;;
 powerpc-*-elf*)
-       tm_file="${tm_file} dbxelf.h elfos.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
        ;;
 powerpc-*-eabialtivec*)
-       tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h newlib-stdint.h 
rs6000/sysv4.h rs6000/eabi.h rs6000/eabialtivec.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/eabialtivec.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="rs6000/t-fprules rs6000/t-ppcendian rs6000/t-ppccomm"
        use_gcc_stdint=wrap
        ;;
 powerpc-*-eabi*)
-       tm_file="${tm_file} dbxelf.h elfos.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
        use_gcc_stdint=wrap
@@ -2628,7 +2628,7 @@ powerpc-*-rtems*spe*)
        tmake_file="${tmake_file} powerpcspe/t-fprules powerpcspe/t-rtems 
powerpcspe/t-ppccomm"
        ;;
 powerpc-*-rtems*)
-       tm_file="rs6000/biarch64.h ${tm_file} dbxelf.h elfos.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/rtems.h rtems.h"
+       tm_file="rs6000/biarch64.h ${tm_file} dbxelf.h elfos.h gnu-user.h 
freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/rtems.h rtems.h"
        extra_options="${extra_options} rs6000/sysv4.opt rs6000/linux64.opt"
        tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-rtems 
rs6000/t-ppccomm"
        ;;
@@ -2727,7 +2727,7 @@ powerpc-wrs-vxworks*spe)
        tm_file="${tm_file} vx-common.h vxworks.h powerpcspe/vxworks.h 
powerpcspe/e500.h"
        ;;
 powerpc-wrs-vxworks*)
-       tm_file="${tm_file} elfos.h freebsd-spec.h rs6000/sysv4.h"
+       tm_file="${tm_file} elfos.h gnu-user.h freebsd-spec.h rs6000/sysv4.h"
        tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-ppccomm 
rs6000/t-vxworks"
        extra_options="${extra_options} rs6000/sysv4.opt"
        extra_headers=ppc-asm.h
@@ -2747,7 +2747,7 @@ powerpc-wrs-vxworks*)
        ;;
 powerpc-*-lynxos*)
        xm_defines=POSIX
-       tm_file="${tm_file} dbxelf.h elfos.h rs6000/sysv4.h rs6000/lynx.h 
lynx.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h rs6000/sysv4.h 
rs6000/lynx.h lynx.h"
        tmake_file="t-lynx rs6000/t-lynx"
        extra_options="${extra_options} rs6000/sysv4.opt lynx.opt"
        thread_file=lynx
@@ -2755,18 +2755,18 @@ powerpc-*-lynxos*)
        gas=yes
        ;;
 powerpcle-*-elf*)
-       tm_file="${tm_file} dbxelf.h elfos.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h"
        tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
        extra_options="${extra_options} rs6000/sysv4.opt"
        ;;
 powerpcle-*-eabisim*)
-       tm_file="${tm_file} dbxelf.h elfos.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h rs6000/eabisim.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h rs6000/eabisim.h"
        tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
        extra_options="${extra_options} rs6000/sysv4.opt"
        use_gcc_stdint=wrap
        ;;
 powerpcle-*-eabi*)
-       tm_file="${tm_file} dbxelf.h elfos.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h usegas.h freebsd-spec.h 
newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h"
        tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
        extra_options="${extra_options} rs6000/sysv4.opt"
        use_gcc_stdint=wrap
diff --git a/gcc/config/rs6000/freebsd.h b/gcc/config/rs6000/freebsd.h
index 53ae40d75b7..5947eff2a1b 100644
--- a/gcc/config/rs6000/freebsd.h
+++ b/gcc/config/rs6000/freebsd.h
@@ -18,6 +18,10 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+/* Undef gnu-user.h macros we don't want.  */
+#undef CPLUSPLUS_CPP_SPEC
+#undef LINK_GCC_C_SEQUENCE_SPEC
+
 /* Override the defaults, which exist to force the proper definition.  */
 
 #undef CPP_OS_DEFAULT_SPEC
@@ -59,14 +63,6 @@
 #undef  WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
 
-/* Override rs6000.h definition.  */
-#undef  ASM_APP_ON
-#define ASM_APP_ON "#APP\n"
-
-/* Override rs6000.h definition.  */
-#undef  ASM_APP_OFF
-#define ASM_APP_OFF "#NO_APP\n"
-
 /* We don't need to generate entries in .fixup, except when
    -mrelocatable or -mrelocatable-lib is given.  */
 #undef RELOCATABLE_NEEDS_FIXUP
diff --git a/gcc/config/rs6000/freebsd64.h b/gcc/config/rs6000/freebsd64.h
index fd3dea5ab89..985f730d764 100644
--- a/gcc/config/rs6000/freebsd64.h
+++ b/gcc/config/rs6000/freebsd64.h
@@ -306,15 +306,6 @@ extern int dot_symbols;
 #undef  WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
 
-
-/* Override rs6000.h definition.  */
-#undef  ASM_APP_ON
-#define ASM_APP_ON "#APP\n"
-
-/* Override rs6000.h definition.  */
-#undef  ASM_APP_OFF
-#define ASM_APP_OFF "#NO_APP\n"
-
 /* Function profiling bits */
 #undef  RS6000_MCOUNT
 #define RS6000_MCOUNT "_mcount"
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index b1818b43cf4..a9aae81a906 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -478,6 +478,13 @@ extern int dot_symbols;
     -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
   %(link_os_extra_spec64)"
 
+/* Use gnu-user.h LINK_GCC_SEQUENCE_SPEC for linux.  */
+#undef LINK_GCC_C_SEQUENCE_SPEC
+#define        LINK_GCC_C_SEQUENCE_SPEC \
+  "%{mads|myellowknife|mmvme|msim:%G %L %G;" \
+  "!mcall-*|mcall-linux:" GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC ";" \
+  ":%G %L %G}"
+
 #undef  TOC_SECTION_ASM_OP
 #define TOC_SECTION_ASM_OP \
   (TARGET_64BIT                                                \
diff --git a/gcc/config/rs6000/lynx.h b/gcc/config/rs6000/lynx.h
index 9e2bb723a92..526494fd834 100644
--- a/gcc/config/rs6000/lynx.h
+++ b/gcc/config/rs6000/lynx.h
@@ -71,16 +71,6 @@
     }                                          \
   while (0)
 
-/* Override the rs6000.h definition.  */
-
-#undef ASM_APP_ON
-#define ASM_APP_ON "#APP\n"
-
-/* Override the rs6000.h definition.  */
-
-#undef ASM_APP_OFF
-#define ASM_APP_OFF "#NO_APP\n"
-
 /* LynxOS does not do anything with .fixup plus let's not create
    writable section for linkonce.r and linkonce.t.  */
 
diff --git a/gcc/config/rs6000/netbsd.h b/gcc/config/rs6000/netbsd.h
index f4c1dd411bb..acc511d64a5 100644
--- a/gcc/config/rs6000/netbsd.h
+++ b/gcc/config/rs6000/netbsd.h
@@ -19,6 +19,10 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+/* Undef gnu-user.h macros we don't want.  */
+#undef CPLUSPLUS_CPP_SPEC
+#undef LINK_GCC_C_SEQUENCE_SPEC
+
 #undef  TARGET_OS_CPP_BUILTINS /* FIXME: sysv4.h should not define this! */
 #define TARGET_OS_CPP_BUILTINS()               \
   do                                           \
diff --git a/gcc/config/rs6000/rtems.h b/gcc/config/rs6000/rtems.h
index 54ddcb4b552..0ac9bfb0ffc 100644
--- a/gcc/config/rs6000/rtems.h
+++ b/gcc/config/rs6000/rtems.h
@@ -288,3 +288,10 @@
   { "asm_spec64",              ASM_SPEC64 },                           \
   { "link_os_spec32",          LINK_OS_SPEC32 },                       \
   { "link_os_spec64",          LINK_OS_SPEC64 },
+
+/* Use gnu-user.h LINK_GCC_SEQUENCE_SPEC for rtems.  */
+#undef LINK_GCC_C_SEQUENCE_SPEC
+#define        LINK_GCC_C_SEQUENCE_SPEC \
+  "%{mads|myellowknife|mmvme|msim:%G %L %G;" \
+  "!mcall-*|mcall-linux:" GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC ";" \
+  ":%G %L %G}"
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index 73541af3e69..0d84f4f3f57 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -23,6 +23,11 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#undef GNU_USER_TARGET_CRTI
+#define GNU_USER_TARGET_CRTI "%{mnewlib:ecrti.o%s;:crti.o%s}"
+#undef GNU_USER_TARGET_CRTN
+#define GNU_USER_TARGET_CRTN "%{mnewlib:ecrtn.o%s;:crtn.o%s}"
+
 /* Yes!  We are ELF.  */
 #define        TARGET_OBJECT_FORMAT OBJECT_ELF
 
@@ -556,8 +561,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
     %{mcall-openbsd: -mno-eabi }}} \
 %{msdata: -msdata=default} \
 %{mno-sdata: -msdata=none} \
-%{!mbss-plt: %{!msecure-plt: %(cc1_secure_plt_default)}} \
-%{profile: -p}"
+%{!mbss-plt: %{!msecure-plt: %(cc1_secure_plt_default)}}" \
+GNU_USER_TARGET_CC1_SPEC
 
 /* Default starting address if specified.  */
 #define LINK_START_SPEC "\
@@ -739,82 +744,27 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
   %{symbolic:-Bsymbolic}"
 
 /* GNU/Linux support.  */
-#define LIB_LINUX_SPEC "%{mnewlib: --start-group -llinux -lc --end-group } \
-%{!mnewlib: %{pthread:-lpthread} %{shared:-lc} \
-%{!shared: %{profile:-lc_p} %{!profile:-lc}}}"
+#define LIB_LINUX_SPEC \
+  "%{mnewlib: --start-group -llinux -lc --end-group; \
+     :" GNU_USER_TARGET_LIB_SPEC "}"
 
-#if ENABLE_OFFLOADING == 1
-#define CRTOFFLOADBEGIN "%{fopenacc|fopenmp:crtoffloadbegin%O%s}"
-#define CRTOFFLOADEND "%{fopenacc|fopenmp:crtoffloadend%O%s}"
-#else
-#define CRTOFFLOADBEGIN ""
-#define CRTOFFLOADEND ""
-#endif
+#define        STARTFILE_LINUX_SPEC GNU_USER_TARGET_STARTFILE_SPEC
 
-/* STARTFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_STARTFILE_SPEC
-   but with the mnewlib ecrti.o%s selection substituted for crti.o%s.  */
-#define        STARTFILE_LINUX_SPEC \
-  "%{shared:; \
-     pg|p|profile:gcrt1.o%s; \
-     static:crt1.o%s; \
-     static-pie|" PIE_SPEC ":Scrt1.o%s; \
-     :crt1.o%s} \
-   %{mnewlib:ecrti.o%s;:crti.o%s} \
-   %{static:crtbeginT.o%s; \
-     shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
-     :crtbegin.o%s} \
-   %{fvtable-verify=none:%s; \
-     fvtable-verify=preinit:vtv_start_preinit.o%s; \
-     fvtable-verify=std:vtv_start.o%s} \
-   " CRTOFFLOADBEGIN
-
-/* ENDFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_ENDFILE_SPEC
-   but with the mnewlib ecrtn.o%s selection substituted for crtn.o%s.  */
-#define ENDFILE_LINUX_SPEC \
-  "%{fvtable-verify=none:%s; \
-     fvtable-verify=preinit:vtv_end_preinit.o%s; \
-     fvtable-verify=std:vtv_end.o%s} \
-   %{static:crtend.o%s; \
-     shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
-     :crtend.o%s} \
-   %{mnewlib:ecrtn.o%s;:crtn.o%s} \
-   " CRTOFFLOADEND
+#define ENDFILE_LINUX_SPEC GNU_USER_TARGET_ENDFILE_SPEC
 
 #define LINK_START_LINUX_SPEC ""
 
 #define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
 
 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
 #undef MUSL_DYNAMIC_LINKER
 #define MUSL_DYNAMIC_LINKER \
   "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
-#ifndef GNU_USER_DYNAMIC_LINKER
-#if DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
-  "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
-#elif DEFAULT_LIBC == LIBC_MUSL
-#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
-  "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
-#elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
-  "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
-#else
-#error "Unsupported DEFAULT_LIBC"
-#endif
-#define GNU_USER_DYNAMIC_LINKER \
-  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
-                        MUSL_DYNAMIC_LINKER)
-#endif
 
 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
   %{rdynamic:-export-dynamic} \
   -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
 
-#if defined(HAVE_LD_EH_FRAME_HDR)
-# define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
-#endif
-
 #define CPP_OS_LINUX_SPEC "%{pthread:-D_REENTRANT}"
 
 /* NetBSD support.  */

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to