140 Commits

Author SHA1 Message Date
Alex Rønne Petersen
5b606d435d
Merge pull request #21882 from alexrp/compiler-fixes
compiler: Fix some real and theoretical miscompilations with `allowzero` and `volatile`
2025-05-13 10:42:05 +02:00
Alex Rønne Petersen
bc3c50c21e
Merge pull request #23700 from sorairolake/rename-trims
chore(std.mem): Rename `trimLeft` and `trimRight` to `trimStart` and `trimEnd`
2025-05-12 17:11:52 +02:00
Alex Rønne Petersen
9d8adb38a1
std.Build: Make no_builtin a property of Module instead of Step.Compile.
This reflects how the compiler actually treats it.

Closes #23424.
2025-05-12 17:08:22 +02:00
Alex Rønne Petersen
e63e3f7a7c
test: Add test-llvm-ir step and harness for testing generated LLVM IR. 2025-05-12 17:07:50 +02:00
Alex Rønne Petersen
af55b27d5a
test: Fix incorrect interpretation of -Dtest-filter=... for test-debugger. 2025-05-12 17:07:50 +02:00
Alex Rønne Petersen
b31b309b53
test: Configure emit_asm/emit_bin correctly for some targets in llvm_targets. 2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
5411358956
test: Allow cases to set emit_asm (defaults to false). 2025-04-27 14:09:05 +02:00
Shun Sakai
5fc4448e45 chore(std.mem): Rename trimLeft and trimRight
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`.
`trimLeft` and `trimRight` functions remain as deprecated aliases for
these new names.
2025-04-27 18:03:59 +09:00
Andrew Kelley
f32a5d349d std: eradicate u29 and embrace std.mem.Alignment 2025-04-13 02:20:32 -04:00
Linus Groh
79460d4a3e Remove uses of deprecated callconv aliases 2025-03-05 03:01:43 +00:00
David Rubin
35b9db3b15 correct some bugs 2025-02-25 11:22:33 -08:00
mlugg
a3b3a33d7a cases: remove old incremental case system
We now run incremental tests with `tools/incr-check.zig` (with the
actual cases being in `test/incremental/`).
2025-02-23 00:52:50 +00:00
Alex Rønne Petersen
253e641ea3 test: Disable packet timeout for debugger tests.
On my machine, the defaults are 5 seconds (LLDB) and 2 seconds (GDB). These are
too low on the CI machines during high load, and the CI system itself already
enforces a timeout on jobs anyway, so just disable the timeout altogether.
2025-02-20 21:39:54 +01:00
Jacob Young
9f87aacaaf test: fix windows CI 2025-02-15 03:45:21 -05:00
Mason Remaley
13c6eb0d71
compiler,std: implement ZON support
This commit allows using ZON (Zig Object Notation) in a few ways.

* `@import` can be used to load ZON at comptime and convert it to a
  normal Zig value. In this case, `@import` must have a result type.
* `std.zon.parse` can be used to parse ZON at runtime, akin to the
  parsing logic in `std.json`.
* `std.zon.stringify` can be used to convert arbitrary data structures
  to ZON at runtime, again akin to `std.json`.
2025-02-03 09:14:37 +00:00
Andrew Kelley
d0d5ca2b6c
Merge pull request #22581 from jacobly0/x86_64-rewrite
x86_64: rewrite `@abs` on floats
2025-01-25 07:30:45 -08:00
Jacob Young
b1fa89439a x86_64: rewrite float vector @abs and equality comparisons 2025-01-24 20:56:11 -05:00
mlugg
5a6666db55
all: update for panic.unwrapError and panic.call signature changes 2025-01-24 22:33:23 +00:00
mlugg
7774287fdc
tests: enable stack trace tests for x86_64-selfhosted
Allows the stack trace tests to be additionally compiled and run with
`.use_llvm = false, .use_lld = false` depending on the host target. This
is currently enabled for x86_64 targets emitting ELF.

Self-hosted backends emit slightly different DWARF info to the LLVM
backend, so the checking logic (and the tests themselves) had to be
tweaked slightly to support both backends at once.
2025-01-23 23:22:13 +00:00
BratishkaErik
941677e083
std.Build: add addLibrary function (#22554)
Acts as a replacement for `addSharedLibrary` and `addStaticLibrary`, but
linking mode can be changed more easily in build.zig, for example:

In library:
```zig
const linkage = b.option(std.builtin.LinkMode, "linkage", "Link mode for a foo_bar library") orelse .static; // or other default

const lib = b.addLibrary(.{
    .linkage = linkage,
    .name = "foo_bar",
    .root_module = mod,
});
```

In consumer:
```zig
const dep_foo_bar = b.dependency("foo_bar", .{
    .target = target,
    .optimize = optimize,
    .linkage = .static // or dynamic
});

