Commit Graph

28604 Commits

Author SHA1 Message Date
Andrew Kelley
a1b083b666
Merge pull request #19120 from jacobly0/os-cleanup
posix: fix socket fd leak
2024-02-28 05:51:15 -08:00
antlilja
5c2e463ecd LLVM: Don't create a debug lexical block when inlining 2024-02-28 14:46:43 +01:00
antlilja
40f99862e1 Builder: Implement StrtabString and use it for Global names 2024-02-28 14:46:43 +01:00
antlilja
826c6c0ec6 LLVM: Implement more efficient blob writing 2024-02-28 14:46:43 +01:00
Andrew Kelley
dff45c266e wasi.c: report no environment variables available
I moved part of the compiler that checks environment variables to the
standard library, so it doesn't have access to `build_options.only_c`
anymore, which means some environment variable checks are leaking into
the zig1.wasm build of zig. This logic still makes it return "no
environment variables found" though.
2024-02-27 22:55:00 -07:00
Andrew Kelley
420b7713d4 CLI: strip lazy built commands by default
Saves a lot of time since we use -OReleaseFast.
Disabled when ZIG_DEBUG_CMD=1 is passed.
2024-02-27 22:55:00 -07:00
Andrew Kelley
a4380a30f5 move zig libc command to be lazily built
part of #19063

This is a prerequisite for doing the same for Resinator.
2024-02-27 22:55:00 -07:00
IntegratedQuantum
6e078883ee Expand the memcpy fast path in flate.CircularBuffer.writeMatch to allow for overlapping regions. 2024-02-27 21:26:26 -08:00
Jacob Young
f446d8e8f9 posix: @as and other general cleanup 2024-02-28 04:30:49 +01:00
Igor Anić
62ce753814 compress: activate tests in wasm32
They were disabled because insufficient stack size.
That is
[changed](d51aa9748f) now.
2024-02-27 19:19:59 -08:00
Jacob Young
17d0bb5bea posix: fix socket fd leaks 2024-02-28 04:09:14 +01:00
Ryan Liptak
ae7f3fc360 Eliminate error.InvalidHandle from OpenError and RealPathError
InvalidHandle in OpenError is no longer a possible error on any platform. In the past it was able to be returned in `openOptionsFromFlagsWasi`, but the implementation was changed in 7680c5330c to make it no longer possible.

InvalidHandle in RealPathError was a holdover from before d5312d53a0, which made realpath a compile error on WASI. However, InvalidHandle was also a possible error in the FreeBSD fallback implementation added in 537624734c. This commit changes the FreeBSD fallback implementation to return FileNotFound instead of InvalidHandle which matches how EBADF is handled in all the other `realpath` implementations (including the FreeBSD non-fallback implementation).

Closes #19084
2024-02-27 15:59:50 -08:00
Travis Staloch
30bf8d7147 testing.expectFmt() - reuse expectEqualStrings() 2024-02-27 14:40:28 -08:00
dweiller
bd0dbb0a13 std.compress.zstd: enable tests for wasm32
The increase in stack size for wasm32 targets in commit d51aa9748f
allows the streaming decompressor to be tested on wasm32-wasi.
2024-02-27 11:37:48 -08:00
Andrew Kelley
6f7354a041
Merge pull request #19102 from ziglang/decouple-zir
JIT `zig fmt` and `zig reduce`
2024-02-27 11:03:08 -08:00
Luuk de Gram
27f589dea1
Merge pull request #18538 from Pangoraw/wasm_vector_abi
wasm: allow non-int vectors
2024-02-27 18:42:12 +01:00
Andrew Kelley
085bde6889
Merge pull request #19087 from squeek502/redundant-test-naming
Remove redundant test name prefixes now that test names are fully qualified
2024-02-26 23:43:02 -08:00
Andrew Kelley
97f2a8b5cb introduce ZIG_DEBUG_CMD to choose debug mode
for lazily built commands such as `zig fmt` and `zig reduce`. Useful if
you want to test a patch to them.
2024-02-26 23:48:56 -07:00
Andrew Kelley
1a01151a4e back out the build_runner.zig moving change
I'd like to move this file but to do so requires a zig1.wasm update, so
I'll choose a more opportune moment to make this change.
2024-02-26 23:44:01 -07:00
Andrew Kelley
dfe430e9f4 move lazily compiled source files to lib/compiler/ 2024-02-26 23:43:56 -07:00
Andrew Kelley
0157e1196c compiler: JIT zig reduce
See #19063
2024-02-26 23:43:42 -07:00
Andrew Kelley
ba575595bb std.zig: don't try to unit test a separate exe
This results in "file exists in multiple modules" errors.

A future commit should move these subcommands to outside std/.
2024-02-26 22:53:17 -07:00
Andrew Kelley
d661f0f35b compiler: JIT zig fmt
See #19063
2024-02-26 22:26:19 -07:00
Andrew Kelley
b116063e02 move AstGen to std.zig.AstGen
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:51:19 -07:00
Andrew Kelley
a2e87aba66 rearrange std.zig
This frees up std.zig.fmt to be used for the implementation of `zig
fmt`.
2024-02-26 21:35:33 -07:00
Andrew Kelley
7b37bc771b move Zir to std.zig.Zir
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:35:30 -07:00
Andrew Kelley
5f3b21a5b6 Zir: decouple from InternPool
Note that the correctness of these enum tag values is still protected
by the comptime logic at the top of Zcu (currently src/Module.zig).
2024-02-26 21:35:30 -07:00
Andrew Kelley
f7143e18e3 move Zcu.LazySrcLoc to std.zig.LazySrcLoc
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:35:30 -07:00
Jacob Young
4e2570baaf http: fix fetching a github release
* Support different keep alive defaults with different http versions.
 * Fix incorrect usage of `copyBackwards`, which copies in a backwards
   direction allowing data to be moved forward in a buffer, not
   backwards in a buffer.
