[Gc] RE: gc6.2alpha6 test results and fixups

Dan Bonachea bonachea@cs.berkeley.edu
Fri, 06 Jun 2003 22:55:22 -0700


At 11:35 AM 6/6/2003, you wrote:
> > * As I reported in my last patch, the file name
> > mips_sgi_mach_dep.S is not
> > acceptable to gcc (2.95.3) on IRIX 6. The file must be renamed to
> > mips_sgi_mach_dep.s (lowercase s extension) in order to
> > compile properly.
>I would like to understand this one a bit better, especially since
>you're using gcc.  According to
>
>http://gcc.gnu.org/onlinedocs/gcc-3.3/gcc/Overall-Options.html#Overall%20Options
>
>and also
>
>http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html#SEC4
>
>the file name should end in .S.  Otherwise the preprocessor won't be
>invoked, and I would be in violation of the one clearly expressed convention
>about names of assembler files.
>
>The error message below in fact suggests that gcc is doing the right thing
>(it's compiling an included file), but perhaps your gcc is installed to
>use the SGI assembler, and those aren't quite compatible?
>
>It would be useful to look at the --save-temps output and see what's being
>misinterpreted.

I've looked into this further. The problem is that the #included files contain 
#ident strings (i.e. #ident  "$Revision: 3.9 $") and the system assembler 
chokes on these if it sees them in preprocessed input.

When you pass a lower-case .s filename to gcc, here's what happens:
-------------------------------------------------------------
gcc -g -O2 -DNO_EXECUTE_PERMISSION=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 
-DSILENT=1 -DNO_SIGNALS=1 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 
-DJAVA_FINALIZATION=1 -DGC_GCJ_SUPPORT=1 -DATOMIC_UNCOLLECTABLE=1 -c 
mips_sgi_mach_dep.s -DPIC -o mips_sgi_mach_dep.lo --save-temps -v

Reading specs from 
/afs/ncsa/packages/GNU/gcc-2.95.3/IRIX_6.5/lib/gcc-lib/mips-sgi-irix6.5/2.95.3/specs
gcc version 2.95.3 20010315 (release)
  /usr/bin/as -O2 -g0 -show -G 0 -w -n32 -o mips_sgi_mach_dep.lo 
mips_sgi_mach_dep.s
/usr/bin/../../usr/lib32/cmplrs/as -DEFAULT:abi=-64:isa=mips4:proc=r10k -O2 
-g0 -show -G 0 -w -n32 -o mips_sgi_mach_dep.lo mips_sgi_mach_dep.s
/usr/lib32/cmplrs/cpp -Dmips -DMIPSEB -D_MIPSEB -D_PIC -D__DSO__ 
-D_LANGUAGE_ASSEMBLY -DLANGUAGE_ASSEMBLY -Xdo_linesplice -dollar -Dunix -Dsgi 
-Dhost_mips -D_SGI_SOURCE -D_LONGLONG -D_SVR4_SOURCE -D__sgi -D__host_mips 
-Amachine(mips) -D_SYSTYPE_SVR4 -D__unix -Asystem(unix) 
-D_COMPILER_VERSION=730 -D__mips=4 -D_MIPS_ISA=4 -D_ABIN32=2 
-D_MIPS_SIM=_ABIN32 -D_MIPS_FPSET=32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 
-D_MIPS_SZPTR=32 -D_SIZE_INT=32 -D_SIZE_LONG=32 -D_SIZE_PTR=32 -I/usr/include 
mips_sgi_mach_dep.s > /tmp/ctmi.AAAa0bmLF
/usr/lib32/cmplrs/asm -t5_ll_sc_bug -EB -pic2 -elf -O2 -g0 -G0 -w -mips4 -n32 
/tmp/ctmi.AAAa0bmLF -o mips_sgi_mach_dep.lo
-------------------------------------------------------------
It calls the system assembler directly (/usr/bin/as), which is smart enough to 
run the system preprocessor (/usr/lib32/cmplrs/cpp) itself, and the system 
preprocessor throws away the #ident line so that it doesn't foul up 
/usr/lib32/cmplrs/asm.

However, when you pass an upper-case .S filename to gcc, here's what happens:
-------------------------------------------------------------------
gcc -g -O2 -DNO_EXECUTE_PERMISSION=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 
-DSILENT=1 -DNO_SIGNALS=1 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 
-DJAVA_FINALIZATION=1 -DGC_GCJ_SUPPORT=1 -DATOMIC_UNCOLLECTABLE=1 -c 
mips_sgi_mach_dep.S -DPIC -o mips_sgi_mach_dep.lo --save-temps -v

Reading specs from 
/afs/ncsa/packages/GNU/gcc-2.95.3/IRIX_6.5/lib/gcc-lib/mips-sgi-irix6.5/2.95.3/specs
gcc version 2.95.3 20010315 (release)
  /afs/ncsa/packages/GNU/gcc-2.95.3/IRIX_6.5/lib/gcc-lib/mips-sgi-irix6.5/2.95.3/cpp0 
-lang-asm -v -$ -Dunix -Dmips -Dsgi -Dhost_mips -DMIPSEB -D_MIPSEB 
-DSYSTYPE_SVR4 -D_LONGLONG -D_SVR4_SOURCE -D_MODERN_C -D__DSO__ -D__unix__ 
-D__mips__ -D__sgi__ -D__host_mips__ -D__MIPSEB__ -D_MIPSEB -D__SYSTYPE_SVR4__ 
-D_LONGLONG -D_SVR4_SOURCE -D_MODERN_C -D__DSO__ -D__unix -D__mips -D__sgi 
-D__host_mips -D__MIPSEB -D__SYSTYPE_SVR4 -Asystem(unix) -Asystem(svr4) 
-Acpu(mips) -Amachine(sgi) -D__ASSEMBLER__ -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ 
-g -D__LANGUAGE_ASSEMBLY -D_LANGUAGE_ASSEMBLY -DLANGUAGE_ASSEMBLY 
-D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D__EXTENSIONS__ 
-D_SGI_SOURCE -D_MIPS_FPSET=32 -D_MIPS_ISA=_MIPS_ISA_MIPS3 -D_ABIN32=2 
-D_MIPS_SIM=_ABIN32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 
-D_COMPILER_VERSION=601 -U__mips -D__mips=3 -D__mips64 
-DNO_EXECUTE_PERMISSION=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 
-DSILENT=1 -DNO_SIGNALS=1 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 
-DJAVA_FINALIZATION=1 -DGC_GCJ_SUPPORT=1 -DATOMIC_UNCOLLECTABLE=1 -DPIC 
mips_sgi_mach_dep.S mips_sgi_mach_dep.s
GNU CPP version 2.95.3 20010315 (release) [AL 1.1, MM 40] SGI running IRIX 6.x
#include "..." search starts here:
#include <...> search starts here:
  /usr/local/include
  /afs/ncsa/packages/GNU/gcc-2.95.3/IRIX_6.5/lib/gcc-lib/mips-sgi-irix6.5/2.95.3/../../../../mips-sgi-irix6.5/include
  /afs/ncsa/packages/GNU/gcc-2.95.3/IRIX_6.5/lib/gcc-lib/mips-sgi-irix6.5/2.95.3/include
  /usr/include
End of search list.
The following default directories have been omitted from the search path:
  /afs/ncsa/packages/GNU/gcc-2.95.3/IRIX_6.5/lib/gcc-lib/mips-sgi-irix6.5/2.95.3/../../../../include/g++-3
End of omitted list.
  /usr/bin/as -O2 -g0 -nocpp -show -G 0 -w -n32 -o mips_sgi_mach_dep.lo 
mips_sgi_mach_dep.s
/usr/bin/../../usr/lib32/cmplrs/as -DEFAULT:abi=-64:isa=mips4:proc=r10k -O2 
-g0 -nocpp -show -G 0 -w -n32 -o mips_sgi_mach_dep.lo mips_sgi_mach_dep.s
/usr/lib32/cmplrs/asm -t5_ll_sc_bug -EB -pic2 -elf -O2 -g0 -G0 -w -mips4 -n32 
mips_sgi_mach_dep.s -o mips_sgi_mach_dep.lo
as: Error: /usr/include/sys/regdef.h, line 17: Expected cpp-generated line 
number
as INTERNAL ERROR:  /usr/lib32/cmplrs/asm returned non-zero status 1
---------------------------------------------------------------------

It uses the GNU C preprocessor, which is not smart enough to discard the 
#ident strings, so when the output is passed to /usr/bin/as with -nocpp 
option, the file is passed as-is to /usr/lib32/cmplrs/asm, which promptly 
barfs on it.

So passing .S files to gcc directly will always break on IRIX if they include 
these headers.  I've verified the same is true on gcc 3.01, so this is not 
just a problem with old versions of gcc. There doesn't appear to be any GNU 
preprocessor option to filter out #ident lines (I tried -fno-ident, it has no 
effect on the preprocessor).

Your Makefile trick of passing the assembly file through gcc -E and then 
explicitly grepping out all lines starting with "#" works, but as currently 
written it also discards all the line number information (so any reported 
errors in the assembly file will have no line information). Also, you'd need 
to implement this in Makefile.am as well if you want this to be a complete 
solution.

However, given the system assembler is always smart enough to call the system 
preprocessor itself (provided you don't pass it -nocpp) and the gcc 
preprocessor always botches it, it seems a more natural and robust solution is 
just to use the .s filename so that gcc will leave it alone and pass it to the 
system assembler untouched, and let the system assembler take care of it in 
the proper way. Furthermore, the .S suffix is not recognized by MIPSPro (the 
native IRIX C compiler) - if you pass it .S directly it will barf with "Object 
file format error (mips_sgi_mach_dep.S): unrecognizable format" - it only 
understands .s as assembly. My simple fix of renaming the file to .s works on 
both compilers, with no messy manual invocation of preprocessors and grepping 
out of lines.

Dan

PS- also see http://gcc.gnu.org/ml/java/2002-03/msg00006.html