]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: include .syso files even if CGO_ENABLED=0
authorIan Lance Taylor <iant@golang.org>
Mon, 13 Jun 2016 18:55:30 +0000 (11:55 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 14 Jun 2016 03:44:27 +0000 (03:44 +0000)
A .syso file may include information that should go into the object file
that is not object code, and should be included even if not using cgo.
The example in the issue is a Windows manifest file.

Fixes #16050.

Change-Id: I1f4f3f80bb007e84d153ca2d26e5919213ea4f8d
Reviewed-on: https://go-review.googlesource.com/24032
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
src/cmd/go/go_test.go
src/cmd/go/pkg.go

index c46e0c7da59506ed916876673f49524edd8f9c67..a6c70d97b6f7cce3fed4e09b0f1397647fd199a7 100644 (file)
@@ -2898,3 +2898,25 @@ func TestBinaryOnlyPackages(t *testing.T) {
        tg.run("run", tg.path("src/p3/p3.go"))
        tg.grepStdout("hello from p1", "did not see message from p1")
 }
+
+// Issue 16050.
+func TestAlwaysLinkSysoFiles(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       tg.parallel()
+       tg.tempDir("src/syso")
+       tg.tempFile("src/syso/a.syso", ``)
+       tg.tempFile("src/syso/b.go", `package syso`)
+       tg.setenv("GOPATH", tg.path("."))
+
+       // We should see the .syso file regardless of the setting of
+       // CGO_ENABLED.
+
+       tg.setenv("CGO_ENABLED", "1")
+       tg.run("list", "-f", "{{.SysoFiles}}", "syso")
+       tg.grepStdout("a.syso", "missing syso file with CGO_ENABLED=1")
+
+       tg.setenv("CGO_ENABLED", "0")
+       tg.run("list", "-f", "{{.SysoFiles}}", "syso")
+       tg.grepStdout("a.syso", "missing syso file with CGO_ENABLED=0")
+}
index ee3f403dd6c337fcc47d03e206ac2b6a2b6b7af7..07aa3ff2bc91ce7572e52fdb0e08ded704ab39d0 100644 (file)
@@ -1022,9 +1022,10 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
                p.MFiles = nil
                p.SwigFiles = nil
                p.SwigCXXFiles = nil
-               p.SysoFiles = nil
                // Note that SFiles are okay (they go to the Go assembler)
                // and HFiles are okay (they might be used by the SFiles).
+               // Also Sysofiles are okay (they might not contain object
+               // code; see issue #16050).
        }
 
        // The gc toolchain only permits C source files with cgo.