28690 Commits

Author SHA1 Message Date
Jakub Konka
c7ed7c4690 elf: generate section symbols when writing symtab 2023-11-07 13:31:31 +01:00
Jakub Konka
3df53d1722 elf: create skeleton of required changes for supporting -r mode 2023-11-07 11:19:55 +01:00
Matthew Lugg
b3462b7cec
Merge pull request #17692 from kcbanner/struct_field_init_pass
sema: analyze struct field bodies in a second pass, to allow them to use the layout of the struct itself
2023-11-07 07:44:32 +00:00
mlugg
d78eda34c5 Sema: emit @intCast safety check correctly for vectors
This code was previously tripping an assertion by not making this value
used in the safety check a vector.
2023-11-07 06:42:15 +00:00
mlugg
9b394a200a Sema: allow destructuring vectors
This was intended to work when destructuring was first implemented, and
was just unintentionally missed out.
2023-11-07 06:11:01 +00:00
Jakub Konka
bf0387b6bb
Merge pull request #17873 from ziglang/elf-archive
elf: implement archiving input object files
2023-11-07 03:22:14 +01:00
Adam Goertz
db785e25b9 Apply same reductions to while 2023-11-07 01:24:19 +00:00
kcbanner
1acb6a53d0
wasm: support rendering unions using their backing type if they have no defined tag type 2023-11-07 00:49:39 +00:00
kcbanner
35c86984a6
cbe: support rendering union values that have no defined tag type
This was regressed in d657b6c0e2ab7c47f5416dc4df1abb2bfbecd4b6, when
the comptime memory model for unions was changed to allow them to have
no defined tag type.
2023-11-07 00:49:39 +00:00
kcbanner
f10499be0a
sema: analyze field init bodies in a second pass
This change allows struct field inits to use layout information
of their own struct without causing a circular dependency.

`semaStructFields` caches the ranges of the init bodies in the `StructType`
trailing data. The init bodies are then resolved by `resolveStructFieldInits`,
which is called before the inits are actually required.

Within the init bodies, the struct decl's instruction is repurposed to refer
to the field type itself. This is to allow us to easily rebuild the inst_map
mapping required for the init body instructions to refer to the field type.

Thanks to @mlugg for the guidance on this one!
2023-11-07 00:49:35 +00:00
Andrew Kelley
234693bcbb tests: skip native CPU std tests on Windows
See tracking issue #17902
2023-11-06 16:03:04 -07:00
XXIV
5ea973dc39 langref: fix malloc return type 2023-11-06 23:46:17 +02:00
Jakub Konka
261db02018 CheckObject: support parsing and dumping archive symtab for ELF 2023-11-06 21:18:26 +01:00
Jacob Young
9ced27dace x86_64: fix passing register-sized payload as non-reigster-sized union
Closes #17885
2023-11-06 14:11:31 -05:00
Bogdan Romanyuk
62e67a2b56
Sema: emit error when pointer to extern function is called 2023-11-06 15:26:28 +00:00
Jakub Konka
6490e2ed82 test/link/elf: improve test linking with static lib 2023-11-06 14:47:01 +01:00
Jakub Konka
1b69b0c621 elf: clearly separate updating and writing symtab from only ZigObject 2023-11-06 14:26:35 +01:00
Jakub Konka
281dabaa88 Compilation: unconditionally close open file handles for writable dance 2023-11-06 13:47:39 +01:00
Andrew Kelley
e74ced21b7 frontend: fix -fsingle-threaded default detection logic
The logic in 509be7cf1f10c5d329d2b0524f2af6bfcabd52de assumed that
`use_llvm` meant that the LLVM backend would be used, however, use_llvm
is false when there are no zig files to compile, which is the case for
zig cc. This logic resulted in `-fsingle-threaded` which made libc++
fail to compile for C++ code that includes the threading abstractions
(such as LLVM).
2023-11-06 01:16:09 -05:00
kcbanner
50e2fb8fd0 cbe: fixup __asm style exports, re-enable 12680 on macos now that alias isn't used 2023-11-05 23:36:11 -05:00
Adam Goertz
91570cc42d zig-reduce: Reduce if expressions
Perform these transformations in this priority order:
1. If the `else` expression is missing or an empty block, replace the condition with `if (true)` if it is not already.
2. If the `then` block is empty, replace the condition with `if (false)` if it is not already.
3. If the condition is `if (true)`, replace the `if` expression with the contents of the `then` expression.
4. If the condition is `if (false)`, replace the `if` expression with the contents of the `else` expression.
2023-11-06 04:31:55 +00:00
kcbanner
8c0e0cd353 cbe: skip std.math.lerp test that fails when compiler_rt fma is used 2023-11-05 20:34:16 -05:00
kcbanner
a4526d260b cbe: fix builtins not being used by zig_import when they are available 2023-11-05 20:34:13 -05:00
kcbanner
26dabbf301 cbe: handle underscore prexfix on macos, don't mangle extern function names 2023-11-05 20:34:13 -05:00
kcbanner
192e9a315d cbe: add DeclVisibility and zig_extern_mangled to handle exporting mangled symbols under a different name 2023-11-05 20:34:13 -05:00
kcbanner
ce293c982e cbe: avoid collisions with builtins and intrinsics
Changes:
- Add `isMangledIdent` to determine if `fmtIdent` would make any edits to the identifier
- Any function that has a mangled identifier is referred to using the mangled identifer
  within the current file, but if it is exported the first export will be with the non-mangled name.
