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
diff --git a/src/cmd/5l/obj.c b/src/cmd/5l/obj.c
index caa13ae..5dbd765 100644
--- a/src/cmd/5l/obj.c
+++ b/src/cmd/5l/obj.c
@@ -104,7 +104,9 @@
ARGBEGIN {
default:
c = ARGC();
- if(c >= 0 && c < sizeof(debug))
+ if(c == 'l')
+ usage();
+ if(c >= 0 && c < sizeof(debug))
debug[c]++;
break;
case 'o':
@@ -136,7 +138,6 @@
break;
case 'u': /* produce dynamically loadable module */
dlm = 1;
- debug['l']++;
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
readundefs(ARGF(), SIMPORT);
break;
@@ -259,9 +260,7 @@
lastp = firstp;
addlibpath("command line", "command line", argv[0], "main");
-
- if(!debug['l'])
- loadlib();
+ loadlib();
// 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
diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c
index edae1c6..537ef9e 100644
--- a/src/cmd/6l/obj.c
+++ b/src/cmd/6l/obj.c
@@ -100,7 +100,9 @@
ARGBEGIN {
default:
c = ARGC();
- if(c >= 0 && c < sizeof(debug))
+ if(c == 'l')
+ usage();
+ if(c >= 0 && c < sizeof(debug))
debug[c]++;
break;
case 'o': /* output to (next arg) */
@@ -131,7 +133,6 @@
break;
case 'u': /* produce dynamically loadable module */
dlm = 1;
- debug['l']++;
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
readundefs(ARGF(), SIMPORT);
break;
@@ -347,9 +348,7 @@
lastp = firstp;
addlibpath("command line", "command line", argv[0], "main");
-
- if(!debug['l'])
- loadlib();
+ loadlib();
deadcode();
diff --git a/src/cmd/8l/obj.c b/src/cmd/8l/obj.c
index 7b8e7f2..6ab4862 100644
--- a/src/cmd/8l/obj.c
+++ b/src/cmd/8l/obj.c
@@ -105,7 +105,9 @@
ARGBEGIN {
default:
c = ARGC();
- if(c >= 0 && c < sizeof(debug))
+ if(c == 'l')
+ usage();
+ if(c >= 0 && c < sizeof(debug))
debug[c]++;
break;
case 'o': /* output to (next arg) */
@@ -137,7 +139,6 @@
break;
case 'u': /* produce dynamically loadable module */
dlm = 1;
- debug['l']++;
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
readundefs(ARGF(), SIMPORT);
break;
@@ -385,9 +386,7 @@
lastp = firstp;
addlibpath("command line", "command line", argv[0], "main");
-
- if(!debug['l'])
- loadlib();
+ loadlib();
deadcode();
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c
index df0b1a7..a11ab90 100644
--- a/src/cmd/ld/lib.c
+++ b/src/cmd/ld/lib.c
@@ -35,8 +35,8 @@
int iconv(Fmt*);
char symname[] = SYMDEF;
-char* libdir[16] = { "." };
-int nlibdir = 1;
+char* libdir[16];
+int nlibdir = 0;
int cout = -1;
char* goroot;
@@ -180,6 +180,11 @@
for(i=0; i<libraryp; i++)
if(strcmp(file, library[i].file) == 0)
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){
nlibrary = 50 + 2*libraryp;
library = realloc(library, sizeof library[0] * nlibrary);
@@ -207,15 +212,24 @@
void
loadlib(void)
{
- int i;
+ char pname[1024];
+ int i, found;
int32 h;
Sym *s;
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");
+ found = 0;
+ for(i=0; i<nlibdir; i++) {
+ snprint(pname, sizeof pname, "%s/runtime.a", libdir[i]);
+ 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:
xrefresolv = 0;