1
0
mirror of https://github.com/golang/go synced 2024-11-25 05:57:57 -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,7 +104,9 @@ main(int argc, char *argv[])
ARGBEGIN { ARGBEGIN {
default: default:
c = ARGC(); c = ARGC();
if(c >= 0 && c < sizeof(debug)) if(c == 'l')
usage();
if(c >= 0 && c < sizeof(debug))
debug[c]++; debug[c]++;
break; break;
case 'o': case 'o':
@ -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,9 +260,7 @@ 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");
loadlib();
if(!debug['l'])
loadlib();
// mark some functions that are only referenced after linker code editing // mark some functions that are only referenced after linker code editing
// TODO(kaib): this doesn't work, the prog can't be found in runtime // TODO(kaib): this doesn't work, the prog can't be found in runtime

View File

@ -100,7 +100,9 @@ main(int argc, char *argv[])
ARGBEGIN { ARGBEGIN {
default: default:
c = ARGC(); c = ARGC();
if(c >= 0 && c < sizeof(debug)) if(c == 'l')
usage();
if(c >= 0 && c < sizeof(debug))
debug[c]++; debug[c]++;
break; break;
case 'o': /* output to (next arg) */ case 'o': /* output to (next arg) */
@ -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,9 +348,7 @@ 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");
loadlib();
if(!debug['l'])
loadlib();
deadcode(); deadcode();

View File

@ -105,7 +105,9 @@ main(int argc, char *argv[])
ARGBEGIN { ARGBEGIN {
default: default:
c = ARGC(); c = ARGC();
if(c >= 0 && c < sizeof(debug)) if(c == 'l')
usage();
if(c >= 0 && c < sizeof(debug))
debug[c]++; debug[c]++;
break; break;
case 'o': /* output to (next arg) */ case 'o': /* output to (next arg) */
@ -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,9 +386,7 @@ 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");
loadlib();
if(!debug['l'])
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;