[dev.cc] liblink: invoke go tool objwriter during writeobj

This doesn't actually use objwriter for any real work.
It's just to check that objwriter is available.
The real work will be moved once the bootstrapping
mechanisms are working.

Change-Id: I5f41c8910c4b11b9d80cb0b0847ff9cb582fc2be
Reviewed-on: https://go-review.googlesource.com/3045
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Russ Cox 2015-01-19 11:38:53 -05:00
parent 328ace91e6
commit 725e3a7afb
1 changed files with 26 additions and 1 deletions

View File

@ -119,11 +119,36 @@ static char *rdstring(Biobuf*);
static void rddata(Biobuf*, uchar**, int*);
static LSym *rdsym(Link*, Biobuf*, char*);
void writeobjdirect(Link*, Biobuf*);
void
writeobj(Link *ctxt, Biobuf *b)
{
char *cmd[2];
// TODO(rsc): Use 'go tool objwriter' to write object file,
// allowing the bulk of liblink to be moved into Go.
// As a first step, we check that we can invoke objwriter at all
// (it is an empty program for now).
// This tests the cmd/dist bootstrap process, making sure
// that objwriter is available when it needs to be.
// Once the support mechanisms are there, we can put the
// real code in.
cmd[0] = smprint("%s/pkg/tool/%s_%s/objwriter", getgoroot(), getgohostos(), getgohostarch());
cmd[1] = "ping";
cmd[2] = nil;
if(runcmd(cmd) < 0)
sysfatal("cannot run objwriter: %r");
writeobjdirect(ctxt, b);
}
// The Go and C compilers, and the assembler, call writeobj to write
// out a Go object file. The linker does not call this; the linker
// does not write out object files.
void
writeobj(Link *ctxt, Biobuf *b)
writeobjdirect(Link *ctxt, Biobuf *b)
{
int flag, found;
Hist *h;