[RS6000] Use config/linux.h for powerpc*-*-linux*
authorAlan Modra <amodra@gmail.com>
Mon, 26 Nov 2018 23:53:56 +0000 (10:23 +1030)
committerAlan Modra <amodra@gcc.gnu.org>
Mon, 26 Nov 2018 23:53:56 +0000 (10:23 +1030)
Using the macros in config/linux.h rather than duplicating them helps
stop future bitrot, and repairs existing bitrot (4 choices for libc in
linux.h, fewer in the rs6000 files not that it matters much).  Also
fixes the fact that __gnu_linux__ was always defined rather than just
when glibc was the libc of choice.

* config.gcc (powerpc*-*-linux*): Add linux.h to tm_file.
* config/rs6000/linux.h (TARGET_OS_CPP_BUILTINS): Use
GNU_USER_TARGET_OS_CPP_BUILTINS.
(RS6000_ABI_NAME): Define.
* config/rs6000/linux64.h (TARGET_OS_CPP_BUILTINS): Use
GNU_USER_TARGET_OS_CPP_BUILTINS.
(MUSL_DYNAMIC_LINKER32): Undef before defining.
(UCLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER64): Don't define.
(CHOOSE_DYNAMIC_LINKER): Don't define.
(GNU_USER_DYNAMIC_LINKER32, GNU_USER_DYNAMIC_LINKER64): Don't define.
* config/rs6000/sysv4.h (MUSL_DYNAMIC_LINKER): Undef before defining.
(CHOOSE_DYNAMIC_LINKER, GNU_USER_DYNAMIC_LINKER): Only define when
not already defined.
(CPP_OS_LINUX_SPEC): Remove defines and asserts handled by
TARGET_OS_CPP_BUILTINS.

From-SVN: r266493

gcc/ChangeLog
gcc/config.gcc
gcc/config/rs6000/linux.h
gcc/config/rs6000/linux64.h
gcc/config/rs6000/sysv4.h

index fd5e8c292a41fb84a37f7e2be23f134edec0ed42..19a802c6c7200725b6733452326e06ae5e893b65 100644 (file)
@@ -1,3 +1,21 @@
+2018-11-27  Alan Modra  <amodra@gmail.com>
+
+       * config.gcc (powerpc*-*-linux*): Add linux.h to tm_file.
+       * config/rs6000/linux.h (TARGET_OS_CPP_BUILTINS): Use
+       GNU_USER_TARGET_OS_CPP_BUILTINS.
+       (RS6000_ABI_NAME): Define.
+       * config/rs6000/linux64.h (TARGET_OS_CPP_BUILTINS): Use
+       GNU_USER_TARGET_OS_CPP_BUILTINS.
+       (MUSL_DYNAMIC_LINKER32): Undef before defining.
+       (UCLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER64): Don't define.
+       (CHOOSE_DYNAMIC_LINKER): Don't define.
+       (GNU_USER_DYNAMIC_LINKER32, GNU_USER_DYNAMIC_LINKER64): Don't define.
+       * config/rs6000/sysv4.h (MUSL_DYNAMIC_LINKER): Undef before defining.
+       (CHOOSE_DYNAMIC_LINKER, GNU_USER_DYNAMIC_LINKER): Only define when
+       not already defined.
+       (CPP_OS_LINUX_SPEC): Remove defines and asserts handled by
+       TARGET_OS_CPP_BUILTINS.
+
 2018-11-26  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
 
        * doc/sourcebuild.texi: Document check_effective_target_newlib_nano_io.
index 8525cb5cb139bf3e1b76abec8e591813c16d40b7..00906fc477dae42284a175fb9915b8bbce18be79 100644 (file)
@@ -2643,7 +2643,7 @@ powerpc*-*-linux*spe*)
        tm_file="${tm_file} powerpcspe/linuxspe.h powerpcspe/e500.h"
        ;;
 powerpc*-*-linux*)
-       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h freebsd-spec.h rs6000/sysv4.h"
+       tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h freebsd-spec.h rs6000/sysv4.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-ppccomm"
        extra_objs="$extra_objs rs6000-linux.o"
