1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:14:40 -07:00

search for runtime.a in the package path instead of hardcoding

the location. remove last remnants of broken -l flag.

R=rsc
CC=golang-dev
https://golang.org/cl/201042
This commit is contained in:
Kai Backman 2010-02-03 22:31:38 -08:00
parent c2cb0d70d5
commit 2f1a321d4f
4 changed files with 33 additions and 22 deletions

View File

@ -104,6 +104,8 @@ main(int argc, char *argv[])
ARGBEGIN { ARGBEGIN {
default: default:
c = ARGC(); c = ARGC();
if(c == 'l')
usage();
if(c >= 0 && c < sizeof(debug)) if(c >= 0 && c < sizeof(debug))
debug[c]++; debug[c]++;
break; break;
@ -136,7 +138,6 @@ main(int argc, char *argv[])
break; break;
case 'u': /* produce dynamically loadable module */ case 'u': /* produce dynamically loadable module */
dlm = 1; dlm = 1;
debug['l']++;
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])) if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
readundefs(ARGF(), SIMPORT); readundefs(ARGF(), SIMPORT);
break; break;
@ -259,8 +260,6 @@ main(int argc, char *argv[])
lastp = firstp; lastp = firstp;
addlibpath("command line", "command line", argv[0], "main"); addlibpath("command line", "command line", argv[0], "main");
if(!debug['l'])
loadlib(); loadlib();
// mark some functions that are only referenced after linker code editing // mark some functions that are only referenced after linker code editing

View File

@ -100,6 +100,8 @@ main(int argc, char *argv[])
ARGBEGIN { ARGBEGIN {
default: default:
c = ARGC(); c = ARGC();
if(c == 'l')
usage();
if(c >= 0 && c < sizeof(debug)) if(c >= 0 && c < sizeof(debug))
debug[c]++; debug[c]++;
break; break;
@ -131,7 +133,6 @@ main(int argc, char *argv[])
break; break;
case 'u': /* produce dynamically loadable module */ case 'u': /* produce dynamically loadable module */
dlm = 1; dlm = 1;
debug['l']++;
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])) if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
readundefs(ARGF(), SIMPORT); readundefs(ARGF(), SIMPORT);
break; break;
@ -347,8 +348,6 @@ main(int argc, char *argv[])
lastp = firstp; lastp = firstp;
addlibpath("command line", "command line", argv[0], "main"); addlibpath("command line", "command line", argv[0], "main");
if(!debug['l'])
loadlib(); loadlib();
deadcode(); deadcode();

View File

@ -105,6 +105,8 @@ main(int argc, char *argv[])
ARGBEGIN { ARGBEGIN {
default: default:
c = ARGC(); c = ARGC();
if(c == 'l')
usage();
if(c >= 0 && c < sizeof(debug)) if(c >= 0 && c < sizeof(debug))
debug[c]++; debug[c]++;
break; break;
@ -137,7 +139,6 @@ main(int argc, char *argv[])
break; break;
case 'u': /* produce dynamically loadable module */ case 'u': /* produce dynamically loadable module */
dlm = 1; dlm = 1;
debug['l']++;
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])) if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
readundefs(ARGF(), SIMPORT); readundefs(ARGF(), SIMPORT);
break; break;
@ -385,8 +386,6 @@ main(int argc, char *argv[])
lastp = firstp; lastp = firstp;
addlibpath("command line", "command line", argv[0], "main"); addlibpath("command line", "command line", argv[0], "main");
if(!debug['l'])
loadlib(); loadlib();
deadcode(); deadcode();

View File

@ -35,8 +35,8 @@
int iconv(Fmt*); int iconv(Fmt*);
char symname[] = SYMDEF; char symname[] = SYMDEF;
char* libdir[16] = { "." }; char* libdir[16];
int nlibdir = 1; int nlibdir = 0;
int cout = -1; int cout = -1;
char* goroot; char* goroot;
@ -180,6 +180,11 @@ addlibpath(char *srcref, char *objref, char *file, char *pkg)
for(i=0; i<libraryp; i++) for(i=0; i<libraryp; i++)
if(strcmp(file, library[i].file) == 0) if(strcmp(file, library[i].file) == 0)
return; return;
if(debug['v'])
Bprint(&bso, "%5.2f addlibpath: srcref: %s objref: %s file: %s pkg: %s\n",
cputime(), srcref, objref, file, pkg);
if(libraryp == nlibrary){ if(libraryp == nlibrary){
nlibrary = 50 + 2*libraryp; nlibrary = 50 + 2*libraryp;
library = realloc(library, sizeof library[0] * nlibrary); library = realloc(library, sizeof library[0] * nlibrary);
@ -207,15 +212,24 @@ addlibpath(char *srcref, char *objref, char *file, char *pkg)
void void
loadlib(void) loadlib(void)
{ {
int i; char pname[1024];
int i, found;
int32 h; int32 h;
Sym *s; Sym *s;
char *a; char *a;
i = strlen(goroot)+strlen(goarch)+strlen(goos)+20; found = 0;
a = mal(i); for(i=0; i<nlibdir; i++) {
snprint(a, i, "%s/pkg/%s_%s/runtime.a", goroot, goos, goarch); snprint(pname, sizeof pname, "%s/runtime.a", libdir[i]);
addlibpath("internal", "internal", a, "runtime"); if(debug['v'])
Bprint(&bso, "searching for runtime.a in %s\n", pname);
if(access(pname, AEXIST) >= 0) {
addlibpath("internal", "internal", pname, "runtime");
found = 1;
break;
}
}
if(!found) Bprint(&bso, "warning: unable to find runtime.a\n");
loop: loop:
xrefresolv = 0; xrefresolv = 0;