diff mbox series

Define __sparcv8 in 64-bit-default Solaris/SPARC gcc with -m32

Message ID ydd36otf9qw.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series Define __sparcv8 in 64-bit-default Solaris/SPARC gcc with -m32 | expand

Commit Message

Rainer Orth Feb. 12, 2019, 12:53 p.m. UTC
I noticed that a 64-bit-default Solaris/SPARC gcc with -m32 doesn't
predefine __sparcv8, unlike the corresponding 32-bit-default compiler.

Since those defines happen in CPP_CPU_SPEC for any explicit -mcpu option
of v8, supersparc, v9 and beyond, this must be due to -mcpu being set in
the driver of the 32-bit compiler, but not in the 64-bit one.

Indeed, I find

	-mcpu=v9

in COLLECT_GCC_OPTIONS of the 32-bit compiler, but only

	-m32

for the 64-bit one.

AFAICS this happens due to OPTION_DEFAULT_SPECS: it includes

  {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \

for 32-bit-default and for 64-bit-default:

  {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \

Without an explicit --with-cpu configure option, config.gcc sets
with_cpu=v9 for both 32 and 64-bit sparc compilers.  For the sparcv9 gcc
with -m32 however, the passing of -mcpu=v9 is suppressed by the second
spec above.

In line with the handling of --with-tune/-mtune below, -mcpu should be
the same when no explicit -mcpu is given, irrespective of -m32 or -m64.

The following patch just removes those guards.  Bootstrapped without
regressions on sparcv9-sun-solaris2.11 and sparc-sun-solaris2.11.
Besides, I've compared the output of

	gcc -m32/-m64 -g3 -E -x c /dev/null

Before the patch, -D__sparcv8 was missing in the sparcv9 gcc's -m32
case, now -m32 and -m64 output is identical between sparc and sparcv9
compilers.

Eric, could you have another look if I'm missing something?  Otherwise,
I'm going to commit the patch (it's necessary to enable
SANITIZER_CAN_FAST_UNWIND on Solaris/SPARC and make use of
libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cc).

	Rainer

Comments

Eric Botcazou Feb. 13, 2019, 8:40 a.m. UTC | #1
> Eric, could you have another look if I'm missing something?

Note that this OPTION_DEFAULT_SPECS code is duplicated in linux64.h.

There is this comment:

   In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
   here, otherwise say -mcpu=v7 would be passed even when -m64.
   CC1_SPEC above takes care of this instead.

Why does CC1_SPEC not work apparently?

> Otherwise, I'm going to commit the patch (it's necessary to enable
> SANITIZER_CAN_FAST_UNWIND on Solaris/SPARC and make use of
> libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cc).

No, it will not be necessary, I have ported the implementation to 64-bit.
diff mbox series

Patch

# HG changeset patch
# Parent  c72a287bd21743e4d6759e58a6adc3ad5e30d52c
Define __sparcv8 in 64-bit-default Solaris/SPARC gcc with -m32

diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h
--- a/gcc/config/sparc/sol2.h
+++ b/gcc/config/sparc/sol2.h
@@ -273,7 +273,7 @@  extern const char *host_detect_local_cpu
 #define OPTION_DEFAULT_SPECS \
   {"cpu_32", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
   {"cpu_64", "%{m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
-  {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+  {"cpu", "%{!mcpu=*:-mcpu=%(VALUE)}" }, \
   {"tune_32", "%{!m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
   {"tune_64", "%{m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
   {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
@@ -282,7 +282,7 @@  extern const char *host_detect_local_cpu
 #define OPTION_DEFAULT_SPECS \
   {"cpu_32", "%{m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
   {"cpu_64", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
-  {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+  {"cpu", "%{!mcpu=*:-mcpu=%(VALUE)}" }, \
   {"tune_32", "%{m32:%{!mtune=*:-mtune=%(VALUE)}}" },	\
   {"tune_64", "%{!m32:%{!mtune=*:-mtune=%(VALUE)}}" },	\
   {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \