]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix -n output in runtime/internal/atomic
authorJay Conrod <jayconrod@google.com>
Fri, 21 Dec 2018 17:23:18 +0000 (12:23 -0500)
committerJay Conrod <jayconrod@google.com>
Fri, 21 Dec 2018 20:44:41 +0000 (20:44 +0000)
When building runtime/internal/atomic, the toolchain writes a symabis2
file. This file is read back in, filtered, and appended to the symabis
file. This breaks with -n, since the symabis2 file is never written.

With this change, when -n is used, an equivalent "grep" command is
printed instead. The output for -x is unchanged.

Fixes #29346

Change-Id: Id25e06e06364fc6689e71660d000f09c649c4f0c
Reviewed-on: https://go-review.googlesource.com/c/155480
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>

src/cmd/go/internal/work/gc.go
src/cmd/go/testdata/script/build_runtime_gcflags.txt [new file with mode: 0644]

index 0df6629f410fbc073da63137b59b1dd66d56a2fd..3d09f69fcc3e43698dbb8182695bb4f4746247f9 100644 (file)
@@ -316,6 +316,12 @@ func (gcToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, erro
 
                // Filter out just the symbol refs and append them to
                // the symabis file.
+               if cfg.BuildN {
+                       // -x will print the lines from symabis2 that are actually appended
+                       // to symabis. With -n, we don't know what those lines will be.
+                       b.Showcmd("", `grep '^ref' <%s | grep -v '^ref\s*""\.' >>%s`, symabis2, a.Objdir+"symabis")
+                       continue
+               }
                abis2, err := ioutil.ReadFile(symabis2)
                if err != nil {
                        return "", err
diff --git a/src/cmd/go/testdata/script/build_runtime_gcflags.txt b/src/cmd/go/testdata/script/build_runtime_gcflags.txt
new file mode 100644 (file)
index 0000000..dc0767c
--- /dev/null
@@ -0,0 +1,4 @@
+# This test verifies the standard library (specifically runtime/internal/atomic)
+# can be built with -gcflags when -n is given. See golang.org/issue/26092.
+go build -n -gcflags=all='-l' std
+stderr 'compile.* -l .* runtime/internal/atomic'