Commit Graph

9500 Commits

Author SHA1 Message Date
Andrew Kelley
c427685a13 zig std: implement sources.tar endpoint
except for the tar format being correct
2024-03-10 17:51:06 -07:00
Andrew Kelley
b7ba0b69b1 std.io.Writer: add writeFile method 2024-03-10 17:51:06 -07:00
Andrew Kelley
574b33e65a zig std: use threads for the http server 2024-03-10 17:51:06 -07:00
Andrew Kelley
c7c7ad1b78 zig std: implement serving the wasm binary 2024-03-10 17:51:06 -07:00
Andrew Kelley
34faf9d12e add skeleton of zig std command impl 2024-03-10 17:51:06 -07:00
Andrew Kelley
0b1b3f0225 upstream new autodocs implementation 2024-03-10 17:51:06 -07:00
Andrew Kelley
94daf87335 no 2024-03-10 17:50:54 -07:00
Techatrix
40e64245fc std: expose Config struct of GeneralPurposeAllocator 2024-03-10 14:08:02 -07:00
mlugg
265f42d472
std.os.linux: rework io_uring support
* `linux.IO_Uring` -> `linux.IoUring` to align with naming conventions.
* All functions `io_uring_prep_foo` are now methods `prep_foo` on `io_uring_sqe`, which is in a file of its own.
* `SubmissionQueue` and `CompletionQueue` are namespaced under `IoUring`.

This is a breaking change.

The new file and namespace layouts are more idiomatic, and allow us to
eliminate one more usage of `usingnamespace` from the standard library.
2 remain.
2024-03-08 08:02:45 +00:00
mlugg
a7f6e73812
std.os.windows: eliminate usage of usingnamespace
Some of the structs I shuffled around might be better namespaced under
CONTEXT, I'm not sure. However, for now, this approach preserves
backwards compatibility.

Eliminates one more usage of `usingnamespace` from the standard library.
3 remain.
2024-03-08 08:02:45 +00:00
mlugg
f4bf061d8a
std.c: remove unnecessary use of usingnamespace
Thanks to Zig's lazy analysis, it's fine for these symbols to be
declared on platform they won't exist on. This is already done in
several places in this file; e.g. `pthread` functions are declared
unconditionally.

Eliminates one more usage of `usingnamespace` from the standard library.
4 remain.
2024-03-08 08:02:45 +00:00
mlugg
508a8739e2
std.c.openbsd: remove nop usingnamespace
I have no idea why this was even here...

Eliminates one more usage of `usingnamespace` from the standard library.
5 remain.
2024-03-08 08:02:45 +00:00
mlugg
474d17c13a
std.c: do not use usingnamespace to define getcontext
Eliminates one more usage of `usingnamespace` from the standard library.
2024-03-08 08:02:44 +00:00
mlugg
17f83ace03
std.enums: remove IndexedMap, IndexedArray, IndexedSet
Searching GitHub indicated that the only use of these types in the wild is
support in getty-zig, and testing for that support. This eliminates 3 more uses
of usingnamespace from the standard library, and removes some unnecessarily
complex generic code.
2024-03-08 08:02:44 +00:00
mlugg
229800482d
std.os.linux: do not use usingnamespace to define getauxval
This usage of `usingnamespace` was removed fairly trivially - the
resulting code is, IMO, more clear.

Eliminates one more usage of `usingnamespace` from the standard library.
2024-03-08 08:02:44 +00:00
mlugg
14ab9fb154
std.os.linux: remove unnecessary use of usingnamespace
This is a trivial change - this code did `usingnamespace` into an
otherwise empty namespace, so the outer namespace was just unnecessary.

Eliminates one more usage of `usingnamespace` from the standard library.
2024-03-08 08:02:44 +00:00
Andrew Kelley
83e578a181
Merge pull request #19163 from ianic/zlib_no_lookahead
compress.zlib: don't overshoot underlying reader
2024-03-07 18:46:47 -08:00
Andrew Kelley
97aa5f7b8a
Merge pull request #19190 from mlugg/struct-equivalence
compiler: namespace type equivalence based on AST node + captures
2024-03-07 18:41:45 -08:00
Dillen Meijboom
377ecc6afb feat: add support for --enable-new-dtags and --disable-new-dtags 2024-03-06 17:52:05 -08:00
Jacob Young
aa7d16aba1 grammar: remove gratuitous ambiguity
Previously, the following matched both ContainerField alternatives:
 * [IDENTIFIER]
 * [IDENTIFIER][COLON][TypeExpr]
