10211 Commits

Author SHA1 Message Date
Adheesh Wadkar
b5a2487f7a Fix chdirC compile error 2025-01-20 15:37:57 -06:00
Alex Rønne Petersen
d5db02728c
Merge pull request #22530 from alexrp/omit-unwind-tables
Fix building the standard library without CFI directives
2025-01-20 07:24:12 +01:00
Alex Rønne Petersen
b074fb7dda std.zig.system.x86: Update Intel/AMD model detection. 2025-01-19 23:42:39 +01:00
Jacob Young
8ee80d61f6 x86_64: add a bunch of instruction encodings
Closes #19773
2025-01-18 23:30:45 -05:00
Alex Rønne Petersen
db8ed730e7 std.Thread: Fix wasi_thread_start() export to use a pointer.
Closes #22518.
2025-01-19 03:23:00 +01:00
Alex Rønne Petersen
8a78d875cc
std.os.linux: Don't emit CFI directives if unwind tables are disabled. 2025-01-19 02:15:30 +01:00
Alex Rønne Petersen
4de661ef18
start: Don't emit CFI directives if unwind tables are disabled. 2025-01-19 02:15:30 +01:00
Andrew Kelley
a5d2aaa936
Merge pull request #22526 from alexrp/cpu-feature-hacks
`std.zig.system`: Move CPU feature hacks after ABI detection.
2025-01-18 18:22:11 -05:00
Jacob Young
128658038d debug: fix std.debug.NoPanic compile errors 2025-01-18 17:33:10 -05:00
andrewkraevskii
3dadb8c4c9 autodocs: reflow comment to prevent it from been put in blockquote 2025-01-18 15:45:03 +01:00
Alex Rønne Petersen
9758371419
std.zig.system: Move CPU feature hacks after ABI detection.
This was accidentally broken in #22434.
2025-01-18 12:59:38 +01:00
axel escalada
f9a43770c8
std.zip: Add ZIP64 support for local file header extra field
This PR adds support for handling ZIP64 format in local file headers,
when a zip file contains entries where the compressed or uncompressed
size fields are set to 0xFFFFFFFF, and the extra field contains ZIP64
extended information tag (0x0001)

The code now:

Reads the actual sizes from the ZIP64 extra field data
Validates these sizes against the entry's compressed and uncompressed sizes

Zip file format spec.: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

This change allows proper extraction of ZIP files that use ZIP64 format in their
local file headers.