- Add `zig_import` to import a symbol under a different name
- Add a level of indirection to float function names. Now, they are referred to as
  `zig_float_fn_<float type>_<operation>`. The definitions in zig.h are wrapped
  with `zig_import` to import the symbol under the real name.

The specific problem that sparked this change was the combination of
`zig_libc_name_f80(name) __##name##x` with the input `fma`, resulting
in `__fmax`, which is a new intrinsic in recent versions of cl.exe.

With the above changes in place, compiler_rt can output the following:

```
static zig_weak_linkage_fn zig_f80 zig_e___fmax(zig_f80, zig_f80, zig_f80);
zig_export(zig_weak_linkage_fn zig_f80 zig_e___fmax(zig_f80, zig_f80, zig_f80), __fmax, "__fmax");
```

Within compiler_rt, `zig_e___fmax` is used to refer to the function, but consumers
will import `__fmax`, which maps to their `zig_float_fn_f80_fma` definition from zig.h.
2023-11-05 20:34:13 -05:00
kcbanner
58789cb054 Revert "CI: disable MSVC C backend checks"
This reverts commit 7c5d01b95e3cb47187726c52dae4abb2e5b4faaf.
2023-11-05 20:34:13 -05:00
Andrew Kelley
1b0b46a8a9
Merge pull request #17871 from jacobly0/x86_64
x86_64: get a compiler compiled with the x86_64 backend passing x86_64 backend tests
2023-11-05 18:45:21 -05:00
Andrew Kelley
702b809ea3
Merge pull request #17815 from Luukdegram/wasm-no-entry
wasm-linker: implement `-fno-entry` and correctly pass `--shared` and `--pie` when given
2023-11-05 18:44:12 -05:00
Igor Anić
bec36aa7c0 io_uring: add multishot accept operation
Server networking application typically accept multiple connections. Multishot
accept simplifies handling these situations. Applications submits once and
receives CQE whenever a new connection request comes in.

Multishot is active until it is canceled or experience error. While active, and
further notification are expected CQE completion will have IORING_CQE_F_MORE set
in the flags. If this flag isn't set, the application must re-arm this request
by submitting a new one.

Reference: [io_uring and networking in 2023](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#multi-shot)
2023-11-06 00:12:39 +02:00
Jacob Young
0ea7189c23 behavior: enable test passing with x86_64 backend 2023-11-05 11:54:29 -05:00
Jacob Young
c2cda947c9 src: fix memory leaks 2023-11-05 11:54:29 -05:00
Jacob Young
7b9f8782c8 build: add option to specify whether to use the llvm backend 2023-11-05 09:30:28 -05:00
Jakub Konka
205f8214d8 test/link/elf: enable our ELF archiver 2023-11-05 13:42:26 +01:00
Jakub Konka
8142925c7e elf: hook up saving object files in an archive 2023-11-05 13:37:13 +01:00
Jakub Konka
55fa8a04f1 elf: add hooks for archiving Objects 2023-11-05 12:56:17 +01:00
Jakub Konka
5c48236103 elf: init objects after parsing them 2023-11-05 12:37:15 +01:00
Jacob Young
8311fac7e8 x86_64: fix indirect return of f80 2023-11-05 06:09:06 -05:00
Jakub Konka
8d7ec05070 elf: actually save correct object names in the archive 2023-11-05 12:08:15 +01:00
Jacob Young
803ea10107 x86_64: fix tracking during br 2023-11-05 06:08:06 -05:00
Bogdan Romanyuk
e9a6197a8e
Sema: fix error notes with wrong extern type 2023-11-05 12:36:06 +02:00
Andrew Kelley
33644546a0 Sema: fix memory leak in zirTypeInfo 2023-11-05 04:48:34 -05:00
Andrew Kelley
dc63426b1e
Merge pull request #17866 from ziglang/reduce-inline-import
zig reduce: support inlining `@import` and more
2023-11-05 03:39:01 -05:00
Andrew Kelley
a9002156a0 zig reduce: add reduction for removing var decls 2023-11-04 20:27:15 -07:00
Andrew Kelley
c4dddcbadb std.zig.render: ability to omit variable declarations 2023-11-04 20:26:39 -07:00
Andrew Kelley
e93d3a3cdb zig reduce: don't try to remove discard statements
those are handled separately
2023-11-04 19:27:46 -07:00
Andrew Kelley
9e81222d92 zig reduce: some adjustments to make it go faster
* don't reset the rng. it seems like it was getting stuck trying the
  same transforms over and over again.
* slide the window over after failing a large transform set, idea being
  that transformations in the failed set are more likely to be
  problematic.
2023-11-04 18:48:08 -07:00
Andrew Kelley
88acdb9aa6 zig reduce: delete statements from blocks 2023-11-04 18:06:11 -07:00
Andrew Kelley
212aa717d7 zig reduce: add transformation for removing container fields 2023-11-04 17:57:43 -07:00
Andrew Kelley
75efb736ce zig reduce: run results through astgen
and use that to fix up usused variable declarations and parameters that
are caused by transformations.

also add a transformation to replace global variable init with
`undefined`.
2023-11-04 17:38:10 -07:00