Previously `AF_UNSPEC` was passed unconditionally to `getaddrinfo`.
This specifies `AF_INET` or `AF_INET6` depending on the value of
HostName.LookupOptions.family.
`AF_UNSPEC` is still set by default (when family == null).
If the `getSize` inside `fileWriteFileStreaming` returns an error, two cases can happen:
- If was canceled, it will return 0, which will make the calling function repeat it, in which case the cancellation is lost
- If it truly returned an error, it will return 0, in which case the calling function will repeat the call and most likely `getSize` will fail again, resulting in an infinite loop
Co-authored-by: Lukas Lalinsky <[email protected]>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36140
Reviewed-by: mlugg <[email protected]>
Follow-up to 9aa93a045e, which fixed this
bug for *shared* library inputs, but not *static* library inputs.
Supersedes https://codeberg.org/ziglang/zig/pulls/31383 by fixing the
bug at the compiler level instead of working around it in the build
system. This seems preferable because it is useful to the compiler to
have full information about a compilation's link inputs---for instance
this could interact with https://github.com/ziglang/zig/issues/20654 in
the future by having the compiler learn about a static library's ABI
even if that static library does not ultimately contribute to the link.
Resolves: https://codeberg.org/ziglang/zig/issues/35624
This logic was not properly implemented when switching to `@memmove` from `mem.copyForwards` in ab4028d579
Before this commit, these lines were guaranteed to panic with `source and destination arguments have non-equal lengths`
this will enable test passing on all linux kernels (particularly WSL)
without version checks and making `skipKernelLessThan` redundant
closes https://github.com/ziglang/zig/pull/24042
Signed-off-by: Bernard Assan <[email protected]>
Technically there is one valid use case for `fieldNames` which is use
with an enum or union so that those types can be used interchangeably.
But in practice these functions are mainly abused, because the callsites
always know what kind of type it is.
This commit encourages Zig users to embrace using `@typeInfo` directly
when doing type reflection.
This needs to return the offset from TP for the variable, which will be negative
because this is TLS variant II. This ABI does not use __tls_get_addr at all, so
it's best not to even export it, as that will help catch bad code.
If I had to guess, `Sema.zirRoundOpType` was probably written when `@trunc` etc. could only have a float as their destination type. As a result, for the ints they can cast to now, they'd expect the expression inside them to be a `comptime_float`, which made `@trunc(@floor(runtime_float))` or `@trunc(@floatFromInt(runtime_int))` impossible.
By changing the returned type in this case to be generic poison, showing we don't know the expected type as *any* float can be converted to an int, `@trunc(@floor(runtime_float))` lowers to effectively `@floor(runtime_float)` and `@trunc(@floatFromInt(runtime_int))` throws the expected error that `@floatFromInt`'s result type is unknown here.
Fixes: https://codeberg.org/ziglang/zig/issues/32111
Co-authored-by: rue04 <[email protected]>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35664
Timeout.none implicitly seems to mean indefinitely nearly
everywhere I can see. However, Io.Threaded.sleep() has a
short-circuit at the top which treats Timeout.none as effectively
zero (no sleep at all), even though the per-target functions it
calls afterwards would otherwise would honor .none correctly.
This patch removes this (presumably erronenous) short-circuit and
documents Timeout.none's meaning explicitly.
This provides a way to forward, e.g. the `-fqemu` argument from
`zig build` to a child process during Maker execution without providing
the information to the configuration logic.
Configuration logic, in general, should not try to guess whether an
executable will be able to be run on the host. This can only be
determined by trying to, and encountering failure, for example because
binfmt_misc might be installed. OS might handle illegal instruction
traps and emulate CPU features not available, etc.
skip_foreign_checks is the mechanism intended to handle this use case.
These were originally intended to tell the configure script whether or
not those third party integrations were enabled.
This is now a problem because we want to produce a configuration file
that is indendent of whether such external integrations will be enabled,
so that the logic does not need to be re-executed when those flags are
changed on the command line.
If we wish to make this feature interact with the configure script, let
us consider carefully how to add it in a future enhancement, and not
leave these dead fields sitting around in the meantime.
closes#35607
Fixes#31797
I finally had time to work on this.
I've implemented it so that, when an adjacent dSYM exist and its uuid match that of the current binary, we load its DWARF and use that for all getDwarfForAddress requests.
All of this is done eagerly at `MachOFile.load` for simplicity rather than later and lazier. Happy to change that to whatever you think is best.
This implementation is quite minimal and makes dSYM support "best-effort" as in, it treats dSYM parsing error as non-fatal and fallbacks using the current stabs/ofiles mechanism.
You can test it that way on macOS:
```
zig build-exe panic.zig
dsymutil panic -o panic.dSYM
strip -S panic
./panic
```
with panic.zig:
```
pub fn main() void {
@panic("panic");
}
```
Before:
```
thread 57569166 panic: panic
???:?:?: 0x103071c2b in _panic.main (/private/tmp/panic)
???:?:?: 0x103071bb3 in _main (/private/tmp/panic)
???:?:?: 0x180d5ab97 in start (/usr/lib/dyld)
fish: Job 1, './panic' terminated by signal SIGABRT (Abort)
```
After:
```
thread 57569653 panic: panic
/private/tmp/panic.zig:2:5: 0x1029d771b in main (panic)
@panic("panic");
^
/Users/cerisier/code/codeberg.org/ziglang/zig/lib/std/start.zig:698:59: 0x1029d76a3 in callMain (panic)
if (fn_info.params.len == 0) return wrapMain(root.main());
^
???:?:?: 0x180d5ab97 in start (/usr/lib/dyld)
fish: Job 1, './panic' terminated by signal SIGABRT (Abort)
```
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35582
Reviewed-by: mlugg <[email protected]>
In legalization for packed struct init with an OPV field, we first try
to see if any field accounts for the entire bit size of the struct and
otherwise fall back to a sequence of bitcasts and shifts on each field
(added in fc1c83a363). However, OPV fields are not accounted for
in the fallback case, which means that codegen eventually panics when
seeing the bit size of 0.
This change makes it so that we ignore all OPV fields in
`packedAggregateInitBlockPayload` since they have no runtime bits.
ArrayList:
- `getLastOrNull` has been deprecated and renamed to `last`
- `getLast` has been removed in favor of `last` combined with `.?`
- `lastPtr` has been added which returns `?*T`
Upgrade guide:
```zig
if (list.getLastOrNull()) |foo| {
// ...
}
const foo = list.getLast();
```
⬇️
```zig
if (list.last()) |foo| {
// ...
}
const foo = list.last().?;
```
Co-authored-by: Ryan Liptak <[email protected]>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36318
Reviewed-by: Ryan Liptak <[email protected]>