Fixes: #22329
2025-01-17 22:55:55 +01:00
pfg
c748eb2416
std.Build: fix setLibCFile() to add step dependencies 2025-01-17 20:42:55 +01:00
Jacob Young
8c8dfb35f3 x86_64: fix crashes compiling the compiler and tests 2025-01-16 20:47:30 -05:00
Jacob Young
63730441d0 x86_64: implement union access 2025-01-16 20:47:30 -05:00
Jacob Young
e5d5a8bc4e x86_64: implement switch jump tables 2025-01-16 20:42:08 -05:00
Jacob Young
ac1a975f9b x86_64: implement clz and not 2025-01-16 20:42:08 -05:00
Jacob Young
7c713251ca x86_64: looped instructions 2025-01-16 20:42:08 -05:00
Jacob Young
beadf702b8 x86_64: rewrite arithmetic 2025-01-16 20:42:08 -05:00
Matthew Lugg
4d8c24c6c5
Merge pull request #22505 from mlugg/easier-modify-builtin
std.builtin.Type renames, and make it easier to modify std.builtin
2025-01-16 22:20:02 +00:00
max
961fc0e140
std.fs.Dir: update deleteTree doc comment to match function signature (#22509)
the actual parameter name is `sub_path` which is also referenced in other
comments describing the fuction.
2025-01-16 20:11:42 +00:00
mlugg
9804cc8bc6
all: update to std.builtin.Type.{Pointer,Array,StructField} field renames 2025-01-16 12:49:58 +00:00
mlugg
89a9cabafd
std.builtin.Type: improve ergonomics of *const anyopaque fields
For representing struct field default values and array/pointer type
sentinel values, we use `*const anyopaque`, since there is no way for
`std.builtin.Type.StructField` etc to refer back to its `type` field.
However, when introspecting a type, this is quite awkward due to the
pointer casts necessary.

As such, this commit renames the `sentinel` fields to `sentinel_ptr`,
and the `default_value` field to `default_value_ptr`, and introduces
helper methods `sentinel()` and `defaultValue()` to load the values.
These methods are marked as `inline` because their return value, which
is always comptime-known, is very often required at comptime by use
sites, so this avoids having to annotate such calls with `comptime`.

This is a breaking change, although note that 0.14.0 is already a
breaking release for all users of `std.builtin.Type` due to the union
fields being renamed.
2025-01-16 12:49:58 +00:00
mlugg
d00e05f186
all: update to std.builtin.Type.Pointer.Size field renames
This was done by regex substitution with `sed`. I then manually went
over the entire diff and fixed any incorrect changes.

This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since
my regex happened to also trigger here. I opted to leave these changes
in, since they *are* a correct migration, even if they're not the one I
was trying to do!
2025-01-16 12:46:29 +00:00
mlugg
af6bad46cd
std.builtin.Type: rename Pointer.Size fields to lowercase
This matches established naming conventions. Now is an opportune time to
make this change, since we're already performing breaking changes to
`std.builtin.Type`.
2025-01-16 11:37:46 +00:00
Andrew Kelley
cf898e242a std.Build.Step.CheckObject: better EOF handling
when unexpected end of stream occurs, just add that as a token into the
text
2025-01-15 19:43:46 -08:00
Andrew Kelley
8abdebecdc wasm linker: implement @tagName for sparse enums 2025-01-15 15:11:36 -08:00
Andrew Kelley
4fccb5ae7a wasm linker: improve error messages by making source locations more lazy 2025-01-15 15:11:36 -08:00
Andrew Kelley
fbbb54bab2 std.io: remove the "temporary workaround" for stage2_aarch64 2025-01-15 15:11:36 -08:00
Andrew Kelley
3cb00c5bcd std.ArrayHashMap: allow passing empty values array
in which case the values array is set to undefined
2025-01-15 15:11:35 -08:00
Andrew Kelley
70414c1f43 std.Thread: don't export wasi_thread_start in single-threaded mode 2025-01-15 15:11:35 -08:00
Andrew Kelley
968941b535 wasm linker: finish the flush function
This branch is passing type checking now.
2025-01-15 15:11:35 -08:00
Andrew Kelley
b9355edfb1 std.array_list: tiny refactor for pleasure 2025-01-15 15:11:35 -08:00
Andrew Kelley
795e7c64d5 wasm linker: aggressive DODification
The goals of this branch are to:
* compile faster when using the wasm linker and backend
* enable saving compiler state by directly copying in-memory linker
  state to disk.
* more efficient compiler memory utilization
* introduce integer type safety to wasm linker code
* generate better WebAssembly code
* fully participate in incremental compilation
* do as much work as possible outside of flush(), while continuing to do
  linker garbage collection.
* avoid unnecessary heap allocations
* avoid unnecessary indirect function calls

In order to accomplish this goals, this removes the ZigObject
abstraction, as well as Symbol and Atom. These abstractions resulted
in overly generic code, doing unnecessary work, and needless
complications that simply go away by creating a better in-memory data
model and emitting more things lazily.

For example, this makes wasm codegen emit MIR which is then lowered to
wasm code during linking, with optimal function indexes etc, or
relocations are emitted if outputting an object. Previously, this would
always emit relocations, which are fully unnecessary when emitting an
executable, and required all function calls to use the maximum size LEB
encoding.

This branch introduces the concept of the "prelink" phase which occurs
after all object files have been parsed, but before any Zcu updates are
sent to the linker. This allows the linker to fully parse all objects
into a compact memory model, which is guaranteed to be complete when Zcu
code is generated.

This commit is not a complete implementation of all these goals; it is
not even passing semantic analysis.
2025-01-15 15:11:35 -08:00
Ben Grant
15fe999572 std.atomic: fix cache line size for RISC-V 2025-01-12 04:51:00 +01:00
mlugg
04c9f50aec compiler: improve "... contains reference to comptime var" errors
`Sema.explainWhyValueContainsReferenceToComptimeVar` (concise name!)
adds notes to an error explaining how to get from a given `Value` to a
pointer to some `comptime var` (or a comptime field). Previously, this
error could be very opaque in any case where it wasn't obvious where the
comptime var pointer came from; particularly for type captures. Now, the
error notes explain this to the user.
2025-01-11 08:54:47 +00:00
mlugg
e9bd2d45d4
Sema: rewrite semantic analysis of function calls
This rewrite improves some error messages, hugely simplifies the logic,
and fixes several bugs. One of these bugs is technically a new rule
which Andrew and I agreed on: if a parameter has a comptime-only type
but is not declared `comptime`, then the corresponding call argument
should not be *evaluated* at comptime; only resolved. Implementing this
required changing how function types work a little, which in turn
required allowing a new kind of function coercion for some generic use
cases: function coercions are now allowed to implicitly *remove*
`comptime` annotations from parameters with comptime-only types. This is
okay because removing the annotation affects only the call site.

Resolves: #22262
2025-01-09 06:46:47 +00:00
Des-Nerger
6a21d18adf -fwine: allow 32-bit .exe's be run on backward-compatible 64-bit arches
Closes #22361.
2025-01-07 19:03:40 +01:00
David Rubin
fc28a71d9f Target: update the extra features before resolving the dynamic linker 2025-01-07 02:58:10 +01:00
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
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
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
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
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
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
Tangtang Zhou
fed8df9217 fix: windows libc lib paths for x86-windows-msvc 2025-01-01 23:47:39 +01:00
mlugg
ba78d79228
Zir: fix instruction tracking when function signatures are given 2025-01-01 12:19:14 +00:00