32093 Commits

Author SHA1 Message Date
Alex Rønne Petersen
03ac40d570
std: Disable some tests affected by #22060 for thumbeb too. 2025-01-06 16:47:40 +01:00
Alex Rønne Petersen
c1ae99efb3
test: Disable align(N) on functions and @alignCast functions for thumbeb too. 2025-01-06 16:31:32 +01:00
Alex Rønne Petersen
52e9fd7c3c
test: Disable vector behavior tests affected by #22060 for thumbeb too. 2025-01-06 16:20:27 +01:00
Alex Rønne Petersen
f54f58b60f
std.zig.system: Handle thumb/thumbeb for QEMU in getExternalExecutor(). 2025-01-06 15:37:25 +01:00
Alex Rønne Petersen
749e67dee8
std.zig.system: Reject x32 for QEMU in getExternalExecutor(). 2025-01-06 15:37:23 +01:00
cdeler
745d3ed0ac
Remove strict verifyContext invocation from hash_map implementation. (#22370)
Fixes #19640

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-01-06 13:37:30 +00:00
Jacob Young
0bf44c3093 x86_64: fix @errorName data
The final offset was clobbering the first error name, which is revealed
by an out of bounds when the global error set is empty.

Closes #22362
2025-01-05 17:15:56 -05:00
mlugg
137787edbb Sema: fix incorrect type in optional_payload instruction
Resolves: #22417
2025-01-05 19:38:19 +00:00
Travis Lange
82e7f23c49 Added support for thin lto 2025-01-05 18:08:11 +01:00
mlugg
da1ffae7d2 std: fix undefined value in Target.Query
This is an RLS footgun.

Resolves: #21834
2025-01-05 16:26:21 +00:00
Matthew Lugg
41786fabfc
Merge pull request #22412 from mlugg/line-number-incremental
incremental: debug line number updates
2025-01-05 11:48:58 +00:00
mlugg
b039a8b615 compiler: slightly simplify builtin decl memoization
Rather than `Zcu.BuiltinDecl.Memoized` being a struct with fields, it
can instead just be an array, indexed by the enum. This allows runtime
indexing, avoiding a few now-unnecessary `inline` switch cases.
2025-01-05 05:52:02 +00:00
Jacob Young
dde3116e50
Dwarf: implement new incremental line number update API 2025-01-05 02:20:56 +00:00
mlugg
065e10c95c
link: new incremental line number update API 2025-01-05 02:20:56 +00:00
Matthew Lugg
136c5a916e
Merge pull request #22403 from mlugg/incremental
incremental: fixes
2025-01-05 00:28:06 +00:00
axel escalada
ff4f2753e4
Improve first() documentation for split iterators
* remove  from doc., add explicit info when panic

* match convention for assert documentation, avoiding to use panic here
2025-01-04 13:45:12 +00:00
mlugg
6cc848e9f6
incremental: add new test cases
These cover the fixes from the last few commits.
2025-01-04 07:51:19 +00:00
mlugg
f01029c4af
incremental: new AnalUnit to group dependencies on std.builtin decls
This commit reworks how values like the panic handler function are
memoized during a compiler invocation. Previously, the value was
resolved by whichever analysis requested it first, and cached on `Zcu`.
This is problematic for incremental compilation, as after the initial
resolution, no dependencies are marked by users of this memoized state.
This is arguably acceptable for `std.builtin`, but it's definitely not
acceptable for the panic handler/messages, because those can be set by
the user (`std.builtin.Panic` checks `@import("root").Panic`).

So, here we introduce a new kind of `AnalUnit`, called `memoized_state`.
There are 3 such units:
* `.{ .memoized_state = .va_list }` resolves the type `std.builtin.VaList`
* `.{ .memoized_state = .panic }` resolves `std.Panic`
* `.{ .memoized_state = .main }` resolves everything else we want

These units essentially "bundle" the resolution of their corresponding
declarations, storing the results into fields on `Zcu`. This way, when,
for instance, a function wants to call the panic handler, it simply runs
`ensureMemoizedStateResolved`, registering one dependency, and pulls the
values from the `Zcu`. This "bundling" minimizes dependency edges. The 3
units are separated to allow them to act independently: for instance,
the panic handler can use `std.builtin.Type` without triggering a
dependency loop.
2025-01-04 07:51:19 +00:00
mlugg
fd62912787
incremental: correctly handle losing file root struct_decl inst 2025-01-04 05:44:29 +00:00
mlugg
f818098971
incremental: correctly return error.AnalysisFail when type structure changes
`Zcu.PerThead.ensureTypeUpToDate` is set up in such a way that it only
returns the updated type the first time it is called. In general, that's
okay; however, the exception is that we want the function to continue
returning `error.AnalysisFail` when the type has been lost, or its
number of captures changed.

Therefore, the check for this case now happens before the up-to-date
success return.

For simplicity, the number of captures is now handled by intentionally
losing the instruction in `Zcu.mapOldZirToNew`, since there is nothing
to gain from tracking a type when old instances of it can never be
reused.
2025-01-04 05:44:29 +00:00
mlugg
814491f599
Zcu: fix crash when incremental re-analysis of type annotation yields same result 2025-01-04 05:44:29 +00:00
mlugg
b4da8eef2a Zir: split up start and end of range in for_len
The old lowering was kind of neat, but it unintentionally allowed the
syntax `for (123) |_| { ... }`, and there wasn't really a way to fix
that. So, instead, we include both the start and the end of the range in
the `for_len` instruction (each operand to `for` now has *two* entries
in this multi-op instruction). This slightly increases the size of ZIR
for loops of predominantly indexables, but the difference is small
enough that it's not worth complicating ZIR to try and fix it.
2025-01-03 22:28:37 +00:00
mlugg
252c203101 Sema: correctly label block_comptime for restoring error return trace index
Resolves: #22384
2025-01-02 16:26:50 +00:00
GalaxyShard
e6879e99e2 compiler_rt: fix incorrect __clzsi2_thumb1 lookup table usage 2025-01-02 01:01:06 +01:00
Tangtang Zhou
fed8df9217 fix: windows libc lib paths for x86-windows-msvc 2025-01-01 23:47:39 +01:00
Matthew Lugg
0585ed0641
Merge pull request #22379 from mlugg/incremental-fixes
incremental: bugfixes
2025-01-01 21:49:02 +00:00
mlugg
5333d2443a Sema: fix invalid coercion *[n:x]T -> *[m]T for n != m
The change in `Sema.coerceExtra` is just to avoid an unhelpful error
message, covered by the added test case.

Resolves: #22373
2025-01-01 16:20:40 +00:00
mlugg
f0d5e0df4d
incremental: fix errors not being deleted upon re-analysis
Previously, logic in `Compilation.getAllErrorsAlloc` was corrupting the
`failed_analysis` hashmap. This meant that on updates after the initial
update, attempts to remove entries from this map (because the `AnalUnit`
in question is being re-analyzed) silently failed. This resulted in
compile errors from earlier updates wrongly getting "stuck", i.e. never
being removed.

This commit also adds a few log calls which helped me to find this bug.
2025-01-01 15:49:37 +00:00
mlugg
ba78d79228
Zir: fix instruction tracking when function signatures are given 2025-01-01 12:19:14 +00:00
Jan200101
d02c2c76fc link/Elf.zig: set stack size and build-id for dynamic libraries. 2024-12-31 17:09:20 +01:00
Matthew Lugg
0df1f3df2f
Merge pull request #22352 from mlugg/zir-comptime-reason
Zir: attach reason to `block_comptime` and improve corresponding error reporting
2024-12-31 14:35:28 +00:00
mlugg
106df881d3
Sema: add doc comments for comptime reason types 2024-12-31 09:56:21 +00:00
mlugg
9ff80d7950
cases: update to new compile error wordings 2024-12-31 09:55:04 +00:00
mlugg
07b936c95f
cases: add cases for runtime code in comptime scopes 2024-12-31 09:55:04 +00:00
mlugg
7e82398cfe
Sema: remove some incorrect calls to requireRuntimeBlock
Most calls to `requireRuntimeBlock` in Sema are not correct. This
function doesn't deal with all of them, but it does deal with ones which
have, in combination with the past few commits, introduced real-world
regressions.

Related: #22353
2024-12-31 09:55:03 +00:00
mlugg
d6120cf6a9
AstGen: better block_comptime elision 2024-12-31 09:55:03 +00:00
mlugg
71bcbd5993
AstGen: add missing comptimeExpr calls
Some sub-expressions should always be evaluated at comptime -- in
particular, type expressions, e.g. `E` in `E!T`. However, bugs in this
logic are easy to miss, because the parent scope is usually comptime
anyway!
2024-12-31 09:55:03 +00:00
mlugg
9a70eeeac5
compiler: ensure local consts in comptime scope are comptime-known
This fixes a bug which exposed a compiler implementation detail (ZIR
alloc elision). Previously, `const` declarations with a runtime-known
value in a comptime scope were permitted only if AstGen was able to
elide the alloc in ZIR, since the error was reported by storing to the
comptime alloc.

This just adds a new instruction to also emit this error when the alloc
is elided.
2024-12-31 09:55:03 +00:00
mlugg
6026a5f217
compiler: ensure result of block_comptime is comptime-known
To avoid this PR regressing error messages, most of the work here has
gone towards improving error notes for why code was comptime-evaluated.
ZIR `block_comptime` now stores a "comptime reason", the enum for which
is also used by Sema. There are two types in Sema:

* `ComptimeReason` represents the reason we started evaluating something
  at comptime.
* `BlockComptimeReason` represents the reason a given block is evaluated
  at comptime; it's either a `ComptimeReason` with an attached source
  location, or it's because we're in a function which was called at
  comptime (and that function's `Block` should be consulted for the
  "parent" reason).

Every `Block` stores a `?BlockComptimeReason`. The old `is_comptime`
field is replaced with a trivial `isComptime()` method which returns
whether that reason is non-`null`.

Lastly, the handling for `block_comptime` has been simplified. It was
previously going through an unnecessary runtime-handling path; now, it
is a trivial sub block exited through a `break_inline` instruction.

Resolves: #22296
2024-12-31 09:55:03 +00:00
Andrew Kelley
6d67658965 langref: move pointer casting section out of volatile subsection 2024-12-30 22:05:30 -08:00
Misaki Kasumi
021289a653 linux: make ptid and ctid in clone() optional 2024-12-31 05:24:10 +01:00
Jacob Young
ec60156f18 InternPool: fix leak when the last namespace bucket is full 2024-12-29 15:28:40 -05:00
Andrew Kelley
271452d225
Merge pull request #22344 from Techatrix/slice-of-slice
fix incorrect slicing by length detection cases
2024-12-29 13:41:17 -05:00
Travis Staloch
45e4b16caf add @Type behavior tests from #19985 2024-12-29 13:37:39 -05:00
David Rubin
b99dbb6fb5 Value: implement orderAgainstZeroInner for errors 2024-12-29 13:36:52 -05:00
Techatrix
5b6326ec65
fix slice of slice with sentinel on the lhs slice
example:
```zig
test {
    var foo: [2:0]u8 = .{ 1, 2 };
    _ = foo[0.. :1][0..2];
}
```

A `.slice_open` ast node will not have a end index nor sentinel.
2024-12-29 07:00:39 +01:00
Techatrix
5d51d4474a
fix slice of slice with sentinel but no end index
example:
```zig
test {
	var foo = "";
	_ = foo[0..][0.. :0];
}
```

A `.slice_sentinel` ast node may not have an end index.
2024-12-29 07:00:35 +01:00
Techatrix
2e40a1d22e
simplify AstGen handling of slicing syntax 2024-12-29 00:47:24 +01:00
mlugg
01081cc8e8 AstGen: lower function addrspace expression correctly
Also, add some basic behavior tests for addrspace and linksection which
would have caught this bug in CI.
2024-12-28 02:15:00 +00:00
David Rubin
5ee2816f62 llvm: fix UB in metadata printer 2024-12-27 15:38:41 -05:00