[build] Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP

Message ID ydd1s84kbce.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series
  • [build] Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP
Related show

Commit Message

Rainer Orth Nov. 1, 2018, 4:32 p.m.
The autoconf 2.69 upgrade broke Solaris/SPARC bootstrap with as:
compiling stage1 libgcc fails with an assembler error:

/usr/ccs/bin/as: "/var/tmp//ccYQ2Dxc.s", line 32: error: detect global register use not covered .register pseudo-op
/usr/ccs/bin/as: "/var/tmp//ccYQ2Dxc.s", line 32: error: detect global register use not covered .register pseudo-op

The line in question is

        srlx %g1,32,%g3

and comparing with older compiler output, I find that two lines were
lost:

-       .register       %g2, #scratch
-       .register       %g3, #scratch

They would be emitted by sparc.c (sparc_output_scratch_registers)
controlled by HAVE_AS_REGISTER_PSEUDO_OP.  Before the upgrade, this
would be 1 everywhere, now it's 0.  Checking gcc/config.log shows

configure:25347: checking assembler for .register
configure:25356: /usr/ccs/bin/as    -o conftest.o conftest.s >&5
/usr/ccs/bin/as: "conftest.s", line 1: error: statement syntax
configure:25359: $? = 1
configure: failed program was
.register %g2, #scratch[]
configure:25370: result: no

and indeed gcc/configure now contains those superfluous trailing
brackets for

      [.register %g2, #scratch],,

    $as_echo '.register %g2, #scratch'[] > conftest.s

I've found two more instances of this issue:

* One for ia64 in gcc_cv_as_ia64_ltoffx_ldxmov_relocs) ...

    $as_echo '	.text
	addl r15 = @ltoffx(x#), gp
	;;
	ld8.mov r16 = [r15], x#'[] > conftest.s

* ... and another in a yet unsubmitted patch of mine to support
  SHF_MERGE with Solaris as.

This is an incompatible change autoconf -Wall doesn't warn about.  It
can be avoided/fixed by using the quadrigraph corresponding to '#',
'@%:@'.

However, for the sparc case there's an even simpler solution: the test
was originally introduced as a workaround when some Solaris 7 assembler
(the first one to support 64-bit SPARC) lacked the .register pseudo-op.
These days, with Solaris 10 the oldest supported Solaris release, both
the Solaris 10 FCS as and the gas 2.15 bundled with Solaris 10 support
.register, so there's no need to check for that.

While I refuse to even try bootstrapping with either of those now
ancient assemblers, I manually checked that both pass the test code from
the current test.

So the current patch removes both the autoconf test and the uses of the
macro.  Solaris 11/SPARC Bootstraps with both as and gas currently
running.  Ok for mainline if they pass?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2018-11-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac (gcc_cv_as_sparc_register_op): Remove.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/sparc/sparc.c (sparc_output_scratch_registers): Remove
	HAVE_AS_REGISTER_PSEUDO_OP guard.
	* config/sparc/sparc.h (ASM_ARCH64_SPEC): Remove
	!HAVE_AS_REGISTER_PSEUDO_OP support.
	(ASM_DECLARE_REGISTER_GLOBAL): Remove HAVE_AS_REGISTER_PSEUDO_OP
	guard.

Comments

Joseph Myers Nov. 1, 2018, 5:08 p.m. | #1
On Thu, 1 Nov 2018, Rainer Orth wrote:

> * One for ia64 in gcc_cv_as_ia64_ltoffx_ldxmov_relocs) ...

> 

>     $as_echo '	.text

