From b8b2253ac78ac76aa5ef171171005b8214e44fec Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 4 Feb 2012 01:23:54 -0500 Subject: [PATCH] cmd/dist: fix build TBR=golang-dev CC=golang-dev https://golang.org/cl/5630049 --- src/cmd/dist/build.c | 15 +++++++++------ src/cmd/dist/unix.c | 8 ++------ src/cmd/dist/windows.c | 6 +++--- src/make.bash | 3 ++- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c index f2b25d991eb..6cd6f6d4ac6 100644 --- a/src/cmd/dist/build.c +++ b/src/cmd/dist/build.c @@ -21,7 +21,7 @@ char *gochar; char *goroot_final; char *goversion; char *slash; // / for unix, \ for windows -char *default_goroot; +char *default_goroot = DEFAULT_GOROOT; static bool shouldbuild(char*, char*); static void copy(char*, char*); @@ -487,7 +487,7 @@ install(char *dir) Buf b, b1, path; Vec compile, files, link, go, missing, clean, lib, extra; Time ttarg, t; - int i, j, k, n; + int i, j, k, n, doclean; binit(&b); binit(&b1); @@ -747,6 +747,8 @@ install(char *dir) vadd(&compile, bprintf(&b, "-DGOARCH_%s", goos)); } + bpathf(&b, "%s/%s", workdir, lastelem(files.p[i])); + doclean = 1; if(!isgo && streq(gohostos, "darwin")) { // To debug C programs on OS X, it is not enough to say -ggdb // on the command line. You have to leave the object files @@ -755,8 +757,8 @@ install(char *dir) bpathf(&b1, "%s/pkg/obj/%s", goroot, dir); xmkdirall(bstr(&b1)); bpathf(&b, "%s/%s", bstr(&b1), lastelem(files.p[i])); - } else - bpathf(&b, "%s/%s", workdir, lastelem(files.p[i])); + doclean = 0; + } b.p[b.len-1] = 'o'; // was c or s vadd(&compile, "-o"); @@ -765,7 +767,8 @@ install(char *dir) bgrunv(bstr(&path), CheckExit, &compile); vadd(&link, bstr(&b)); - vadd(&clean, bstr(&b)); + if(doclean) + vadd(&clean, bstr(&b)); } bgwait(); @@ -1144,7 +1147,7 @@ cmdenv(int argc, char **argv) binit(&b); binit(&b1); - format = "%s=\"%s\""; + format = "%s=\"%s\"\n"; pflag = 0; ARGBEGIN{ case 'p': diff --git a/src/cmd/dist/unix.c b/src/cmd/dist/unix.c index 465a86c0df8..d62ebcaa833 100644 --- a/src/cmd/dist/unix.c +++ b/src/cmd/dist/unix.c @@ -475,6 +475,8 @@ fatal(char *msg, ...) vfprintf(stderr, msg, arg); va_end(arg); fprintf(stderr, "\n"); + + bgwait(); exit(1); } @@ -624,16 +626,10 @@ xsetenv(char *name, char *value) int main(int argc, char **argv) { - char *p; Buf b; struct utsname u; binit(&b); - p = argv[0]; - if(hassuffix(p, "bin/tool/dist")) { - default_goroot = xstrdup(p); - default_goroot[strlen(p)-strlen("bin/tool/dist")] = '\0'; - } slash = "/"; diff --git a/src/cmd/dist/windows.c b/src/cmd/dist/windows.c index 89bd3d733a9..fade7bc0269 100644 --- a/src/cmd/dist/windows.c +++ b/src/cmd/dist/windows.c @@ -688,6 +688,8 @@ fatal(char *msg, ...) va_end(arg); xprintf("go tool dist: %s\n", buf1); + + bgwait(); ExitProcess(1); } @@ -800,7 +802,7 @@ xstrlen(char *p) void xexit(int n) { - exit(n); + ExitProcess(n); } void @@ -831,8 +833,6 @@ main(int argc, char **argv) setvbuf(stdout, nil, _IOLBF, 0); setvbuf(stderr, nil, _IOLBF, 0); - default_goroot = DEFAULT_GOROOT; - slash = "\\"; gohostos = "windows"; diff --git a/src/make.bash b/src/make.bash index 1c29568fdc4..fcc320e573d 100755 --- a/src/make.bash +++ b/src/make.bash @@ -47,7 +47,8 @@ done echo '# Building C bootstrap tool.' mkdir -p ../bin/tool -gcc -O2 -Wall -Werror -o ../bin/tool/dist -Icmd/dist cmd/dist/*.c +DEFGOROOT='-DDEFAULT_GOROOT="'"$(cd .. && pwd)"'"' +gcc -O2 -Wall -Werror -o ../bin/tool/dist -Icmd/dist "$DEFGOROOT" cmd/dist/*.c echo echo '# Building compilers and Go bootstrap tool.'