Commit graph

646 commits

Author SHA1 Message Date
mlugg
fac120bc3a Module: mark function body dependencies, don't re-analyze anonymous decls 2023-04-20 09:09:15 -07:00
Jacob Young
562170681a link: cleanup lazy symbols
We now only update one lazy symbol in flushModule.
Updating the rest from updateDecl is TBD.
2023-04-03 18:02:53 +02:00
Veikka Tuominen
4a5628e730 Module: fix lazy srcloc resolution for new for loop syntax
Closes #15081
2023-03-26 15:14:03 +03:00
John Schmidt
ec445fb6b8 Improve error messages for break type coercion 2023-03-21 15:09:42 +02:00
Jacob Young
cfcd6698cd main: add debug option to dump unoptimized llvm ir 2023-03-17 01:57:14 -04:00
Andrew Kelley
1dbb616e73 Module: handle incremental update from ZIR with AST errors 2023-03-15 10:48:15 -07:00
Andrew Kelley
572cb24d1a progress towards semantic error serialization
Introduces std.zig.ErrorBundle which is a trivially serializeable set
of compilation errors. This is in the standard library so that both
the compiler and the build runner can use it. The idea is they will
use it to communicate compilation errors over a binary protocol.

The binary encoding of ErrorBundle is a bit problematic - I got a little
too aggressive with compaction. I need to change it in a follow-up
commit to use some indirection in the error message list, otherwise
iteration is too unergonomic. In fact it's so problematic right now that
the logic getAllErrorsAlloc() actually fails to produce a viable
ErrorBundle because it puts SourceLocation data in between the root
level ErrorMessage data.

This commit has a simplification - redundant logic for rendering AST
errors to stderr has been removed in favor of moving the logic for
lowering AST errors into AstGen. So even if we get parse errors, the
errors will get lowered into ZIR before being reported. I believe this
will be useful when working on --autofix. Either way, some redundant
brittle logic was happily deleted.

In Compilation, updateSubCompilation() is improved to properly perform
error reporting when a sub-compilation object fails. It no longer dumps
directly to stderr; instead it populates an ErrorBundle object, which
gets added to the parent one during getAllErrorsAlloc().

In package fetching code, instead of dumping directly to stderr, it now
populates an ErrorBundle object, and gets properly reported at the CLI
layer of abstraction.
2023-03-15 10:48:12 -07:00
Andrius Bentkus
4ea2f441df Module: retry ZIR cache file creation
There are no dir components, so you would think that this was
unreachable, however we have observed on macOS two processes racing to
do openat() with O_CREAT manifest in ENOENT.

closes #12138
2023-03-11 06:20:51 -05:00
Jacob Young
e3cf9d1650 Module: rewrite zir caching logic
Multiple processes can sit waiting for the exclusive lock at the same
time, so we want to recheck whether it needs to be updated whenever
we get an exclusive lock.

This also fixes a race condition between one process truncating the
cache file and another process reading it without atomic locking.
2023-03-08 00:00:52 -05:00
Andrew Kelley
c839c180ef stage2: add zig_backend to ZIR cache namespace 2023-03-05 17:23:09 -07:00
mlugg
b8a96baab8
Improve multi-module error messages
- Fix assertion failure if AstGen failed on a multi-module file
- Cap number of per-error reference notes and total multi-module errors each at 5
- Always put "root of package" reference notes first

Resolves: #14499
2023-02-21 02:05:35 +00:00
mlugg
705d2a3c2c
Implement new module CLI 2023-02-21 01:59:37 +00:00
Andrew Kelley
4dd958d585 improve error message for byref capture of byval array 2023-02-18 19:20:19 -07:00
Andrew Kelley
22965e6fcb Sema: improve error message for mismatched for loop lengths 2023-02-18 19:17:21 -07:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Andrew Kelley
9cb52ca6ce move the cache system from compiler to std lib 2023-02-13 06:42:25 -07:00
Andrew Kelley
11cc1c16fa make @embedFile support module-mapped names the same way as @import
closes #14553
2023-02-05 03:25:43 -05:00
Luuk de Gram
c9b957c937 link: remove FnData and make it self-owned
This finishes the work started in #14502 where atoms are owned by the
linker themselves. This now makes debug atoms fully owned by dwarf,
and no information is left stored on the decl.
2023-02-03 22:55:46 +01:00
Andrew Kelley
873bb29c98 introduce ZON: Zig Object Notation
* std.zig.parse is moved to std.zig.Ast.parse
 * the new function has an additional parameter that requires passing
   Mode.zig or Mode.zon
 * moved parser.zig code to Parse.zig
 * added parseZon function next to parseRoot function
2023-02-03 00:06:11 -07:00
Jakub Konka
beb20d29db link: remove union types which are now internal to backends 2023-02-01 19:32:54 +01:00
Luuk de Gram
46f54b23ae
link: make Wasm atoms fully owned by the linker 2023-02-01 19:10:56 +01:00
Jakub Konka
e0f3975fc8 link: make SpirV atoms fully owned by the linker 2023-02-01 16:01:43 +01:00
Jakub Konka
5de2aae63c link: decouple DI atoms from linker atoms, and manage them in Dwarf linker 2023-02-01 15:03:55 +01:00
Jakub Konka
b3277c8936 link: make Plan9 atoms fully owned by the linker 2023-02-01 11:12:53 +01:00
Jakub Konka
c430e9afa7 link: make Coff atoms fully owned by the linker 2023-01-31 20:27:17 +01:00
Jakub Konka
4404c4d200 link: make Elf atoms fully owned by the linker 2023-01-31 17:54:12 +01:00
Jakub Konka
d42a931051 link: make MachO atoms fully owned by the linker 2023-01-31 00:43:25 +01:00
Jakub Konka
a898729139 self-hosted: remove allocateDeclIndexes from the public link.File API 2023-01-27 19:51:06 +01:00
Luuk de Gram
b25efb86e1
wasm: migrate to new non-allocateDeclIndexes API 2023-01-27 19:24:15 +01:00
Jakub Konka
cc1d7a0e31 coff: migrate to new non-allocateDeclIndexes API 2023-01-26 14:29:14 +01:00
Jakub Konka
e1b9800ffa elf: migrate to new non-allocateDeclIndexes API 2023-01-26 14:29:14 +01:00
Jakub Konka
4d804c1b23 macho: completely remove allocateDeclIndexes in favor of linker tracking 2023-01-26 14:29:14 +01:00
mlugg
5f9186d0ce
AstGen: detect and error on files included in multiple packages
Previously, if a source file was referenced from multiple packages, it
just became owned by the first one AstGen happened to reach; this was a
problem, because it could lead to inconsistent behaviour in the compiler
based on a race condition. This could be fixed by just analyzing such
files multiple times - however, it was pointed out by Andrew that it
might make more sense to enforce files being part of at most a single
package. Having a file in multiple packages would not only impact
compile times (due to Sema having to run multiple times on potentially a
lot of code) but is also a confusing anti-pattern which more often than
not is a mistake on the part of the user.

Resolves: #13662
2023-01-22 19:00:03 +00:00
mlugg
6d71d79dc2
Package: store package name directly
By @Vexu's suggestion, since fetching the name from the parent package
is error-prone and complex, and optimising Package for size isn't really
a priority.
2023-01-22 19:00:03 +00:00
Veikka Tuominen
342bae02d8 Sema: automatically optimize order of struct fields
This is a simple starting version of the optimization described in #168
where the fields are just sorted by order of descending alignment.
2023-01-16 19:46:41 +02:00
Veikka Tuominen
d8128c272a Sema: fix typeInfo decls with usingnamespace
Closes #12403
2023-01-11 21:11:21 +02:00
Techatrix
1f8f79cd53
std: add helper functions to std.zig.Ast for extracting data out of nodes 2023-01-09 16:59:19 +02:00
Veikka Tuominen
f2faa303a5 Sema: handle enum expressions referencing local variables
Closes #12272
2023-01-05 22:03:32 +02:00
Veikka Tuominen
8c4727f9ab Sema: remove generic function from monomorphed_funcs on any error 2023-01-05 14:26:53 +02:00
Veikka Tuominen
01dba1c054 Sema: add system for checking backend feature support 2023-01-05 14:26:53 +02:00
Veikka Tuominen
abd005f302 Sema: do not immediately destroy failed generic instantiation
Closes #12535
Closes #12765
Closes #12927
2023-01-03 18:38:15 +02:00
Veikka Tuominen
4e64373fc0 fix generic function arg debug info referencing wrong parameter
Closes #14123
2022-12-30 17:00:50 +02:00
Andrew Kelley
32d76f0e4a stage2: remove pub from a private function 2022-12-14 14:26:02 -07:00
Andrew Kelley
a62c8d36d5 std.fs.Dir.statFile rework
* revert changes to Module because the error set is consistent across
   operating systems.
 * remove duplicated Stat.fromSystem code and use a less redundant name.
 * make fs.Dir.statFile follow symlinks, and avoid pointless control
   flow through the posix layer.
2022-12-14 14:26:02 -07:00
Philippe Pittoli
f65cdef7c8 std.fs.Dir.statFile: use fstatat
This avoids extra syscalls.
2022-12-14 14:11:59 -07:00
Veikka Tuominen
bc97a5662d Sema: display cimport errors from clang 2022-12-14 14:08:22 +02:00
IntegratedQuantum
15a6336bb4
Add a helpful note when using ** on number types. (#13871) 2022-12-11 14:41:42 -05:00
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Veikka Tuominen
59dad43de2 Sema: add error for failed assumption about struct having runtime bits 2022-12-02 18:46:59 +02:00
Andrew Kelley
ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00