[Solaris 7/64-bit] Handle .register pseudo-op
Rainer Orth
ro@TechFak.Uni-Bielefeld.DE
Mon Jun 28 12:17:00 GMT 1999
Trying to build a bi-arch (32-bit/64-bit) gcc on SPARC Solaris 7 to compare
handling of structure passing conventions on SPARC V9 vs. MIPS N32/N64, I
failed initially when the stage1 compiler tried to build a 64-bit libgcc
(_muldi3):
/usr/ccs/bin/as: "/var/tmp/cctkZOVp.s", line 274: error: detect global register use not covered .register pseudo-op
also reported in http://egcs.cygnus.com/ml/egcs-bugs/1999-02/msg00820.html .
This happens because I inadvertently used the patched /usr/ccs/bin/as from
Solaris 7 patch 107058-01, necessary to run Sun's WorkShop 5.0 compilers,
but breaking gcc (see
http://egcs.cygnus.com/ml/egcs-bugs/1999-03/msg00386.html ). This version
of the assembler is going to stay around and will one day be usable by
gcc once Sun publishes a fix for their linker bug, so I decided to fix the
underlying problem:
As explained in WorkShop 5.0's /opt/SUNWspro/READMEs/64bit_Compilers, the
new assembler requires the g2, g3, g6 and g7 registers to be declared as
scratch or temporary with the new .register pseudo-op if they are to be
used, otherwise the assembler generates the error above and stops.
Previous versions of the assembler don't understand .register, so I
autoconfigured the detection and emit the necessary .register decls if
necessary/appropriate. With this change, I could successfully bootstrap
the compiler.
The patch below also includes Casper Dik's patch to build a bi-arch
compiler on Solaris 7 and beyond. Since this will cause problems on
systems which don't have the necessary 64-bit support installed, I added a
check to config-ml.in along the lines of the IRIX 6 N64 ABI detection.
Rainer
Mon Jun 28 20:28:06 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
From Casper H.S. Dik on comp.unix.solaris, 23 Oct 1998:
* configure.in: Try building a bi-arch 32/64-bit compiler on
sparc-*-solaris2.7 and higher.
Sat Jun 26 00:53:24 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* sparc/sol2-sld-64.h: Use it.
* acconfig.h (HAVE_AS_REGISTER_PSEUDO_OP): Provide template.
* configure.in: Check if as supports the Solaris 7/sparcv9
.register pseudo-op.
* configure: Regenerate.
* config.in: Likewise.
Fri Jun 25 01:24:46 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* config-ml.in (sparc*-*-*): Disable sparcv9 support if the
necessary libraries are missing.
* sparc/sol2-sld-64.h (ASM_FILE_START): Redefine.
Index: config-ml.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/config-ml.in,v
retrieving revision 1.6
diff -u -p -r1.6 config-ml.in
--- config-ml.in 1999/04/11 23:00:24 1.6
+++ config-ml.in 1999/06/28 18:54:38
@@ -401,6 +401,30 @@ powerpc*-*-* | rs6000*-*-*)
done
fi
;;
+sparc*-*-*)
+ case " $multidirs " in
+ *" m64 "*)
+ # We will not be able to create libraries with -m64 if
+ # we cannot even link a trivial program. It usually
+ # indicates the 64bit libraries are missing.
+ if echo 'main() {}' > conftest.c &&
+ ${CC-gcc} -m64 conftest.c -o conftest; then
+ :
+ else
+ echo Could not link program with -m64, disabling it.
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *m64* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ rm -f conftest.c conftest
+ ;;
+ esac
+ ;;
esac
# Remove extraneous blanks from multidirs.
Index: gcc/acconfig.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/acconfig.h,v
retrieving revision 1.32
diff -u -p -r1.32 acconfig.h
--- acconfig.h 1999/04/23 19:41:00 1.32
+++ acconfig.h 1999/06/28 18:54:38
@@ -29,6 +29,9 @@
/* Define if your assembler supports .balign and .p2align. */
#undef HAVE_GAS_BALIGN_AND_P2ALIGN
+/* Define if your assembler supports .register. */
+#undef HAVE_AS_REGISTER_PSEUDO_OP
+
/* Define if your assembler supports .subsection and .subsection -1 starts
emitting at the beginning of your section */
#undef HAVE_GAS_SUBSECTION_ORDERING
Index: gcc/configure.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/configure.in,v
retrieving revision 1.246.4.8
diff -u -p -r1.246.4.8 configure.in
--- configure.in 1999/06/14 02:59:13 1.246.4.8
+++ configure.in 1999/06/28 18:54:41
@@ -3120,6 +3128,15 @@ changequote([,])dnl
extra_parts="crt1.o crti.o crtn.o gcrt1.o gmon.o crtbegin.o crtend.o"
case $machine in
changequote(,)dnl
+ *-*-solaris2.[0-6]*) ;;
+changequote([,])dnl
+ *-*-solaris2*)
+ tm_file=sparc/sol2-sld-64.h
+ tmake_file="$tmake_file sparc/t-sol2-64"
+ ;;
+ esac
+ case $machine in
+changequote(,)dnl
*-*-solaris2.[0-4])
changequote([,])dnl
float_format=i128
@@ -4040,6 +4057,19 @@ EOF
fi
AC_MSG_RESULT($gcc_cv_as_subsections)
+AC_MSG_CHECKING(assembler .register pseudo-op support)
+gcc_cv_as_register_pseudo_op=
+if test x$gcc_cv_as != x; then
+ # Check if we have .register
+ echo ".register %g2, #scratch" > conftest.s
+ if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+ gcc_cv_as_register_pseudo_op=yes
+ AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP)
+ fi
+ rm -f conftest.s conftest.o
+fi
+AC_MSG_RESULT($gcc_cv_as_register_pseudo_op)
+
AC_MSG_CHECKING(assembler instructions)
gcc_cv_as_instructions=
if test x$gcc_cv_as != x; then
Index: gcc/config/sparc/sol2-sld-64.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/sparc/sol2-sld-64.h,v
retrieving revision 1.6
diff -u -p -r1.6 sol2-sld-64.h
--- sol2-sld-64.h 1998/12/16 21:13:25 1.6
+++ sol2-sld-64.h 1999/06/28 18:54:41
@@ -361,3 +361,27 @@ __enable_execute_stack (addr) \
fprintf (FILE, "\n"); \
} while (0)
+/* This is necessary if the assembler supports .register, but doesn't work
+ otherwise. */
+
+#ifdef HAVE_AS_REGISTER_PSEUDO_OP
+
+/* This is how to begin an assembly language file, from svr4.h.
+
+ The registers g2-g3, g6-g7 need to be declared as scratch or temporary
+ in v9 code with the .register pseudo-op, starting with the Solaris 7
+ assembler patch 107058-01. This is explained in Sun WorkShop 5.0's
+ /opt/SUNWspro/READMEs/64bit_Compilers (SPARC ASSEMBLER).
+
+ gcc on v9 uses g2-g3 only, see sparc.h (FIXED_REGISTERS). */
+#undef ASM_FILE_START
+#define ASM_FILE_START(FILE) \
+ do { \
+ output_file_directive ((FILE), main_input_filename); \
+ if (TARGET_ARCH64 && TARGET_APP_REGS) \
+ { \
+ fputs ("\t.register %g2, #scratch\n", FILE); \
+ fputs ("\t.register %g3, #scratch\n", FILE); \
+ } \
+ } while (0)
+#endif /* HAVE_AS_REGISTER_PSEUDO_OP */
More information about the Gcc-patches
mailing list