Commit Graph

21462 Commits

Author SHA1 Message Date
Andrew Kelley
ef447c3eca redo CMakeLists.txt to use WASI interpreter
current status is that it hits error: OutOfMemory for unknown reasons,
probably due to bugs in the C WASI interpreter port.
2022-12-06 12:15:04 -07:00
Andrew Kelley
8c1c67bdd0 stage2: take advantage of the new WasmAllocator 2022-12-06 12:15:04 -07:00
Andrew Kelley
3dcdd5544f stage2: make --color override apply to std.Progress 2022-12-06 12:15:04 -07:00
Andrew Kelley
55ca43a04c std.wasm: add Opcode.prefixed and make PrefixedOpcode nonexhaustive 2022-12-06 12:15:04 -07:00
Andrew Kelley
6b0d773266 std: clean up imports in a couple files 2022-12-06 12:15:04 -07:00
Andrew Kelley
3a8117439d allow build-obj and build-exe in -Donly-c builds 2022-12-06 12:15:04 -07:00
Andrew Kelley
d5312d53a0 WASI: remove absolute path emulation from std lib
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.
2022-12-06 12:15:04 -07:00
Andrew Kelley
0a2fdfbdb9 build.zig: add bulk_memory to -Dwasi-bootstrap
In theory this will enhance the performance of interpreting a WASI build
of Zig.
2022-12-06 12:15:04 -07:00
Andrew Kelley
3ba916584d actually remove stage1 2022-12-06 12:15:04 -07:00
Andrew Kelley
4e2a960b52 std.fs: fix openDirAbsolute
These functions had a compile error since the introduction of
IterableDir.
2022-12-06 12:15:04 -07:00
Andrew Kelley
db023b98a4 build: introduce -Dwasi-bootstrap option
Also, make -Donly-c prevent Autodoc from being included in the binary.

