33013 Commits

Author SHA1 Message Date
David Rubin
f2c838d2cf
Sema: increment extra index even if return type is generic 2025-04-02 08:43:28 +02:00
Ali Cheraghi
edaa9584cc
zon: normalize negative zeroes 2025-04-02 08:43:21 +02:00
mlugg
f5e7850686
Sema: allow @ptrCast slice of zero-bit type to slice of non-zero-bit type
This is actually completely well-defined. The resulting slice always has
0 elements. The only disallowed case is casting *to* a slice of a
zero-bit type, because in that case, you cna't figure out how many
destination elements to use (and there's *no* valid destination length
if the source slice corresponds to more than 0 bits).
2025-04-02 08:43:13 +02:00
Parker Liu
6ecd143212
translate-c: fix referencing extern locals from nested blocks 2025-04-02 08:43:13 +02:00
Jacob Young
373ae980c0 Elf: fix incrementally reallocating the last atom in a section 2025-03-31 23:18:38 -04:00
Alex Rønne Petersen
b8d7866193
Merge pull request #23371 from alexrp/ci-redundancy
Remove some `aarch64-linux` CI steps that are already covered by `x86_64-linux`
2025-03-31 17:52:34 +02:00
Alex Rønne Petersen
4c0913ff7c
Merge pull request #23417 from dweiller/zstd-fixes
Zstd fixes
2025-03-31 17:52:23 +02:00
Simon Brown
e5ea175ffb
Add quota for comptime sort, add test 2025-03-31 17:52:16 +02:00
David Rubin
aca8ed9dec
Sema: convert slice sentinel to single pointer correctly 2025-03-31 17:36:45 +02:00
mlugg
6ac462b088
Zcu: resolve layout of analyzed declaration type
Resolves: #19888
2025-03-31 17:36:44 +02:00
Sean Stasiak
9025f73733
check result of mmap() call to handle a large base_addr value correctly 2025-03-27 21:08:23 +01:00
Alex Rønne Petersen
1423b38c45
Merge pull request #23378 from alexrp/build-zig-cleanup 2025-03-27 21:08:10 +01:00
Alex Rønne Petersen
ed6418544c
Merge pull request #23373 from alexrp/get-base-address
`std.process`: Some minor fixes for `getBaseAddress()`
2025-03-27 21:08:04 +01:00
Alex Rønne Petersen
3ae9a99f62
build: increase test-std max rss 2025-03-27 12:19:16 +01:00
Андрей Краевский
8088105b05
std.meta.FieldType -> @FieldType 2025-03-27 12:19:07 +01:00
孙冰
38a8fd5d85
std.posix: update LFS64 interfaces for android bionic C 2025-03-26 23:52:16 +01:00
Felix "xq" Queißner
3592868435
Enables parsing for '-Wl,-rpath,' in pkg-config output, allows better support for NixOS linking. 2025-03-26 23:51:58 +01:00
wooster0
27ae10afe0
linux: don't export getauxval when not required 2025-03-26 21:52:44 +01:00
Kendall Condon
f391a2cd20
Allocator.create: properly handle alignment for zero-sized types (#21864) 2025-03-26 21:52:12 +01:00
dweiller
172dc6c314
zig build: add env_map entries to hash for Step.Run
This change fixes false-positive cache hits for run steps that get run
with different sets of environment variables due the the environment map
being excluded from the cache hash.
2025-03-26 15:41:17 +01:00
Andrew Barchuk
0d65b014ea
Clarify the multidimensional array example
Use a rectangular matrix instead of a square one to distinguish rows and
columns more clearly. Extend the example with row access.
2025-03-26 15:41:14 +01:00
mlugg
27f3e8b61d
Zcu: include named tests in resolved references
Oops, a little typo from yours truly! No test for this one, because we
don't have any way of testing the reference trace.
2025-03-26 15:41:09 +01:00
Arnau Camprubí
9c857bb32d
Fix std.debug.dumpHex address offsets 2025-03-26 15:40:56 +01:00
Alex Rønne Petersen
38ececf0a7
Merge pull request #23310 from Rexicon226/fix-23309
big.int: return normalized results from `{add,sub}Carry`
2025-03-25 18:44:58 +01:00
Chris Clark
cb3eec285f
std.zig.Ast: Fix error case memory leak in parse() 2025-03-25 15:40:55 +01:00
David Rubin
598413357d
Sema: use unwrapped generic owner in getFuncInstanceIes 2025-03-25 15:24:41 +01:00
godalming123
0367d46d3c
Update the documentation comment in arena_allocator.zig to be more accurate
Update the documentation comment in arena_allocator.zig to specify that free() is a no-op unless the item is the most recent allocation.
2025-03-25 15:24:20 +01:00
孙冰
d67bf8bde3
std.c: android bionic C supports arc4random_buf and getentropy
1. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/getentropy.h
2. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/stdlib.h
2025-03-25 15:24:07 +01:00
Alex Rønne Petersen
7d8a556ba9
Merge pull request #23220 from samy-00007/bytesAsSlice-fix
Minor fix for `Allocator.remap` and `mem.bytesAsSlice` for zero-sized types
2025-03-25 15:23:08 +01:00
rpkak
1aca3dd6e0
DepTokenizer: allow space between target and colon 2025-03-24 15:31:59 +01:00
Shun Sakai
f062ec2a1a
docs(std.base64): Add references to RFC 4648
There are multiple implementations of Base64, but `std.base64` appears
to be based on RFC 4648, so we clarify that it is based on RFC 4648.
2025-03-24 15:31:58 +01:00
GasInfinity
a7cfc23e5a
fix(std/fmt.zig): fix overflow in fmtDurationSigned
fixes #23315
2025-03-24 15:31:53 +01:00
Carl Åstholm
e62a3ea74e
Use -unknown when converting WASI/Emscripten target triples into LLVM triples
The "musl" part of the Zig target triples `wasm32-wasi-musl` and
`wasm32-emscripten-musl` refers to the libc, not really the ABI.

For WASM, most LLVM-based tooling uses `wasm32-wasi`, which is
normalized into `wasm32-unknown-wasi`, with an implicit `-unknown` and
without `-musl`.

Similarly, Emscripten uses `wasm32-unknown-emscripten` without `-musl`.

By using `-unknown` instead of `-musl` we get better compatibility with
external tooling.
2025-03-24 07:04:51 +01:00
mlugg
eedfce92b0
Sema: fix in-memory coercion of functions introducing new generic parameters
While it is not allowed for a function coercion to change whether a
function is generic, it *is* okay to make existing concrete parameters
of a generic function also generic, or vice versa. Either of these cases
implies that the result is a generic function, so comptime type checks
will happen when the function is ultimately called.

Resolves: #21099
2025-03-24 07:02:05 +01:00
Jacob Young
7b9e482ed6 x86_64: fix rare miscomp that clobbers memory 2025-03-23 21:59:18 -04:00
Jacob Young
7757302c3a big.int: fix negative multi-limb shift right adjust crash 2025-03-23 21:59:12 -04:00
Jacob Young
4f47be5c6b big.int: fix yet another truncate bug
Too many bugs have been found with `truncate` at this point, so it was
rewritten from scratch.

Based on the doc comment, the utility of `convertToTwosComplement` over
`r.truncate(a, .unsigned, bit_count)` is unclear and it has a subtle
behavior difference that is almost certainly a bug, so it was deleted.
2025-03-23 21:59:07 -04:00
Jacob Young
7199a86b97 Merge pull request #23256 from xtexx/fix-gh-20113
x86_64: fix packedStore miscomp by spilling EFLAGS
2025-03-23 21:53:16 -04:00
Jacob Young
fe8bdf6f04 codegen: fix packed byte-aligned relocations
Closes #23131
2025-03-23 21:40:03 -04:00
mlugg
c71b78eb01 link: mark prelink tasks as procesed under -fno-emit-bin
The old logic only decremented `remaining_prelink_tasks` if `bin_file`
was not `null`. This meant that on `-fno-emit-bin` builds with
registered prelink tasks (e.g. C source files), we exited from
`Compilation.performAllTheWorkInner` early, assuming a prelink error.

Instead, when `bin_file` is `null`, we still decrement
`remaining_prelink_tasks`; we just don't do any actual work.

Resolves: #22682
2025-03-22 18:45:34 -07:00
Ryan Liptak
59bdd77229 Trick the meson build system into thinking zig rc is rc.exe
When determining the type of RC compiler, meson passes `/?` or `--version` and then reads from `stdout` looking for particular string(s) anywhere in the output.

So, by adding the string "Microsoft Resource Compiler" to the `/?` output, meson will recognize `zig rc` as rc.exe and give it the correct options, which works fine since `zig rc` is drop-in CLI compatible with rc.exe.

This allows using `zig rc` with meson for (cross-)compiling, by either:

- Setting WINDRES="zig rc" or putting windres = ['zig', 'rc'] in the cross-file
  + This will work like rc.exe, so it will output .res files. This will only link successfully if you are using a linker that can do .res -> .obj conversion (so something like zig cc, MSVC, lld)
- Setting WINDRES="zig rc /:output-format coff" or putting windres = ['zig', 'rc', '/:output-format', 'coff'] in the cross-file
  + This will make meson pass flags as if it were rc.exe, but it will cause the resulting .res file to actually be a COFF object file, meaning it will work with any linker that handles COFF object files

Example cross file that uses `zig cc` (which can link `.res` files, so `/:output-format coff` is not necessary) and `zig rc`:

```
[binaries]
c = ['zig', 'cc', '--target=x86_64-windows-gnu']
windres = ['zig', 'rc']

[target_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
```
2025-03-21 15:07:57 -07:00
Alex Rønne Petersen
bfc554b542 compiler: Support more GCC code models and fix the mapping to LLVM code models.
Closes #22517.
2025-03-20 13:34:04 -07:00
Alex Rønne Petersen
fbdf64a7da
mingw: Rename mingw32.lib to libmingw32.lib.
LLD expects the library file name (minus extension) to be exactly libmingw32. By
calling it mingw32 previously, we prevented it from being detected as being in
LLD's list of libraries that are excluded from the MinGW-specific auto-export
mechanism.

b9d27ac252/lld/COFF/MinGW.cpp (L30-L56)

As a result, a DLL built for *-windows-gnu with Zig would export a bunch of
internal MinGW symbols. This sometimes worked out fine, but it could break at
link or run time when linking an EXE with a DLL, where both are targeting
*-windows-gnu and thus linking separate copies of mingw32.lib. In #23204, this
manifested as the linker getting confused about _gnu_exception_handler() because
it was incorrectly exported by the DLL while also being defined in the
mingw32.lib that was being linked into the EXE.

Closes #23204.
2025-03-18 20:49:35 +01:00
Roman Frołow
74a79da4ec
typo: was issues -> was issued 2025-03-18 04:58:08 +01:00
Jonathan Gautheron
18b821666e
std.zig.c_translation: fix function pointer casting 2025-03-18 04:58:03 +01:00
mlugg
6c690a966a
Sema: correctly handle empty by-ref initializers
Resolves: #23210
2025-03-18 04:57:57 +01:00
Loris Cro
f954950485
std.Build.Watch: fix macos implementation
The code did one useless thing and two wrong things:

- ref counting was basically a noop
- last_dir_fd was chosen from the wrong index and also under the wrong
  condition

This caused regular crashes on macOS which are now gone.
2025-03-18 04:57:31 +01:00
Elijah M. Immer
f79dacbfc4
lib/std/http/Client.zig: Ignore empty proxy environment variables (#23223)
This fixes #21032 by ignoring proxy environment variables that are
empty.
2025-03-14 21:20:55 +01:00
TCROC
dc75a64c46
glibc: fix uninitialized memory in __pthread_cond_s for <=2.40
* https://sourceware.org/bugzilla/show_bug.cgi?id=32786
* https://inbox.sourceware.org/libc-alpha/87zfhpfqsm.fsf@oldenburg.str.redhat.com
2025-03-14 21:19:17 +01:00
mlugg
fdc9326868 Zcu: rename skip_analysis_errors to skip_analysis_this_update and respect it
On updates with failed files, we should refrain from doing any semantic
analysis, or even touching codegen/link. That way, incremental
compilation state is untouched for when the user fixes the AstGen
errors.

Resolves: #23205
2025-03-12 12:25:50 -07:00