Hello,

using the -mcall-linux option on powerpc64le-linux (which should be a no-op)
currently causes the compiler driver to pass -mbig to the linker.  Likewise,
using -mcall-aixdesc (which is allowed when also using -mabi=elfv1, like
certain versions of the Linux kernel do), causes the compiler driver to
pass -mbig to the linker.

While in both cases the incorrect effect can be worked around by using an
explicit -mlittle-endian, this should not be required in a compiler built
for the powerpc64le-linux target.

The reason for this behaviour is use of an ENDIAN_SELECT statement in
ASM_SPEC as defined in sysv4.h, and this ENDIAN_SELECT macro hard-codes
certain byte orders in response to various -mcall- options:
 big-endian for -mcall-aixdesc, -mcall-{free,net,open}bsd and -mcall-linux;
 little-endian for -mcall-i960-old.

Interestingly enough, for the big-endian cases above, this affects only
the *assembler*; the compiler itself will not switch endianness.  However,
for -mcall-i960-old, there is code in SUBTARGET_OVERRIDE_OPTIONS to also
switch the compiler's byte order.

I'm not 100% sure what to do about -mcall-i960-old, but at least the
behaviour is self-consistent, so I left it alone for now.

However, -mcall-aixdesc, -mcall-linux (and possibly in the future
also -mcall-*bsd) should clearly not imply a particular byte order,
and don't work in a consistent manner on little-endian systems today
anyway, so the patch below removes this clause from ENDIAN_SELECT.

As a side-effect, I noticed that there apparently was some attempt
in the past to pass endian options to cc1, as evidenced by specs
substrings like %cc1_endian_default.  However, the current set of
header files never defines any of those specs to any non-empty
value, so this patch removes all of them as well.

Tested on powerpc64-linux (-m64/-m32) and powerpc64le-linux.

OK for mainline?

Bye,
Ulrich


ChangeLog:

        * config/rs6000/sysv4.h (ENDIAN_SELECT): Do not attempt to enforce
        big-endian mode for -mcall-aixdesc, -mcall-freebsd, -mcall-netbsd,
        -mcall-openbsd, or -mcall-linux.
        (CC1_ENDIAN_BIG_SPEC): Remove.
        (CC1_ENDIAN_LITTLE_SPEC): Remove.
        (CC1_ENDIAN_DEFAULT_SPEC): Remove.
        (CC1_SPEC): Remove (always empty) %cc1_endian_... spec.
        (SUBTARGET_EXTRA_SPECS): Remove %cc1_endian_big, %cc1_endian_little,
        and %cc1_endian_default.
        * config/rs6000/sysv4le.h (CC1_ENDIAN_DEFAULT_SPEC): Remove.

Index: gcc/config/rs6000/sysv4le.h
===================================================================
--- gcc/config/rs6000/sysv4le.h (revision 207578)
+++ gcc/config/rs6000/sysv4le.h (working copy)
@@ -22,9 +22,6 @@
 #undef  TARGET_DEFAULT
 #define TARGET_DEFAULT MASK_LITTLE_ENDIAN
 
-#undef CC1_ENDIAN_DEFAULT_SPEC
-#define        CC1_ENDIAN_DEFAULT_SPEC "%(cc1_endian_little)"
-
 #undef DEFAULT_ASM_ENDIAN
 #define        DEFAULT_ASM_ENDIAN " -mlittle"
 
Index: gcc/config/rs6000/sysv4.h
===================================================================
--- gcc/config/rs6000/sysv4.h   (revision 207578)
+++ gcc/config/rs6000/sysv4.h   (working copy)
@@ -522,8 +522,6 @@
 #define ENDIAN_SELECT(BIG_OPT, LITTLE_OPT, DEFAULT_OPT)        \
 "%{mlittle|mlittle-endian:"    LITTLE_OPT ";"  \
   "mbig|mbig-endian:"          BIG_OPT    ";"  \
-  "mcall-aixdesc|mcall-freebsd|mcall-netbsd|"  \
-  "mcall-openbsd|mcall-linux:" BIG_OPT    ";"  \
   "mcall-i960-old:"            LITTLE_OPT ";"  \
   ":"                          DEFAULT_OPT "}"
 
@@ -536,20 +534,12 @@
 %{memb|msdata=eabi: -memb}" \
 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 
-#define        CC1_ENDIAN_BIG_SPEC ""
-
-#define        CC1_ENDIAN_LITTLE_SPEC ""
-
-#define        CC1_ENDIAN_DEFAULT_SPEC "%(cc1_endian_big)"
-
 #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
 #define CC1_SECURE_PLT_DEFAULT_SPEC ""
 #endif
 
-/* Pass -G xxx to the compiler and set correct endian mode.  */
+/* Pass -G xxx to the compiler.  */
 #define        CC1_SPEC "%{G*} %(cc1_cpu)" \
-  ENDIAN_SELECT(" %(cc1_endian_big)", " %(cc1_endian_little)", \
-               " %(cc1_endian_default)")                       \
 "%{meabi: %{!mcall-*: -mcall-sysv }} \
 %{!meabi: %{!mno-eabi: \
     %{mrelocatable: -meabi } \
@@ -903,9 +893,6 @@
   { "link_os_netbsd",          LINK_OS_NETBSD_SPEC },                  \
   { "link_os_openbsd",         LINK_OS_OPENBSD_SPEC },                 \
   { "link_os_default",         LINK_OS_DEFAULT_SPEC },                 \
-  { "cc1_endian_big",          CC1_ENDIAN_BIG_SPEC },                  \
-  { "cc1_endian_little",       CC1_ENDIAN_LITTLE_SPEC },               \
-  { "cc1_endian_default",      CC1_ENDIAN_DEFAULT_SPEC },              \
   { "cc1_secure_plt_default",  CC1_SECURE_PLT_DEFAULT_SPEC },          \
   { "cpp_os_ads",              CPP_OS_ADS_SPEC },                      \
   { "cpp_os_yellowknife",      CPP_OS_YELLOWKNIFE_SPEC },              \
-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com

Reply via email to