> 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 + \