doug@genmri.UUCP (Doug Becker) (07/14/90)
I'm a novice at using gcc, and I'm having trouble with the rgb executable in the rgb subdirectory. BEFORE YOU TUNE OUT, I HAVE read the latest "most frequently asked questions." :-) I'm getting a segmentation violation from rgb/rgb when I compile with gcc 1.37.1 on a Sun 4/280 running SunOS 4.0.3c (fixincludes WAS run). I'm running X11R4 through patchlevel 12. Here is a sample (some newlines inserted by the selection mechanism): genmri# pwd /home/X11/mit/rgb genmri# make clean rm -f rgb rm -f showrgb rm -f rgb.pag rgb.dir rm -f *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut \#* genmri# make gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return -g -I../. -I../. -I.././ server/include -DNDBM -sun4 -c rgb.c rm -f rgb gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return -o rgb rgb.o -g -ldbm gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return -g -I../. -I../. -I.././ server/include -DNDBM -sun4 -c showrgb.c rm -f showrgb gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return -o showrgb showrgb.o -g -ldbm rm -f rgb.pag rgb.dir ./rgb rgb < rgb.txt sh: 5904 Memory fault - core dumped *** Error code 139 make: Fatal error: Command failed for target `rgb.dir' genmri# It seems to be dying in dbm_nextkey (in dbm_store): genmri# dbx rgb Reading symbolic information... Read 341 symbols (dbx) where dbm_nextkey() at 0x3e6c dbm_store() at 0x34fc main(argc = 2, argv = 0xf7fffb9c), line 124 in "rgb.c" (dbx) Recompiling with cc works fine. I made pains to ensure that the gcc binaries installed were those compiled by gcc (the stage3 binaries, actually), per the gcc documentation. Also, it appears that just modifying the default sun.cf to define HasGcc to YES causes numerous error messages to be generated during the build. It seems that the preprocessor is complaining that alloca is redefined, and in server/include/os.h, alloca looks to be defined twice: once for the default -DINCLUDE_ALLOCA_H present in sun.cf, and again because __GNUC__ is defined. I manually deleted -DINCLUDE_ALLOCA_H from server/Makefile (and I assume I could do the same in sun.cf), although I'm beginning to wonder if that was the right thing to do... (I haven't got the gcc-compiled server working yet -- it dies after two or three events are processed). Any ideas? -- Douglas H. Becker doug@nmri.GE.COM {somewhere}!crdgw1.GE.COM!sane!doug
casper@fwi.uva.nl (Casper H.S. Dik) (07/15/90)
In article <9007131856.AA06628@genmri.sane.COM> doug@genmri.UUCP (Doug Becker) writes: |I'm a novice at using gcc, and I'm having trouble with the rgb |executable in the rgb subdirectory. BEFORE YOU TUNE OUT, I HAVE read |the latest "most frequently asked questions." :-) | |I'm getting a segmentation violation from rgb/rgb when I compile with |gcc 1.37.1 on a Sun 4/280 running SunOS 4.0.3c (fixincludes WAS run). |I'm running X11R4 through patchlevel 12. Here is a sample (some |newlines inserted by the selection mechanism): | |genmri# pwd |/home/X11/mit/rgb |genmri# make clean |rm -f rgb |rm -f showrgb |gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return -o showrgb showrgb.o -g | -ldbm ^^^^^ This is the tell tale sign. |rm -f rgb.pag rgb.dir |./rgb rgb < rgb.txt |sh: 5904 Memory fault - core dumped |*** Error code 139 |make: Fatal error: Command failed for target `rgb.dir' There is a known incompatibility in the way functions returning structures are handled between native gcc, pcc (gcc -fpcc-struct-return) and Sun SPARC compilers. You try to combine CC compiled functions returning structures (dbm*) with gcc compiled invocations. This doesn't work. Use CC instead. In my experience, code generated by cc -O4 outperforms gcc by sometimes as much as 25% on the SPARC. -- Casper H.S. Dik VCP/HIP: +31205922022 University of Amsterdam | casper@fwi.uva.nl The Netherlands | casper%fwi.uva.nl@hp4nl.nluug.nl
strauss@aerospace.aero.ORG (07/15/90)
In article <9007131856.AA06628@genmri.sane.COM> you write: >I'm a novice at using gcc, and I'm having trouble with the rgb >executable in the rgb subdirectory. BEFORE YOU TUNE OUT, I HAVE read >the latest "most frequently asked questions." :-) > >I'm getting a segmentation violation from rgb/rgb when I compile with >gcc 1.37.1 on a Sun 4/280 running SunOS 4.0.3c (fixincludes WAS run). >I'm running X11R4 through patchlevel 12. Here is a sample (some >newlines inserted by the selection mechanism): > You can't use gcc for the RGB program. The problem is that gcc returns structures differently than cc. On the sun3 there is an option to -fpcc-struct-return, but it is listed as a bug with gcc that the switch is ignored for the sparc. DBM is a cc compiled library that uses structure returns. Just compile that with cc. In fact, I am not sure why you are trying to use gcc for the X stuff on the sparc. From my experience the code on a sparc using gcc and cc is almost identical. - |Daryll ------------------------------------------------------------------------------- Daryll Strauss f The Aerospace Corp. strauss@aero.org n Mail Stop: M1-102 ...!uunet!aero.org!strauss o P.O. Box 92957 r Los Angeles, Ca. 90009 "MY opinions. You here me? They're mine!" d (213) 336-9358 -------------------------------------------------------------------------------