Commit b8b2253a authored by Russ Cox's avatar Russ Cox

cmd/dist: fix build

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/5630049
parent 961f96b5
...@@ -21,7 +21,7 @@ char *gochar; ...@@ -21,7 +21,7 @@ char *gochar;
char *goroot_final; char *goroot_final;
char *goversion; char *goversion;
char *slash; // / for unix, \ for windows char *slash; // / for unix, \ for windows
char *default_goroot; char *default_goroot = DEFAULT_GOROOT;
static bool shouldbuild(char*, char*); static bool shouldbuild(char*, char*);
static void copy(char*, char*); static void copy(char*, char*);
...@@ -487,7 +487,7 @@ install(char *dir) ...@@ -487,7 +487,7 @@ install(char *dir)
Buf b, b1, path; Buf b, b1, path;
Vec compile, files, link, go, missing, clean, lib, extra; Vec compile, files, link, go, missing, clean, lib, extra;
Time ttarg, t; Time ttarg, t;
int i, j, k, n; int i, j, k, n, doclean;
binit(&b); binit(&b);
binit(&b1); binit(&b1);
...@@ -747,6 +747,8 @@ install(char *dir) ...@@ -747,6 +747,8 @@ install(char *dir)
vadd(&compile, bprintf(&b, "-DGOARCH_%s", goos)); vadd(&compile, bprintf(&b, "-DGOARCH_%s", goos));
} }
bpathf(&b, "%s/%s", workdir, lastelem(files.p[i]));
doclean = 1;
if(!isgo && streq(gohostos, "darwin")) { if(!isgo && streq(gohostos, "darwin")) {
// To debug C programs on OS X, it is not enough to say -ggdb // 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 // on the command line. You have to leave the object files
...@@ -755,8 +757,8 @@ install(char *dir) ...@@ -755,8 +757,8 @@ install(char *dir)
bpathf(&b1, "%s/pkg/obj/%s", goroot, dir); bpathf(&b1, "%s/pkg/obj/%s", goroot, dir);
xmkdirall(bstr(&b1)); xmkdirall(bstr(&b1));
bpathf(&b, "%s/%s", bstr(&b1), lastelem(files.p[i])); bpathf(&b, "%s/%s", bstr(&b1), lastelem(files.p[i]));
} else doclean = 0;
bpathf(&b, "%s/%s", workdir, lastelem(files.p[i])); }
b.p[b.len-1] = 'o'; // was c or s b.p[b.len-1] = 'o'; // was c or s
vadd(&compile, "-o"); vadd(&compile, "-o");
...@@ -765,7 +767,8 @@ install(char *dir) ...@@ -765,7 +767,8 @@ install(char *dir)
bgrunv(bstr(&path), CheckExit, &compile); bgrunv(bstr(&path), CheckExit, &compile);
vadd(&link, bstr(&b)); vadd(&link, bstr(&b));
vadd(&clean, bstr(&b)); if(doclean)
vadd(&clean, bstr(&b));
} }
bgwait(); bgwait();
...@@ -1144,7 +1147,7 @@ cmdenv(int argc, char **argv) ...@@ -1144,7 +1147,7 @@ cmdenv(int argc, char **argv)
binit(&b); binit(&b);
binit(&b1); binit(&b1);
format = "%s=\"%s\""; format = "%s=\"%s\"\n";
pflag = 0; pflag = 0;
ARGBEGIN{ ARGBEGIN{
case 'p': case 'p':
......
...@@ -475,6 +475,8 @@ fatal(char *msg, ...) ...@@ -475,6 +475,8 @@ fatal(char *msg, ...)
vfprintf(stderr, msg, arg); vfprintf(stderr, msg, arg);
va_end(arg); va_end(arg);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
bgwait();
exit(1); exit(1);
} }
...@@ -624,16 +626,10 @@ xsetenv(char *name, char *value) ...@@ -624,16 +626,10 @@ xsetenv(char *name, char *value)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
char *p;
Buf b; Buf b;
struct utsname u; struct utsname u;
binit(&b); 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 = "/"; slash = "/";
......
...@@ -688,6 +688,8 @@ fatal(char *msg, ...) ...@@ -688,6 +688,8 @@ fatal(char *msg, ...)
va_end(arg); va_end(arg);
xprintf("go tool dist: %s\n", buf1); xprintf("go tool dist: %s\n", buf1);
bgwait();
ExitProcess(1); ExitProcess(1);
} }
...@@ -800,7 +802,7 @@ xstrlen(char *p) ...@@ -800,7 +802,7 @@ xstrlen(char *p)
void void
xexit(int n) xexit(int n)
{ {
exit(n); ExitProcess(n);
} }
void void
...@@ -831,8 +833,6 @@ main(int argc, char **argv) ...@@ -831,8 +833,6 @@ main(int argc, char **argv)
setvbuf(stdout, nil, _IOLBF, 0); setvbuf(stdout, nil, _IOLBF, 0);
setvbuf(stderr, nil, _IOLBF, 0); setvbuf(stderr, nil, _IOLBF, 0);
default_goroot = DEFAULT_GOROOT;
slash = "\\"; slash = "\\";
gohostos = "windows"; gohostos = "windows";
......
...@@ -47,7 +47,8 @@ done ...@@ -47,7 +47,8 @@ done
echo '# Building C bootstrap tool.' echo '# Building C bootstrap tool.'
mkdir -p ../bin/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
echo '# Building compilers and Go bootstrap tool.' echo '# Building compilers and Go bootstrap tool.'
......
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