summaryrefslogtreecommitdiff
path: root/src/cmd/dist/build.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/dist/build.c')
-rw-r--r--src/cmd/dist/build.c267
1 files changed, 130 insertions, 137 deletions
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
index 6884e0aae..d638ae4eb 100644
--- a/src/cmd/dist/build.c
+++ b/src/cmd/dist/build.c
@@ -35,7 +35,6 @@ bool rebuildall;
bool defaultclang;
static bool shouldbuild(char*, char*);
-static void copy(char*, char*, int);
static void dopack(char*, char*, char**, int);
static char *findgoversion(void);
@@ -56,6 +55,7 @@ static char *okgoos[] = {
"darwin",
"dragonfly",
"linux",
+ "android",
"solaris",
"freebsd",
"nacl",
@@ -366,8 +366,8 @@ static char *oldtool[] = {
// not be in release branches.
static char *unreleased[] = {
"src/cmd/link",
- "src/pkg/debug/goobj",
- "src/pkg/old",
+ "src/debug/goobj",
+ "src/old",
};
// setup sets up the tree for the initial build.
@@ -590,7 +590,7 @@ static struct {
"$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/libbio.a",
"$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/lib9.a",
}},
- {"pkg/runtime", {
+ {"runtime", {
"zaexperiment.h", // must sort above zasm
"zasm_$GOOS_$GOARCH.h",
"zsys_$GOOS_$GOARCH.s",
@@ -607,7 +607,6 @@ char *depsuffix[] = {
".h",
".s",
".go",
- ".goc",
};
// gentab records how to generate some trivial files.
@@ -639,7 +638,7 @@ install(char *dir)
{
char *name, *p, *elem, *prefix, *exe;
bool islib, ispkg, isgo, stale, ispackcmd;
- Buf b, b1, path;
+ Buf b, b1, path, final_path, final_name;
Vec compile, files, link, go, missing, clean, lib, extra;
Time ttarg, t;
int i, j, k, n, doclean, targ;
@@ -654,6 +653,8 @@ install(char *dir)
binit(&b);
binit(&b1);
binit(&path);
+ binit(&final_path);
+ binit(&final_name);
vinit(&compile);
vinit(&files);
vinit(&link);
@@ -666,15 +667,9 @@ install(char *dir)
// path = full path to dir.
bpathf(&path, "%s/src/%s", goroot, dir);
+ bpathf(&final_path, "%s/src/%s", goroot_final, dir);
name = lastelem(dir);
- // For misc/prof, copy into the tool directory and we're done.
- if(hasprefix(dir, "misc/")) {
- copy(bpathf(&b, "%s/%s", tooldir, name),
- bpathf(&b1, "%s/misc/%s", goroot, name), 1);
- goto out;
- }
-
// set up gcc command line on first run.
if(gccargs.len == 0) {
bprintf(&b, "%s %s", defaultcc, defaultcflags);
@@ -704,7 +699,7 @@ install(char *dir)
}
islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd/gc");
- ispkg = hasprefix(dir, "pkg");
+ ispkg = !islib && !hasprefix(dir, "cmd/");
isgo = ispkg || streq(dir, "cmd/go") || streq(dir, "cmd/cgo");
exe = "";
@@ -730,11 +725,11 @@ install(char *dir)
// Go library (package).
ispackcmd = 1;
vadd(&link, "pack"); // program name - unused here, but all the other cases record one
- p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4);
+ p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir);
*xstrrchr(p, '/') = '\0';
xmkdirall(p);
targ = link.len;
- 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, goos, goarch, dir));
} else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) {
// Go command.
vadd(&link, bpathf(&b, "%s/%sl", tooldir, gochar));
@@ -881,18 +876,22 @@ install(char *dir)
goto out;
// For package runtime, copy some files into the work space.
- if(streq(dir, "pkg/runtime")) {
- copy(bpathf(&b, "%s/arch_GOARCH.h", workdir),
+ if(streq(dir, "runtime")) {
+ copyfile(bpathf(&b, "%s/arch_GOARCH.h", workdir),
bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch), 0);
- copy(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir),
+ copyfile(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir),
bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch), 0);
p = bpathf(&b1, "%s/signal_%s_%s.h", bstr(&path), goos, goarch);
if(isfile(p))
- copy(bpathf(&b, "%s/signal_GOOS_GOARCH.h", workdir), p, 0);
- copy(bpathf(&b, "%s/os_GOOS.h", workdir),
+ copyfile(bpathf(&b, "%s/signal_GOOS_GOARCH.h", workdir), p, 0);
+ copyfile(bpathf(&b, "%s/os_GOOS.h", workdir),
bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0);
- copy(bpathf(&b, "%s/signals_GOOS.h", workdir),
+ copyfile(bpathf(&b, "%s/signals_GOOS.h", workdir),
bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0);
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/textflag.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/cmd/ld/textflag.h", goroot), 0);
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/funcdata.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/runtime/funcdata.h", goroot), 0);
}
// Generate any missing files; regenerate existing ones.
@@ -907,7 +906,7 @@ install(char *dir)
errprintf("generate %s\n", p);
gentab[j].gen(bstr(&path), p);
// Do not add generated file to clean list.
- // In pkg/runtime, we want to be able to
+ // In runtime, we want to be able to
// build the package with the go tool,
// and it assumes these generated files already
// exist (it does not know how to build them).
@@ -925,27 +924,11 @@ install(char *dir)
// One more copy for package runtime.
// The last batch was required for the generators.
// This one is generated.
- if(streq(dir, "pkg/runtime")) {
- copy(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir),
+ if(streq(dir, "runtime")) {
+ copyfile(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir),
bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch), 0);
}
- // Generate .c files from .goc files.
- if(streq(dir, "pkg/runtime")) {
- for(i=0; i<files.len; i++) {
- p = files.p[i];
- if(!hassuffix(p, ".goc"))
- continue;
- // b = path/zp but with _goos_goarch.c instead of .goc
- bprintf(&b, "%s%sz%s", bstr(&path), slash, lastelem(p));
- b.len -= 4;
- bwritef(&b, "_%s_%s.c", goos, goarch);
- goc2c(p, bstr(&b));
- vadd(&files, bstr(&b));
- }
- vuniq(&files);
- }
-
if((!streq(goos, gohostos) || !streq(goarch, gohostarch)) && isgo) {
// We've generated the right files; the go command can do the build.
if(vflag > 1)
@@ -1086,7 +1069,7 @@ install(char *dir)
else
vadd(&compile, "main");
- if(streq(dir, "pkg/runtime"))
+ if(streq(dir, "runtime"))
vadd(&compile, "-+");
vcopy(&compile, go.p, go.len);
@@ -1115,11 +1098,11 @@ install(char *dir)
nobuild:
// In package runtime, we install runtime.h and cgocall.h too,
// for use by cgo compilation.
- if(streq(dir, "pkg/runtime")) {
- copy(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot), 0);
- copy(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot), 0);
+ if(streq(dir, "runtime")) {
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/runtime/cgocall.h", goroot), 0);
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/runtime/runtime.h", goroot), 0);
}
@@ -1149,7 +1132,7 @@ matchfield(char *f)
p = xstrrchr(f, ',');
if(p == nil)
- return streq(f, goos) || streq(f, goarch) || streq(f, "cmd_go_bootstrap") || streq(f, "go1.1");
+ return streq(f, goos) || streq(f, goarch) || streq(f, "cmd_go_bootstrap") || streq(f, "go1.1") || (streq(goos, "android") && streq(f, "linux"));
*p = 0;
res = matchfield(f) && matchfield(p+1);
*p = ',';
@@ -1241,8 +1224,8 @@ out:
}
// copy copies the file src to dst, via memory (so only good for small files).
-static void
-copy(char *dst, char *src, int exec)
+void
+copyfile(char *dst, char *src, int exec)
{
Buf b;
@@ -1303,8 +1286,6 @@ static char *buildorder[] = {
"libbio",
"liblink",
- "misc/pprof",
-
"cmd/cc", // must be before c
"cmd/gc", // must be before g
"cmd/%sl", // must be before a, c, g
@@ -1316,47 +1297,47 @@ static char *buildorder[] = {
// back when there were build scripts. Will have to
// be maintained by hand, but shouldn't change very
// often.
- "pkg/runtime",
- "pkg/errors",
- "pkg/sync/atomic",
- "pkg/sync",
- "pkg/io",
- "pkg/unicode",
- "pkg/unicode/utf8",
- "pkg/unicode/utf16",
- "pkg/bytes",
- "pkg/math",
- "pkg/strings",
- "pkg/strconv",
- "pkg/bufio",
- "pkg/sort",
- "pkg/container/heap",
- "pkg/encoding/base64",
- "pkg/syscall",
- "pkg/time",
- "pkg/os",
- "pkg/reflect",
- "pkg/fmt",
- "pkg/encoding",
- "pkg/encoding/json",
- "pkg/flag",
- "pkg/path/filepath",
- "pkg/path",
- "pkg/io/ioutil",
- "pkg/log",
- "pkg/regexp/syntax",
- "pkg/regexp",
- "pkg/go/token",
- "pkg/go/scanner",
- "pkg/go/ast",
- "pkg/go/parser",
- "pkg/os/exec",
- "pkg/os/signal",
- "pkg/net/url",
- "pkg/text/template/parse",
- "pkg/text/template",
- "pkg/go/doc",
- "pkg/go/build",
+ "runtime",
+ "errors",
+ "sync/atomic",
+ "sync",
+ "io",
+ "unicode",
+ "unicode/utf8",
+ "unicode/utf16",
+ "bytes",
+ "math",
+ "strings",
+ "strconv",
+ "bufio",
+ "sort",
+ "container/heap",
+ "encoding/base64",
+ "syscall",
+ "time",
+ "os",
+ "reflect",
+ "fmt",
+ "encoding",
+ "encoding/json",
+ "flag",
+ "path/filepath",
+ "path",
+ "io/ioutil",
+ "log",
+ "regexp/syntax",
+ "regexp",
+ "go/token",
+ "go/scanner",
+ "go/ast",
+ "go/parser",
+ "os/exec",
+ "os/signal",
+ "net/url",
+ "text/template/parse",
+ "text/template",
+ "go/doc",
+ "go/build",
"cmd/go",
};
@@ -1364,6 +1345,7 @@ static char *buildorder[] = {
// It is bigger than the buildorder because we clean all the
// compilers but build only the $GOARCH ones.
static char *cleantab[] = {
+ // Commands and C libraries.
"cmd/5a",
"cmd/5c",
"cmd/5g",
@@ -1382,46 +1364,48 @@ static char *cleantab[] = {
"lib9",
"libbio",
"liblink",
- "pkg/bufio",
- "pkg/bytes",
- "pkg/container/heap",
- "pkg/encoding",
- "pkg/encoding/base64",
- "pkg/encoding/json",
- "pkg/errors",
- "pkg/flag",
- "pkg/fmt",
- "pkg/go/ast",
- "pkg/go/build",
- "pkg/go/doc",
- "pkg/go/parser",
- "pkg/go/scanner",
- "pkg/go/token",
- "pkg/io",
- "pkg/io/ioutil",
- "pkg/log",
- "pkg/math",
- "pkg/net/url",
- "pkg/os",
- "pkg/os/exec",
- "pkg/path",
- "pkg/path/filepath",
- "pkg/reflect",
- "pkg/regexp",
- "pkg/regexp/syntax",
- "pkg/runtime",
- "pkg/sort",
- "pkg/strconv",
- "pkg/strings",
- "pkg/sync",
- "pkg/sync/atomic",
- "pkg/syscall",
- "pkg/text/template",
- "pkg/text/template/parse",
- "pkg/time",
- "pkg/unicode",
- "pkg/unicode/utf16",
- "pkg/unicode/utf8",
+
+ // Go packages.
+ "bufio",
+ "bytes",
+ "container/heap",
+ "encoding",
+ "encoding/base64",
+ "encoding/json",
+ "errors",
+ "flag",
+ "fmt",
+ "go/ast",
+ "go/build",
+ "go/doc",
+ "go/parser",
+ "go/scanner",
+ "go/token",
+ "io",
+ "io/ioutil",
+ "log",
+ "math",
+ "net/url",
+ "os",
+ "os/exec",
+ "path",
+ "path/filepath",
+ "reflect",
+ "regexp",
+ "regexp/syntax",
+ "runtime",
+ "sort",
+ "strconv",
+ "strings",
+ "sync",
+ "sync/atomic",
+ "syscall",
+ "text/template",
+ "text/template/parse",
+ "time",
+ "unicode",
+ "unicode/utf16",
+ "unicode/utf8",
};
static void
@@ -1450,9 +1434,9 @@ clean(void)
xremove(bpathf(&b, "%s/%s", bstr(&path), cleantab[i]+4));
}
- // remove src/pkg/runtime/z* unconditionally
+ // remove src/runtime/z* unconditionally
vreset(&dir);
- bpathf(&path, "%s/src/pkg/runtime", goroot);
+ bpathf(&path, "%s/src/runtime", goroot);
xreaddir(&dir, bstr(&path));
for(j=0; j<dir.len; j++) {
if(hasprefix(dir.p[j], "z"))
@@ -1589,6 +1573,15 @@ cmdbootstrap(int argc, char **argv)
if(argc > 0)
usage();
+ if(isdir(bpathf(&b, "%s/src/pkg", goroot))) {
+ fatal("\n\n"
+ "The Go package sources have moved to $GOROOT/src.\n"
+ "*** %s still exists. ***\n"
+ "It probably contains stale files that may confuse the build.\n"
+ "Please (check what's there and) remove it and try again.\n"
+ "See http://golang.org/s/go14nopkg\n", bpathf(&b, "%s/src/pkg", goroot));
+ }
+
if(rebuildall)
clean();
goversion = findgoversion();
@@ -1619,9 +1612,9 @@ cmdbootstrap(int argc, char **argv)
xsetenv("GOARCH", goarch);
xsetenv("GOOS", goos);
- // Build pkg/runtime for actual goos/goarch too.
+ // Build runtime for actual goos/goarch too.
if(!streq(goos, gohostos) || !streq(goarch, gohostarch))
- install("pkg/runtime");
+ install("runtime");
bfree(&b);
}