Instead of checking for absolute paths and current working directories
in various file system operations, there is one simple solution: allow
overriding `std.fs.cwd` on WASI.
os.realpath is back to causing a compile error when used on WASI. This
caused a compile error in the Sema handling of `@src()`. The compiler
should never call realpath, so the commit that made this change is
reverted (95ab942184). If this breaks
debug info, a different strategy is needed to solve it other than using
realpath.
I also removed the preopens code and replaced it with something much
simpler. There is no longer any global state in the standard library.
Additionally-
* os.openat no longer does an unnecessary fstat on WASI when O.WRONLY
is not provided.
* os.chdir is back to causing a compile error on WASI.
Before this commit, I observe a crash from this abiSize call because the
element type is a struct that is not yet resolved. This is triggered by
running the behavior tests with -ofmt=c -target x86_64-windows.
When the bulk_memory feature is enabled, wasi-libc will only use
it if the number of bytes is >= BULK_MEMORY_THRESHOLD
Set it to 32 as in the original wasi-libc Makefile.
This is a partial revert of 0d533433e2,
which regressed this behavior. The idea here is to avoid aliases, which
happens when the same function is exported with multiple names. The
problem with aliases is that weak aliases don't seem to work, causing
symbol collisions when multiple of the same symbol are provided, despite
the desired behavior that weak symbols are overridden.
In this case we export redundant functions with different names. Thanks
to -ffunction-sections, the unused functions will be garbage-collected
at link time. This leaves us with the best of both worlds: Zig's
compiler-rt will provide both sets of symbols, and it will be
binary-compatible with different compilers that expect different names,
while still resulting in binaries without garbage.
When a local defined outside a loop dies inside the loop, it can still
be needed on subsequent loop iterations, so reuse of the local must be
deferred until after the loop ends. This causes behavior tests to pass.
In both backends they did not observe the Liveness information for try
instructions. Now they do. For the C backend this is necessary for
correctness; for the LLVM backend, it improves code generation.
I did not do a full audit, but I did notice a few issues which are
resolved in this commit. Probably it would be worth adding debug
infrastructure to assert that the number of reaps equals the number of
calls to resolveInst() per air lowering function.