pell@ISY.LIU.SE (P{r Emanuelsson) (07/30/89)
INSTALLING G++ ON THE SUN 386i ------------------------------ THESE PATCHES ARE FOR THE 1.35.1- RELEASE!!!!! Apply these patches. There shouldn't be any *.rej files! Use config.g++ as usual. Edit the makefile libdir spec, etc. Make sure to define "-DNO_GNU_LD" to the compiling of gcc.c. Also add "-lld" to CLIB. Collect needs this. Do a make. The make will fail on ld++. You have two options: 1. Fix ld++ => stop reading this file and post your fixes. 2. Do a "make collect". Continue reading. - "make install" - Copy collect to the same directory where g++ will go. - Create libg++ (it's a separate distribution). Now it should work! Note that dbx seems to have problems with the executables so there is no debugging available until someone fixes gdb. Also note that all linking is static since the G++ crt0 doesn't support dynamic linking. Yet... Furthermore, the incremental linking facility is not supported. Some of the tests in libg++ get failed assertions. In a way this is good, because that means that this port may help uncover possible compiler bugs. Unfortunately, I haven't had the time to look at it yet. With the release of these patches I hope that someone else may have time to do it. It's important to fix all bugs quickly. I *have* compiled a rather large software package which uses SunView and interfaces to C and FORTRAN with G++ on the Sun386i with no problems. Looks pretty stable to me... It's certainly production quality. Questions will be answered, time permitting. -- P{r Emanuelsson, pell@isy.liu.se, ...!uunet!isy.liu.se!pell -- diff -rc2 g++-old/Makefile g++-1.35.0/Makefile *** g++-old/Makefile Sat Jul 29 19:52:10 1989 --- g++-1.35.0/Makefile Sat Jul 29 21:55:33 1989 *************** *** 244,251 **** COLLECT_OPTIONS=''; \ fi; \ ! $(CC) $(PROFILE) $$COLLECT_OPTIONS $(CFLAGS) -c $< ! collect: collect.o $(LIBDEPS) ! $(CC) -o collect $(PROFILE) collect.o -lg $(LIBS) -lc crt0+.o: crt0.c config.h --- 244,251 ---- COLLECT_OPTIONS=''; \ fi; \ ! $(CC) $(PROFILE) $$COLLECT_OPTIONS $(CFLAGS) -Iconfig -c $< ! collect: collect.o version.o $(LIBDEPS) ! $(CC) -o collect $(PROFILE) collect.o version.o -lg $(LIBS) -lc crt0+.o: crt0.c config.h diff -rc2 g++-old/collect.c g++-1.35.0/collect.c *** g++-old/collect.c Wed May 17 08:45:20 1989 --- g++-1.35.0/collect.c Sat Jul 29 20:51:00 1989 *************** *** 41,44 **** --- 41,60 ---- #include "config.h" + #include <sys/types.h> + #include <sys/stat.h> + + #include <stdio.h> + #include <a.out.h> + #include <ar.h> + + #ifdef UMAX + #include <sgs.h> + #endif + + /* This should really be in a tm- or xm- file */ + #if defined(sun386) + #define NO_UNDERSCORES + #endif + /* * This may not always be true, but I can't find another flag *************** *** 56,60 **** #undef ASM_OUTPUT_LABELREF ! #if defined(COFF) #define ASM_OUTPUT_INT(FILE,VALUE) \ --- 72,76 ---- #undef ASM_OUTPUT_LABELREF ! #if defined(COFF) && !defined(sun386) #define ASM_OUTPUT_INT(FILE,VALUE) \ *************** *** 67,71 **** fprintf (FILE, "\t.double _%s\n", NAME); - #else --- 83,86 ---- *************** *** 80,87 **** --- 95,113 ---- #else + #define ASM_OUTPUT_INT(FILE,VALUE) \ fprintf (FILE, "\t.long %d\n", VALUE) + #if defined(NO_UNDERSCORES) /* E.g. the sun386i */ + #define ASM_OUTPUT_PTR_INT_SUM(FILE,PTRNAME,VALUE) \ + fprintf (FILE, "\t.long %s+%d\n", PTRNAME, VALUE) + + #define ASM_OUTPUT_LABELREF(FILE,NAME) \ + fprintf (FILE, "\t.long %s\n", NAME); + + #else + + #define ASM_OUTPUT_PTR_INT_SUM(FILE,PTRNAME,VALUE) \ fprintf (FILE, "\t.long _%s+%d\n", PTRNAME, VALUE) *************** *** 88,105 **** #define ASM_OUTPUT_LABELREF(FILE,NAME) \ fprintf (FILE, "\t.long _%s\n", NAME); #endif /* hp9000s300 */ #endif /* COFF */ - #include <sys/types.h> - #include <sys/stat.h> - - #include <stdio.h> - #include <a.out.h> - #include <ar.h> - - #ifdef UMAX - #include <sgs.h> - #endif - extern int xmalloc (); extern void free (); --- 114,122 ---- #define ASM_OUTPUT_LABELREF(FILE,NAME) \ fprintf (FILE, "\t.long _%s\n", NAME); + + #endif /* NO_UNDERSCORES */ #endif /* hp9000s300 */ #endif /* COFF */ extern int xmalloc (); extern void free (); *************** *** 130,133 **** --- 147,155 ---- static char *outfile_name = "a.out"; + /* For compatibility with toplev.c and tm-sun386.h */ + char *dump_base_name; + int optimize = 0; + char *language_string = "GNU C++"; + /* The table of destructors elements must be laid out in the reverse order that the table of constructors is laid out. Thus, *************** *** 164,168 **** } ! main_input_filename = outfile_name; ASM_FILE_START(outfile); --- 186,190 ---- } ! dump_base_name = main_input_filename = outfile_name; ASM_FILE_START(outfile); *************** *** 278,287 **** ldtbread(ldptr, symindex, &symbol); symbol_name = ldgetname(ldptr, &symbol); if (! strncmp ("__GLOBAL_$", symbol_name, 10)) { - if (symbol_name[10] == 'I') { ASM_OUTPUT_LABELREF (outfile, symbol_name+1); } else { --- 300,318 ---- ldtbread(ldptr, symindex, &symbol); + + /* Skip all type declarations */ + if ((symbol.n_type & N_TMASK) != (DT_NON << N_BTSHFT)) continue; + symbol_name = ldgetname(ldptr, &symbol); + #ifdef NO_UNDERSCORES + if (! strncmp ("_GLOBAL_$", symbol_name, 9)) { + if (symbol_name[9] == 'I') { + ASM_OUTPUT_LABELREF (outfile, symbol_name); + #else if (! strncmp ("__GLOBAL_$", symbol_name, 10)) { if (symbol_name[10] == 'I') { ASM_OUTPUT_LABELREF (outfile, symbol_name+1); + #endif } else { *************** *** 290,295 **** --- 321,331 ---- xmalloc (sizeof (struct dtor_list_elem)); new->next = dtor_chain; + #ifdef NO_UNDERSCORES + new->name = (char *)xmalloc (strlen (symbol_name)+1); + strcpy (new->name, symbol_name); + #else new->name = (char *)xmalloc (strlen (symbol_name)); strcpy (new->name, symbol_name+1); + #endif dtor_chain = new; } *************** *** 573,577 **** --- 609,617 ---- fputs (&name[1], file); else + #ifdef NO_UNDERSCORES + fprintf (file, "%s", name); + #else fprintf (file, "_%s", name); + #endif } diff -rc2 g++-old/config.g++ g++-1.35.0/config.g++ *** g++-old/config.g++ Sat Jul 29 19:52:42 1989 --- g++-1.35.0/config.g++ Tue Jul 25 15:35:37 1989 *************** *** 115,119 **** sun386 | sun386i | roadrunner) cpu_type=i386 ! configuration_file=xm-sun386i.h machine_type=sun386i ;; --- 115,120 ---- sun386 | sun386i | roadrunner) cpu_type=i386 ! sed 's/-e _start//' < config/xm-sun386i.h | sed 's/-dc -dp %{g:-Bstatic}/ -Bstatic /' > config/xm-sun386i+.h ! configuration_file=xm-sun386i+.h machine_type=sun386i ;; diff -rc2 g++-old/cplus-lex.c g++-1.35.0/cplus-lex.c *** g++-old/cplus-lex.c Sat Jul 29 19:52:51 1989 --- g++-1.35.0/cplus-lex.c Sat Jul 29 20:55:19 1989 *************** *** 856,860 **** pending_inlines = pending_inlines->next; finput = finput2; ! #if defined(i386) && !defined(sequent) finput2->_ptr = finput2->_base = t->buf; _bufend(finput2) = t->buf + t->len; --- 856,860 ---- pending_inlines = pending_inlines->next; finput = finput2; ! #if defined(i386) && !defined(sequent) && !defined(sun386) finput2->_ptr = finput2->_base = t->buf; _bufend(finput2) = t->buf + t->len; *************** *** 1718,1722 **** end of this function. */ pending_inlines = pending_inlines->next; ! #if defined(i386) && !defined(sequent) finput2->_ptr = finput2->_base = t->buf; _bufend(finput2) = t->buf + t->len; --- 1718,1722 ---- end of this function. */ pending_inlines = pending_inlines->next; ! #if defined(i386) && !defined(sequent) && !defined(sun386) finput2->_ptr = finput2->_base = t->buf; _bufend(finput2) = t->buf + t->len; diff -rc2 g++-old/crt0.c g++-1.35.0/crt0.c *** g++-old/crt0.c Wed May 17 08:45:28 1989 --- g++-1.35.0/crt0.c Sat Jul 29 21:27:38 1989 *************** *** 198,201 **** --- 198,207 ---- #endif + #if defined(sun) + #define ON_EXIT(PROCP, ARG) \ + do { extern void PROCP (); on_exit (PROCP, ARG); } while (0) + #endif + + #ifndef sun386 /* Not compatible with i386, sigh */ #if defined(i386) || defined(ALTOS) _start(arg) *************** *** 211,214 **** --- 217,221 ---- } #endif + #endif /* sun386 */ #if defined(orion) || defined(pyramid) || defined(celerity) || defined(ALLIANT) *************** *** 403,407 **** #else /* m68000, not m68k */ ! #if defined(m68000) || defined(mc68000) || defined(mc68020) #ifdef ISI68K --- 410,414 ---- #else /* m68000, not m68k */ ! #if defined(m68000) || defined(mc68000) || defined(mc68020) || defined(sun386) #ifdef ISI68K *************** *** 423,439 **** _start () { ! /* On 68000, _start pushes a6 onto stack */ start1 (); } #endif /* not ISI68k */ ! #endif /* m68000 || mc68000 || mc68020 */ #endif /* m68k */ ! #if defined(sun) ! #define ON_EXIT(PROCP, ARG) \ ! do { extern void PROCP (); on_exit (PROCP, ARG); } while (0) ! #endif ! ! #if defined(m68k) || defined(m68000) || defined(mc68000) || defined(mc68020) /* ignore takes care of skipping the a6 value pushed in start. */ static --- 430,442 ---- _start () { ! static start1 (); ! /* On 68000, _start pushes a6 onto stack (as does the sun386i, sort of...) */ start1 (); } #endif /* not ISI68k */ ! #endif /* m68000 || mc68000 || mc68020 || sun386 */ #endif /* m68k */ ! #if defined(m68k) || defined(m68000) || defined(mc68000) || defined(mc68020) || defined(sun386) /* ignore takes care of skipping the a6 value pushed in start. */ static *************** *** 466,470 **** } ! #endif /* m68k or m68000 or mc68000 or mc68020 */ #endif /* not CRT0_DUMMIES */ --- 469,473 ---- } ! #endif /* m68k or m68000 or mc68000 or mc68020 or sun386 */ #endif /* not CRT0_DUMMIES */ diff -rc2 g++-old/gcc.c g++-1.35.0/gcc.c *** g++-old/gcc.c Sat Jul 29 19:52:25 1989 --- g++-1.35.0/gcc.c Sat Jul 29 21:51:29 1989 *************** *** 319,328 **** --- 319,337 ---- /* C++: Here is the spec for collecting global ctor and dtor requirements. */ + #ifdef sun386 char *collect_spec = "%{!c:%{!M*:%{!E:%{!S:collect -o %g.S %g.R\n\ as %g.S -o %g.O\n\ + ld -Bstatic -e _start %{o*} %g.R %g.O\n\ + rm -f %g.R %g.O\n\ + }}}}"; + #else + char *collect_spec = + "%{!c:%{!M*:%{!E:%{!S:collect -o %g.S %g.R\n\ + as %g.S -o %g.O\n\ ld %{o*} %g.R %g.O\n\ rm -f %g.R %g.O\n\ }}}}"; + #endif /* Here is the spec for running the linker, after compiling all files. */
pell@isy.liu.se (P{r Emanuelsson) (07/31/89)
I forgot to mention that the SUN assembler thinks that you shouldn't use long file names, like cplus-parse.tab.c. How's that for 10 years backwards development? Note the commands for compiling this file. Then rename it to e.g. "c.c", compile it the same way, and rename c.o to cplus-parse-tab.o. That's an easy temporary fix until we can use all the GNU tools, i.e. GAS. /Pell -- "Don't think; let the machine do it for you!" -- E. C. Berkeley Dept. of Electrical Engineering pell@isy.liu.se University of Linkoping, Sweden ...!uunet!isy.liu.se!pell