> 	addl r15 = @ltoffx(x#), gp

> 	;;

> 	ld8.mov r16 = [r15], x#'[] > conftest.s


Thanks for pointing this out.  I've applied this patch to fix this by 
adding a newline at the end of the test input (which is what I did for all 
the cases where adding AC_LANG_SOURCE resulted in autoconf errors if the 
last line of the AC_LANG_SOURCE argument contained '#'; I don't know how 
related the issues are, but it's at least less cryptic for the reader than 
using a quadrigraph).


Avoid stray [] in ia64 assembler test.

Noted in <https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00034.html>.
Fix by adding extra newline in test input is analogous to many such
newlines added in cases where argument to a newly added AC_LANG_SOURCE
had a preprocessor directive on its last line.

2018-11-01  Joseph Myers  <joseph@codesourcery.com>

	* configure.ac (gcc_cv_as_ia64_ltoffx_ldxmov_relocs): Add newline
	at end of assembler input text.
	* configure: Regenerate.

Index: configure
===================================================================
--- configure	(revision 265722)
+++ configure	(working copy)
@@ -26646,7 +26646,8 @@
     $as_echo '	.text
 	addl r15 = @ltoffx(x#), gp
 	;;
-	ld8.mov r16 = [r15], x#'[] > conftest.s
+	ld8.mov r16 = [r15], x#
+' > conftest.s
     if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
   (eval $ac_try) 2>&5
Index: configure.ac
===================================================================
--- configure.ac	(revision 265722)
+++ configure.ac	(working copy)
@@ -4550,7 +4550,8 @@
 [	.text
 	addl r15 = @ltoffx(x#), gp
 	;;
-	ld8.mov r16 = [[r15]], x#],,
+	ld8.mov r16 = [[r15]], x#
+],,
     [AC_DEFINE(HAVE_AS_LTOFFX_LDXMOV_RELOCS, 1,
 	  [Define if your assembler supports ltoffx and ldxmov relocations.])])
 

-- 
Joseph S. Myers
joseph@codesourcery.com
Eric Botcazou Nov. 1, 2018, 11:36 p.m. | #2
> So the current patch removes both the autoconf test and the uses of the

> macro.  Solaris 11/SPARC Bootstraps with both as and gas currently

> running.  Ok for mainline if they pass?


Sure, thanks for fixing this!

-- 
Eric Botcazou
Rainer Orth Nov. 3, 2018, 3:16 p.m. | #3
Hi Joseph,

> On Thu, 1 Nov 2018, Rainer Orth wrote:

>

>> * One for ia64 in gcc_cv_as_ia64_ltoffx_ldxmov_relocs) ...

>> 

>>     $as_echo '	.text

>> 	addl r15 = @ltoffx(x#), gp

>> 	;;

>> 	ld8.mov r16 = [r15], x#'[] > conftest.s

>

> Thanks for pointing this out.  I've applied this patch to fix this by 

> adding a newline at the end of the test input (which is what I did for all 

> the cases where adding AC_LANG_SOURCE resulted in autoconf errors if the 

> last line of the AC_LANG_SOURCE argument contained '#'; I don't know how 

> related the issues are, but it's at least less cryptic for the reader than 

> using a quadrigraph).


very much so, thanks for the hint.  I've applied it to my Solaris as
SHF_MERGE patch, too.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Patch

# HG changeset patch
# Parent  9f1fd4adf7454b08bcb179652a217c48e17cfa08
Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -5583,7 +5583,6 @@  sparc_initial_elimination_offset (int to
 void
 sparc_output_scratch_registers (FILE *file ATTRIBUTE_UNUSED)
 {
-#ifdef HAVE_AS_REGISTER_PSEUDO_OP
   int i;
 
   if (TARGET_ARCH32)
@@ -5604,7 +5603,6 @@  sparc_output_scratch_registers (FILE *fi
 	}
       if (i == 3) i = 5;
     }
-#endif
 }
 
 #define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP)
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -365,11 +365,7 @@  extern enum cmodel sparc_cmodel;
    This is what GAS uses.  Add %(asm_arch) to ASM_SPEC to enable.  */
 
 #define ASM_ARCH32_SPEC "-32"
-#ifdef HAVE_AS_REGISTER_PSEUDO_OP
 #define ASM_ARCH64_SPEC "-64 -no-undeclared-regs"
-#else
-#define ASM_ARCH64_SPEC "-64"
-#endif
 #define ASM_ARCH_DEFAULT_SPEC \
 (DEFAULT_ARCH32_P ? ASM_ARCH32_SPEC : ASM_ARCH64_SPEC)
 
@@ -1197,7 +1193,6 @@  init_cumulative_args (& (CUM), (FNTYPE),
 
 extern GTY(()) char sparc_hard_reg_printed[8];
 
-#ifdef HAVE_AS_REGISTER_PSEUDO_OP
 #define ASM_DECLARE_REGISTER_GLOBAL(FILE, DECL, REGNO, NAME)		\
 do {									\
   if (TARGET_ARCH64)							\
@@ -1216,8 +1211,6 @@  do {									\
 	  }								\
     }									\
 } while (0)
-#endif
-
 
 /* Emit rtl for profiling.  */
 #define PROFILE_HOOK(LABEL)   sparc_profile_hook (LABEL)
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4077,11 +4077,6 @@  EOF
     ;;
 
   sparc*-*-*)
-    gcc_GAS_CHECK_FEATURE([.register], gcc_cv_as_sparc_register_op,,,
-      [.register %g2, #scratch],,
-      [AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
-		[Define if your assembler supports .register.])])
-
     gcc_GAS_CHECK_FEATURE([-relax option], gcc_cv_as_sparc_relax,,
       [-relax], [.text],,
       [AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,