1
0
mirror of https://github.com/golang/go synced 2024-11-26 19:51:17 -07:00

cmd/dist, cmd/go: embed default C++ compiler into cmd/go

Fixes #6426.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/13704044
This commit is contained in:
Shenghou Ma 2013-09-24 00:17:08 -04:00
parent b80ef1ab48
commit 7616c94921
5 changed files with 19 additions and 3 deletions

1
src/cmd/dist/a.h vendored
View File

@ -75,6 +75,7 @@ extern char *goroot_final;
extern char *goextlinkenabled;
extern char *goversion;
extern char *defaultcc;
extern char *defaultcxx;
extern char *workdir;
extern char *tooldir;
extern char *slash;

10
src/cmd/dist/build.c vendored
View File

@ -27,6 +27,7 @@ char *gochar;
char *goversion;
char *slash; // / for unix, \ for windows
char *defaultcc;
char *defaultcxx;
bool rebuildall;
bool defaultclang;
@ -163,6 +164,15 @@ init(void)
}
defaultcc = btake(&b);
xgetenv(&b, "CXX");
if(b.len == 0) {
if(defaultclang)
bprintf(&b, "clang++");
else
bprintf(&b, "g++");
}
defaultcxx = btake(&b);
xsetenv("GOROOT", goroot);
xsetenv("GOARCH", goarch);
xsetenv("GOOS", goos);

View File

@ -12,6 +12,7 @@
//
// package main
// const defaultCC = <defaultcc>
// const defaultCXX = <defaultcxx>
//
// It is invoked to write cmd/go/zdefaultcc.go
// but we also write cmd/cgo/zdefaultcc.go.
@ -28,8 +29,9 @@ mkzdefaultcc(char *dir, char *file)
"\n"
"package main\n"
"\n"
"const defaultCC = `%s`\n",
defaultcc);
"const defaultCC = `%s`\n"
"const defaultCXX = `%s`\n",
defaultcc, defaultcxx);
writefile(&out, file, 0);

View File

@ -1837,8 +1837,9 @@ func (b *builder) gccCmd(objdir string) []string {
}
// gxxCmd returns a g++ command line prefix
// defaultCXX is defined in zdefaultcc.go, written by cmd/dist.
func (b *builder) gxxCmd(objdir string) []string {
return b.ccompilerCmd("CXX", "g++", objdir)
return b.ccompilerCmd("CXX", defaultCXX, objdir)
}
// ccompilerCmd returns a command line prefix for the given environment

View File

@ -54,6 +54,8 @@ func mkEnv() []envVar {
cmd := b.gccCmd(".")
env = append(env, envVar{"CC", cmd[0]})
env = append(env, envVar{"GOGCCFLAGS", strings.Join(cmd[3:], " ")})
cmd = b.gxxCmd(".")
env = append(env, envVar{"CXX", cmd[0]})
}
if buildContext.CgoEnabled {