29095 Commits

Author SHA1 Message Date
Jacob Young
33c3bf0631 cmake: make static curses configurable
Not sure why this exists in the first place, but disabling it reduces
the required dependencies of a CI runner.
2024-05-22 07:01:21 -07:00
Jacob Young
2563d32425 fs: handle OBJECT_NAME_COLLISION in makeOpenPath
This fixes a race condition when two threads/processes try to
`makeOpenPath` the same path simultaneously.
2024-05-22 07:01:14 -07:00
mlugg
33809a0c53 InternPool: eliminate var_args_param_type
This was a "fake" type used to handle C varargs parameters, much like
generic poison. In fact, it is treated identically to generic poison in
all cases other than one (the final coercion of a call argument), which
is trivially special-cased. Thus, it makes sense to remove this special
tag and instead use `generic_poison_type` in its place. This fixes
several bugs in Sema related to missing handling of this tag.

Resolves: #19781
2024-05-22 07:01:07 -07:00
Jacob Young
2648e3651e link: restore lost passthrough behavior
Fixes bug introduced by 3b5be9fb6e06f6494ca05fb087a2121e220beb3f
2024-05-22 07:00:19 -07:00
Jacob Young
d09afc08da lld: use a response file on NameTooLong 2024-05-22 06:59:22 -07:00
Ryan Liptak
ddde99bdfa Build system: Allow specifying Win32 resource include paths using LazyPath
Adds an `include_paths` field to RcSourceFile that takes a slice of LazyPaths. The paths are resolved and subsequently appended to the -rcflags as `/I <resolved path>`.

This fixes an accidental regression from https://github.com/ziglang/zig/pull/19174. Before that PR, all Win32 resource compilation would inherit the CC flags (via `addCCArgs`), which included things like include directories. After that PR, though, that is no longer the case.

However, this commit intentionally does not restore the previous behavior (inheriting the C include paths). Instead, each .rc file will need to have its include paths specified directly and the include paths only apply to one particular resource script. This allows more fine-grained control and has less potentially surprising behavior (at the cost of some convenience).