index fd06b14d837ea9c8472cafc1e529486294c1fadf..29653c1345573bb43f39147f824adf6ff411f630 100644 (file)
 #define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function
 
 #undef  TARGET_OS_CPP_BUILTINS
-#define TARGET_OS_CPP_BUILTINS()               \
-  do                                           \
-    {                                          \
-      builtin_define_std ("PPC");              \
-      builtin_define_std ("powerpc");          \
-      builtin_assert ("cpu=powerpc");          \
-      builtin_assert ("machine=powerpc");      \
-      TARGET_OS_SYSV_CPP_BUILTINS ();          \
-    }                                          \
+#define TARGET_OS_CPP_BUILTINS()                       \
+  do                                                   \
+    {                                                  \
+      if (strcmp (rs6000_abi_name, "linux") == 0)      \
+       GNU_USER_TARGET_OS_CPP_BUILTINS();              \
+      builtin_define_std ("PPC");                      \
+      builtin_define_std ("powerpc");                  \
+      builtin_assert ("cpu=powerpc");                  \
+      builtin_assert ("machine=powerpc");              \
+      TARGET_OS_SYSV_CPP_BUILTINS ();                  \
+    }                                                  \
   while (0)
 
 #define GNU_USER_TARGET_D_OS_VERSIONS()                \
 #define RELOCATABLE_NEEDS_FIXUP \
   (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
 
+#undef RS6000_ABI_NAME
+#define        RS6000_ABI_NAME "linux"
+
 #ifdef TARGET_LIBC_PROVIDES_SSP
 /* ppc32 glibc provides __stack_chk_guard in -0x7008(2).  */
 #define TARGET_THREAD_SSP_OFFSET       -0x7008
index 0d8e164a598a12cbf4202d3d0e90fec4ba46d6a8..b1818b43cf465005993b666399e15f6d3815e0c1 100644 (file)
@@ -369,6 +369,8 @@ extern int dot_symbols;
 #define TARGET_OS_CPP_BUILTINS()                       \
   do                                                   \
     {                                                  \
+      if (strcmp (rs6000_abi_name, "linux") == 0)      \
+       GNU_USER_TARGET_OS_CPP_BUILTINS();              \
       if (TARGET_64BIT)                                        \
        {                                               \
          builtin_define ("__PPC__");                   \
@@ -438,32 +440,13 @@ extern int dot_symbols;
 ":%(dynamic_linker_prefix)/lib64/ld64.so.1}"
 #endif
 
+#undef MUSL_DYNAMIC_LINKER32
 #define MUSL_DYNAMIC_LINKER32 \
   "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+#undef MUSL_DYNAMIC_LINKER64
 #define MUSL_DYNAMIC_LINKER64 \
   "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
 
-#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
-#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
-#if DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
-  "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
-#elif DEFAULT_LIBC == LIBC_GLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
-  "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
-#elif DEFAULT_LIBC == LIBC_MUSL
-#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
-  "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
-#else
-#error "Unsupported DEFAULT_LIBC"
-#endif
-#define GNU_USER_DYNAMIC_LINKER32 \
-  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
-                        MUSL_DYNAMIC_LINKER32)
-#define GNU_USER_DYNAMIC_LINKER64 \
-  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
-                        MUSL_DYNAMIC_LINKER64)
-
 #undef  DEFAULT_ASM_ENDIAN
 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
 #define DEFAULT_ASM_ENDIAN " -mlittle"
index 0c676349cf72e602ff65cd20a955c32a06c47d10..73541af3e69a9a72488ce3adb76732af68b3bf6e 100644 (file)
@@ -786,8 +786,10 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 
 #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 "}}"
@@ -803,6 +805,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 #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} \
@@ -812,12 +815,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 # define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
 #endif
 
-#define CPP_OS_LINUX_SPEC "-D__unix__ -D__gnu_linux__ -D__linux__ \
-%{!undef:                                                        \
-  %{!ansi:                                                       \
-    %{!std=*:-Dunix -D__unix -Dlinux -D__linux}                          \
-    %{std=gnu*:-Dunix -D__unix -Dlinux -D__linux}}}              \
--Asystem=linux -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}"
+#define CPP_OS_LINUX_SPEC "%{pthread:-D_REENTRANT}"
 
 /* NetBSD support.  */
 #define LIB_NETBSD_SPEC "\