As already noted in the Solaris configuration cleanup patch, the ASM_SPEC handling on Solaris can be simplified. This patch does this, also as a prerequisite for a followup to provide a 64-bit default Solaris/x86 configuration.
The basic observation is that there's a common part handled by both Sun as and GNU as, and parts that are assembler-specific. The common part now lives in config/sol2.h (ASM_SPEC_BASE), and I also define ASM_PIC_SPEC there. In theory, this is understood by Sun as everywhere, but GNU as only handles it on SPARC. In practice, Sun as on Solaris/x86 warns about various constructs with -K PIC which makes the option useless. I'm moving the 32-bit vs. 64-bit handling on Solaris/x86 to ASM_CPU_SPEC which already used for that purpose on SPARC. Bootstrapped on i386-pc-solaris2.10, i386-pc-solaris2.11, and sparc-sun-solaris2.11 with Sun as/ld, GNU as/Sun ld, and GNU as/ld without regressions. Will commit shortly together with the amd64-pc-solaris2.1? patch Rainer 2011-07-02 Rainer Orth <r...@cebitec.uni-bielefeld.de> * config/sol2.h (ASM_SPEC): Split into ... (ASM_SPEC_BASE, ASM_PIC_SPEC): ... this. * config/i386/sol2.h (ASM_SPEC): Define using ASM_SPEC_BASE. * config/i386/sol2-bi.h (ASM_CPU_SPEC): Redefine. (ASM_SPEC): Use ASM_SPEC_BASE. * config/sparc/sol2.h (ASM_SPEC): Redefine. diff --git a/gcc/config/i386/sol2-bi.h b/gcc/config/i386/sol2-bi.h --- a/gcc/config/i386/sol2-bi.h +++ b/gcc/config/i386/sol2-bi.h @@ -31,13 +31,20 @@ along with GCC; see the file COPYING3. /* GNU as understands --32 and --64, but the native Solaris assembler requires -xarch=generic or -xarch=generic64 instead. */ +#undef ASM_CPU_SPEC +#ifdef USE_GAS +#define ASM_CPU_SPEC "%{m32:--32} %{m64:--64}" +#else +#define ASM_CPU_SPEC "%{m32:-xarch=generic} %{m64:-xarch=generic64}" +#endif + +/* Don't let i386/x86-64.h override i386/sol2.h version. Since Solaris + 10, Sun as can handle -K PIC correctly. */ #undef ASM_SPEC #ifdef USE_GAS -#define ASM_SPEC "%{m32:--32} %{m64:--64} -s %(asm_cpu)" +#define ASM_SPEC ASM_SPEC_BASE #else -#define ASM_SPEC "%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} " \ - "%{m32:-xarch=generic} %{m64:-xarch=generic64} " \ - "-s %(asm_cpu)" +#define ASM_SPEC ASM_SPEC_BASE ASM_PIC_SPEC #endif /* We do not need to search a special directory for startup files. */ diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -61,12 +61,12 @@ along with GCC; see the file COPYING3. #define ASM_CPU_SPEC "" -/* Removed -K PIC from generic sol2.h ASM_SPEC: the Solaris 8 and 9 assembler - gives many warnings: R_386_32 relocation is used for symbol ".text", and +/* Don't include ASM_PIC_SPEC. While the Solaris 8 and 9 assembler accepts + -K PIC, it gives many warnings: + R_386_32 relocation is used for symbol ".text" GNU as doesn't recognize -K at all. */ -/* FIXME: Perhaps split between common and CPU-specific parts? */ #undef ASM_SPEC -#define ASM_SPEC "%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)" +#define ASM_SPEC ASM_SPEC_BASE #define SUBTARGET_CPU_EXTRA_SPECS \ { "cpp_subtarget", CPP_SUBTARGET_SPEC }, \ diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -99,13 +99,12 @@ along with GCC; see the file COPYING3. TARGET_SUB_OS_CPP_BUILTINS(); \ } while (0) -/* It's safe to pass -s always, even if -g is not used. */ -#undef ASM_SPEC -#define ASM_SPEC "\ -%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s \ -%{fpic|fpie|fPIC|fPIE:-K PIC} \ -%(asm_cpu) \ -" +/* It's safe to pass -s always, even if -g is not used. Those options are + handled by both Sun as and GNU as. */ +#define ASM_SPEC_BASE \ +"%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)" + +#define ASM_PIC_SPEC " %{fpic|fpie|fPIC|fPIE:-K PIC}" #undef LIB_SPEC #define LIB_SPEC \ 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 @@ -120,6 +120,10 @@ along with GCC; see the file COPYING3. #define ASM_CPU_DEFAULT_SPEC ASM_CPU32_DEFAULT_SPEC #endif +/* Both Sun as and GNU as understand -K PIC. */ +#undef ASM_SPEC +#define ASM_SPEC ASM_BASE_SPEC ASM_PIC_SPEC + #undef CPP_CPU_SPEC #define CPP_CPU_SPEC "\ %{mcpu=sparclet|mcpu=tsc701:-D__sparclet__} \ -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University