2024-03-06 13:59:46 -08:00
mlugg
2c4ac44f25
compiler: treat decl_val/decl_ref of potentially generic decls as captures
This fixes an issue with the implementation of #18816. Consider the
following code:

```zig
pub fn Wrap(comptime T: type) type {
    return struct {
        pub const T1 = T;
        inner: struct { x: T1 },
    };
}
```

Previously, the type of `inner` was not considered to be "capturing" any
value, as `T1` is a decl. However, since it is declared within a generic
function, this decl reference depends on the context, and thus should be
treated as a capture.

AstGen has been augmented to tunnel references to decls through closure
when the decl was declared in a potentially-generic context (i.e. within
a function).
2024-03-06 21:26:38 +00:00
mlugg
a6ca20b9a1
compiler: change representation of closures
This changes the representation of closures in Zir and Sema. Rather than
a pair of instructions `closure_capture` and `closure_get`, the system
now works as follows:

* Each ZIR type declaration (`struct_decl` etc) contains a list of
  captures in the form of ZIR indices (or, for efficiency, direct
  references to parent captures). This is an ordered list; indexes into
  it are used to refer to captured values.
* The `extended(closure_get)` ZIR instruction refers to a value in this
  list via a 16-bit index (limiting this index to 16 bits allows us to
  store this in `extended`).
* `Module.Namespace` has a new field `captures` which contains the list
  of values captured in a given namespace. This is initialized based on
  the ZIR capture list whenever a type declaration is analyzed.

