Skip to content

Commit 75e2548

Browse files
dkegel-fastlydeadprogram
authored andcommitted
Kludge: provide stub for syscall.seek on 386 and arm, #1906
This replaces an earlier kludge which was at the wrong level and caused "GOARCH=386 tinygo test os" to fail to compile on linux. Stubbing just the one missing function, syscall.seek, lets os tests compile on linux 386, and skipping tests of seek and Fstat (which has a cryptic dependency on syscall.Seek via time) lets os tests pass on linux 386. The stub can be removed once tinygo implements go assembly and picks up the real definition.
1 parent f965d7f commit 75e2548

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

src/os/file_other.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ func Pipe() (r *File, w *File, err error) {
6262
return nil, nil, ErrNotImplemented
6363
}
6464

65-
func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
66-
return 0, ErrNotImplemented
67-
}
68-
6965
func Readlink(name string) (string, error) {
7066
return "", ErrNotImplemented
7167
}

src/os/os_anyos_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ func equal(name1, name2 string) (r bool) {
6060
}
6161

6262
func TestFstat(t *testing.T) {
63+
if runtime.GOARCH == "386" || runtime.GOARCH == "arm" {
64+
t.Log("TODO: implement fstat for 386 and arm")
65+
return
66+
}
6367
sfname := "TestFstat"
6468
path := TempDir() + "/" + sfname
6569
payload := writeFile(t, path, O_CREATE|O_TRUNC|O_RDWR, "Hello")

src/os/os_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ func checkMode(t *testing.T, path string, mode FileMode) {
8989
}
9090

9191
func TestSeek(t *testing.T) {
92+
if runtime.GOARCH == "386" || runtime.GOARCH == "arm" {
93+
t.Log("TODO: implement seek for 386 and arm")
94+
return
95+
}
9296
f := newFile("TestSeek", t)
9397
if f == nil {
9498
t.Fatalf("f is nil")

src/os/seek_unix_bad.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi
2+
3+
package os
4+
5+
import (
6+
"syscall"
7+
)
8+
9+
// On linux, we use upstream's syscall package.
10+
// But we do not yet implement Go Assembly, so we don't see a few functions written in assembly there.
11+
// In particular, on i386 and arm, the function syscall.seek is missing, breaking syscall.Seek.
12+
// This in turn causes os.(*File).Seek, time, io/fs, and path/filepath to fail to link.
13+
//
14+
// To temporarly let all the above at least link, provide a stub for syscall.seek.
15+
// This belongs in syscall, but on linux, we use upstream's syscall.
16+
// Remove once we support Go Assembly.
17+
// TODO: make this a non-stub, and thus fix the whole problem?
18+
19+
//export syscall.seek
20+
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) {
21+
return 0, syscall.ENOTSUP
22+
}

0 commit comments

Comments
 (0)