Re: [PATCH] Fix target default on biarch Linux/Sparc

2011-10-14 Thread Eric Botcazou
 If you configure a biarch Linux/Sparc compiler defaulting to
 32-bit, but give --with-cpu= for a v9 cpu it erroneously
 turns on 64-bit in TARGET_DEFAULT.

PR target/50354 reports the breakage of the opposite case after the change:
configuring for sparc64-linux --with-cpu=v8 used to build a 32-bit compiler, 
now the build aborts because of an architecture mismatch.

 The right thing to do is what the Solaris/Sparc target does,
 which is to key things off of a cpp macro (TARGET_64BIT_DEFAULT)
 which is defined by a header that gets prepended to the target
 header list based upon the target triplet.

There is a discrepancy between Solaris and Linux: on Solaris, we don't support 
the weird sparc64-* --with-cpu=v8 combination, whereas it is the default for 
some Linux distros (e.g. Debian).  So we cannot have the full symmetry here.

Something like the attached patch would be sufficient.  What do you think?


PR target/50354
* config/sparc/linux64.h (TARGET_DEFAULT): Only override if the default
processor is at least V9 and TARGET_64BIT_DEFAULT is defined.


-- 
Eric Botcazou
Index: config/sparc/linux64.h
===
--- config/sparc/linux64.h	(revision 179894)
+++ config/sparc/linux64.h	(working copy)
@@ -31,7 +31,9 @@ along with GCC; see the file COPYING3.
 }		\
   while (0)
 
-#ifdef TARGET_64BIT_DEFAULT
+/* On Linux, the combination sparc64-* --with-cpu=v8 is supported and
+   selects a 32-bit compiler.  */
+#if defined(TARGET_64BIT_DEFAULT)  TARGET_CPU_DEFAULT = TARGET_CPU_v9
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT \
   (MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_STACK_BIAS + \


Re: [PATCH] Fix target default on biarch Linux/Sparc

2011-10-14 Thread David Miller
From: Eric Botcazou ebotca...@adacore.com
Date: Fri, 14 Oct 2011 20:27:03 +0200

 If you configure a biarch Linux/Sparc compiler defaulting to
 32-bit, but give --with-cpu= for a v9 cpu it erroneously
 turns on 64-bit in TARGET_DEFAULT.
 
 PR target/50354 reports the breakage of the opposite case after the change:
 configuring for sparc64-linux --with-cpu=v8 used to build a 32-bit compiler, 
 now the build aborts because of an architecture mismatch.

Thanks for looking into this Eric.

If one wants a 32-bit default compiler, they should build for the
sparc-linux target.  And this is absolutely trivial to make happen
in the environments where this is supposedly a problem.

We could allow it for compatability, but I'd prefer not to.


Re: [PATCH] Fix target default on biarch Linux/Sparc

2011-10-14 Thread Eric Botcazou
 If one wants a 32-bit default compiler, they should build for the
 sparc-linux target.  And this is absolutely trivial to make happen
 in the environments where this is supposedly a problem.

I have criticized so many times this combination in the past, while Jakub and 
also you IIRC were defending it, that I find it a bit strange that the table 
have been turned like that...

 We could allow it for compatability, but I'd prefer not to.

I beg to differ though.  Breaking backward compatibility should be the last 
resort solution; restoring it in this case appears to be totally harmless.

-- 
Eric Botcazou


Re: [PATCH] Fix target default on biarch Linux/Sparc

2011-10-14 Thread David Miller
From: Eric Botcazou ebotca...@adacore.com
Date: Fri, 14 Oct 2011 22:31:53 +0200

 If one wants a 32-bit default compiler, they should build for the
 sparc-linux target.  And this is absolutely trivial to make happen
 in the environments where this is supposedly a problem.
 
 I have criticized so many times this combination in the past, while Jakub and 
 also you IIRC were defending it, that I find it a bit strange that the table 
 have been turned like that...

The last time I discussed these kind of issues with you, I wanted us
to consider allowing the compiler to change it's output default based
upon the output of 'uname'.

This is effectively what Linux distributions on Sparc do, they provide
a special 'gcc' binary that looks at uname's output and munges the
command line to the real 'gcc' as needed.

If the primary users of gcc for this target are going to play these
games anyways, better to provide the facility in the gcc sources
itself.

Anyways, that is a seperate discussion.

 We could allow it for compatability, but I'd prefer not to.
 
 I beg to differ though.  Breaking backward compatibility should be the last 
 resort solution; restoring it in this case appears to be totally harmless.

Agreed, please install this patch if you haven't already.

Thanks Eric.


Re: [PATCH] Fix target default on biarch Linux/Sparc

2011-10-14 Thread Eric Botcazou
 Agreed, please install this patch if you haven't already.

Thanks, done after successfully bootstrapping on SPARC64/Linux.

-- 
Eric Botcazou


[PATCH] Fix target default on biarch Linux/Sparc

2011-09-05 Thread David Miller

If you configure a biarch Linux/Sparc compiler defaulting to
32-bit, but give --with-cpu= for a v9 cpu it erroneously
turns on 64-bit in TARGET_DEFAULT.

The right thing to do is what the Solaris/Sparc target does,
which is to key things off of a cpp macro (TARGET_64BIT_DEFAULT)
which is defined by a header that gets prepended to the target
header list based upon the target triplet.

Therefore I moved sol2-64.h to default-64.h and use it for Linux
biarch builds too when appropriate.

gcc/

* config/sparc/sol2-64.h: Move ...
* config/sparc/default-64.h: ... to here.  Update comment.
* config.gcc: Update Solaris sparc to use default-64.h, also
prefix this header into the list on sparc64-*-linux.
* config/sparc/linux64.h (TARGET_DEFAULT): Only override if
TARGET_64BIT_DEFAULT is defined.  Remove commented out reference
to MASK_HARD_QUAD.

Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 178557)
+++ gcc/config.gcc  (revision 178558)
@@ -2501,7 +2501,7 @@
tm_file=sparc/biarch64.h ${tm_file} ${sol2_tm_file} sol2-bi.h
case ${target} in
sparc64-*-* | sparcv9-*-*)
-   tm_file=sparc/sol2-64.h ${tm_file}
+   tm_file=sparc/default-64.h ${tm_file}
;;
*)
test x$with_cpu != x || with_cpu=v9
@@ -2523,7 +2523,7 @@
tmake_file=${tmake_file} t-rtems
;;
 sparc64-*-linux*)