Closes #19605
2024-05-22 06:58:09 -07:00
reokodoku
f2110b0c0d Change std.os to std.posix in error messages 2024-05-22 06:57:16 -07:00
Anton Lilja
7ce03acb9d LLVM: Fix panic when using tagged union backed by enum with negative values 2024-05-22 06:56:49 -07:00
Antonio Gomes
c3aa32e984 Sema: Don't generate runtime instructions on zirSplat if dest_ty doesn't have runtime bits 2024-05-22 06:56:30 -07:00
Igor Anić
efe06c5f31 std.tar: fix finding tar root_dir (#19829)
For issue #19820.
2024-05-01 12:05:29 -07:00
Jacob Young
7b908cb024 cbe: fix ub with integer @abs 2024-05-01 12:05:25 -07:00
Andrew Kelley
16d3f7b2fa std.Build.Step.CheckObject: fix parseDumpNames
This function incorrectly assumed that module name subsections, function
name subsections, and local name subsections are encoded the same,
however according to
[the specification](https://webassembly.github.io/spec/core/appendix/custom.html)
they are encoded differently.

This commit adds support for parsing module name subsections correctly,
which started appearing after upgrading to LLVM 18.
2024-05-01 12:05:20 -07:00
Andrew Kelley
fa5011aa31 C backend: avoid memcpy when len=0
As of Clang 18, calling memcpy() with a misaligned pointer trips UBSAN,
even if the length is zero. This unfortunately includes any call to
`@memcpy` when source or destination are undefined and the length is
zero.

This patch makes the C backend avoid calling memcpy when the length is
zero, thereby avoiding undefined behavior.

A zig1.wasm update will be needed in the llvm18 branch to activate this
code.
2024-05-01 12:05:12 -07:00
Alain Greppin
595a7f8b08 NetBSD: avoid ldd error on executables. zig cc produce 4 PT_LOAD segments,
wheras on NetBSD, only 2 PT_LOAD are usually produced by other compilers
(tested with host gcc and clang).

    $ ldd -v main_4segs
    .../main_4segs: wrong number of segments (4 != 2)
    .../main_4segs: invalid ELF class 2; expected 1
2024-05-01 12:05:05 -07:00
daurnimator
6c482b8033 test/link/glibc_compat: fix incorrect strlcpy result 2024-05-01 12:04:52 -07:00
Julian
ad63be7eb9 Sema+llvm: properly implement Interrupt callconv
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2024-05-01 12:04:44 -07:00
Alexandre Janon
704f8f4013 Fix ELF alignment for freestanding targets (#19766)
* Fix the ELF binaries for freestanding target created with the self-hosted linker.

    The ELF specification (generic ABI) states that ``loadable process segments must have congruent
    values for p_vaddr and p_offset, modulo the page size''. Linux refuses to load binaries that
    don't meet this requirement (execve() fails with EINVAL).
2024-05-01 12:04:19 -07:00
zhylmzr
ef9fb428b7 fix: object size error in archive 2024-05-01 12:04:03 -07:00
Andrew Kelley
600b652825 Merge pull request #19698 from squeek502/windows-batbadbut
std.process.Child: Mitigate arbitrary command execution vulnerability on Windows (BatBadBut)
2024-04-24 13:50:29 -07:00
Ryan Liptak
e36bf2baff windows.GetFinalPathNameByHandle: Support volumes mounted as paths
A volume can be mounted as a NTFS path, e.g. as C:\Mnt\Foo. In that case, IOCTL_MOUNTMGR_QUERY_POINTS gives us a mount point with a symlink value something like `\??\Volume{383da0b0-717f-41b6-8c36-00500992b58d}`. In order to get the `C:\Mnt\Foo` path, we can query the mountmgr again using IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH.

Fixes #19731
2024-04-24 13:45:36 -07:00
IntegratedQuantum
4babedf1be Clarify the blocking behavior of RwLock.lockShared(). (#19752) 2024-04-24 13:45:29 -07:00
Sean
0dc64d9064 Update fmt.zig tests
Changed uses of `std.testing.expect` to `std.testing.expectEqual`, `std.testing.expectError`, and `std.testing.expectEqualStrings` where appropriate
2024-04-24 13:45:18 -07:00
Andrew Kelley
5d29b9fad6 CI: enable builds of 0.12.x branch 2024-04-23 17:23:29 -07:00
Eric Joldasov
6de152ec7c std.zig.system: fix ELF file search
* Adjust buffer length a bit.
 * Fix detecting if file is a script. Logic below was unreachable,
 because 99% of scripts failed "At least 255 bytes long" check and were detected as ELF files.
 It should be "At least 4" instead (minimum value of "ELF magic length" and "smallest possible interpreter path length").
 * Fix parsing interpreter path, when text after shebang:
     1. does not have newline,
     2. has leading spaces and tabs,
     3. separates interpreter and arguments by tab or NUL.
 * Remove empty error set from `defaultAbiAndDynamicLinker`.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-04-23 17:22:04 -07:00
clickingbuttons
cc25f75478 std.crypto: make ff.ct_unprotected.limbsCmpLt compile (#19741)
* std.crypto: make ff.ct_unprotected.limbsCmpLt compile

* std.crypto: add ff.ct test

* fix testCt to work on x86

* disable test on stage2-c

---------

Co-authored-by: Frank Denis <124872+jedisct1@users.noreply.github.com>
2024-04-23 17:17:02 -07:00
David Rubin
eb28c8aa35 error on undefined end index 2024-04-23 17:16:54 -07:00
Frank Denis
f6773232ac Fix WASI threads, again
Properly call the entrypoint when it doesn't return an optional error,
and use the per-thread copy of the arguments list.
2024-04-23 17:16:08 -07:00
Jacob Young
9deea9b1d8 x86_64: fix C abi for unions
Closes #19721
2024-04-23 17:16:03 -07:00
Jakub Konka
8e0a802ea1 link/macho: make --verbose-link represent the actual linker line 2024-04-23 17:15:47 -07:00
Jakub Konka
eb5d67b146 Merge pull request #19714 from ziglang/elf-merge-strings
link/elf: implement string merging
2024-04-23 17:14:03 -07:00
Jakub Konka
082e5091af Merge pull request #19710 from jacobly0/elf-segment-align
Elf: fix unaligned segments on non-linux
2024-04-23 17:13:22 -07:00
Jared Baur
3b1f9b476c Fix usage of unexpectedErrno
`unexpectedErrno` comes from `std.posix`, not `std.os`.
2024-04-23 17:12:24 -07:00
Marco F
2478b5bb0e update list of missing features in no-LLVM built zig2 2024-04-23 17:12:07 -07:00
Linus Groh
7974576967 std.fs.Dir.openDir: use wasi libc API when -lc
Same as #19680 but for directories.
2024-04-23 17:11:48 -07:00
Andrew Kelley
011a78325e start the 0.12.1 release cycle 2024-04-23 17:10:15 -07:00
Andrew Kelley
a685ab1499 Release 0.12.0 0.12.0 2024-04-19 14:00:35 -07:00
GethDW
db96ad4a16 std: fix Thread.Pool.spawn
`@alignCast` was required for args with greater alignment than that of a pointer.
2024-04-19 13:49:06 -07:00
Andrew Kelley
844da16d8e update .mailmap
keeps our contributor count in the release notes somewhat accurate
2024-04-19 13:16:09 -07:00
Jacob Young
ebce190321 llvm: fix debug info when running tests 2024-04-19 12:13:29 -07:00
Meghan Denny
f03829a2da
define std.crypto.sha2.Sha512224 (#19697)
* define std.crypto.sha2.Sha512224

* rename blunder

* add sha512-224 and sha512-256 tests

* fix Sha2x64 for variations that aren't a multiple of 64 bits
2024-04-19 14:50:46 +00:00
cryptocode
3adfaf91f7 The Mach-O header flags gained two new members at some point, and these are missing in the Zig std library. This PR adds these.
The macOS libc header is already up-to-date: 130fb5cb0f/lib/libc/include/any-macos-any/mach-o/loader.h (L232-L241)
2024-04-18 20:08:03 -07:00
Andrew Kelley
d06e5b4349 std.fs.Dir.openFile: use wasi libc API when -lc
Also removes the LOCK namespace from std.c.wasi because wasi libc does
not have flock.

closes #19336
related to #19352

Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
2024-04-18 17:49:05 -07:00
Andrew Kelley
3c221463fd
Merge pull request #19689 from nektro/nektro-patch-29794
std: fix and add test for Build.dependencyFromBuildZig
2024-04-18 16:38:11 -07:00
Jacob Young
544397ce6d
Merge pull request #19649 from ziglang/x86_64-windows-ci
ci: add self-hosted `x86_64 windows`
2024-04-18 19:13:29 -04:00
Erik Arvstedt
130fb5cb0f cmake: support setting the dynamic linker 2024-04-18 12:16:24 -07:00
Meghan Denny
1b4ea80654
do more robust import
Co-authored-by: Carl Åstholm <carl@astholm.se>
2024-04-18 11:24:42 -07:00
Meghan Denny
0820aa4a46 std: fix and add test for Build.dependencyFromBuildZig 2024-04-18 03:07:44 -07:00
Andrew Kelley
22a97cd235 std.Build: revert --host-target, --host-cpu, --host-dynamic-linker
This is a partial revert of 105db13536b4dc2affe130cb8d2eee6c97c89bcd.

As we learned from Void Linux packaging, these options are not actually
helpful since the distribution package manager may very well want to
cross-compile the packages that it is building.

So, let's not overcomplicate things. There are already the standard
options: -Dtarget, -Dcpu, and -Ddynamic-linker.

These options are generally provided when the project generates machine
code artifacts, however, there may be a project that does no such thing,
in which case it makes sense for these options to be missing. The Zig
Build System is a general-purpose build system, after all.
2024-04-18 03:02:13 -07:00
mlugg
21a6a1b0f2 Sema: cap depth of value printing in type names
Certain types (notably, `std.ComptimeStringMap`) were resulting in excessively
long type names when instantiated, which in turn resulted in excessively long
symbol names. These are problematic for two reasons:

* Symbol names are sometimes read by humans -- they ought to be readable.
* Some other applications (looking at you, xcode) trip on very long symbol names.

To work around this for now, we cap the depth of value printing at 1, as opposed
to the normal 3. This doesn't guarantee anything -- there could still be, for
instance, an incredibly long aggregate -- but it works around the issue in
practice for the time being.
2024-04-17 22:47:54 -07:00
David Rubin
187f0c1e26
Sema: correctly make inferred allocs constant
Resolves: #19677
2024-04-18 04:45:14 +00:00