jjc@UUNET.UU.NET (James Clark) (04/01/89)
I have been trying to get g++ 1.34.1 working under 386/ix, which is System V rel 3.2 for the 386. I am not using COFF encapsulation so I did config.g++ i386-sysv. I applied the diffs posted by Dirk Grunwald to comp.lang.c++ implementing COFF support with collect. I had to make the following changes: * I renamed cplus-parse.y to cplus-p.y, since the name cplus-parse.tab.c is too long for System V. * I commented out the definition of vfprintf in gcc.c; it's declared in <stdio.h> to return int, but the definition in gcc.c declares it to return void. * The assembler refuses to accept dollars in identifiers. I fixed this by replacing the dollar sign on output. I just redefined ASM_OUTPUT_LABELREF in tm-att386.h, and assemble_name in varasm.c to replace dollar signs with a couple of underscores. * I removed the definition of LIB_SPEC and STARTFILE_SPEC from tm.h, so that the definitions in gcc.c would be used. * I had to hack collect.c a bit. It assumes in several places that an underscore gets prepended by the compiler, which isn't so on my machine. I also had to modify it to take account of the replacement of the dollar sign. I haven't included diffs for any of the above since I haven't integrated the changes cleanly yet. collect.c, in particular, needs a bit of reworking to improve its portability. I have included diffs for the rest at the end. * cplus-lex.c calls setbuffer in 2 places. I tried calling setvbuf as is done if hp9000s300 is defined; but this didn't work. I think the problem may be that setvbuf is being called after the stream has been read from. So I manipulated the FILE structure directly. * I had to make a few changes to sdbout.c to get as and ld to work. The change to PUT_SDB_EPILOGUE_END is only needed in order to ensure that dollar signs get replaced. * crt0.c didn't have a suitable definition for this system, so I had to discover one. That's all, I think. It seems to work just fine now. It would be really nice to have a SDB+ format. I wondered whether anybody had given any thought to implementing this. It isn't very obvious to me how to do it; the format used by COFF to represent types doesn't seem very extensible, and I think it might be hard to design extensions that as and ld will let through. Or is everybody going down the encapsulated COFF route? *** ../gcc/sdbout.c Wed Mar 29 06:26:07 1989 --- sdbout.c Sat Apr 1 08:23:43 1989 *************** *** 134,142 **** #ifndef PUT_SDB_EPILOGUE_END #define PUT_SDB_EPILOGUE_END(NAME) \ ! fprintf (asm_out_file, \ ! "\t.def\t%s;\t.val\t.;\t.scl\t-1;\t.endef\n", \ ! (NAME)) #endif #ifndef SDB_GENERATE_FAKE --- 134,142 ---- #ifndef PUT_SDB_EPILOGUE_END #define PUT_SDB_EPILOGUE_END(NAME) \ ! do { fprintf (asm_out_file, "\t.def\t"); \ ! ASM_OUTPUT_LABELREF (asm_out_file, (NAME)); \ ! fprintf (asm_out_file, ";\t.val\t.;\t.scl\t-1;\t.endef\n"); } while (0) #endif #ifndef SDB_GENERATE_FAKE *************** *** 353,358 **** --- 353,359 ---- int m = plain_type (TREE_TYPE (type)); return PUSH_DERIVED_LEVEL (DT_PTR, m); } + case METHOD_TYPE: case FUNCTION_TYPE: { int m = plain_type (TREE_TYPE (type)); *************** *** 488,494 **** return; /* Ok, start a symtab entry and output the variable name. */ ! PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl))); if (GET_CODE (DECL_RTL (decl)) == MEM && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF) --- 489,502 ---- return; /* Ok, start a symtab entry and output the variable name. */ ! if (DECL_LANG_SPECIFIC (decl)) { ! char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0); ! if (name[0] == '*') ! name += 1; ! PUT_SDB_DEF (name); ! } ! else ! PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl))); if (GET_CODE (DECL_RTL (decl)) == MEM && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF) *** ../src-g++/crt0.c Wed Mar 29 16:56:59 1989 --- crt0.c Fri Mar 31 13:05:51 1989 *************** *** 197,202 **** --- 197,213 ---- asm(" .set _387_flt,0"); #endif + #if defined(i386) + _start(arg) + char *arg; + { + int argc = (int)(&arg)[-1]; + environ = &arg + argc + 1; + setchrclass((char *)0); + __do_global_init(); + exit(main(argc, &arg, environ)); + } + #endif #if defined(orion) || defined(pyramid) || defined(celerity) || defined(ALLIANT) #ifdef ALLIANT *************** *** 703,709 **** int status; { __do_global_cleanup (); ! #ifdef hp9000s300 _cleanup (); #endif _exit (status); --- 714,720 ---- int status; { __do_global_cleanup (); ! #if defined(hp9000s300) || defined(i386) _cleanup (); #endif _exit (status); *** ../src-g++/cplus-lex.c Wed Mar 29 16:56:53 1989 --- cplus-lex.c Sat Apr 1 08:43:57 1989 *************** *** 25,31 **** #include <errno.h> #include "config.h" #include "tree.h" ! #include "cplus-parse.tab.h" #include "cplus-parse.h" #include "cplus-tree.h" #include "flags.h" --- 25,31 ---- #include <errno.h> #include "config.h" #include "tree.h" ! #include "cplus-p.tab.h" #include "cplus-parse.h" #include "cplus-tree.h" #include "flags.h" *************** *** 849,854 **** --- 849,860 ---- t = pending_inlines; pending_inlines = pending_inlines->next; finput = finput2; + #ifdef i386 + finput2->_ptr = finput2->_base = t->buf; + _bufend(finput2) = t->buf + t->len; + finput2->_flag = _IOFBF | _IOREAD; + finput2->_cnt = t->len - 1; + #else #ifndef hp9000s300 setbuffer (finput2, t->buf, t->len); finput2->_cnt = finput2->_bufsiz - 1; *************** *** 856,861 **** --- 862,868 ---- setvbuf(finput2,t->buf,_IOFBF,t->len); finput2->_cnt = t->len-1; #endif + #endif lineno = t->lineno; input_filename = t->filename; #ifdef DO_INLINES_THE_OLD_WAY *************** *** 1597,1602 **** --- 1604,1615 ---- /* The buffer we used will be freed at the end of this function. */ pending_inlines = pending_inlines->next; + #ifdef i386 + finput2->_ptr = finput2->_base = t->buf; + _bufend(finput2) = t->buf + t->len; + finput2->_flag = _IOFBF | _IOREAD; + finput2->_cnt = t->len - 1; + #else #ifndef hp9000s300 setbuffer (finput2, t->buf, t->len); finput2->_cnt = finput2->_bufsiz - 1; *************** *** 1603,1608 **** --- 1616,1622 ---- #else setvbuf(finput2,t->buf,_IOFBF,t->len); finput2->_cnt = t->len-1; + #endif #endif } else James Clark jjc@jclark.uucp uunet!mcvax!jclark!jjc