This change eliminates `CaptureScope` from semantic analysis, which is a
nice simplification; but the main motivation here is that this change is
a prerequisite for #18816.
2024-03-06 21:26:37 +00:00
Veikka Tuominen
90ab8ea9e6
Sync Aro sources (#19199)
ref: 02353ad9f17f659e173f68975a442fcec3dd2c94
2024-03-06 14:17:41 -05:00
OK Ryoko
0b2e23b066 std.os.linux: enforce null-terminated path arguments 2024-03-05 20:11:49 +02:00
Igor Anić
a06a305f97 zlib: fix missing comptime attribute 2024-03-04 09:53:01 +01:00
Igor Anić
c680b5d138 compress.zlib: add overshoot test cast
Using example from [zigimg](https://github.com/zigimg/zigimg/pull/164) project.
2024-03-04 09:53:01 +01:00
Igor Anić
f2508abfa6 flate: use 4 bytes lookahead for zlib
That ensures no bytes are left in the BitReader buffer after we reach
end of the stream.
2024-03-04 09:53:01 +01:00
Igor Anić
711281602a flate: option to fill BitReader
fill(0) will fill all bytes in bit reader. If bit reader is aligned to
the byte, as it is at the end of the stream this ensures no overshoot
when reading footer. Footer is 4 bytes (zlib) or 8 bytes (gzip). For
zlib we will use 4 bytes BitReader and 8 for gzip. After align and fill
we will read those bytes and leave BitReader empty after that.
2024-03-04 09:53:01 +01:00
Igor Anić
8a963fd66e flate: 32 bit BitReader
Extend BitReader to accept size of internal buffer. It can be u64 (only
option until now) or u32.
2024-03-04 09:53:01 +01:00
Andrew Kelley
33de937fd9 move zig objcopy command to be lazily built
part of #19063
2024-03-02 21:22:45 -08:00
Andrew Kelley
671c2acf47
Merge pull request #19094 from truemedian/std-http-fields
std.http: fix http field parsing
2024-03-02 14:34:43 -08:00
Matthew Lugg
9d500bda2d
Merge pull request #19117 from mlugg/dbg-var-blocks
Major ZIR size optimizations & small cleanups in Sema
2024-03-02 04:52:19 +00:00
Andrew Kelley
64f77f32df
Merge pull request #19136 from squeek502/windows-symlink-path-sep
Fix symLink's handling of `/` path separators on Windows
2024-03-01 17:45:33 -08:00
Jacob Young
b60fc16b4f compiler: audit debug mode checks
* Introduce `-Ddebug-extensions` for enabling compiler debug helpers
 * Replace safety mode checks with `std.debug.runtime_safety`
 * Replace debugger helper checks with `!builtin.strip_debug_info`

Sometimes, you just have to debug optimized compilers...
2024-03-01 17:42:54 -08:00
Roman Frołow
155f5274ff typo: http_proxy -> https_proxy 2024-03-01 17:41:14 -08:00
mlugg
6a87e42c2e
AstGen: fix latent bug causing incorrect elision of dbg_stmt instructions
Thanks to jacobly0 for figuring this out. The chain of events causing
the failure this triggered is as follows.

* As of a recent commit, certain bodies no longer emit a redundant
  `block`, meaning there are more likely to be "interesting"
  instructions (i.e. not blocks) at the end of parent GenZir scopes.

* When emitting the first `dbg_stmt` in such a body, the elision logic
  incorrectly looks at a tag from an instruction in an enclosing scope.

* The tag of this instruction may be `undefined`, meaning that in unsafe
  builds it may be incorrectly identified as a `dbg_stmt` instruction.

* This instruction from another body is clobbered rather than emitting
  an actual `dbg_stmt` instruction. Note that this does not produce
  invalid ZIR, since the creator of the undefined instruction replaces
  the previously-undefined payload later.
2024-03-01 23:54:31 +00:00
binarycraft007
a7a5f4cf4d objcopy: support multiple only sections 2024-03-01 09:23:54 -08:00
mlugg
eefa60e376
AstGen: optimize ZIR for -1 literal 2024-03-01 06:01:53 +00:00
Ryan Liptak
f1dd1ee5ed fs/test: Make testWithAllSupportedPathTypes also test all supported path separators
Now, all the tests that use `testWithAllSupportedPathTypes` will also run each test with both `/` and `\` as the path separator on Windows.

Also, removes the now-redundant "Dir.symLink with relative target that has a / path separator" since the same thing is now tested in the "Dir.readLink" test
2024-02-29 17:55:27 -08:00
Ryan Liptak
e80d4bc6f8 Re-enable and fix tar pipeToFileSystem test on Windows 2024-02-29 16:12:24 -08:00
Ryan Liptak
e233971e4f Fix symLink's handling of / path separators on Windows
Symlink targets require canonicalized path separators on Windows
2024-02-29 16:12:24 -08:00
mlugg
07d8740882
AstGen: do not generate defers at unreachable end of block
Resolves: #8822
2024-02-29 23:38:17 +00:00
mlugg
f6abf022b7
AstGen: elide block instruction when already in empty body
In the code `if (cond) { ... }`, the "then body" of the `if` is
technically a block. However, we don't need to emit a real ZIR `block`
corresponding to it, because we are already within a condbr body; we
have a separate gz, and appropriate scoping for allocs and debug
variables. In this case, and many like it, we can trivially elide the
block here, instead emitting the block statements directly into the
current `GenZir`. This results in a significant decrease in ZIR bytes
for real code.
2024-02-29 23:38:17 +00:00
mlugg
f0a4bb6bd1
AstGen: avoid unnecessary coercion instructions
Coercions such as `@as(usize, 0)` can be trivially elided by matching
these cases and translating to fixed InternPool indices.
2024-02-29 23:38:17 +00:00
Andrew Kelley
af06584241
Merge pull request #19126 from ianic/tar_case_sensitive
std.tar: fix unconditional error return
2024-02-29 10:12:39 -08:00
Igor Anić
e57800610b std.tar: disable test failing on windows
Just to pass ci of regression fix #19126.
I'll return to this later.
Currently can't reproduce on my Windows wm, here I'm failing on symlink creation
in ci fails later in the process.
2024-02-29 07:57:49 +01:00
Andrew Kelley
beca85e644 std.tar.iterator: make the buffers configurable
Provides more API flexibility and correctness, while still preserving
the handy high level `pipeToFileSystem` API.
2024-02-28 20:33:29 -07:00
Andrew Kelley
b3ad45f267 std.tar: avoid dependency on file system
In the iterator function which is the low-level API, don't depend on
`std.fs.MAX_PATH_BYTES` because this is not defined on all operating
systems, such as freestanding.

However in such environments it still makes sense to be able to extract
from a tar file.

An even more flexible solution would be to accept the buffers as
arguments to iterator() which I think is a good idea, but for now let's
just set the same upper limmit across all operating systems.
2024-02-28 20:14:21 -07:00
Igor Anić
7d536e8970 std.tar: fix unconditional error return 2024-02-29 01:22:49 +01:00
Nameless
e62b0773cc
std.http: add tests against regressions for conforming fields 2024-02-28 15:12:44 -06:00