Commit Graph

28863 Commits

Author SHA1 Message Date
Jakub Konka fda9a32fef macho: fix double free 2024-03-28 20:17:36 -07:00
Andrew Kelley 3661133f98 Merge pull request #19399 from ypsvlq/mingw
mingw: support -municode
2024-03-28 14:16:30 -07:00
Andrew Kelley c808e546a7 Merge pull request #19461 from Vexu/tests
add tests for stage1 bugs; remove cbe.zig
2024-03-28 11:53:37 -07:00
Veikka Tuominen 9106fdffaf Sema: check error union payload types in @errorCast 2024-03-28 15:39:47 +02:00
Veikka Tuominen 60614b2a85 add tests for fixed stage1 bugs
Closes #10357
Closes #11236
Closes #11615
Closes #12055
2024-03-28 15:24:01 +02:00
Veikka Tuominen 0588595128 std.PackedInt: remove workaround for stage1 bug
Closes #7635
2024-03-28 15:24:01 +02:00
Veikka Tuominen 2cdc48a632 remove test/cbe.zig
The C backend is far enough along for these tests to be redundant with all the other tests.
2024-03-28 15:24:01 +02:00
HydroH 7aa42f47b7 allow @errorcast to cast error sets to error unions 2024-03-28 10:23:32 +00:00
Andrew Kelley 17053887d0 Merge pull request #19458 from ianprime0509/all-module-docs
Autodoc: include all modules in output
2024-03-28 02:17:50 -07:00
Ian Johnson 3fb6bb1449 std-docs: include builtin module in sources.tar
Now that `-femit-docs` includes all modules, including the builtin
module, in the generated source tarball, it makes sense to apply the
same logic to the std-docs server. std-docs constructs its own tarball,
so a different approach is needed to achieve the same end result.
2024-03-28 00:30:42 -04:00
Ian Johnson 424dd17b6c Autodoc: add all modules to sources.tar
Closes #19403

This commit adds all modules in the compilation to the generated
`sources.tar` when using `-femit-docs` (including `std` and `builtin`).
Additionally, it considers the main module when doing so, rather than
the root module, so the behavior when running `zig test -femit-docs
test.zig` is now correct.
2024-03-28 00:30:29 -04:00
Jakub Konka 9dac8db2df Merge pull request #19430 from ziglang/dwarf-ub
link: fix undefined memory being written out in dwarf and codegen
2024-03-27 17:29:30 +01:00
Ryan Liptak bad9efbcc1 Add standalone test for all possible MinGW exe entry points 2024-03-27 10:06:06 +00:00
Ryan Liptak 4e428415e5 Build.Step.Compile: Add mingw_unicode_entry_point field
Corresponds to the `-municode` CLI flag
2024-03-27 10:06:06 +00:00
Elaine Gibson add74427b9 mingw: support -municode 2024-03-27 10:05:57 +00:00
Jacob Young 71d878ba50 std.zig: remove extraneous newlines in log messages 2024-03-27 01:55:42 -04:00
Jacob Young 77ff6bc656 haiku: fix poll definitions 2024-03-27 01:55:42 -04:00
HydroH 7684423c08 translate-c: handle string concatenation of function calls 2024-03-26 21:16:53 -07:00
Andrew Kelley 5140f2726a Merge pull request #19437 from mlugg/value-cleanups
Follow-up to #19414
2024-03-26 21:11:18 -07:00
mlugg 5132549565 Zcu: remove some unused functions 2024-03-26 21:35:21 +00:00
mlugg 845226a7c9 cases: necessary changes from branch 2024-03-26 17:06:14 +00:00
mlugg bfc0c35689 Value: fix underflow reading large u64 values from packed memory 2024-03-26 17:06:14 +00:00
mlugg 951fc09a7e print_value: improve value printing
Notably, this improves string printing from
`@as(*[5:0]u8, &@as([5:0]u8, "hello".*))` to `@as(*[5:0]u8, "hello")`,
omitting the pointless ref-deref pair.
2024-03-26 17:06:14 +00:00
mlugg 2a245e3b78 compiler: eliminate TypedValue
The only logic which remained in this file was the Value printing logic.
This has been moved into a new `print_value.zig`.
2024-03-26 13:48:07 +00:00
mlugg a61def10c6 compiler: eliminate most usages of TypedValue 2024-03-26 13:48:07 +00:00
mlugg b8d114a29e Zcu: use Value instead of TypedValue when initializing legacy anon decls
Also removes some unnecessary uses of legacy anon decls for constructing
the array of test functions for the test runner.
2024-03-26 13:48:07 +00:00
mlugg 0d8c7ae007 Zcu.Decl: replace typedValue with valueOrFail
Now that the legacy `Value` representation is eliminated, we can begin
to phase out the redundant `TypedValue` type.
2024-03-26 13:48:07 +00:00
mlugg 920f2c7794 compiler: minor cleanups 2024-03-26 13:48:07 +00:00
mlugg 26a94e8481 Zcu: eliminate Decl.alive field
Legacy anon decls now have three uses:
* Type owner decls
* Function owner decls
* `@export` and `@extern`