-   tm_file=sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h 
gnu-user.h linux.h glibc-stdint.h sparc/linux64.h
+   tm_file=sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h 
gnu-user.h linux.h glibc-stdint.h sparc/default-64.h sparc/linux64.h
extra_options=${extra_options} sparc/long-double-switch.opt
tmake_file=${tmake_file} sparc/t-linux sparc/t-linux64
extra_parts=${extra_parts} crtfastmath.o
Index: gcc/config/sparc/sol2-64.h
===
--- gcc/config/sparc/sol2-64.h  (revision 178557)
+++ gcc/config/sparc/sol2-64.h  (revision 178558)
@@ -1,22 +0,0 @@
-/* Definitions of target machine for GCC, for bi-arch SPARC
-   running Solaris 2, defaulting to 64-bit code generation.
-
-   Copyright (C) 1999, 2010, 2011 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-http://www.gnu.org/licenses/.  */
-
-#define TARGET_64BIT_DEFAULT 1
Index: gcc/config/sparc/linux64.h
===
--- gcc/config/sparc/linux64.h  (revision 178557)
+++ gcc/config/sparc/linux64.h  (revision 178558)
@@ -31,20 +31,11 @@
 }  \
   while (0)
 
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara2 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara3 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara4
-/* A 64 bit v9 compiler with stack-bias,
-   in a Medium/Low code model environment.  */
-
+#ifdef TARGET_64BIT_DEFAULT
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT \
-  (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
-   + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
+  (MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_STACK_BIAS + \
+   MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
 #endif
 
 /* This must be v9a not just v9 because by default we enable
Index: gcc/config/sparc/default-64.h
===
--- gcc/config/sparc/default-64.h   (revision 0)
+++ gcc/config/sparc/default-64.h   (revision 178558)
@@ -0,0 +1,22 @@
+/* Definitions of target machine for GCC, for bi-arch SPARC,
+   defaulting to 64-bit code generation.
+
+   Copyright (C) 1999, 2010, 2011 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A