Reviewers: golang-dev1,
Message:
Hello
golan...@googlegroups.com,
I'd like you to review this change to
https://code.google.com/p/go/
Description:
build: on OS X use clang instead of gcc
Fixes issue 5822.
Will no doubt cause other problems, but Apple has forced our hand.
Please review this at
https://codereview.appspot.com/12350044/
Affected files:
M src/cmd/dist/build.c
M src/cmd/go/build.go
Index: src/cmd/dist/build.c
===================================================================
--- a/src/cmd/dist/build.c
+++ b/src/cmd/dist/build.c
@@ -617,8 +617,17 @@
// set up gcc command line on first run.
if(gccargs.len == 0) {
xgetenv(&b, "CC");
- if(b.len == 0)
- bprintf(&b, "gcc");
+ if(b.len == 0) {
+ // Use clang on OS X, because gcc is deprecated there.
+ // Xcode for OS X 10.9 Mavericks will ship a fake "gcc" binary that
+ // actually runs clang. We prepare different command
+ // lines for the two binaries, so it matters what we call it.
+ // See
golang.org/issue/5822.
+ if(streq(gohostos, "darwin")
+ bprintf(&b, "clang");
+ else
+ bprintf(&b, "gcc");
+ }
clang = contains(bstr(&b), "clang");
splitfields(&gccargs, bstr(&b));
for(i=0; i<nelem(proto_gccargs); i++)
Index: src/cmd/go/build.go
===================================================================
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -1771,6 +1771,19 @@
return b.run(p.Dir, p.ImportPath, nil, cmd, "-o", out, obj, flags)
}
+var defaultCC = "gcc"
+
+func init() {
+ // Use clang on OS X, because gcc is deprecated there.
+ // Xcode for OS X 10.9 Mavericks will ship a fake "gcc" binary that
+ // actually runs clang. We prepare different command
+ // lines for the two binaries, so it matters what we call it.
+ // See
golang.org/issue/5822.
+ if runtime.GOOS == "darwin" {
+ defaultCC = "clang"
+ }
+}
+
// gccCmd returns a gcc command line prefix
func (b *builder) gccCmd(objdir string) []string {
return b.ccompilerCmd("CC", "gcc", objdir)