Therefore, there are no longer any cases where we wish to explicitly
omit legacy anon decls from the binary. This means we can remove the
concept of an "alive" vs "dead" `Decl`, which also allows us to remove
the separate `anon_work_queue` in `Compilation`.
2024-03-26 13:48:06 +00:00
mlugg 152a2ceaf7 compiler: audit uses of ptr.addr in the frontend
This commit also performs some refactors to `TypedValue.print` in
preparation for improved comptime pointer access logic. Once that logic
exists, `TypedValue.print` can use Sema to access pointers for more
helpful printing.

This commit also implements proposal #19435, because the existing logic
there relied on some blatantly incorrect code in `Value.sliceLen`.

Resolves: #19435
2024-03-26 13:48:06 +00:00
mlugg 884d957b6c compiler: eliminate legacy Value representation
Good riddance!

Most of these changes are trivial. There's a fix for a minor bug this
exposed in `Value.readFromPackedMemory`, but aside from that, it's all
just things like changing `intern` calls to `toIntern`.
2024-03-26 13:48:06 +00:00
mlugg 5ec6e3036b Sema: introduce separate MutableValue representation for comptime-mutable memory
Perhaps someday, we will make Sema operate on mutable values more
generally. For now, it makes sense to split out this representation,
since it is only used in comptime pointer accesses.

There are some currently unused methods on `MutableValue` which will
be used once I rewrite the comptime pointer access logic to be less
terrible.

