30685 Commits

Author SHA1 Message Date
Jens Goldberg
af007ec1ff std.os.linux: Add support for AF_PACKET V3 2024-08-19 15:01:58 +02:00
Matthew Lugg
54e48f7b7d
Merge pull request #21128 from mlugg/incremental
incremental: more progress
2024-08-19 06:30:54 +01:00
Andrew Kelley
c6677be53b llvm: disable instrumentation in naked functions
closes #21130
2024-08-18 20:36:27 -07:00
Andrew Kelley
93ba960e3b
Merge pull request #21127 from jacobly0/self-dwarf
Dwarf: more progress
2024-08-18 18:43:28 -07:00
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
Jacob Young
9a64b80377 Dwarf: test enums 2024-08-18 16:21:11 -04:00
Jacob Young
49e6041391 Dwarf: fix and test unions 2024-08-18 16:21:10 -04:00
mlugg
de49a9a173
Zir: add instructions to fetch std.builtin types
This replaces the constant `Zir.Inst.Ref` tags (and the analagous tags
in `Air.Inst.Ref`, `InternPool.Index`) referring to types in
`std.builtin` with a ZIR instruction `extended(builtin_type(...))` which
instructs Sema to fetch such a type, effectively as if it were a
shorthand for the ZIR for `@import("std").builtin.xyz`.

Previously, this was achieved through constant tags in `Ref`. The
analagous `InternPool` indices began as `simple_type` values, and were
later rewritten to the correct type information. This system was kind of
brittle, and more importantly, isn't compatible with incremental
compilation of std, since incremental compilation relies on the ability
to recreate types at different indices when they change. Replacing the
old system with this instruction slightly increases the size of ZIR, but
it simplifies logic and allows incremental compilation to work correctly
on the standard library.

This shouldn't have a significant impact on ZIR size or compiler
performance, but I will take measurements in the PR to confirm this.
2024-08-18 18:10:59 +01:00
mlugg
a239d8d4e2
test: add incremental case 2024-08-18 18:10:59 +01:00
mlugg
b745fee1f8
frontend: handle incremental updates of replaced runtime functions 2024-08-18 18:10:59 +01:00
mlugg
93a5bd262d
frontend: removed resolved IES data for outdated functions
Without this, incremental updates which would change inferred error sets
fail, since they assume the IES is resolved and equals the old set,
resulting in false positive compile errors when e.g. coercing to an IES.
2024-08-18 18:10:59 +01:00
Alex Rønne Petersen
1045537141 Revert "ci: Enable -Dtest-slow-targets."
This reverts commit 55cc9dda66a24ed2a86a358533ecf5840d47b3d7.
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