leech@luther.cs.unc.edu (02/06/89)
I just finished installing cfront 1.2.1 on a Stellar GS/1000. Useful things which other porters may wish to know: - Stellix is System-V based (more or less), but doesn't have libld, so the munch option should be used. - when bootstrapping ('make fillscratch') on a machine already using C++, make sure to copy <datalock.h> along with <stdio.h> and <ctype.h> from the Stellar. When adding prototypes to <stdio.h>, include these: int __putc(int, FILE *); int __getc(FILE *); as well as the usual stdio prototypes. - the Stellar optimizer is untrustworthy and should be avoided. This is actually not a problem in installing C++, but might be with C++ code you attempt to port to the Stellar (or C code, for that matter). - The following changes to lib/static/munch.c (presented in 'diff -c' form) must be made to deal with Stellar's 'nm' output and mangling of function names: *** munch.c Sun Feb 5 17:08:46 1989 --- munch_att.c Sun Feb 5 17:08:49 1989 *************** *** 1,13 **** /* @(#) munch.c 1.7 2/16/87 11:03:03 */ /*ident "@(#)cfront:lib/static/munch.c 1.7"*/ /* - This version of munch.c is hacked for the Stellar GS/1000. - Stellar's 'nm' puts the symbol name first on each line, - and their object format creates two symbols for each procedure - entry point, e.g. "main_E" and "main_T". - Jon Leech 2/6/89 - scan nm output and detect constructors and destructors for static objects. the name is expected to be on the form _STD*_ or _STI*_ and less than 100 characters long. nm output lines are assumed to be less than 256 characters long. --- 1,8 ---- /* @(#) munch.c 1.7 2/16/87 11:03:03 */ /*ident "@(#)cfront:lib/static/munch.c 1.7"*/ /* scan nm output and detect constructors and destructors for static objects. + the name on an nm output line is expected to be in the right hand margin. the name is expected to be on the form _STD*_ or _STI*_ and less than 100 characters long. nm output lines are assumed to be less than 256 characters long. *************** *** 15,24 **** destructors found are called by exit(). return 0 if no constructor or destructor is found otherwise. The output is redirected by CC into _ctdt.c */ #include <stdio.h> - #include <ctype.h> //extern int strcpy(char*, char*); //extern char * strtok(char*, char*); --- 10,19 ---- destructors found are called by exit(). return 0 if no constructor or destructor is found otherwise. The output is redirected by CC into _ctdt.c + */ #include <stdio.h> //extern int strcpy(char*, char*); //extern char * strtok(char*, char*); *************** *** 55,94 **** goto done; case '\n': { *p = 0; // terminate string ! ! /* Find start of symbol */ ! for (p = buf; isspace(*p); p++) ! ; ! ! /* Verify this is a legal constructor/destructor name */ ! if (strncmp(p, "_ST", 3)) ! goto newline; ! ! /* Find end of symbol */ ! for (char *end = p; isalpha(*end) || *end == '_'; end++) ! ; ! ! /* Verify this is the entry point, not the text address */ ! if (strncmp(end-2, "_E", 2)) ! goto newline; ! ! /* Remove _E which will be appended back by cc */ ! *(end-2) = '\0'; ! ! /* printf("Adding name '%s'\n", p); */ ! ! switch (p[3]) { case 'D': ! dtor = new sbuf(dtor,p); ! break; case 'I': ! ctor = new sbuf(ctor,p); ! break; default: - break; - } goto newline; } default: *p++ = c; } --- 50,70 ---- goto done; case '\n': { *p = 0; // terminate string ! p = buf; ! while (*p++!='_') if (*p == 0) goto newline; ! for (p--; *p == '_'; p++) ; // accept _STI and __STI ! register char* st = p-1; ! if (st[0]!='_' || st[1]!='S' || st[2]!='T') goto newline; ! switch (st[3]) { case 'D': ! dtor = new sbuf(dtor,st); ! goto newline; case 'I': ! ctor = new sbuf(ctor,st); default: goto newline; } + } default: *p++ = c; } -- Jon Leech (leech@cs.unc.edu) __@/ "Totally bounded: A set that can be patrolled by a finite number of arbitrarily near-sighted policemen." A. Wilonsky, 1978