Commit Graph

15 Commits

Author SHA1 Message Date
Crypt Keeper
15fa5c4de5 Changes build to test go 1.21rc2 (#1571)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-10 13:39:37 +08:00
Takeshi Yoneda
9aa8f4e0ae platform: removes unnecessary code (#1492)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-29 09:09:24 +10:00
Achille
1b35900911 linux: support using huge pages (#1475)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
2023-05-17 11:14:31 -07:00
Achille
d3efad1fc4 compiler: remove intermediary copy of compiled functions code (#1466)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-05-14 23:22:16 -07:00
Takeshi Yoneda
d9e5d6b0d3 Avoids unnecessary allocations during mmap executables (#1366)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-17 14:03:35 +09:00
Edoardo Vacchi
d63813a830 fs: stat and cache mode for stdio devices (#1295)
Ensure that stdio device modes are consistent with the given
file descriptors by stat'ing, instead of returning mocks.

* Use `Stat()` on `poll_oneoff()` too, instead of `IsTerminal()`,
thus avoiding a useless syscall.

* Delete leftover type decl `fileModeStat`.

* Remove IsPlatform()

* Propagate error when Stat() fails

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-28 12:48:24 +02:00
Crypt Keeper
4d90a5c364 platform: Allows sysfs to implement utimens natively (#1215)
platform: Allows sysfs to implement utimesns natively

This moves away from `syscall.UtimesNano` as it has intentionally
avoided common features in POSIX, such as handling UTIME_NOW and
UTIME_OMIT. When we eventually expose this API, users will be free to
override `UTIME_NOW` with a fake clock, possibly the same that was
supplied to wazero's `ModuleConfig`.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-09 13:14:09 +08:00
Crypt Keeper
e77f24fe31 sysfs: drops os.File special casing for fs.FS to pass wasi-testsuite (#1174)
This adds a wazero adapter which passes wasi-testsuite 100pct on darwin,
linux and windows. While the main change was adding inodes to the wasi
`fd_readdir` dirents, there was a lot of incidental work needed.

Most of the work was troubleshooting in nature, around windows
specifically, but also wrapping of files. This backfills a lot of tests
and reworked how wrapping works, particularly around windows.

To accommodate this, we drop `os.File` special casing except for
`sysfs.DirFS`

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-01 13:28:57 +08:00
Edoardo Vacchi
28b0084e62 compiler(amd64): return false on SSE4 unsupported CPUs (#1121)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-02-14 08:33:18 +09:00
Crypt Keeper
407f3ea3c0 wasi: detect if stdio are char devices instead of assuming (#935)
This uses ioctl syscalls or appropriate alternative, to detect if
stdin/out/err are character devices or not. This caches the result, to
ensure performance is ok at runtime as executing stat can approach
microsecond overhead.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-12-16 16:06:54 +09:00
Takeshi Yoneda
3b32c2028b Externalize compilation cache by compilers (#747)
This adds the experimental support of the file system compilation cache.
Notably, experimental.WithCompilationCacheDirName allows users to configure
where the compiler writes the cache into.

Versioning/validation of binary compatibility has been done via the release tag
(which will be created from the end of this month). More specifically, the cache
file starts with a header with the hardcoded wazero version.


Fixes #618

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2022-08-18 19:37:11 +09:00
Crypt Keeper
891761ac1e Adds support for FreeBSD (#671)
FreeBSD was disabled due to lack of testing. This works around the
compilation problems. Note: We can't currently test arm64 automatically!

Notes:

* GitHub Actions doesn’t support FreeBSD, and may never.
* We could use Travis to run FreeBSD, but it would split our CI config.
* Using Vagrant directly is easier to debug than vmactions/freebsd-vm.
* GitHub Actions only supports virtualization on MacOS.
* GitHub Actions removed vagrant from the image starting with macos-11.
* Since VirtualBox doesn't work on arm64, freebsd/arm64 is untestabl

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-07-01 18:59:19 +08:00
Crypt Keeper
507ce79080 Adds sys.Walltime and sys.Nanotime for security and determinism (#616)
This adds two clock interfaces: sys.Walltime and sys.Nanotime to
allow implementations to override readings for purposes of security or
determinism.

The default values of both are a fake timestamp, to avoid the sandbox
break we formerly had by returning the real time. This is similar to how
we don't inherit OS Env values.
2022-06-04 15:14:31 +08:00
Crypt Keeper
50d504cfdd Narrows compiler support to operating systems currently known to work (#612)
This narrows to what the `internal/platform` package supports, which is
currently bound by Go SDK source that include `Mprotect` or windows.

Ex. `zsyscall_linux_amd64.go` includes `Mprotect`, but
`zsyscall_freebsd_amd64.go` does not.

This should prevent errors like below, by allowing `wazero.NewRuntime()`
to properly fallback to the interpreter.

```
.../mmap.go:74:16: undefined: syscall.Mprotect
```

A later change will implement FreeBSD. This is just here to ensure users
don't crash on unexpected OS.

See #607

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-06-01 13:49:55 +08:00
Crypt Keeper
e0e9e27326 Extracts platform-specific runtime code into its own package (#608)
This moves the platform-specific runtime code (currently only used by
the compiler) into its own package. Specifically, this moves the mmap
logic, and in doing so makes it easier to test, for example new
operating systems.

This also backfills missing RATIONALE about x/sys and hints at a future
possibility to allow a plugin. However, the next step is to get FreeBSD
working natively on the compiler without any additional dependencies.

See #607

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-06-01 09:24:02 +08:00