The commit following this one will - at long last - delete the legacy
Value representation
2024-03-26 13:48:06 +00:00
mlugg c6f3e9d79c Zcu.Decl: remove ty field
`Decl` can no longer store un-interned values, so this field is now
unnecessary. The type can instead be fetched with the new `typeOf`
helper method, which just gets the type of the Decl's `Value`.
2024-03-26 13:48:06 +00:00
David Rubin 341857e5cd make addCSourceFiles assert options.files are relative 2024-03-26 14:03:39 +02:00
Prokop Randáček 055023efb4 valgrind client request wrappers take const pointers (#19237)
* valgrind client request wrappers take const pointers

* require zero terminated strings in valgrind wrappers
2024-03-26 14:00:13 +02:00
Veikka Tuominen 59203cb4f2 Merge pull request #19385 from markus-oberhumer-forks/improve-old-glibc-versions
Improve old glibc versions
2024-03-26 13:56:07 +02:00
Luis Cáceres 29e41c6850 std.Build: dupe provided paths for Step.Fmt.create() 2024-03-26 13:54:24 +02:00
Andrew Kelley 405502286d Merge pull request #19414 from mlugg/comptime-mutable-memory-yet-again
compiler: implement analysis-local comptime-mutable memory
2024-03-25 16:32:18 -07:00
Jakub Konka ae1b2bfcad dwarf+codegen: use appendNTimes instead of writer().writeByteNTimes 2024-03-25 23:48:39 +01:00
Andrew Kelley abadad4640 Merge pull request #19402 from ianprime0509/markdown-autolinks
Autodoc: hyperlink URLs in text
2024-03-25 15:36:37 -07:00
Andrew Kelley 32b4d85605 Merge pull request #19406 from jacobly0/haiku
haiku: get a cross-compiled compiler working
2024-03-25 15:33:51 -07:00
Jakub Konka 69e9fe4ede dwarf: actually write zeroed out unresolved relocs into emitted DWARF in initDeclState 2024-03-25 23:22:20 +01:00
HydroH ef31d8f48f autodoc: better indentation handling when rendering source code (#19422)
Closes #19293
2024-03-25 18:20:15 -04:00
mlugg 31a7f22b80 llvm: update current debug location scope when entering debug scope
This issue was causing debug information to sometimes not function
correctly for some local variables, with debuggers simply reporting that
the variable does not exist. What was happening was that after an AIR
body - and thus debug lexical scope - begins, but before any `dbg_stmt`
within it, the `scope` on `self.wip.debug_location` refers to the parent
scope, but the `scope` field on the `DILocalVariable` metadata passed to
`@llvm.dbg.declare` points, correctly, to the nested scope. I haven't
looked into precisely what happens here, but in short, it would appear
that LLVM Doesn't Like It (tm).

The fix is simple: when we change `self.scope` at the start or end of an
AIR body, also modify the scope on `self.wip.debug_location`. This is
correct as we always want the debug info for an instruction to be
associated with the block it is within, even if the line/column are
slightly outdated for any reason.
2024-03-25 15:05:52 +00:00
mlugg f8b8259e5c behavior: skip newly failing test
This test has regressed due to a bug in the self-hosted COFF linker.
Jakub recommended disabling it for now, since the COFF linker is being
effectively rewritten, so there is little point in fixing the bug now.
2024-03-25 14:49:41 +00:00
mlugg 9c3670fc93 compiler: implement analysis-local comptime-mutable memory
This commit changes how we represent comptime-mutable memory
(`comptime var`) in the compiler in order to implement the intended
behavior that references to such memory can only exist at comptime.

It does *not* clean up the representation of mutable values, improve the
representation of comptime-known pointers, or fix the many bugs in the
comptime pointer access code. These will be future enhancements.

Comptime memory lives for the duration of a single Sema, and is not
permitted to escape that one analysis, either by becoming runtime-known
or by becoming comptime-known to other analyses. These restrictions mean
that we can represent comptime allocations not via Decl, but with state
local to Sema - specifically, the new `Sema.comptime_allocs` field. All
comptime-mutable allocations, as well as any comptime-known const allocs
containing references to such memory, live in here. This allows for
relatively fast checking of whether a value references any
comptime-mtuable memory, since we need only traverse values up to
pointers: pointers to Decls can never reference comptime-mutable memory,
and pointers into `Sema.comptime_allocs` always do.

This change exposed some faulty pointer access logic in `Value.zig`.
I've fixed the important cases, but there are some TODOs I've put in
which are definitely possible to hit with sufficiently esoteric code. I
plan to resolve these by auditing all direct accesses to pointers (most
of them ought to use Sema to perform the pointer access!), but for now
this is sufficient for all realistic code and to get tests passing.

This change eliminates `Zcu.tmp_hack_arena`, instead using the Sema
arena for comptime memory mutations, which is possible since comptime
memory is now local to the current Sema.

This change should allow `Decl` to store only an `InternPool.Index`
rather than a full-blown `ty: Type, val: Value`. This commit does not
perform this refactor.
2024-03-25 14:49:41 +00:00
Jakub Konka e599ed4a5f codegen: actually write out padding for packed structs upfront 2024-03-25 00:00:33 +01:00
Simon Brown 5c628312b1 std.enums: fix EnumSet.init and EnumMap.init for non-exhaustive enums 2024-03-24 22:29:27 +00:00
Jakub Konka c5a5b420dc dwarf: actually write out well-defined placeholder bytes for relocs 2024-03-24 20:18:26 +01:00
Jacob Young af0668d6c2 Build.Cache: fix UAF during unhit 2024-03-24 18:28:16 +00:00