diff --git a/src/runtime/secret/asm_amd64.s b/src/runtime/secret/asm_amd64.s
index 7011afc..0f2a474 100644
--- a/src/runtime/secret/asm_amd64.s
+++ b/src/runtime/secret/asm_amd64.s
@@ -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 goexperiment.runtimesecret
+
// Note: this assembly file is used for testing only.
// We need to access registers directly to properly test
// that secrets are erased and go test doesn't like to conditionally
@@ -208,6 +210,6 @@
// registers contain secrets.
// It also tests the path from G stack to M stack
// to scheduler and back.
- CALL ·delay(SB)
+ CALL runtime∕secret·delay(SB)
RET
diff --git a/src/runtime/secret/asm_arm64.s b/src/runtime/secret/asm_arm64.s
index 1d7f7c1..6fa625a 100644
--- a/src/runtime/secret/asm_arm64.s
+++ b/src/runtime/secret/asm_arm64.s
@@ -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 goexperiment.runtimesecret
+
// Note: this assembly file is used for testing only.
// We need to access registers directly to properly test
// that secrets are erased and go test doesn't like to conditionally
diff --git a/src/runtime/secret/stubs.go b/src/runtime/secret/stubs.go
index ec66ef2..3438d97 100644
--- a/src/runtime/secret/stubs.go
+++ b/src/runtime/secret/stubs.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 arm64 || amd64
+//go:build goexperiment.runtimesecret && (arm64 || amd64)
// testing stubs, these are implemented in assembly in
// asm_$GOARCH.s
@@ -13,7 +13,10 @@
package secret
-import "unsafe"
+import (
+ "time"
+ "unsafe"
+)
// Load data from p into test registers.
//
@@ -30,3 +33,8 @@
//
//go:noescape
func useSecret(secret []byte)
+
+// callback from assembly
+func delay() {
+ time.Sleep(1 * time.Millisecond)
+}
diff --git a/src/runtime/secret/testdata/crash.go b/src/runtime/secret/testdata/crash.go
index cf48fb7..1ee1ea6 100644
--- a/src/runtime/secret/testdata/crash.go
+++ b/src/runtime/secret/testdata/crash.go
@@ -18,13 +18,6 @@
"weak"
)
-// callback from assembly
-//
-//go:linkname delay main.delay
-func delay() {
- time.Sleep(1 * time.Millisecond)
-}
-
// Same secret as in ../../crash_test.go
var secretStore = [8]byte{
0x00,