]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo/internal/testtls: build and run everywhere
authorAustin Clements <austin@google.com>
Wed, 17 May 2023 19:32:41 +0000 (15:32 -0400)
committerAustin Clements <austin@google.com>
Fri, 19 May 2023 01:37:35 +0000 (01:37 +0000)
This makes testtls build and run on all platforms in the default build
configuration (though it will Skip on some).

Change-Id: I6aba96a82d618c9798a0d4418b40b2644cfceec9
Reviewed-on: https://go-review.googlesource.com/c/go/+/496177
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/cgo/internal/testtls/tls.c [moved from src/cmd/cgo/internal/testtls/tls_unix.c with 79% similarity]
src/cmd/cgo/internal/testtls/tls.go
src/cmd/cgo/internal/testtls/tls_none.go [new file with mode: 0644]
src/cmd/cgo/internal/testtls/tls_test.go
src/cmd/dist/test.go

similarity index 79%
rename from src/cmd/cgo/internal/testtls/tls_unix.c
rename to src/cmd/cgo/internal/testtls/tls.c
index 957afce90d4aedc8a79f8bfa5e447871086876b2..0e2bbee5422656658cc8669ccb332af46d3e9f41 100644 (file)
@@ -2,6 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Darwin does not have __thread.
+
+//go:build cgo && unix && !darwin
+
 #include <pthread.h>
 
 static __thread int tls;
index 4684f82ebde7b836009e2503031d2786d4845d00..eb59ad41eb8548aea270883edab6f1bba86dc343 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 unix
+//go:build cgo && unix && !darwin
 
 package cgotlstest
 
diff --git a/src/cmd/cgo/internal/testtls/tls_none.go b/src/cmd/cgo/internal/testtls/tls_none.go
new file mode 100644 (file)
index 0000000..81c9c5e
--- /dev/null
@@ -0,0 +1,13 @@
+// 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 && unix && !darwin)
+
+package cgotlstest
+
+import "testing"
+
+func testTLS(t *testing.T) {
+       t.Skip("__thread is not supported")
+}
index 10b71f074ed4590cdcda80191ae3d38222d7b146..8e14add9886211296e759eed36982425c9bcb281 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build cgo && unix
-
 package cgotlstest
 
 import "testing"
index fe818036b5548462605d9aaffc177b4569f304b8..40df8c03b8ff043e7f32c9cefe99c1d076c671fd 100644 (file)
@@ -1129,6 +1129,7 @@ func (t *tester) registerCgoTests(heading string) {
        }
 
        cgoTest("auto", "test", "auto", "")
+       cgoTest("auto", "testtls", "auto", "")
 
        // Stub out various buildmode=pie tests  on alpine until 54354 resolved.
        builderName := os.Getenv("GO_BUILDER_NAME")
@@ -1162,7 +1163,6 @@ func (t *tester) registerCgoTests(heading string) {
                gt := cgoTest("external-g0", "test", "external", "")
                gt.env = append(gt.env, "CGO_CFLAGS=-g0 -fdiagnostics-color")
 
-               cgoTest("auto", "testtls", "auto", "")
                cgoTest("external", "testtls", "external", "")
                switch {
                case os == "aix":