2024-02-26 20:11:43 -08:00
Matthew Lugg
8775d8bbce
Merge pull request #19062 from mlugg/dbg-var-blocks
compiler: decide dbg_var scoping based on AIR blocks
2024-02-27 03:25:04 +00:00
John Schmidt
f803761e13 Fix tuple default values
- Add default values to the list of comptime-known elements in
  `zirValidatePtrArrayInit`
- In `structFieldValueComptime`, only assert `haveFieldInits` if we
  enter the`fieldIsComptime` branch (otherwise they are not needed).
2024-02-26 17:03:20 -08:00
John Schmidt
7a045ede7c Check for inactive union field when calling fn at comptime
Reuse `unionFieldPtr` here to ensure that all the safety checks are
included.

Closes https://github.com/ziglang/zig/issues/18546.
2024-02-26 16:55:17 -08:00
Andrew Kelley
3e79c0f18c
Merge pull request #18859 from schmee/switch-union-capture-align
Sema: preserve field alignment in union pointer captures
2024-02-26 16:52:39 -08:00
John Schmidt
00ff123b1e Sema: fix compile error for switching on undefined union
Before this fix, passing an undefined union value to `Sema.switchCond`
returned an undefined value of the union type, not the tag type, since
`Value.unionTag` forwards undefined values unchanged.
This leads us into the `.Union` branch in `Sema.zirSwitchBlock` which is
unreachable, now we take the `.Enum` branch instead.
2024-02-26 16:51:37 -08:00
John Schmidt
8bd94759bf Sema: evaluate generic instantiations in fn decls capture scope
The generic call `S.foo()` was evaluated with the
capture scope of the owner decl (i.e the `test` block), when it should
use the capture scope of the function declaration.
2024-02-26 16:50:00 -08:00
Ryan Liptak
726a1149e0 Change many test blocks to doctests/decltests 2024-02-26 15:18:31 -08:00
Ryan Liptak
16b3d1004e Remove redundant test name prefixes now that test names are fully qualified
Follow up to #19079, which made test names fully qualified.

This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit:

"priority_queue.test.std.PriorityQueue: shrinkAndFree"

and the same test's name after the changes in this commit:

"priority_queue.test.shrinkAndFree"
2024-02-26 15:18:31 -08:00
Andrew Kelley
1b79a42da0 std.http.Server: fix use case of streaming both reading and writing 2024-02-26 13:42:01 -08:00
Andrew Kelley
81aa74e7e1
Merge pull request #19081 from ianic/tar_case_sensitive
std.tar don't overwrite files on unpack
2024-02-26 12:23:22 -08:00
Andrew Kelley
d51aa9748f change default WASI stack size
to match the other operating systems. 16 MiB

closes #18885
2024-02-26 10:33:17 -08:00
mlugg
59447e5305
compiler: decide dbg_var scoping based on AIR blocks
This commit eliminates the `dbg_block_{begin,end}` instructions from
both ZIR and AIR. Instead, lexical scoping of `dbg_var_{ptr,val}`
instructions is decided based on the AIR block they exist within. This
is a much more robust system, and also results in a huge drop in ZIR
bytes - around 7% for Sema.zig.

This required some enhancements to Sema to prevent elision of blocks
when they are required for debug variable scoping. This can be observed
by looking at the AIR for the following simple test program with and
without `-fstrip`:

```zig
export fn f() void {
    {
        var a: u32 = 0;
        _ = &a;
    }
    {
        var a: u32 = 0;
        _ = &a;
    }
}
```

When `-fstrip` is passed, no AIR blocks are generated. When `-fno-strip`
is passed, the ZIR blocks are lowered to true AIR blocks to give correct
lexical scoping to the debug vars.

The changes here incidentally reolve #19060. A corresponding behavior
test has been added.

Resolves: #19060
2024-02-26 13:20:45 +00:00
Andrew Kelley
031f23117d
Merge pull request #19083 from antlilja/llvm-blockinfo
LLVM reduce size of emitted bitcode
2024-02-26 04:03:40 -08:00
Andrew Kelley
032c2ee9bc std.http.Client: fix UAF when handling redirects
closes #19071
2024-02-26 01:01:16 -08:00
John Schmidt
723d13f831 AstGen: fix OoB crash on ast-check -t
The `decl_node` was offset from the wrong source node.
2024-02-26 07:01:32 +00:00
Andrew Kelley
9dda2eb1ab
Merge pull request #19080 from jacobly0/llvm-per-mod-strip
llvm: implement per-module stripping
2024-02-25 21:44:10 -08:00
Andrew Kelley
91fb211faa
Merge pull request #18906 from jacobly0/x86_64-tests
x86_64: pass more tests
2024-02-25 21:43:20 -08:00
Jacob Young
d656c2a7ab test: rework how filtering works
* make test names contain the fully qualified name
 * make test filters match the fully qualified name
 * allow multiple test filters, where a test is skipped if it does not
   match any of the specified filters
2024-02-25 19:12:08 -08:00
Jakub Konka
429e542f3f macho: count rebases for synthetic __objc_selrefs 2024-02-26 02:22:36 +01:00
Jakub Konka
2901026425 macho: fix section to segment mapping 2024-02-26 02:22:36 +01:00
Jakub Konka
d7276c1527 macho: actually set SG_READ_ONLY on __DATA_CONST segment 2024-02-26 02:22:36 +01:00