]> Cypherpunks.ru repositories - gostls13.git/commitdiff
misc/cgo/test: add cgo build constraints
authorAustin Clements <austin@google.com>
Sat, 6 May 2023 02:29:11 +0000 (22:29 -0400)
committerAustin Clements <austin@google.com>
Fri, 12 May 2023 12:00:00 +0000 (12:00 +0000)
We're about to move this package to cmd/cgo/internal, where it will
get caught up in the "CGO_ENABLED=0 go install cmd" done by make.bash.
Currently, building this package with CGO_ENABLED=0 fails because it
contains several source files that don't themselves import "C", but do
import a subdirectory where that package imports "C" and thus has no
exported API.

Fix the CGO_ENABLED=0 build of this package by adding the necessary
cgo build tags. Not all source files need it, but this CL makes
"CGO_ENABLED=0 go test -c" work in this package.

For #37486.

Change-Id: Id137cdfbdd950eea802413536d990ab642ebcd7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/493215
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Austin Clements <austin@google.com>

20 files changed:
misc/cgo/test/cgo_linux_test.go
misc/cgo/test/cgo_test.go
misc/cgo/test/cgo_unix_test.go
misc/cgo/test/gcc68255.go
misc/cgo/test/issue18146.go
misc/cgo/test/issue23555.go
misc/cgo/test/issue24161_darwin_test.go
misc/cgo/test/issue26430.go
misc/cgo/test/issue26743.go
misc/cgo/test/issue27340.go
misc/cgo/test/issue29563.go
misc/cgo/test/issue30527.go
misc/cgo/test/issue43639.go
misc/cgo/test/issue52611.go
misc/cgo/test/issue8828.go
misc/cgo/test/issue9026.go
misc/cgo/test/issue9400/stubs.go
misc/cgo/test/issue9510.go
misc/cgo/test/test26213.go
misc/cgo/test/test_unix.go

index 3a1cf98c2a49594986b1ff5c5d727a30194020f6..3defc32ffd8562bf8d0a76c7638e76daf314d900 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 package cgotest
 
 import (
index 5b298954f59e592699bd0ba7c3bce0af8da8d6f9..5a07c4c0fa3d969bdf59b062e6cf338f94ee4708 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 package cgotest
 
 import "testing"
index e6d6ee54b4aba3db448ccc4b523ac8094a36b60e..5c1f9b7e4060f61d2a68024717daff61a6a9c739 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !windows
+//go:build cgo && !windows
 
 package cgotest
 
index 7b25e02ad8903ba03b331896b956e84f1590c2f6..954bba9b5c588cbceadaca302adea4a5c180e323 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 package cgotest
 
 import (
index f02fc4476d88418c16ad0bbcad3ce109c4a42e53..d302bd029fa26ecab45df69e5baf53f989df7584 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !windows
+//go:build cgo && !windows
 
 // Issue 18146: pthread_create failure during syscall.Exec.
 
index e84c23cfd43dca90086ad822de21f1c869c4b8a3..299fdcb9144504532a8787ff70eb22b979ed206f 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Test that we can have two identical cgo packages in a single binary.
 // No runtime test; just make sure it compiles.
 
index 7bb2af69a5dcd1115e9e5471e252d2dd1060f2bc..9054d6205cbb39d3de4121798668985dfe5b8b81 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 package cgotest
 
 import (
index b55193973d8cbd870e166b138c81f0275c0ea9d2..cf276a036268d9aa6c3918b2e36715d65f496c8d 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Issue 26430: incomplete typedef leads to inconsistent typedefs error.
 // No runtime test; just make sure it compiles.
 
index 716f2e48d9ed1d0c75392b65c619b80b3222f10f..903caeeada7e779b46388c19f1bf8bc4fd3681d3 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Issue 26743: typedef of uint leads to inconsistent typedefs error.
 // No runtime test; just make sure it compiles.
 
index 2c51088363263d388543de1c72e4383ef5b44c5f..d70f104179c8dc2612cff12a89f3c28fb9a07faa 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Failed to resolve typedefs consistently.
 // No runtime test; just make sure it compiles.
 
index bbe98bbd48c2650a6416fc7a2ef04c4e8f6f5f34..800b5461af83ec23c31898d0cab8f674a9635e15 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !windows
+//go:build cgo && !windows
 
 // Issue 29563: internal linker fails on duplicate weak symbols.
 // No runtime test; just make sure it compiles.
index e0e18bebdfcde6beffb7bc50588c2f10a35d9312..982455084d568a17c572efac394ed1eae8138007 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Issue 30527: function call rewriting casts untyped
 // constants to int because of ":=" usage.
 
index 41e14710591b214a4472492b696939614c707168..38dae41d5e56d3e45f5f60f13ecc70f0a1f3bfef 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 package cgotest
 
 // Issue 43639: No runtime test needed, make sure package misc/cgo/test/issue43639 compiles well.
index 2b59d521f70ba331ba30c0d076d32c635cef7507..a190a1088443e3aced391606c934e8795a72fd43 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Issue 52611: inconsistent compiler behaviour when compiling a C.struct.
 // No runtime test; just make sure it compiles.
 
index 3b5765d3068a7ec66668000791bd266248c66810..e9ec2652683683aa24f3ad50c5ec21958abc1e30 100644 (file)
@@ -1,9 +1,9 @@
-// compile
-
 // Copyright 2014 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Issue 8828: compiling a file with -compiler=gccgo fails if a .c file
 // has the same name as compiled directory.
 
index a30196c99f084c9313766534d65786d2b5ebc70d..fc4df07a3b0ce0d42788a1653d18672385748dbf 100644 (file)
@@ -1,3 +1,9 @@
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build cgo
+
 package cgotest
 
 import (
index 08cde2e33b418f5baad182b2ad501643f8372b42..c2b235abab1f1b9d531f900eb658613fe8fbcba8 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build gc
+//go:build linux && gc
 
 package issue9400
 
index 325b0cfb4aa38d360523f497872f0e01c306144b..9bccfeb5e790edc49301165e1a1eeb4913d863d3 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 // Test that we can link together two different cgo packages that both
 // use the same libgcc function.
 
index f8149cd7c80767c4b6dd59eafa16e17d032f51bf..3669590f47073d09cb84efaaa42cabf9e73fc0dc 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
+
 package cgotest
 
 import (
index 50fb0d4db2235eda0098b951d7cbdaa7a1d61ae8..664c4850d387231a8403ae4184c362198ce52a24 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !windows
+//go:build unix
 
 package cgotest