mod.linkLibrary(dep_foor_bar.artifact("foo_bar"));
```

It also matches nicely with `linkLibrary` name.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2025-01-22 02:29:21 +00:00
Jacob Young
5de880c288 Dwarf: emit debug info for extern globals 2025-01-12 23:40:57 -05:00
mlugg
6179d9ef55
test-debugger: migrate from deprecated std.Build APIs 2024-12-18 01:49:07 +05:00
mlugg
1cfbfc1d34
test-run-translated-c: migrate from deprecated std.Build APIs 2024-12-18 01:49:05 +05:00
mlugg
8c5c1de60b
test-compare-output: migrate from deprecated std.Build APIs 2024-12-18 01:49:03 +05:00
mlugg
11b9933970
test-stack-traces: migrate from deprecated std.Build APIs 2024-12-18 01:49:01 +05:00
mlugg
6d4e2a9171
test-cases: migrate from deprecated std.Build APIs 2024-12-18 01:49:00 +05:00
Alex Rønne Petersen
78b8ce5095
test: Change llvm_targets to actually emit an object for each target.
Without doing this, we don't actually test whether the data layout string we
generate matches LLVM's.

A number of targets had to be commented out due to this change:

* Some are using a non-working experimental LLVM backend (arc, csky, ...).
* Some don't have working LLD support (lanai, sparc, ...).
* Some don't have working self-hosted linker support (nvptx).
* Some are using ABIs that haven't been standardized (loongarch32).

Finally, all non-x86 uefi targets are hopelessly broken and can't really be
fixed until we change our emit logic to lower *-uefi-* verbatim rather than to
*-windows-*. See: https://github.com/ziglang/zig/issues/21630
2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
8594f179f9
Merge pull request #22067 from alexrp/pie-tests
Add PIC/PIE tests and fix some bugs + some improvements to the test harness
2024-11-28 14:07:28 +01:00
Jacob Young
c894ac09a3 dwarf: fix stepping through an inline loop containing one statement
Previously, stepping from the single statement within the loop would
always exit the loop because all of the code unrolled from the loop is
associated with the same line and treated by the debugger as one line.
2024-11-24 17:28:12 -05:00
Alex Rønne Petersen
2298108daf
test: Allow tests to set emit_bin=false. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
c4cd3c0541
test: Force compile test cases to be codegen'd if requested. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
fefcdc5673
test: Allow setting PIC/PIE in test cases. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
9d10246a80
test: Enable -Dtest-target-filter=... to work for test-debugger. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
2a29381117
test: Enable -Dtest-target-filter=... to work for test-cases and test-translate-c. 2024-11-24 22:11:17 +01:00
Jacob Young
70ad7dcd48 lldb: implement tuple types 2024-11-23 23:51:35 -05:00
mlugg
d11bbde5f9
compiler: remove anonymous struct types, unify all tuples
This commit reworks how anonymous struct literals and tuples work.

Previously, an untyped anonymous struct literal
(e.g. `const x = .{ .a = 123 }`) was given an "anonymous struct type",
which is a special kind of struct which coerces using structural
equivalence. This mechanism was a holdover from before we used
RLS / result types as the primary mechanism of type inference. This
commit changes the language so that the type assigned here is a "normal"
struct type. It uses a form of equivalence based on the AST node and the
type's structure, much like a reified (`@Type`) type.

Additionally, tuples have been simplified. The distinction between
"simple" and "complex" tuple types is eliminated. All tuples, even those
explicitly declared using `struct { ... }` syntax, use structural
equivalence, and do not undergo staged type resolution. Tuples are very
restricted: they cannot have non-`auto` layouts, cannot have aligned
fields, and cannot have default values with the exception of `comptime`
fields. Tuples currently do not have optimized layout, but this can be
changed in the future.

This change simplifies the language, and fixes some problematic
coercions through pointers which led to unintuitive behavior.

Resolves: #16865
2024-10-31 20:42:53 +00:00
Robin Voetter
49a067ccfe
spirv: forbid merging logical pointers
Under some architecture/operating system combinations it is forbidden
to return a pointer from a merge, as these pointers must point to a
location at compile time. This adds a check for those cases when
returning a pointer from a block merge.
2024-10-27 16:31:45 +01:00
Jacob Young
c127c06fd7 Dwarf: implement and test lexical blocks 2024-10-09 07:48:09 -04:00
Jacob Young
65f6623ba4 lldb: print field names with a leading dot
This more closely resembles zig struct literals.
2024-10-09 07:48:07 -04:00
Jacob Young
6aa6d088d9 Dwarf: implement and test hash maps 2024-09-10 13:06:08 -04:00
Jacob Young
d5a7fcfc13 Dwarf: implement and test multi array list slices 2024-09-10 13:06:08 -04:00
Jacob Young
e048e78886 Dwarf: implement and test multi array list 2024-09-10 12:27:57 -04:00
Jacob Young
6459212ebe Dwarf: implement and test segmented list 2024-09-10 12:27:57 -04:00
Jacob Young
f34b198251 Dwarf: implement and test decls 2024-09-10 12:27:56 -04:00
Jacob Young
6a21875ddb
Merge pull request #21230 from jacobly0/stack-trace
Dwarf: fix self-hosted stack traces
2024-08-28 17:39:35 -04:00
Jacob Young
4cc16fd6f7 Dwarf: fix and test inline function bugs 2024-08-28 04:25:08 -04:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Jacob Young
8c3f6c72c0 Dwarf: fix and test string format 2024-08-27 02:09:59 -04:00
Jacob Young
4a132d4bce Type: fix inconsistency between zig fmt and @typeName 2024-08-22 20:08:04 -04:00
Jakub Konka
b2fad5c58b test/debugger: test emitting relocs by ELF linker 2024-08-21 01:43:21 -04:00