Fix linker errors for runtime.vgetrandom and crypto/internal/sysrand.fatal

This commit is contained in:
Ben Krieger
2025-09-18 23:46:46 -04:00
committed by Ron Evans
parent 93a11e266f
commit 821f2aeae0
2 changed files with 20 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
package runtime
import _ "unsafe"
// TODO: Use hardware when available
//
//go:linkname vgetrandom
func vgetrandom(p []byte, flags uint32) (ret int, supported bool) { return 0, false }
//go:linkname fatal crypto/internal/sysrand.fatal
func fatal(msg string) { runtimePanic(msg) }
+9
View File
@@ -4,6 +4,8 @@ package os_smoke_test
// Intended to catch build tag mistakes affecting bare metal targets.
import (
"crypto/rand"
"crypto/rsa"
"fmt"
"path/filepath"
"testing"
@@ -25,3 +27,10 @@ func TestFmt(t *testing.T) {
t.Errorf("printf returned %d, expected 14", n)
}
}
// Regression test for https://github.com/tinygo-org/tinygo/issues/4921
func TestRand(t *testing.T) {
if _, err := rsa.GenerateKey(rand.Reader, 2048); err != nil {
t.Error(err)
}
}