Commit 3c7a1ef2 authored by Kai Backman's avatar Kai Backman

Added automatic detection of system libraries to 5l.

R=rsc
APPROVED=rsc
DELTA=83  (73 added, 3 deleted, 7 changed)
OCL=29276
CL=29382
parent 79435569
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define EXTERN #define EXTERN
#include "l.h" #include "l.h"
#include "compat.h"
#include <ar.h> #include <ar.h>
#ifndef DEFAULT #ifndef DEFAULT
...@@ -144,6 +145,10 @@ main(int argc, char *argv[]) ...@@ -144,6 +145,10 @@ main(int argc, char *argv[])
diag("usage: 5l [-options] objects"); diag("usage: 5l [-options] objects");
errorexit(); errorexit();
} }
mywhatsys(); // get goroot, goarch, goos
if(strcmp(goarch, thestring) != 0)
print("goarch is not known: %s\n", goarch);
if(!debug['9'] && !debug['U'] && !debug['B']) if(!debug['9'] && !debug['U'] && !debug['B'])
debug[DEFAULT] = 1; debug[DEFAULT] = 1;
if(HEADTYPE == -1) { if(HEADTYPE == -1) {
...@@ -259,19 +264,20 @@ main(int argc, char *argv[]) ...@@ -259,19 +264,20 @@ main(int argc, char *argv[])
firstp = prg(); firstp = prg();
lastp = firstp; lastp = firstp;
if(INITENTRY == 0) { if(INITENTRY == nil) {
INITENTRY = "_main"; INITENTRY = mal(strlen(goarch)+strlen(goos)+10);
if(debug['p']) sprint(INITENTRY, "_rt0_%s_%s", goarch, goos);
INITENTRY = "_mainp"; }
if(!debug['l'])
lookup(INITENTRY, 0)->type = SXREF;
} else
lookup(INITENTRY, 0)->type = SXREF; lookup(INITENTRY, 0)->type = SXREF;
while(*argv) while(*argv)
objfile(*argv++); objfile(*argv++);
if(!debug['l']) if(!debug['l']) {
loadlib(); loadlib();
a = mal(strlen(goroot)+strlen(goarch)+strlen(goos)+20);
sprint(a, "%s/lib/lib_%s_%s.a", goroot, goarch, goos);
objfile(a);
}
firstp = firstp->link; firstp = firstp->link;
if(firstp == P) if(firstp == P)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment