From: Austin Clements Date: Wed, 17 May 2023 19:32:41 +0000 (-0400) Subject: cmd/cgo/internal/testtls: build and run everywhere X-Git-Tag: go1.21rc1~439 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ab3c2b6d89daa54679cdaa0d78d2902473e0d63b;p=gostls13.git cmd/cgo/internal/testtls: build and run everywhere 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 Run-TryBot: Austin Clements Reviewed-by: Bryan Mills --- diff --git a/src/cmd/cgo/internal/testtls/tls_unix.c b/src/cmd/cgo/internal/testtls/tls.c similarity index 79% rename from src/cmd/cgo/internal/testtls/tls_unix.c rename to src/cmd/cgo/internal/testtls/tls.c index 957afce90d..0e2bbee542 100644 --- a/src/cmd/cgo/internal/testtls/tls_unix.c +++ b/src/cmd/cgo/internal/testtls/tls.c @@ -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 static __thread int tls; diff --git a/src/cmd/cgo/internal/testtls/tls.go b/src/cmd/cgo/internal/testtls/tls.go index 4684f82ebd..eb59ad41eb 100644 --- a/src/cmd/cgo/internal/testtls/tls.go +++ b/src/cmd/cgo/internal/testtls/tls.go @@ -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 index 0000000000..81c9c5e23d --- /dev/null +++ b/src/cmd/cgo/internal/testtls/tls_none.go @@ -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") +} diff --git a/src/cmd/cgo/internal/testtls/tls_test.go b/src/cmd/cgo/internal/testtls/tls_test.go index 10b71f074e..8e14add988 100644 --- a/src/cmd/cgo/internal/testtls/tls_test.go +++ b/src/cmd/cgo/internal/testtls/tls_test.go @@ -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" diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index fe818036b5..40df8c03b8 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -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":