Commit graph

29842 commits

Author SHA1 Message Date
Jacob Young
373a4990a4 rewrite CI scripts in Zig 2024-07-18 08:26:30 -04:00
Andrew Kelley
a57479afc2
Merge pull request #20652 from pavelverigo/stage2-wasm-finishAir
stage2-wasm: finishAir enhancement
2024-07-17 22:33:29 -07:00
Jacob Young
8ab70f80cb ci: update aarch64-macos for a persistent work dir 2024-07-17 21:52:28 -04:00
Pavel Verigo
31706dc31a stage2-wasm: finishAir handle .stack result
By allowing finishAir to handle .stack results, we simplify a lot of code in
air*** functions, which try to handle this case. Also this changes will result in optimization, if one of operands is dead after instruction its place could be reused by result.

The only downside to this change is that finishAir now can return error, though it handled by returning finishAir result, because it always needs to be final in air*** functions.

Additionally I migrated WValue{ to .{ inside CodeGen.zig.
2024-07-18 00:57:45 +02:00
Pavel Verigo
6eb76f930d stage2-wasm: typeToValtype focus on .auto callconv
This is required for toLocal() correctly handling isByRef values, previous behavior was a hack.
2024-07-18 00:57:18 +02:00
eric-saintetienne
c3faae6bf1
format: do not force user to provide an alignment field when it's not necessary (#19049)
* format: fix default character when no alignment

When no alignment is specified, the character that should be used is the
fill character that is otherwise provided, not space.

This is closer to the default that C programmers (and other languages)
use: "04x" fills with zeroes (in zig as of today x:04 fills with spaces)

Test:

    const std = @import("std");
    const expectFmt = std.testing.expectFmt;

    test "fmt.defaultchar.no-alignment" {

        // as of today the following test passes:
        try expectFmt("0x00ff", "0x{x:0>4}", .{255});

        // as of today the following test fails (returns "0x  ff" instead)
        try expectFmt("0x00ff", "0x{x:04}", .{255});
    }

* non breaking improvement of string formatting

* improved comment

* simplify the code a little

* small improvement around how  characters identified as valid are consumed
2024-07-17 19:02:10 +00:00
Jakub Konka
9d9b5a11e8
Merge pull request #20474 from Rexicon226/riscv
more RISC-V backend progress
2024-07-17 08:39:44 +02:00
Andrew Kelley
ddc399440d build.zig: expose valgrind flag
Allows to enable Valgrind integrations in release builds, sometimes
useful in combination with tooling.
2024-07-16 23:07:34 -07:00
Matthew Lugg
e82f7d3800
Merge pull request #20653 from mlugg/incremental-fix
Zcu: updateZirRefs typo
2024-07-17 00:08:13 +01:00
Hayden Riddiford
20563d8457 - Added special handling for translating C extern variables declared within scoped blocks
- Added test/cases/run_translated_c/extern_typedef_variables_in_functions.c to test for issue 19687
2024-07-16 23:29:44 +03:00
Jacob Young
88bb0fd288
Merge pull request #20632 from jacobly0/codegen-thread
InternPool: enable separate codegen/linking thread
2024-07-16 14:49:49 -04:00
mlugg
6bd640c7a0
Sema: typo 2024-07-16 19:48:05 +01:00
mlugg
21cde7ad90
Zcu: updateZirRefs typo 2024-07-16 19:46:10 +01:00
mlugg
d8f81372f1
Sema: fix bad merge 2024-07-16 19:44:41 +01:00
mlugg
5093a5cd19
std.Zir: some declaration traversal fixes 2024-07-16 19:44:15 +01:00
Matthew Lugg
ee695c8ef4
Merge pull request #20637 from mlugg/comptime-resolution-strat
Type,Value: mark `ResolveStrat` parameter of type queries as `comptime`
2024-07-16 19:22:39 +01:00
Andrew Kelley
a58ceb3d55
Merge pull request #20646 from ziglang/fix-updateZirRefs
frontend: fix updateZirRefs
2024-07-16 10:47:42 -07:00
Will Lillis
a9d544575d
Sema: add error note for failed coercions to optional types and error unions 2024-07-16 16:42:13 +00:00
mlugg
f84a4953d2
Value: eliminate static recursion loop from value printing 2024-07-16 11:38:21 +01:00
mlugg
67cd14dbdb
Type: avoid incorrect type resolution calls 2024-07-16 11:38:20 +01:00
mlugg
b1d3d48f68
Type,Value: mark ResolveStrat parameter of type queries as comptime
This eliminates the statically-reachable recursion loop between code
generation backends and Sema. This is beneficial for optimizers
(although I do not measure any performance improvement for this change),
and for profilers.
2024-07-16 11:38:20 +01:00
Jacob Young
00fdbf05f3 InternPool: enable separate codegen/linking thread
Let's see what happens :)
2024-07-16 06:28:42 -04:00
Jacob Young
9d1820d206 InternPool: reduce max tid width by one bit
@mlugg keeps stealing my bits!
2024-07-16 06:28:41 -04:00
Jacob Young
b0fe7eef54 InternPool: fix various data structure invariants 2024-07-16 05:14:38 -04:00
Jacob Young
e32454796c indexOfSentinel: fix ub 2024-07-16 05:14:38 -04:00
Jacob Young
14caccb477 Progress: avoid race on global_progress.draw_buffer 2024-07-16 05:14:38 -04:00
Raed Rizqie
9356cb1475 Allocate enough memory when building zig2 2024-07-16 00:41:24 -07:00
Andrew Kelley
4e6518badb
Merge pull request #20640 from BratishkaErik/std.c/setlocale-fix
std.c: setlocale fixes
2024-07-16 00:39:31 -07:00
Jacob Young
7dbd2a6bb5 InternPool: fix DependencyIterator iteration 2024-07-16 02:24:16 -04:00
Andrew Kelley
a20d081129 Air: remove deprecated/unused decl 2024-07-15 22:04:29 -07:00
Andrew Kelley
3a6ef6ffe1 frontend server: serveUpdateResults fix
Serve empty error bundle to indicate the update is done. Otherwise the
build system, when using -fno-emit-bin, fails to detect the update is
done.
2024-07-15 22:03:10 -07:00
Andrew Kelley
8cb09db4e3 update some Module references to Zcu instead
I ended up reverting my real change, so here's a consolation prize
instead.
2024-07-15 19:05:55 -07:00
Andrew Kelley
ba623b160e Zir: fix wrong union field access for declaration 2024-07-15 18:57:36 -07:00
Andrew Kelley
60318a1e39 frontend: move updateZirRefs to be single-threaded
for simplicity's sake. This makes it O(M) instead of O(N*M) where N is
tracked insts and M is number of changed source files.
2024-07-15 18:54:41 -07:00
Eric Joldasov
5af68a651c
std.c.LC: mark enum as non-exhaustive
They are implementation-defined and can have values other than
hard-coded here. Also, standard permits other values not mentioned
there:

> Additional macro definitions, beginning with the characters LC_
> and an uppercase letter, may also be specified by the implementation.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-07-16 00:32:29 +05:00
Eric Joldasov
ece8480fc2
std.c.setlocale: fix return type to nullable pointer
According to https://en.cppreference.com/mwiki/index.php?title=c/locale/setlocale&oldid=171500 ,
`setlocale` "returns null value on failure":

> Return value
> pointer to a narrow null-terminated string identifying the C locale
> after applying the changes, if any, or null pointer on failure.

Example program:
```zig
const std = @import("std");

pub fn main() void {
    const ptr = std.c.setlocale(.ALL, "non_existent");
    std.debug.print("ptr = {d}\n", .{@intFromPtr(ptr)});
}
```

Output:
```console
ptr = 0
```

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-07-16 00:27:56 +05:00
Wooster
888708ec8a
Sema: support pointer subtraction 2024-07-15 18:18:38 +00:00
Lucas Santos
89942ebd03
Better implementation of GetLastError. (#20623)
Instead of calling the dynamically loaded kernel32.GetLastError, we can extract it from the TEB.
As shown by [Wine](34b1606019/include/winternl.h (L439)), the last error lives at offset 0x34 of the TEB in 32-bit Windows and at offset 0x68 in 64-bit Windows.
2024-07-15 10:49:51 -07:00
KNnut
cf36d3fdd3 add a missing comment in build.zig.zon 2024-07-15 10:47:36 -07:00
Vesim
e5c974fa5c
std.os.linux: export getauxval only when building executable or root has main function 2024-07-15 15:48:40 +03:00
gooncreeper
9002977051
start: refactor callMain return type checking 2024-07-15 12:29:07 +03:00
Veikka Tuominen
5675553aed
Merge pull request #20622 from squeek502/windows-arg-iterator-cleanup
`ArgIteratorWindows`: Cleanup and some optimizations
2024-07-15 12:03:25 +03:00
gooncreeper
c50f300387 Tokenizer bug fixes and improvements
Fixes many error messages corresponding to invalid bytes displaying the
wrong byte. Additionaly improves handling of UTF-8 in some places.
2024-07-15 11:31:19 +03:00
Andrew Kelley
9d38e82b5c
Merge pull request #20633 from ziglang/long-live-zig
make zig compiler processes live across rebuilds
2024-07-15 01:27:23 -07:00
fmaggi
583e698256
Sema: disallow casting to opaque 2024-07-15 10:58:33 +03:00
David Rubin
5a4fe39fbb
riscv: disable failing tests 2024-07-14 23:04:06 -07:00
David Rubin
5ec926cdbf
riscv: refactor bin_file and zcu usage 2024-07-14 23:04:05 -07:00
David Rubin
5a2c547fc1
riscv: vectors part 3 2024-07-14 23:02:35 -07:00
David Rubin
09e9812086
riscv: vectors part 2 2024-07-14 23:02:34 -07:00
David Rubin
571aa694fd
riscv: vectors part 1 2024-07-14 23:02:34 -07:00