This produces a 2.6 MiB zig.wasm file. 781 KB if piped through zstd.
2022-12-06 12:15:04 -07:00
Andrew Kelley
28514476ef remove -fstage1 option
After this commit, the self-hosted compiler does not offer the option to
use stage1 as a backend anymore.
2022-12-06 12:15:04 -07:00
Pyrolistical
bf316e5506 std: added eql to DynamicBitSet and DynamicBitSetUnmanaged 2022-12-06 21:09:33 +02:00
Andrew Kelley
36da3000c0 Sema: resolve elem type for non-default aligned ptrs
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.
2022-12-06 02:54:58 -05:00
Andrew Kelley
80be5e4832 zig cc: fix wrong flag name from earlier commit
In dfe9420244, I made a typo. This commit
corrects it. I tested this commit via a patch to zig-bootstrap.
2022-12-06 00:09:17 -07:00
Frank Denis
861aa98ac2
wasi-libc: define BULK_MEMORY_THRESHOLD for the bulk_memory feature (#13787)
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.
2022-12-06 04:05:00 +00:00
Andrew Kelley
b0b1cc3566 delete another rogue file
I didn't see this one until pushing the previous commit
2022-12-05 18:26:47 -07:00
Andrew Kelley
68f8cbbf37 delete rogue file
what the hell, how did this file get here
2022-12-05 18:25:35 -07:00
Andrew Kelley
2c49a6c190 compiler_rt: avoid using weak aliases
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.
2022-12-05 18:09:37 -07:00
Andrew Kelley
dfe9420244 zig cc: support -stack in addition to --stack for linker arg 2022-12-05 18:08:31 -07:00
Frank Denis
397881fefb treshold -> threshold 2022-12-05 19:25:10 -05:00
Andrew Kelley
dc852f8226 CI: adjust logic for cancelling workflows
This prevents clobbering when two contributors' PRs have the same head
ref.
2022-12-05 15:51:10 -07:00
Jakub Konka
12e34e7037 dwarf: pull out debug line program internals into DeclState helpers 2022-12-05 22:35:07 +01:00
Jason Phan
97827d6d38
std.fmt.formatInt: Use an optimized path for decimals
It enables faster decimal-to-string conversions for values in the range
[0, 100).
2022-12-05 22:58:45 +02:00
Pyrolistical
9e74e4c1f8 std: added pure functions to StaticBitSet
The following functions were added to both IntegerBitSet and ArrayBitSet:
fn eql(self: Self, other: Self) bool
fn subsetOf(self: Self, other: Self) bool
fn supersetOf(self: Self, other: Self) bool
fn complement(self: Self) Self
fn unionWith(self: Self, other: Self) Self
fn intersectWith(self: Self, other: Self) Self
fn xorWith(self: Self, other: Self) Self
fn differenceWith(self: Self, other: Self) Self
2022-12-05 21:06:10 +02:00
nc
a7cb5027ae std.atomic.Queue: fix unget implementation and add doc 2022-12-05 17:01:56 +02:00
Jakub Konka
8796da0283 dwarf: reuse getDbgInfoAtom helper in all of Dwarf.zig
We need to access it outside of `DeclState` too so why not reuse
the helper anyway.
2022-12-05 14:19:22 +01:00
Jakub Konka
3575048c0a
Merge pull request #13763 from ziglang/macho-dsym-incr
macho+dsym: refactor and reorganize file layout to support incremental DWARF updates
2022-12-05 13:48:12 +01:00
Martin Wickham
b1c4227763 Allow const ArrayLists to be cloned 2022-12-05 04:36:10 -05:00
Frank Denis
4be1bb4aac
std.crypto benchmark: don't use a relative path to import std (#13772) 2022-12-05 04:44:14 +00:00
Jacob Young
4ee79aa33c CBE: revert broken change that got missed 2022-12-04 22:37:48 -05:00
Andrew Kelley
70ad5bc363
Merge pull request #13768 from ziglang/cbe-reuse-locals-2
C backend: reuse locals but respect loops to pass behavior tests
2022-12-04 21:59:01 -05:00
Jacob Young
7d3cc3bc8d CBE: defer invariant local reuse in loops
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.
2022-12-04 15:57:40 -07:00
Andrew Kelley
518392d6fe disable CBE behavior tests that are not passing in release modes 2022-12-04 15:57:40 -07:00
Andrew Kelley
cc8bcae8c0 CBE: fix liveness issue with wrapping optionals 2022-12-04 15:57:40 -07:00
Andrew Kelley
4a6deaff5f CBE: remove stray comment 2022-12-04 15:57:40 -07:00
Andrew Kelley
701cebeb30 CBE: fix union init wrong field name 2022-12-04 15:57:40 -07:00
Andrew Kelley
aa98517b3e CBE: aggregate_init: resolve all operands before processing Liveness 2022-12-04 15:57:40 -07:00
Andrew Kelley
4aae0b09cf CBE and LLVM: handle unused try instructions
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.
2022-12-04 15:57:40 -07:00
Andrew Kelley
f2e59e41c1 CBE: fix various regressions caught by behavior tests 2022-12-04 15:57:40 -07:00
Andrew Kelley
6c0a1417c6 CBE: fix static allocs being double allocated 2022-12-04 15:57:40 -07:00
Andrew Kelley
da73410e7f CBE: avoid curly inits because they don't work in assignments 2022-12-04 15:57:40 -07:00
Andrew Kelley
db1819e8ed CBE: fix use-after-free of Type keys in free_locals map 2022-12-04 15:57:40 -07:00
Andrew Kelley
7bd63a602a CBE: fix assignment expr and switch free tracking 2022-12-04 15:57:40 -07:00
Andrew Kelley
8bfbfa589c CBE: fix clone of freed locals not being deep clone 2022-12-04 15:57:40 -07:00
Andrew Kelley
73a76b45c5 CBE: take advantage of switch_br and cond_br liveness 2022-12-04 15:57:40 -07:00
Andrew Kelley
8d8b2c834d CBE: exploit Liveness analysis to reuse locals 2022-12-04 15:57:40 -07:00
Andrew Kelley
3a9375cae9 wasm codegen: fix some missing Liveness reaps
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.
2022-12-04 15:57:40 -07:00
Andrew Kelley
954019983d std: add move() functions to hash maps 2022-12-04 15:57:40 -07:00
Andrew Kelley
2a0efbee56 Revert "cbe: reduce amount of temporary locals"
This reverts commit 15cc83e27a.
2022-12-04 15:57:40 -07:00