aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2018-10-24 12:01:13 -0400
committerAndrew Bonventre <andybons@golang.org>2018-10-29 16:43:15 +0000
commitedb6c16b9b62ed8586d2e3e422911d646095b7e5 (patch)
tree5c281d3eebaae9d715ee3ef5b28b5d2f965a0f18
parent05b2b9b4d5cf5f6e34d0edecf497dd0b00dc8f07 (diff)
downloadgo-edb6c16b9b62ed8586d2e3e422911d646095b7e5.tar.gz
go-edb6c16b9b62ed8586d2e3e422911d646095b7e5.zip
[release-branch.go1.11] cmd/go, cmd/link: silence bogus Apple Xcode warning
Certain installations of Xcode are affected by a bug that causes them to print an inconsequential link-time warning that looks like: ld: warning: text-based stub file /System/Library/Frameworks//Security.framework/Security.tbd and library file /System/Library/Frameworks//Security.framework/Security are out of sync. Falling back to library file for linking. This has nothing to do with Go, and we've sent this repro case to Apple: $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version version: 10.0.0.0.1.1535735448 $ clang --version Apple LLVM version 10.0.0 (clang-1000.10.44.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin $ cat > issue.c int main() { return 0; } ^D $ clang issue.c -framework CoreFoundation ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking. $ Even if Apple does release a fixed Xcode, many people are seeing this useless warning, and we might as well make it go away. Fixes #26073. Change-Id: Ifc17ba7da1f6b59e233c11ebdab7241cb6656324 Reviewed-on: https://go-review.googlesource.com/c/144112 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org> (cherry picked from commit 66bb8ddb956c5ee55b471a019fac2c6817c08ef5) Reviewed-on: https://go-review.googlesource.com/c/145458 Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/cmd/go/internal/work/exec.go27
-rw-r--r--src/cmd/link/internal/ld/lib.go19
2 files changed, 42 insertions, 4 deletions
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
index 12e15276f4..91c4816fd0 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -2077,14 +2077,37 @@ func (b *Builder) ccompile(a *Action, p *load.Package, outfile string, flags []s
}
// gccld runs the gcc linker to create an executable from a set of object files.
-func (b *Builder) gccld(p *load.Package, objdir, out string, flags []string, objs []string) error {
+func (b *Builder) gccld(p *load.Package, objdir, outfile string, flags []string, objs []string) error {
var cmd []string
if len(p.CXXFiles) > 0 || len(p.SwigCXXFiles) > 0 {
cmd = b.GxxCmd(p.Dir, objdir)
} else {
cmd = b.GccCmd(p.Dir, objdir)
}
- return b.run(nil, p.Dir, p.ImportPath, b.cCompilerEnv(), cmd, "-o", out, objs, flags)
+
+ cmdargs := []interface{}{cmd, "-o", outfile, objs, flags}
+ dir := p.Dir
+ out, err := b.runOut(dir, b.cCompilerEnv(), cmdargs...)
+ if len(out) > 0 {
+ // Filter out useless linker warnings caused by bugs outside Go.
+ // See also cmd/link/internal/ld's hostlink method.
+ var save [][]byte
+ for _, line := range bytes.SplitAfter(out, []byte("\n")) {
+ // golang.org/issue/26073 - Apple Xcode bug
+ if bytes.Contains(line, []byte("ld: warning: text-based stub file")) {
+ continue
+ }
+ save = append(save, line)
+ }
+ out = bytes.Join(save, nil)
+ if len(out) > 0 {
+ b.showOutput(nil, dir, p.ImportPath, b.processOutput(out))
+ if err != nil {
+ err = errPrintedOutput
+ }
+ }
+ }
+ return err
}
// Grab these before main helpfully overwrites them.
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 220aab310f..0c3338a861 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1323,9 +1323,24 @@ func (ctxt *Link) hostlink() {
ctxt.Logf("\n")
}
- if out, err := exec.Command(argv[0], argv[1:]...).CombinedOutput(); err != nil {
+ out, err := exec.Command(argv[0], argv[1:]...).CombinedOutput()
+ if err != nil {
Exitf("running %s failed: %v\n%s", argv[0], err, out)
- } else if len(out) > 0 {
+ }
+
+ // Filter out useless linker warnings caused by bugs outside Go.
+ // See also cmd/go/internal/work/exec.go's gccld method.
+ var save [][]byte
+ for _, line := range bytes.SplitAfter(out, []byte("\n")) {
+ // golang.org/issue/26073 - Apple Xcode bug
+ if bytes.Contains(line, []byte("ld: warning: text-based stub file")) {
+ continue
+ }
+ save = append(save, line)
+ }
+ out = bytes.Join(save, nil)
+
+ if len(out) > 0 {
// always print external output even if the command is successful, so that we don't
// swallow linker warnings (see https://golang.org/issue/17935).
ctxt.Logf("%s", out)