1
0
mirror of https://github.com/golang/go synced 2024-11-22 01:34:41 -07:00

ld: include main and runtime in the library loop

Fixes #585.

R=r
CC=golang-dev
https://golang.org/cl/195075
This commit is contained in:
Russ Cox 2010-02-03 16:30:45 -08:00
parent 4a9a0056c1
commit 00f4c6a1b5
5 changed files with 36 additions and 17 deletions

View File

@ -258,7 +258,7 @@ main(int argc, char *argv[])
firstp = prg(); firstp = prg();
lastp = firstp; lastp = firstp;
objfile(argv[0], "main"); addlibpath("command line", "command line", argv[0], "main");
if(!debug['l']) if(!debug['l'])
loadlib(); loadlib();

View File

@ -346,7 +346,7 @@ main(int argc, char *argv[])
firstp = prg(); firstp = prg();
lastp = firstp; lastp = firstp;
objfile(argv[0], "main"); addlibpath("command line", "command line", argv[0], "main");
if(!debug['l']) if(!debug['l'])
loadlib(); loadlib();

View File

@ -384,7 +384,7 @@ main(int argc, char *argv[])
firstp = prg(); firstp = prg();
lastp = firstp; lastp = firstp;
objfile(argv[0], "main"); addlibpath("command line", "command line", argv[0], "main");
if(!debug['l']) if(!debug['l'])
loadlib(); loadlib();

View File

@ -94,7 +94,6 @@ addlib(char *src, char *obj)
{ {
char name[1024], pname[1024], comp[256], *p; char name[1024], pname[1024], comp[256], *p;
int i, search; int i, search;
Library *l;
if(histfrogp <= 0) if(histfrogp <= 0)
return; return;
@ -160,9 +159,26 @@ addlib(char *src, char *obj)
if(debug['v']) if(debug['v'])
Bprint(&bso, "%5.2f addlib: %s %s pulls in %s\n", cputime(), obj, src, pname); Bprint(&bso, "%5.2f addlib: %s %s pulls in %s\n", cputime(), obj, src, pname);
addlibpath(src, obj, pname, name);
}
/*
* add library to library list.
* srcref: src file referring to package
* objref: object file referring to package
* file: object file, e.g., /home/rsc/go/pkg/container/vector.a
* pkg: package import path, e.g. container/vector
*/
void
addlibpath(char *srcref, char *objref, char *file, char *pkg)
{
int i;
Library *l;
char *p;
for(i=0; i<libraryp; i++) for(i=0; i<libraryp; i++)
if(strcmp(pname, library[i].file) == 0) if(strcmp(file, library[i].file) == 0)
return; return;
if(libraryp == nlibrary){ if(libraryp == nlibrary){
nlibrary = 50 + 2*libraryp; nlibrary = 50 + 2*libraryp;
@ -171,20 +187,20 @@ addlib(char *src, char *obj)
l = &library[libraryp++]; l = &library[libraryp++];
p = mal(strlen(obj) + 1); p = mal(strlen(objref) + 1);
strcpy(p, obj); strcpy(p, objref);
l->objref = p; l->objref = p;
p = mal(strlen(src) + 1); p = mal(strlen(srcref) + 1);
strcpy(p, src); strcpy(p, srcref);
l->srcref = p; l->srcref = p;
p = mal(strlen(pname) + 1); p = mal(strlen(file) + 1);
strcpy(p, pname); strcpy(p, file);
l->file = p; l->file = p;
p = mal(strlen(name) + 1); p = mal(strlen(pkg) + 1);
strcpy(p, name); strcpy(p, pkg);
l->pkg = p; l->pkg = p;
} }
@ -196,6 +212,11 @@ loadlib(void)
Sym *s; Sym *s;
char *a; char *a;
i = strlen(goroot)+strlen(goarch)+strlen(goos)+20;
a = mal(i);
snprint(a, i, "%s/pkg/%s_%s/runtime.a", goroot, goos, goarch);
addlibpath("internal", "internal", a, "runtime");
loop: loop:
xrefresolv = 0; xrefresolv = 0;
for(i=0; i<libraryp; i++) { for(i=0; i<libraryp; i++) {
@ -203,16 +224,13 @@ loop:
Bprint(&bso, "%5.2f autolib: %s (from %s)\n", cputime(), library[i].file, library[i].objref); Bprint(&bso, "%5.2f autolib: %s (from %s)\n", cputime(), library[i].file, library[i].objref);
objfile(library[i].file, library[i].pkg); objfile(library[i].file, library[i].pkg);
} }
if(xrefresolv) if(xrefresolv)
for(h=0; h<nelem(hash); h++) for(h=0; h<nelem(hash); h++)
for(s = hash[h]; s != S; s = s->link) for(s = hash[h]; s != S; s = s->link)
if(s->type == SXREF) if(s->type == SXREF)
goto loop; goto loop;
i = strlen(goroot)+strlen(goarch)+strlen(goos)+20;
a = mal(i);
snprint(a, i, "%s/pkg/%s_%s/runtime.a", goroot, goos, goarch);
objfile(a, "runtime");
} }
void void

View File

@ -63,6 +63,7 @@ EXTERN int32 nsymbol;
EXTERN char* thestring; EXTERN char* thestring;
void addlib(char *src, char *obj); void addlib(char *src, char *obj);
void addlibpath(char *srcref, char *objref, char *file, char *pkg);
void copyhistfrog(char *buf, int nbuf); void copyhistfrog(char *buf, int nbuf);
void addhist(int32 line, int type); void addhist(int32 line, int type);
void histtoauto(void); void histtoauto(void);