From: Alan Modra Date: Mon, 26 Nov 2018 23:53:56 +0000 (+1030) Subject: [RS6000] Use config/linux.h for powerpc*-*-linux* X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=426a04b84f4fed696149d8ba980dd48c6eb49de7;p=gcc.git [RS6000] Use config/linux.h for powerpc*-*-linux* 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fd5e8c292a4..19a802c6c72 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2018-11-27 Alan Modra + + * 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 * doc/sourcebuild.texi: Document check_effective_target_newlib_nano_io. diff --git a/gcc/config.gcc b/gcc/config.gcc index 8525cb5cb13..00906fc477d 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -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" diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h index fd06b14d837..29653c13455 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h @@ -46,15 +46,17 @@ #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() \ @@ -126,6 +128,9 @@ #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 diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 0d8e164a598..b1818b43cf4 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -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" diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 0c676349cf7..73541af3e69 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -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 "\