Commit Graph

30675 Commits

Author SHA1 Message Date
Andrew Kelley
cf9f8de661 update comment in init template
Unit tests are not run from the install step.

closes #21123
2024-08-18 14:23:49 -07:00
Alex Rønne Petersen
1045537141 Revert "ci: Enable -Dtest-slow-targets."
This reverts commit 55cc9dda66.
2024-08-18 12:35:57 -04:00
Matthew Lugg
4929cf23ce
Merge pull request #21063 from mlugg/incremental
Incremental compilation progress
2024-08-18 12:56:04 +01:00
mlugg
f0374fe3f0 Compilation: simplify totalErrorCount
This function now has to allocate anyway to resolve references, so we
may as well just build the error bundle and check its length.

Also remove some unnecessary calls of this function for efficiency.
2024-08-17 18:50:10 -04:00
mlugg
9e6318a4ea compiler: add some doc comments 2024-08-17 18:50:10 -04:00
mlugg
7f2466e65f std.BoundedArray: add clear() 2024-08-17 18:50:10 -04:00
mlugg
9c3324173d compiler: merge conflicts and typos 2024-08-17 18:50:10 -04:00
mlugg
d63d9b9918 compiler: use incremental cache mode with -fincremental
This results in correct reporting to the build system of file system
inputs with `-fincremental --watch` on a `fno-emit-bin` build.
2024-08-17 18:50:10 -04:00
mlugg
04b13547e1 Zcu: avoid unnecessary re-analysis in some dependency loop situations
I'm like 80% sure this is correct
2024-08-17 18:50:10 -04:00
mlugg
90116d92b0 Compilation: don't call resolveReferences unnecessarily
This function is slow and should only be called in compile error cases.
2024-08-17 18:50:10 -04:00
mlugg
89f02d1c10 std.zig.Zir: fix declaration traversal
The old logic here had bitrotted, largely because there were some
incorrect `else` cases. This is now implemented correctly for all
current ZIR instructions. This prevents instructions being lost in
incremental updates, which is important for updates to be minimal.
2024-08-17 18:50:10 -04:00
mlugg
84c2ebd6c6 frontend: incremental compilation progress
Another big commit, sorry! This commit makes all fixes necessary for
incremental updates of the compiler itself (specifically, adding a
breakpoint to `zirCompileLog`) to succeed, at least on the frontend.

The biggest change here is a reform to how types are handled. It works
like this:
* When a type is first created in `zirStructDecl` etc, its namespace is
  scanned. If the type requires resolution, an `interned` dependency is
  declared for the containing `AnalUnit`.
* `zirThis` also declared an `interned` dependency for its `AnalUnit` on
  the namespace's owner type.
* If the type's namespace changes, the surrounding source declaration
  changes hash, so `zirStructDecl` etc will be hit again. We check
  whether the namespace has been scanned this generation, and re-scan it
  if not.
* Namespace lookups also check whether the namespace in question
  requires a re-scan based on the generation. This is because there's no
  guarantee that the `zirStructDecl` is re-analyzed before the namespace
  lookup is re-analyzed.
* If a type's structure (essentially its fields) change, then the type's
  `Cau` is considered outdated. When the type is re-analyzed due to
  being outdated, or the `zirStructDecl` is re-analyzed by being
  transitively outdated, or a corresponding `zirThis` is re-analyzed by
  being transitively outdated, the struct type is recreated at a new
  `InternPool` index. The namespace's owner is updated (but not
  re-scanned, since that is handled by the mechanisms above), and the
  old type, while remaining a valid `Index`, is removed from the map
  metadata so it will never be found by lookups. `zirStructDecl` and
  `zirThis` store an `interned` dependency on the *new* type.
2024-08-17 18:50:10 -04:00
mlugg
65cbdefe4d tools: add CBE option to incr-check 2024-08-17 18:50:10 -04:00
mlugg
5a8780838f Sema: don't set union tag type if it's not an enum 2024-08-17 18:50:10 -04:00
mlugg
46388d338a InternPool: don't remove outdated types
When a type becomes outdated, there will still be lingering references
to the old index -- for instance, any declaration whose value was that
type holds a reference to that index. These references may live for an
arbitrarily long time in some cases. So, we can't just remove the type
from the pool -- the old `Index` must remain valid!

Instead, we want to preserve the old `Index`, but avoid it from ever
appearing in lookups. (It's okay if analysis of something referencing
the old `Index` does weird stuff -- such analysis are guaranteed by the
incremental compilation model to always be unreferenced.) So, we use the
new `InternPool.putKeyReplace` to replace the shard entry for this index
with the newly-created index.
2024-08-17 18:50:10 -04:00
mlugg
978fe68a65 Compilation: actually do codegen on non-initial updates 2024-08-17 18:50:10 -04:00
mlugg
1ccbc6ca20 test: add new incremental test
This case is adapted from #11344, and passes with `-fno-emit-bin`.

Resolves: #11344
2024-08-17 18:50:10 -04:00
mlugg
3fb5cad07d Sema: don't delete reified enum type with error in field
An enum type is kind of like a struct or union type, in that field
errors are happening during type resolution. The only difference is that
type resolution happens at the time the type is created. So, errors in
fields should not cause the type to be deleted: we've already added a
reference entry, and incremenetal dependencies which must be invalidated
if the compile error is fixed. Once we call `WipEnumType.prepare`, we
should never call `WipEnumType.cancel`. This is analagous to logic for
enum declarations in `Sema.zirEnumDecl`.
2024-08-17 18:50:10 -04:00
mlugg
50960fac80 compiler: be more cautious about source locations
Two fixes here.

* Prevent a crash when sorting the list of analysis errors when some
  errors refer to lost source locations. These errors can be sorted
  anywhere in the list, because they are (in theory) guaranteed to never
  be emitted by the `resolveReferences` logic. This case occurs, for
  instance, when a declaration has compile errors in the initial update
  and is deleted in the second update.

* Prevent a crash when resolving the source location for `entire_file`
  errors for a non-existent file. This is the bug underlying #20954.

Resolves: #20954.
2024-08-17 18:50:10 -04:00
mlugg
4e5834a9f2 Compilation: don't queue std analysis twice when testing std 2024-08-17 18:50:10 -04:00
mlugg
8f8fe89276 Zcu: panic on usingnamespace with -fincremental 2024-08-17 18:50:10 -04:00
mlugg
93f2d9a77f Zcu: typo
We were accidentally over-reporting most `namespace_name` deps and *not*
reporting some actually outdated ones!
2024-08-17 18:50:10 -04:00
mlugg
434ad90610 Sema: disable comptime call memoization under -fincremental 2024-08-17 18:50:10 -04:00
mlugg
936a79f428 tools,test: improve incr-check and add new incremental tests 2024-08-17 18:50:10 -04:00
mlugg
aa6c1c40ec frontend: yet more incremental work 2024-08-17 18:50:10 -04:00
mlugg
6faa4cc7e6 Zcu: construct full reference graph
This commit updates `Zcu.resolveReferences` to traverse the graph of
`AnalUnit` references (starting from the 1-3 roots of analysis) in order
to determine which `AnalUnit`s are referenced in an update. Errors for
unreferenced entities are omitted from the error bundle. However, note
that unreferenced `Nav`s are not removed from the binary.
2024-08-17 18:50:10 -04:00
mlugg
b65865b027 tools: improve incr-check
And add a new incremental test to match!
2024-08-17 18:50:10 -04:00
mlugg
895267c916 frontend: incremental progress
This commit makes more progress towards incremental compilation, fixing
some crashes in the frontend. Notably, it fixes the regressions introduced
by #20964. It also cleans up the "outdated file root" mechanism, by
virtue of deleting it: we now detect outdated file roots just after
updating ZIR refs, and re-scan their namespaces.
2024-08-17 18:50:10 -04:00
Jacob Young
2b05e85107
Merge pull request #21111 from jacobly0/self-dwarf
Dwarf: debug info progress
2024-08-17 18:47:27 -04:00
Forest
cf939b096a cmake: CLANG_LIBRARIES: find libclang-cpp.so.18.1
This fixes the failure to find CLANG_LIBRARIES on debian, which packages
the relevant .so file at these paths:

