aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-06-13 11:55:30 -0700
committerIan Lance Taylor <iant@golang.org>2016-06-14 03:44:27 +0000
commit0deb49f9c09d15bf0e4c5ec843bd374f9a377e97 (patch)
treec2ec7af6cd52418e699f1685f4be3105280d0dd2
parent9273e25eccbe82edff839b125b49bfb5578f24eb (diff)
downloadgo-0deb49f9c09d15bf0e4c5ec843bd374f9a377e97.tar.gz
go-0deb49f9c09d15bf0e4c5ec843bd374f9a377e97.zip
cmd/go: include .syso files even if CGO_ENABLED=0
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>
-rw-r--r--src/cmd/go/go_test.go22
-rw-r--r--src/cmd/go/pkg.go3
2 files changed, 24 insertions, 1 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index c46e0c7da5..a6c70d97b6 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -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")
+}
diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
index ee3f403dd6..07aa3ff2bc 100644
--- a/src/cmd/go/pkg.go
+++ b/src/cmd/go/pkg.go
@@ -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.