Skip to content

Commit 821f2ae

Browse files
ben-kriegerdeadprogram
authored andcommitted
Fix linker errors for runtime.vgetrandom and crypto/internal/sysrand.fatal
1 parent 93a11e2 commit 821f2ae

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/runtime/rand.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package runtime
2+
3+
import _ "unsafe"
4+
5+
// TODO: Use hardware when available
6+
//
7+
//go:linkname vgetrandom
8+
func vgetrandom(p []byte, flags uint32) (ret int, supported bool) { return 0, false }
9+
10+
//go:linkname fatal crypto/internal/sysrand.fatal
11+
func fatal(msg string) { runtimePanic(msg) }

tests/os/smoke/smoke_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package os_smoke_test
44
// Intended to catch build tag mistakes affecting bare metal targets.
55

66
import (
7+
"crypto/rand"
8+
"crypto/rsa"
79
"fmt"
810
"path/filepath"
911
"testing"
@@ -25,3 +27,10 @@ func TestFmt(t *testing.T) {
2527
t.Errorf("printf returned %d, expected 14", n)
2628
}
2729
}
30+
31+
// Regression test for https://github.com/tinygo-org/tinygo/issues/4921
32+
func TestRand(t *testing.T) {
33+
if _, err := rsa.GenerateKey(rand.Reader, 2048); err != nil {
34+
t.Error(err)
35+
}
36+
}

0 commit comments

Comments
 (0)