mirror of
https://github.com/golang/go
synced 2024-11-21 23:44:39 -07:00
cmd/dist: cross-compiling fixes
This CL makes it possible to run make.bash with GOOS and GOARCH set to something other than the native host GOOS and GOARCH. As part of the CL, the tool directory moves from bin/tool/ to pkg/tool/goos_goarch where goos and goarch are the values for the host system (running the build), not the target. pkg/ is not technically appropriate, but C objects are there now tool (pkg/obj/) so this puts all the generated binaries in one place (rm -rf $GOROOT/pkg cleans everything). Including goos_goarch in the name allows different systems to share a single $GOROOT on a shared file system. Fixes #2920. R=golang-dev, r CC=golang-dev https://golang.org/cl/5645093
This commit is contained in:
parent
569ef7d49e
commit
7b848c6964
@ -9,5 +9,5 @@ if [ ! -f make.bash ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
. ./make.bash --no-banner
|
. ./make.bash --no-banner
|
||||||
bash run.bash --no-rebuild
|
bash run.bash --no-rebuild --banner
|
||||||
../bin/tool/dist banner # print build info
|
$GOTOOLDIR/dist banner # print build info
|
||||||
|
2
src/cmd/dist/a.h
vendored
2
src/cmd/dist/a.h
vendored
@ -72,7 +72,9 @@ extern char *goroot;
|
|||||||
extern char *goroot_final;
|
extern char *goroot_final;
|
||||||
extern char *goversion;
|
extern char *goversion;
|
||||||
extern char *workdir;
|
extern char *workdir;
|
||||||
|
extern char *tooldir;
|
||||||
extern char *slash;
|
extern char *slash;
|
||||||
|
extern bool rebuildall;
|
||||||
|
|
||||||
int find(char*, char**, int);
|
int find(char*, char**, int);
|
||||||
void init(void);
|
void init(void);
|
||||||
|
172
src/cmd/dist/build.c
vendored
172
src/cmd/dist/build.c
vendored
@ -13,15 +13,19 @@
|
|||||||
char *goarch;
|
char *goarch;
|
||||||
char *gobin;
|
char *gobin;
|
||||||
char *gohostarch;
|
char *gohostarch;
|
||||||
|
char *gohostchar;
|
||||||
char *gohostos;
|
char *gohostos;
|
||||||
char *goos;
|
char *goos;
|
||||||
char *goroot = GOROOT_FINAL;
|
char *goroot = GOROOT_FINAL;
|
||||||
char *goroot_final = GOROOT_FINAL;
|
char *goroot_final = GOROOT_FINAL;
|
||||||
char *workdir;
|
char *workdir;
|
||||||
|
char *tooldir;
|
||||||
char *gochar;
|
char *gochar;
|
||||||
char *goversion;
|
char *goversion;
|
||||||
char *slash; // / for unix, \ for windows
|
char *slash; // / for unix, \ for windows
|
||||||
|
|
||||||
|
bool rebuildall = 0;
|
||||||
|
|
||||||
static bool shouldbuild(char*, char*);
|
static bool shouldbuild(char*, char*);
|
||||||
static void copy(char*, char*);
|
static void copy(char*, char*);
|
||||||
static char *findgoversion(void);
|
static char *findgoversion(void);
|
||||||
@ -99,14 +103,18 @@ init(void)
|
|||||||
if(b.len > 0)
|
if(b.len > 0)
|
||||||
gohostarch = btake(&b);
|
gohostarch = btake(&b);
|
||||||
|
|
||||||
if(find(gohostarch, okgoarch, nelem(okgoarch)) < 0)
|
i = find(gohostarch, okgoarch, nelem(okgoarch));
|
||||||
|
if(i < 0)
|
||||||
fatal("unknown $GOHOSTARCH %s", gohostarch);
|
fatal("unknown $GOHOSTARCH %s", gohostarch);
|
||||||
|
bprintf(&b, "%c", gochars[i]);
|
||||||
|
gohostchar = btake(&b);
|
||||||
|
|
||||||
xgetenv(&b, "GOARCH");
|
xgetenv(&b, "GOARCH");
|
||||||
if(b.len == 0)
|
if(b.len == 0)
|
||||||
bwritestr(&b, gohostarch);
|
bwritestr(&b, gohostarch);
|
||||||
goarch = btake(&b);
|
goarch = btake(&b);
|
||||||
if((i=find(goarch, okgoarch, nelem(okgoarch))) < 0)
|
i = find(goarch, okgoarch, nelem(okgoarch));
|
||||||
|
if(i < 0)
|
||||||
fatal("unknown $GOARCH %s", goarch);
|
fatal("unknown $GOARCH %s", goarch);
|
||||||
bprintf(&b, "%c", gochars[i]);
|
bprintf(&b, "%c", gochars[i]);
|
||||||
gochar = btake(&b);
|
gochar = btake(&b);
|
||||||
@ -124,6 +132,9 @@ init(void)
|
|||||||
workdir = xworkdir();
|
workdir = xworkdir();
|
||||||
xatexit(rmworkdir);
|
xatexit(rmworkdir);
|
||||||
|
|
||||||
|
bpathf(&b, "%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch);
|
||||||
|
tooldir = btake(&b);
|
||||||
|
|
||||||
bfree(&b);
|
bfree(&b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +267,7 @@ static char *oldtool[] = {
|
|||||||
"8a", "8c", "8g", "8l",
|
"8a", "8c", "8g", "8l",
|
||||||
"6cov",
|
"6cov",
|
||||||
"6nm",
|
"6nm",
|
||||||
|
"6prof",
|
||||||
"cgo",
|
"cgo",
|
||||||
"ebnflint",
|
"ebnflint",
|
||||||
"goapi",
|
"goapi",
|
||||||
@ -281,11 +293,8 @@ setup(void)
|
|||||||
|
|
||||||
binit(&b);
|
binit(&b);
|
||||||
|
|
||||||
// Create tool directory.
|
// Create bin directory.
|
||||||
p = bpathf(&b, "%s/bin", goroot);
|
p = bpathf(&b, "%s/bin", goroot);
|
||||||
if(!isdir(p))
|
|
||||||
xmkdir(p);
|
|
||||||
p = bpathf(&b, "%s/bin/tool", goroot);
|
|
||||||
if(!isdir(p))
|
if(!isdir(p))
|
||||||
xmkdir(p);
|
xmkdir(p);
|
||||||
|
|
||||||
@ -293,20 +302,41 @@ setup(void)
|
|||||||
p = bpathf(&b, "%s/pkg", goroot);
|
p = bpathf(&b, "%s/pkg", goroot);
|
||||||
if(!isdir(p))
|
if(!isdir(p))
|
||||||
xmkdir(p);
|
xmkdir(p);
|
||||||
p = bpathf(&b, "%s/pkg/%s_%s", goroot, goos, goarch);
|
p = bpathf(&b, "%s/pkg/%s_%s", goroot, gohostos, gohostarch);
|
||||||
|
if(rebuildall)
|
||||||
xremoveall(p);
|
xremoveall(p);
|
||||||
xmkdir(p);
|
xmkdir(p);
|
||||||
|
if(!streq(goos, gohostos) || !streq(goarch, gohostarch)) {
|
||||||
|
p = bpathf(&b, "%s/pkg/%s_%s", goroot, goos, goarch);
|
||||||
|
if(rebuildall)
|
||||||
|
xremoveall(p);
|
||||||
|
xmkdir(p);
|
||||||
|
}
|
||||||
|
|
||||||
// Create object directory.
|
// Create object directory.
|
||||||
// We keep it in pkg/ so that all the generated binaries
|
// We keep it in pkg/ so that all the generated binaries
|
||||||
// are in one tree.
|
// are in one tree. If pkg/obj/libgc.a exists, it is a dreg from
|
||||||
p = bpathf(&b, "%s/pkg/obj", goroot);
|
// before we used subdirectories of obj. Delete all of obj
|
||||||
|
// to clean up.
|
||||||
|
bpathf(&b, "%s/pkg/obj/libgc.a", goroot);
|
||||||
|
if(isfile(bstr(&b)))
|
||||||
|
xremoveall(bpathf(&b, "%s/pkg/obj", goroot));
|
||||||
|
p = bpathf(&b, "%s/pkg/obj/%s_%s", goroot, gohostos, gohostarch);
|
||||||
|
if(rebuildall)
|
||||||
xremoveall(p);
|
xremoveall(p);
|
||||||
xmkdir(p);
|
xmkdirall(p);
|
||||||
|
|
||||||
|
// Create tool directory.
|
||||||
|
// We keep it in pkg/, just like the object directory above.
|
||||||
|
xremoveall(tooldir);
|
||||||
|
xmkdirall(tooldir);
|
||||||
|
|
||||||
|
// Remove tool binaries from before the tool/gohostos_gohostarch
|
||||||
|
xremoveall(bpathf(&b, "%s/bin/tool", goroot));
|
||||||
|
|
||||||
// Remove old pre-tool binaries.
|
// Remove old pre-tool binaries.
|
||||||
for(i=0; i<nelem(oldtool); i++)
|
for(i=0; i<nelem(oldtool); i++)
|
||||||
xremove(bprintf(&b, "%s%s%s%s%s", goroot, slash, "bin", slash, oldtool[i]));
|
xremove(bpathf(&b, "%s/bin/%s", goroot, oldtool[i]));
|
||||||
|
|
||||||
// If $GOBIN is set and has a Go compiler, it must be cleaned.
|
// If $GOBIN is set and has a Go compiler, it must be cleaned.
|
||||||
for(i=0; gochars[i]; i++) {
|
for(i=0; gochars[i]; i++) {
|
||||||
@ -390,37 +420,37 @@ static struct {
|
|||||||
"../cc/pgen.c",
|
"../cc/pgen.c",
|
||||||
"../cc/pswt.c",
|
"../cc/pswt.c",
|
||||||
"../5l/enam.c",
|
"../5l/enam.c",
|
||||||
"$GOROOT/pkg/obj/libcc.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a",
|
||||||
}},
|
}},
|
||||||
{"cmd/6c", {
|
{"cmd/6c", {
|
||||||
"../cc/pgen.c",
|
"../cc/pgen.c",
|
||||||
"../cc/pswt.c",
|
"../cc/pswt.c",
|
||||||
"../6l/enam.c",
|
"../6l/enam.c",
|
||||||
"$GOROOT/pkg/obj/libcc.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a",
|
||||||
}},
|
}},
|
||||||
{"cmd/8c", {
|
{"cmd/8c", {
|
||||||
"../cc/pgen.c",
|
"../cc/pgen.c",
|
||||||
"../cc/pswt.c",
|
"../cc/pswt.c",
|
||||||
"../8l/enam.c",
|
"../8l/enam.c",
|
||||||
"$GOROOT/pkg/obj/libcc.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a",
|
||||||
}},
|
}},
|
||||||
{"cmd/5g", {
|
{"cmd/5g", {
|
||||||
"../gc/cplx.c",
|
"../gc/cplx.c",
|
||||||
"../gc/pgen.c",
|
"../gc/pgen.c",
|
||||||
"../5l/enam.c",
|
"../5l/enam.c",
|
||||||
"$GOROOT/pkg/obj/libgc.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
|
||||||
}},
|
}},
|
||||||
{"cmd/6g", {
|
{"cmd/6g", {
|
||||||
"../gc/cplx.c",
|
"../gc/cplx.c",
|
||||||
"../gc/pgen.c",
|
"../gc/pgen.c",
|
||||||
"../6l/enam.c",
|
"../6l/enam.c",
|
||||||
"$GOROOT/pkg/obj/libgc.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
|
||||||
}},
|
}},
|
||||||
{"cmd/8g", {
|
{"cmd/8g", {
|
||||||
"../gc/cplx.c",
|
"../gc/cplx.c",
|
||||||
"../gc/pgen.c",
|
"../gc/pgen.c",
|
||||||
"../8l/enam.c",
|
"../8l/enam.c",
|
||||||
"$GOROOT/pkg/obj/libgc.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
|
||||||
}},
|
}},
|
||||||
{"cmd/5l", {
|
{"cmd/5l", {
|
||||||
"../ld/data.c",
|
"../ld/data.c",
|
||||||
@ -442,9 +472,9 @@ static struct {
|
|||||||
"enam.c",
|
"enam.c",
|
||||||
}},
|
}},
|
||||||
{"cmd/", {
|
{"cmd/", {
|
||||||
"$GOROOT/pkg/obj/libmach.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libmach.a",
|
||||||
"$GOROOT/pkg/obj/libbio.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libbio.a",
|
||||||
"$GOROOT/pkg/obj/lib9.a",
|
"$GOROOT/pkg/obj/$GOOS_$GOARCH/lib9.a",
|
||||||
}},
|
}},
|
||||||
{"pkg/runtime", {
|
{"pkg/runtime", {
|
||||||
"zasm_$GOOS_$GOARCH.h",
|
"zasm_$GOOS_$GOARCH.h",
|
||||||
@ -490,8 +520,12 @@ install(char *dir)
|
|||||||
Time ttarg, t;
|
Time ttarg, t;
|
||||||
int i, j, k, n, doclean;
|
int i, j, k, n, doclean;
|
||||||
|
|
||||||
if(vflag)
|
if(vflag) {
|
||||||
|
if(!streq(goos, gohostos) || !streq(goarch, gohostarch))
|
||||||
|
xprintf("%s (%s/%s)\n", dir, goos, goarch);
|
||||||
|
else
|
||||||
xprintf("%s\n", dir);
|
xprintf("%s\n", dir);
|
||||||
|
}
|
||||||
|
|
||||||
binit(&b);
|
binit(&b);
|
||||||
binit(&b1);
|
binit(&b1);
|
||||||
@ -521,7 +555,7 @@ install(char *dir)
|
|||||||
|
|
||||||
islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd/gc");
|
islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd/gc");
|
||||||
ispkg = hasprefix(dir, "pkg");
|
ispkg = hasprefix(dir, "pkg");
|
||||||
isgo = ispkg || streq(dir, "cmd/go");
|
isgo = ispkg || streq(dir, "cmd/go") || streq(dir, "cmd/cgo");
|
||||||
|
|
||||||
exe = "";
|
exe = "";
|
||||||
if(streq(gohostos, "windows"))
|
if(streq(gohostos, "windows"))
|
||||||
@ -536,27 +570,30 @@ install(char *dir)
|
|||||||
prefix = "";
|
prefix = "";
|
||||||
if(!hasprefix(name, "lib"))
|
if(!hasprefix(name, "lib"))
|
||||||
prefix = "lib";
|
prefix = "lib";
|
||||||
vadd(&link, bpathf(&b, "%s/pkg/obj/%s%s.a", goroot, prefix, name));
|
vadd(&link, bpathf(&b, "%s/pkg/obj/%s_%s/%s%s.a", goroot, gohostos, gohostarch, prefix, name));
|
||||||
} else if(ispkg) {
|
} else if(ispkg) {
|
||||||
// Go library (package).
|
// Go library (package).
|
||||||
vadd(&link, bpathf(&b, "%s/bin/tool/pack", goroot));
|
vadd(&link, bpathf(&b, "%s/pack", tooldir));
|
||||||
vadd(&link, "grc");
|
vadd(&link, "grc");
|
||||||
p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4);
|
p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, gohostos, gohostarch, dir+4);
|
||||||
*xstrrchr(p, '/') = '\0';
|
*xstrrchr(p, '/') = '\0';
|
||||||
xmkdirall(p);
|
xmkdirall(p);
|
||||||
vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch, dir+4));
|
vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, gohostos, gohostarch, dir+4));
|
||||||
} else if(streq(dir, "cmd/go")) {
|
} else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) {
|
||||||
// Go command.
|
// Go command.
|
||||||
vadd(&link, bpathf(&b, "%s/bin/tool/%sl", goroot, gochar));
|
vadd(&link, bpathf(&b, "%s/%sl", tooldir, gochar));
|
||||||
vadd(&link, "-o");
|
vadd(&link, "-o");
|
||||||
vadd(&link, bpathf(&b, "%s/bin/tool/go_bootstrap%s", goroot, exe));
|
elem = name;
|
||||||
|
if(streq(elem, "go"))
|
||||||
|
elem = "go_bootstrap";
|
||||||
|
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, elem, exe));
|
||||||
} else {
|
} else {
|
||||||
// C command.
|
// C command.
|
||||||
// Use gccargs, but ensure that link.p[2] is output file,
|
// Use gccargs, but ensure that link.p[2] is output file,
|
||||||
// as noted above.
|
// as noted above.
|
||||||
vadd(&link, gccargs.p[0]);
|
vadd(&link, gccargs.p[0]);
|
||||||
vadd(&link, "-o");
|
vadd(&link, "-o");
|
||||||
vadd(&link, bpathf(&b, "%s/bin/tool/%s%s", goroot, name, exe));
|
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, name, exe));
|
||||||
vcopy(&link, gccargs.p+1, gccargs.len-1);
|
vcopy(&link, gccargs.p+1, gccargs.len-1);
|
||||||
if(streq(gohostarch, "amd64"))
|
if(streq(gohostarch, "amd64"))
|
||||||
vadd(&link, "-m64");
|
vadd(&link, "-m64");
|
||||||
@ -636,7 +673,7 @@ install(char *dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is the target up-to-date?
|
// Is the target up-to-date?
|
||||||
stale = 1; // TODO: Decide when 0 is okay.
|
stale = rebuildall;
|
||||||
n = 0;
|
n = 0;
|
||||||
for(i=0; i<files.len; i++) {
|
for(i=0; i<files.len; i++) {
|
||||||
p = files.p[i];
|
p = files.p[i];
|
||||||
@ -683,12 +720,6 @@ install(char *dir)
|
|||||||
bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos));
|
bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For cmd/prof, copy pprof into the tool directory.
|
|
||||||
if(streq(dir, "cmd/prof")) {
|
|
||||||
copy(bpathf(&b, "%s/bin/tool/pprof", goroot),
|
|
||||||
bpathf(&b1, "%s/src/cmd/prof/pprof", goroot));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate any missing files; regenerate existing ones.
|
// Generate any missing files; regenerate existing ones.
|
||||||
for(i=0; i<files.len; i++) {
|
for(i=0; i<files.len; i++) {
|
||||||
p = files.p[i];
|
p = files.p[i];
|
||||||
@ -738,6 +769,13 @@ install(char *dir)
|
|||||||
vuniq(&files);
|
vuniq(&files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!streq(goos, gohostos) || !streq(goarch, gohostarch)) {
|
||||||
|
// We've generated the right files; the go command can do the build.
|
||||||
|
if(vflag > 1)
|
||||||
|
xprintf("skip build for cross-compile %s\n", dir);
|
||||||
|
goto nobuild;
|
||||||
|
}
|
||||||
|
|
||||||
// Compile the files.
|
// Compile the files.
|
||||||
for(i=0; i<files.len; i++) {
|
for(i=0; i<files.len; i++) {
|
||||||
if(!hassuffix(files.p[i], ".c") && !hassuffix(files.p[i], ".s"))
|
if(!hassuffix(files.p[i], ".c") && !hassuffix(files.p[i], ".s"))
|
||||||
@ -762,7 +800,7 @@ install(char *dir)
|
|||||||
vadd(&compile, "-I");
|
vadd(&compile, "-I");
|
||||||
vadd(&compile, bstr(&path));
|
vadd(&compile, bstr(&path));
|
||||||
|
|
||||||
// runtime/goos.c gets the default constants hard-coded.
|
// lib9/goos.c gets the default constants hard-coded.
|
||||||
if(streq(name, "goos.c")) {
|
if(streq(name, "goos.c")) {
|
||||||
vadd(&compile, bprintf(&b, "-DGOOS=\"%s\"", goos));
|
vadd(&compile, bprintf(&b, "-DGOOS=\"%s\"", goos));
|
||||||
vadd(&compile, bprintf(&b, "-DGOARCH=\"%s\"", goarch));
|
vadd(&compile, bprintf(&b, "-DGOARCH=\"%s\"", goarch));
|
||||||
@ -780,9 +818,9 @@ install(char *dir)
|
|||||||
} else {
|
} else {
|
||||||
// Supporting files for a Go package.
|
// Supporting files for a Go package.
|
||||||
if(hassuffix(files.p[i], ".s"))
|
if(hassuffix(files.p[i], ".s"))
|
||||||
vadd(&compile, bpathf(&b, "%s/bin/tool/%sa", goroot, gochar));
|
vadd(&compile, bpathf(&b, "%s/%sa", tooldir, gochar));
|
||||||
else {
|
else {
|
||||||
vadd(&compile, bpathf(&b, "%s/bin/tool/%sc", goroot, gochar));
|
vadd(&compile, bpathf(&b, "%s/%sc", tooldir, gochar));
|
||||||
vadd(&compile, "-FVw");
|
vadd(&compile, "-FVw");
|
||||||
}
|
}
|
||||||
vadd(&compile, "-I");
|
vadd(&compile, "-I");
|
||||||
@ -820,7 +858,7 @@ install(char *dir)
|
|||||||
// The last loop was compiling individual files.
|
// The last loop was compiling individual files.
|
||||||
// Hand the Go files to the compiler en masse.
|
// Hand the Go files to the compiler en masse.
|
||||||
vreset(&compile);
|
vreset(&compile);
|
||||||
vadd(&compile, bpathf(&b, "%s/bin/tool/%sg", goroot, gochar));
|
vadd(&compile, bpathf(&b, "%s/%sg", tooldir, gochar));
|
||||||
|
|
||||||
bpathf(&b, "%s/_go_.%s", workdir, gochar);
|
bpathf(&b, "%s/_go_.%s", workdir, gochar);
|
||||||
vadd(&compile, "-o");
|
vadd(&compile, "-o");
|
||||||
@ -853,6 +891,7 @@ install(char *dir)
|
|||||||
|
|
||||||
runv(nil, nil, CheckExit, &link);
|
runv(nil, nil, CheckExit, &link);
|
||||||
|
|
||||||
|
nobuild:
|
||||||
// In package runtime, we install runtime.h and cgocall.h too,
|
// In package runtime, we install runtime.h and cgocall.h too,
|
||||||
// for use by cgo compilation.
|
// for use by cgo compilation.
|
||||||
if(streq(dir, "pkg/runtime")) {
|
if(streq(dir, "pkg/runtime")) {
|
||||||
@ -921,6 +960,8 @@ shouldbuild(char *file, char *dir)
|
|||||||
// so special case that file.
|
// so special case that file.
|
||||||
if(hassuffix(file, "cmd/go/doc.go") || hassuffix(file, "cmd\\go\\doc.go"))
|
if(hassuffix(file, "cmd/go/doc.go") || hassuffix(file, "cmd\\go\\doc.go"))
|
||||||
return 0;
|
return 0;
|
||||||
|
if(hassuffix(file, "cmd/cgo/doc.go") || hassuffix(file, "cmd\\cgo\\doc.go"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Check file contents for // +build lines.
|
// Check file contents for // +build lines.
|
||||||
binit(&b);
|
binit(&b);
|
||||||
@ -940,7 +981,7 @@ shouldbuild(char *file, char *dir)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if(contains(p, "package main") && !streq(dir, "cmd/go")) {
|
if(contains(p, "package main") && !streq(dir, "cmd/go") && !streq(dir, "cmd/cgo")) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1044,7 +1085,6 @@ static char *buildorder[] = {
|
|||||||
"pkg/net/url",
|
"pkg/net/url",
|
||||||
"pkg/text/template/parse",
|
"pkg/text/template/parse",
|
||||||
"pkg/text/template",
|
"pkg/text/template",
|
||||||
|
|
||||||
"cmd/go",
|
"cmd/go",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1140,15 +1180,18 @@ clean(void)
|
|||||||
xremove(bpathf(&b, "%s/%s", bstr(&path), cleantab[i]+4));
|
xremove(bpathf(&b, "%s/%s", bstr(&path), cleantab[i]+4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(rebuildall) {
|
||||||
// Remove object tree.
|
// Remove object tree.
|
||||||
xremoveall(bpathf(&b, "%s/pkg/obj", goroot));
|
xremoveall(bpathf(&b, "%s/pkg/obj/%s_%s", goroot, gohostos, gohostarch));
|
||||||
|
|
||||||
// Remove installed packages and tools.
|
// Remove installed packages and tools.
|
||||||
|
xremoveall(bpathf(&b, "%s/pkg/%s_%s", goroot, gohostos, gohostarch));
|
||||||
xremoveall(bpathf(&b, "%s/pkg/%s_%s", goroot, goos, goarch));
|
xremoveall(bpathf(&b, "%s/pkg/%s_%s", goroot, goos, goarch));
|
||||||
xremove(bpathf(&b, "%s/bin/tool", goroot));
|
xremoveall(tooldir);
|
||||||
|
|
||||||
// Remove cached version info.
|
// Remove cached version info.
|
||||||
xremove(bpathf(&b, "%s/VERSION.cache", goroot));
|
xremove(bpathf(&b, "%s/VERSION.cache", goroot));
|
||||||
|
}
|
||||||
|
|
||||||
bfree(&b);
|
bfree(&b);
|
||||||
bfree(&path);
|
bfree(&path);
|
||||||
@ -1212,7 +1255,11 @@ cmdenv(int argc, char **argv)
|
|||||||
xprintf(format, "GOBIN", gobin);
|
xprintf(format, "GOBIN", gobin);
|
||||||
xprintf(format, "GOARCH", goarch);
|
xprintf(format, "GOARCH", goarch);
|
||||||
xprintf(format, "GOOS", goos);
|
xprintf(format, "GOOS", goos);
|
||||||
|
xprintf(format, "GOHOSTARCH", gohostarch);
|
||||||
|
xprintf(format, "GOHOSTOS", gohostos);
|
||||||
|
xprintf(format, "GOTOOLDIR", tooldir);
|
||||||
xprintf(format, "GOCHAR", gochar);
|
xprintf(format, "GOCHAR", gochar);
|
||||||
|
|
||||||
if(pflag) {
|
if(pflag) {
|
||||||
sep = ":";
|
sep = ":";
|
||||||
if(streq(gohostos, "windows"))
|
if(streq(gohostos, "windows"))
|
||||||
@ -1233,8 +1280,14 @@ cmdbootstrap(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Buf b;
|
Buf b;
|
||||||
|
char *oldgoos, *oldgoarch, *oldgochar;
|
||||||
|
|
||||||
|
binit(&b);
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'a':
|
||||||
|
rebuildall = 1;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
vflag++;
|
vflag++;
|
||||||
break;
|
break;
|
||||||
@ -1249,9 +1302,32 @@ cmdbootstrap(int argc, char **argv)
|
|||||||
goversion = findgoversion();
|
goversion = findgoversion();
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
binit(&b);
|
// For the main bootstrap, building for host os/arch.
|
||||||
for(i=0; i<nelem(buildorder); i++)
|
oldgoos = goos;
|
||||||
install(bprintf(&b, buildorder[i], gochar));
|
oldgoarch = goarch;
|
||||||
|
oldgochar = gochar;
|
||||||
|
goos = gohostos;
|
||||||
|
goarch = gohostarch;
|
||||||
|
gochar = gohostchar;
|
||||||
|
xsetenv("GOARCH", goarch);
|
||||||
|
xsetenv("GOOS", goos);
|
||||||
|
|
||||||
|
for(i=0; i<nelem(buildorder); i++) {
|
||||||
|
install(bprintf(&b, buildorder[i], gohostchar));
|
||||||
|
if(!streq(oldgochar, gohostchar) && xstrstr(buildorder[i], "%s"))
|
||||||
|
install(bprintf(&b, buildorder[i], oldgochar));
|
||||||
|
}
|
||||||
|
|
||||||
|
goos = oldgoos;
|
||||||
|
goarch = oldgoarch;
|
||||||
|
gochar = oldgochar;
|
||||||
|
xsetenv("GOARCH", goarch);
|
||||||
|
xsetenv("GOOS", goos);
|
||||||
|
|
||||||
|
// Build pkg/runtime for actual goos/goarch too.
|
||||||
|
if(!streq(goos, gohostos) || !streq(goarch, gohostarch))
|
||||||
|
install("pkg/runtime");
|
||||||
|
|
||||||
bfree(&b);
|
bfree(&b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
src/cmd/dist/buildruntime.c
vendored
4
src/cmd/dist/buildruntime.c
vendored
@ -191,7 +191,7 @@ ok:
|
|||||||
// Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -a proc.c
|
// Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -a proc.c
|
||||||
// to get acid [sic] output.
|
// to get acid [sic] output.
|
||||||
vreset(&argv);
|
vreset(&argv);
|
||||||
vadd(&argv, bpathf(&b, "%s/bin/tool/%sc", goroot, gochar));
|
vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
|
||||||
vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
|
vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
|
||||||
vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
|
vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
|
||||||
vadd(&argv, bprintf(&b, "-I%s", workdir));
|
vadd(&argv, bprintf(&b, "-I%s", workdir));
|
||||||
@ -287,7 +287,7 @@ mkzruntimedefs(char *dir, char *file)
|
|||||||
|
|
||||||
// Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -q
|
// Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -q
|
||||||
// on each of the runtimedefs C files.
|
// on each of the runtimedefs C files.
|
||||||
vadd(&argv, bpathf(&b, "%s/bin/tool/%sc", goroot, gochar));
|
vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
|
||||||
vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
|
vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
|
||||||
vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
|
vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
|
||||||
vadd(&argv, bprintf(&b, "-I%s", workdir));
|
vadd(&argv, bprintf(&b, "-I%s", workdir));
|
||||||
|
12
src/cmd/dist/goc2c.c
vendored
12
src/cmd/dist/goc2c.c
vendored
@ -709,15 +709,23 @@ goc2c(char *goc, char *c)
|
|||||||
|
|
||||||
// TODO: set gcc=1 when using gcc
|
// TODO: set gcc=1 when using gcc
|
||||||
|
|
||||||
if(!gcc && streq(goarch, "amd64")) {
|
if(!gcc) {
|
||||||
|
if(streq(goarch, "amd64")) {
|
||||||
type_table[Uintptr].size = 8;
|
type_table[Uintptr].size = 8;
|
||||||
type_table[String].size = 16;
|
type_table[String].size = 16;
|
||||||
type_table[Slice].size = 8+4+4;
|
type_table[Slice].size = 8+4+4;
|
||||||
type_table[Eface].size = 8+8;
|
type_table[Eface].size = 8+8;
|
||||||
structround = 8;
|
structround = 8;
|
||||||
|
} else {
|
||||||
|
type_table[Uintptr].size = 4;
|
||||||
|
type_table[String].size = 8;
|
||||||
|
type_table[Slice].size = 16;
|
||||||
|
type_table[Eface].size = 4+4;
|
||||||
|
structround = 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bprintf(&out, "// auto generated by go tool dist\n\n");
|
bprintf(&out, "// auto generated by go tool dist\n// goos=%s goarch=%s\n\n", goos, goarch);
|
||||||
input = bstr(&in);
|
input = bstr(&in);
|
||||||
output = &out;
|
output = &out;
|
||||||
|
|
||||||
|
7
src/cmd/dist/unix.c
vendored
7
src/cmd/dist/unix.c
vendored
@ -145,6 +145,7 @@ static struct {
|
|||||||
int pid;
|
int pid;
|
||||||
int mode;
|
int mode;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
Buf *b;
|
||||||
} bg[MAXBG];
|
} bg[MAXBG];
|
||||||
static int nbg;
|
static int nbg;
|
||||||
static int maxnbg = nelem(bg);
|
static int maxnbg = nelem(bg);
|
||||||
@ -219,6 +220,7 @@ genrun(Buf *b, char *dir, int mode, Vec *argv, int wait)
|
|||||||
bg[nbg].pid = pid;
|
bg[nbg].pid = pid;
|
||||||
bg[nbg].mode = mode;
|
bg[nbg].mode = mode;
|
||||||
bg[nbg].cmd = btake(&cmd);
|
bg[nbg].cmd = btake(&cmd);
|
||||||
|
bg[nbg].b = b;
|
||||||
nbg++;
|
nbg++;
|
||||||
|
|
||||||
if(wait)
|
if(wait)
|
||||||
@ -233,6 +235,7 @@ bgwait1(void)
|
|||||||
{
|
{
|
||||||
int i, pid, status, mode;
|
int i, pid, status, mode;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
Buf *b;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
while((pid = wait(&status)) < 0) {
|
while((pid = wait(&status)) < 0) {
|
||||||
@ -248,9 +251,13 @@ ok:
|
|||||||
cmd = bg[i].cmd;
|
cmd = bg[i].cmd;
|
||||||
mode = bg[i].mode;
|
mode = bg[i].mode;
|
||||||
bg[i].pid = 0;
|
bg[i].pid = 0;
|
||||||
|
b = bg[i].b;
|
||||||
|
bg[i].b = nil;
|
||||||
bg[i] = bg[--nbg];
|
bg[i] = bg[--nbg];
|
||||||
|
|
||||||
if(mode == CheckExit && (!WIFEXITED(status) || WEXITSTATUS(status) != 0)) {
|
if(mode == CheckExit && (!WIFEXITED(status) || WEXITSTATUS(status) != 0)) {
|
||||||
|
if(b != nil)
|
||||||
|
xprintf("%s\n", bstr(b));
|
||||||
fatal("FAILED: %s", cmd);
|
fatal("FAILED: %s", cmd);
|
||||||
}
|
}
|
||||||
xfree(cmd);
|
xfree(cmd);
|
||||||
|
@ -347,7 +347,13 @@ func (b *builder) action(mode buildMode, depMode buildMode, p *Package) *action
|
|||||||
a.deps = append(a.deps, b.action(depMode, depMode, p1))
|
a.deps = append(a.deps, b.action(depMode, depMode, p1))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(p.CgoFiles) > 0 {
|
// If we are not doing a cross-build, then record the binary we'll
|
||||||
|
// generate for cgo as a dependency of the build of any package
|
||||||
|
// using cgo, to make sure we do not overwrite the binary while
|
||||||
|
// a package is using it. If this is a cross-build, then the cgo we
|
||||||
|
// are writing is not the cgo we need to use.
|
||||||
|
if b.goos == runtime.GOOS && b.goarch == runtime.GOARCH {
|
||||||
|
if len(p.CgoFiles) > 0 || p.Standard && p.ImportPath == "runtime/cgo" {
|
||||||
var stk importStack
|
var stk importStack
|
||||||
p1 := loadPackage("cmd/cgo", &stk)
|
p1 := loadPackage("cmd/cgo", &stk)
|
||||||
if p1.Error != nil {
|
if p1.Error != nil {
|
||||||
@ -356,6 +362,7 @@ func (b *builder) action(mode buildMode, depMode buildMode, p *Package) *action
|
|||||||
a.cgo = b.action(depMode, depMode, p1)
|
a.cgo = b.action(depMode, depMode, p1)
|
||||||
a.deps = append(a.deps, a.cgo)
|
a.deps = append(a.deps, a.cgo)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if p.Standard {
|
if p.Standard {
|
||||||
switch p.ImportPath {
|
switch p.ImportPath {
|
||||||
@ -567,7 +574,11 @@ func (b *builder) build(a *action) error {
|
|||||||
sfiles = nil
|
sfiles = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
outGo, outObj, err := b.cgo(a.p, a.cgo.target, obj, gccfiles)
|
cgoExe := tool("cgo")
|
||||||
|
if a.cgo != nil {
|
||||||
|
cgoExe = a.cgo.target
|
||||||
|
}
|
||||||
|
outGo, outObj, err := b.cgo(a.p, cgoExe, obj, gccfiles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -295,13 +295,14 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string
|
|||||||
|
|
||||||
if info.Package == "main" {
|
if info.Package == "main" {
|
||||||
_, elem := filepath.Split(importPath)
|
_, elem := filepath.Split(importPath)
|
||||||
|
full := ctxt.GOOS + "_" + ctxt.GOARCH + "/" + elem
|
||||||
|
if t.Goroot && isGoTool[p.ImportPath] {
|
||||||
|
p.target = filepath.Join(t.Path, "pkg/tool", full)
|
||||||
|
} else {
|
||||||
if ctxt.GOOS != toolGOOS || ctxt.GOARCH != toolGOARCH {
|
if ctxt.GOOS != toolGOOS || ctxt.GOARCH != toolGOARCH {
|
||||||
// Install cross-compiled binaries to subdirectories of bin.
|
// Install cross-compiled binaries to subdirectories of bin.
|
||||||
elem = ctxt.GOOS + "_" + ctxt.GOARCH + "/" + elem
|
elem = full
|
||||||
}
|
}
|
||||||
if t.Goroot && isGoTool[p.ImportPath] {
|
|
||||||
p.target = filepath.Join(t.Path, "bin/tool", elem)
|
|
||||||
} else {
|
|
||||||
p.target = filepath.Join(t.BinDir(), elem)
|
p.target = filepath.Join(t.BinDir(), elem)
|
||||||
}
|
}
|
||||||
if ctxt.GOOS == "windows" {
|
if ctxt.GOOS == "windows" {
|
||||||
|
@ -31,7 +31,7 @@ var (
|
|||||||
toolGOOS = runtime.GOOS
|
toolGOOS = runtime.GOOS
|
||||||
toolGOARCH = runtime.GOARCH
|
toolGOARCH = runtime.GOARCH
|
||||||
toolIsWindows = toolGOOS == "windows"
|
toolIsWindows = toolGOOS == "windows"
|
||||||
toolDir = filepath.Join(build.Path[0].Path, "bin", "tool")
|
toolDir = build.ToolDir
|
||||||
)
|
)
|
||||||
|
|
||||||
const toolWindowsExtension = ".exe"
|
const toolWindowsExtension = ".exe"
|
||||||
@ -97,6 +97,7 @@ func listTools() {
|
|||||||
setExitStatus(2)
|
setExitStatus(2)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
// Unify presentation by going to lower case.
|
// Unify presentation by going to lower case.
|
||||||
|
@ -61,24 +61,36 @@ mkdir -p ../bin/tool
|
|||||||
export GOROOT="$(cd .. && pwd)"
|
export GOROOT="$(cd .. && pwd)"
|
||||||
GOROOT_FINAL="${GOROOT_FINAL:-$GOROOT}"
|
GOROOT_FINAL="${GOROOT_FINAL:-$GOROOT}"
|
||||||
DEFGOROOT='-DGOROOT_FINAL="'"$GOROOT_FINAL"'"'
|
DEFGOROOT='-DGOROOT_FINAL="'"$GOROOT_FINAL"'"'
|
||||||
gcc -O2 -Wall -Werror -o ../bin/tool/dist -Icmd/dist "$DEFGOROOT" cmd/dist/*.c
|
gcc -O2 -Wall -Werror -ggdb -o cmd/dist/dist -Icmd/dist "$DEFGOROOT" cmd/dist/*.c
|
||||||
|
eval $(./cmd/dist/dist env)
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [ "$1" = "--dist-tool" ]; then
|
if [ "$1" = "--dist-tool" ]; then
|
||||||
# Stop after building dist tool.
|
# Stop after building dist tool.
|
||||||
|
mv cmd/dist/dist $GOTOOLDIR/dist
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '# Building compilers and Go bootstrap tool.'
|
echo "# Building compilers and Go bootstrap tool for host, $GOHOSTOS/$GOHOSTARCH."
|
||||||
../bin/tool/dist bootstrap -v # builds go_bootstrap
|
./cmd/dist/dist bootstrap -a -v # builds go_bootstrap
|
||||||
|
# Delay move of dist tool to now, because bootstrap cleared tool directory.
|
||||||
|
mv cmd/dist/dist $GOTOOLDIR/dist
|
||||||
|
$GOTOOLDIR/go_bootstrap clean -i std
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo '# Building packages and commands.'
|
if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then
|
||||||
../bin/tool/go_bootstrap clean std
|
echo "# Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH."
|
||||||
../bin/tool/go_bootstrap install -a -v std
|
GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
|
||||||
rm -f ../bin/tool/go_bootstrap
|
$GOTOOLDIR/go_bootstrap install -v std
|
||||||
echo
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "# Building packages and commands for $GOOS/$GOARCH."
|
||||||
|
$GOTOOLDIR/go_bootstrap install -v std
|
||||||
|
echo
|
||||||
|
|
||||||
|
rm -f $GOTOOLDIR/go_bootstrap
|
||||||
|
|
||||||
if [ "$1" != "--no-banner" ]; then
|
if [ "$1" != "--no-banner" ]; then
|
||||||
../bin/tool/dist banner
|
$GOTOOLDIR/dist banner
|
||||||
fi
|
fi
|
||||||
|
36
src/make.bat
36
src/make.bat
@ -25,26 +25,48 @@ echo # Building C bootstrap tool.
|
|||||||
echo cmd/dist
|
echo cmd/dist
|
||||||
if not exist ..\bin\tool mkdir ..\bin\tool
|
if not exist ..\bin\tool mkdir ..\bin\tool
|
||||||
:: Windows has no glob expansion, so spell out cmd/dist/*.c.
|
:: Windows has no glob expansion, so spell out cmd/dist/*.c.
|
||||||
gcc -O2 -Wall -Werror -o ../bin/tool/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c
|
gcc -O2 -Wall -Werror -o cmd/dist/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
|
.\cmd\dist\dist env -wp >env.bat
|
||||||
|
if errorlevel 1 goto fail
|
||||||
|
call env.bat
|
||||||
|
del env.bat
|
||||||
:: Echo with no arguments prints whether echo is turned on, so echo dot.
|
:: Echo with no arguments prints whether echo is turned on, so echo dot.
|
||||||
echo .
|
echo .
|
||||||
|
|
||||||
echo # Building compilers and Go bootstrap tool.
|
echo # Building compilers and Go bootstrap tool.
|
||||||
..\bin\tool\dist bootstrap -v
|
.\cmd\dist\dist bootstrap -a -v
|
||||||
|
if errorlevel 1 goto fail
|
||||||
|
:: Delay move of dist tool to now, because bootstrap cleared tool directory.
|
||||||
|
move .\cmd\dist\dist.exe %GOTOOLDIR%\dist.exe
|
||||||
|
%GOTOOLDIR%\go_bootstrap clean -i std
|
||||||
|
echo .
|
||||||
|
|
||||||
|
if not %GOHOSTARCH% == %GOARCH% goto localbuild
|
||||||
|
if not %GOHOSTOS% == %GOOS% goto localbuild
|
||||||
|
goto mainbuild
|
||||||
|
|
||||||
|
:localbuild
|
||||||
|
echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
|
||||||
|
set oldGOOS=%GOOS%
|
||||||
|
set oldGOARCH=%GOARCH%
|
||||||
|
set GOOS=%GOHOSTOS%
|
||||||
|
set GOARCH=%GOHOSTARCH%
|
||||||
|
%GOTOOLDIR%\go_bootstrap install -v std
|
||||||
|
set GOOS=%oldGOOS%
|
||||||
|
set GOARCH=%oldGOARCH%
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
echo .
|
echo .
|
||||||
|
|
||||||
|
:mainbuild
|
||||||
echo # Building packages and commands.
|
echo # Building packages and commands.
|
||||||
..\bin\tool\go_bootstrap clean std
|
%GOTOOLDIR%\go_bootstrap install -a -v std
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
..\bin\tool\go_bootstrap install -a -v std
|
del %GOTOOLDIR%\go_bootstrap.exe
|
||||||
if errorlevel 1 goto fail
|
|
||||||
del ..\bin\tool\go_bootstrap.exe
|
|
||||||
echo .
|
echo .
|
||||||
|
|
||||||
if "x%1"=="x--no-banner" goto nobanner
|
if "x%1"=="x--no-banner" goto nobanner
|
||||||
..\bin\tool\dist banner
|
%GOTOOLDIR%\dist banner
|
||||||
:nobanner
|
:nobanner
|
||||||
|
|
||||||
goto end
|
goto end
|
||||||
|
@ -6,7 +6,9 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
|
"go/build"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -31,7 +33,7 @@ func init() {
|
|||||||
gcPath = gcName
|
gcPath = gcName
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gcPath = filepath.Join(runtime.GOROOT(), "/bin/tool/", gcName)
|
gcPath = filepath.Join(build.ToolDir, gcName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func compile(t *testing.T, dirname, filename string) {
|
func compile(t *testing.T, dirname, filename string) {
|
||||||
@ -90,6 +92,13 @@ func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGcImport(t *testing.T) {
|
func TestGcImport(t *testing.T) {
|
||||||
|
// On cross-compile builds, the path will not exist.
|
||||||
|
// Need to use GOHOSTOS, which is not available.
|
||||||
|
if _, err := os.Stat(gcPath); err != nil {
|
||||||
|
t.Logf("skipping test: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
compile(t, "testdata", "exports.go")
|
compile(t, "testdata", "exports.go")
|
||||||
|
|
||||||
nimports := 0
|
nimports := 0
|
||||||
|
@ -12,6 +12,9 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ToolDir is the directory containing build tools.
|
||||||
|
var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
|
||||||
|
|
||||||
// Path is a validated list of Trees derived from $GOROOT and $GOPATH at init.
|
// Path is a validated list of Trees derived from $GOROOT and $GOPATH at init.
|
||||||
var Path []*Tree
|
var Path []*Tree
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
eval $(../bin/tool/dist env -p)
|
eval $(go tool dist env)
|
||||||
|
|
||||||
unset CDPATH # in case user has it set
|
unset CDPATH # in case user has it set
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $G $D/bug302.dir/p.go && "$GOROOT"/bin/tool/pack grc pp.a p.$A && $G $D/bug302.dir/main.go
|
// $G $D/bug302.dir/p.go && pack grc pp.a p.$A && $G $D/bug302.dir/main.go
|
||||||
|
|
||||||
// Copyright 2010 The Go Authors. All rights reserved.
|
// Copyright 2010 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
4
test/run
4
test/run
@ -3,7 +3,7 @@
|
|||||||
# Use of this source code is governed by a BSD-style
|
# Use of this source code is governed by a BSD-style
|
||||||
# license that can be found in the LICENSE file.
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
eval $(../bin/tool/dist env)
|
eval $(go tool dist env)
|
||||||
export GOARCH GOOS GOROOT
|
export GOARCH GOOS GOROOT
|
||||||
export E=
|
export E=
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ failed=0
|
|||||||
PATH=${GOBIN:-$GOROOT/bin}:`pwd`:/bin:/usr/bin:/usr/local/bin
|
PATH=${GOBIN:-$GOROOT/bin}:`pwd`:/bin:/usr/bin:/usr/local/bin
|
||||||
|
|
||||||
# TODO: We add the tool directory to the PATH to avoid thinking about a better way.
|
# TODO: We add the tool directory to the PATH to avoid thinking about a better way.
|
||||||
PATH="$GOROOT/bin/tool":$PATH
|
PATH="$GOTOOLDIR:$PATH"
|
||||||
|
|
||||||
RUNFILE="/tmp/gorun-$$-$USER"
|
RUNFILE="/tmp/gorun-$$-$USER"
|
||||||
TMP1FILE="/tmp/gotest1-$$-$USER"
|
TMP1FILE="/tmp/gotest1-$$-$USER"
|
||||||
|
Loading…
Reference in New Issue
Block a user