libclang-cpp18: /usr/lib/llvm-18/lib/libclang-cpp.so.18.1
libclang-cpp18: /usr/lib/x86_64-linux-gnu/libclang-cpp.so.18.1
libclang-cpp18: /usr/lib/x86_64-linux-gnu/libclang-cpp.so.18

(The latter two paths are symlinks to the first.)
2024-08-17 13:15:32 -07:00
Jakub Konka
5d2bf96c02
Merge pull request #21098 from ziglang/macho-zig-got
macho: replace __got_zig with distributed jump table
2024-08-17 17:17:01 +02:00
Jacob Young
d4e3d0e676 Dwarf: fix and test error unions 2024-08-17 09:27:15 -04:00
Jacob Young
f601aa780e Dwarf: fix and test allowzero pointers 2024-08-17 05:57:45 -04:00
Jakub Konka
df9ac485da codegen: fix rebase gone wrong 2024-08-17 08:31:16 +02:00
Jakub Konka
96441bd829 macho: update codegen and linker to distributed jump table approach 2024-08-17 08:14:38 +02:00
Jacob Young
bb70501060
Merge pull request #21078 from jacobly0/new-dwarf
Dwarf: rework self-hosted debug info from scratch
2024-08-17 01:15:04 -04:00
Jacob Young
ed19ecd115 Coff: fix missing error lazy symbols 2024-08-16 16:23:53 -04:00
Jacob Young
e9df5ab7f1 std: disable failing debug info test for self-hosted 2024-08-16 16:23:53 -04:00
Jacob Young
0ecf0cf867 x86_64: fix debug arg spills clobbering other args 2024-08-16 15:22:56 -04:00
Jacob Young
00ca818805 Dwarf: incremental also needs end_sequence
The spec says that addresses can only increase within a sequence, so
every decl must be a separate sequence since they are not sorted.
2024-08-16 15:22:56 -04:00
Jacob Young
ad634537ce x86_64: move end of prologue to after function arguments are spilled
This prevents the first step in to a function from displaying bogus
argument values.
2024-08-16 15:22:56 -04:00
Jacob Young
7a0acc8be6 Dwarf: fix cross-module inline function line info 2024-08-16 15:22:56 -04:00
Jacob Young
ef11bc9899 Dwarf: rework self-hosted debug info from scratch
This is in preparation for incremental and actually being able to debug
executables built by the x86_64 backend.
2024-08-16 15:22:55 -04:00
Jakub Konka
90989be0e3
Merge pull request #21065 from ziglang/elf-zig-got
elf: replace .got.zig with a zig jump table
2024-08-16 21:19:44 +02:00
David Rubin
f1eed99f3d
add an error for stack allocations in naked functions (#21082)
closes #72
2024-08-16 09:41:58 -07:00
Jakub Konka
73f385eec5
Update src/arch/x86_64/CodeGen.zig
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
2024-08-16 11:49:23 +02:00
Jacob Young
624016e8f3 riscv64: fix incorrect branch target 2024-08-16 05:44:55 -04:00
Andrew Kelley
11176d22f8
Merge pull request #21073 from alexrp/test-changes
`test`: QoL for port work, more mips re-enablement
2024-08-15 22:23:48 -07:00
Andrew Kelley
05c7968920
Merge pull request #21020 from alexrp/target-fixes
`std.Target`: Assorted corrections, plus cleanup around ELF/COFF machine types
2024-08-15 22:13:31 -07:00
Andrew Kelley
b917d778c6
Merge pull request #21056 from alexrp/start-fix-precedence
`start`: Avoid string concatenation in inline asm.
2024-08-15 22:10:59 -07:00