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:
parent
b80ef1ab48
commit
7616c94921
1
src/cmd/dist/a.h
vendored
1
src/cmd/dist/a.h
vendored
@ -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
10
src/cmd/dist/build.c
vendored
@ -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);
|
||||
|
6
src/cmd/dist/buildgo.c
vendored
6
src/cmd/dist/buildgo.c
vendored
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user