Commit Graph

9934 Commits

Author SHA1 Message Date
Jakub Konka
86d8688c7f
Merge pull request #19431 from Rexicon226/revive-riscv
revive STAGE2 RISCV64 backend
2024-05-11 21:35:18 +02:00
Andrew Kelley
661a9be66b std.Build.Step.Run: add missing call to writeManifest
fixes #19938
2024-05-11 06:28:45 -07:00
David Rubin
ffb63a05a3 riscv: finally fix bug + airAggregateInit
i just hadn't realized that I placed the `riscv_start` branch in the non-simplified
starts
2024-05-11 02:17:24 -07:00
David Rubin
d9e0cafe64 riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
David Rubin
e622485df8 riscv: actually working test runner 2024-05-11 02:17:11 -07:00
David Rubin
d19b77d63f riscv: back to hello world panics 2024-05-11 02:17:11 -07:00
David Rubin
6740c1f084 riscv: big rewrite to use latest liveness
this one is even harder to document then the last large overhaul.

TLDR;
- split apart Emit.zig into an Emit.zig and a Lower.zig
- created seperate files for the encoding, and now adding a new instruction
is as simple as just adding it to a couple of switch statements and providing the encoding.
- relocs are handled in a more sane maner, and we have a clear defining boundary between
lea_symbol and load_symbol now.
- a lot of different abstractions for things like the stack, memory, registers, and others.
- we're using x86_64's FrameIndex now, which simplifies a lot of the tougher design process.
- a lot more that I don't have the energy to document. at this point, just read the commit itself :p
2024-05-11 02:17:11 -07:00
David Rubin
8ac239ebce riscv: add enough components to get a test runner working 2024-05-11 02:17:11 -07:00
David Rubin
3bf008a3d0 riscv: implement slices 2024-05-11 02:17:11 -07:00
David Rubin
350ad90cee riscv: totally rewrite how we do loads and stores
this commit is a little too large to document fully, however the main gist of it this

- finish the `genInlineMemcpy` implement
- rename `setValue` to `genCopy` as I agree with jacob that it's a better name
- add in `genVarDbgInfo` for a better gdb experience
- follow the x86_64's method for genCall, as the procedure is very similar for us
- add `airSliceLen` as it's trivial
- change up the `airAddWithOverflow implementation a bit
- make sure to not spill of the elem_ty is 0 size
- correctly follow the RISC-V calling convention and spill the used calle saved registers in the prologue
and restore them in the epilogue
- add `address`, `deref`, and `offset` helper functions for MCValue. I must say I love these,
they make the code very readable and super verbose :)
- fix a `register_manager.zig` issue where when using the last register in the set, the value would overflow at comptime.
was happening because we were adding to `max_id` before subtracting from it.
2024-05-11 02:17:11 -07:00
David Rubin
cbf62bd6dc riscv: switch default_panic to use the message 2024-05-11 02:17:11 -07:00
David Rubin
685f828218 riscv: add a custom panic function
this provides a much better indication of when we are having a controlled panic with an error message
or when we are actually segfaulting, as before the `trap` as causing a segfault.
2024-05-11 02:17:11 -07:00
David Rubin
63bbf66553 riscv: remove an allocation from dwarf.zig 2024-05-11 02:17:11 -07:00
David Rubin
3ccf0fd4c2 riscv: basic struct field access
the current implementation only works when the struct is in a register. we use some shifting magic
to get the field into the LSB, and from there, given the type provenance, the generated code should
never reach into the bits beyond the bit size of the type and interact with the rest of the struct.
2024-05-11 02:17:11 -07:00
David Rubin
2be3033acd riscv: implement basic branching
we use a code offset map in Emit.zig to pre-compute what byte offset each MIR instruction is at. this is important because they can be
of different size
2024-05-11 02:17:11 -07:00
David Rubin
28df64cba4 riscv: implement @abs
- add the `abs` MIR instruction
- implement `@abs` by shifting to the right by `bits - 1`, and xoring.
2024-05-11 02:17:11 -07:00
David Rubin
060c475fcd riscv: update start.zig and restore ra from the proper stack offset 2024-05-11 02:17:11 -07:00
David Rubin
dceff2592f riscv: initial cleanup and work 2024-05-11 02:17:11 -07:00
Dominic
1550b5b16d
astgen: fix result info for catch switch_block_err_union 2024-05-11 12:06:13 +03:00
190n
cc39ce28a1
Do not run asserts for WASI alignment when not targeting WASI 2024-05-11 07:23:07 +00:00
Lucas Santos
f71f27bcb0 Avoid unnecessary operation in PageAllocator.
There's no need to call `alignForward` before `VirtualAlloc`.
From [MSDN](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc):
```
If the lpAddress parameter is NULL, this value is rounded up to the next page boundary
```
2024-05-10 22:51:52 +03:00
Abhinav Gupta
fe1b397606
ChildProcess: document StdIo behaviors (#17553)
Add some basic documentation for the different ChildProcess.StdIo
behaviors and the fields they affect.
2024-05-10 14:05:20 +00:00
expikr
841bb0a1fd
std.os.windows: add compileError warning against TCHAR & their corresponding string/pointer types (#18741) 2024-05-10 07:48:05 +00:00
Veikka Tuominen
c4e3a49898 define an error set for std.io.tty.Config.setColor 2024-05-10 10:29:16 +03:00
Ryan Liptak
cdc0cee135 WindowsSdk: Fix every registry key being opened with KEY_WOW64_32KEY
Now, an options struct is used to determine whether or not KEY_WOW64_32KEY should be set when opening a registry key.
2024-05-09 23:15:18 -07:00
Ryan Liptak
cf8f0cdae9 WindowsSdk: Fix finding the _Instances directory when it's not in the default location
Information about installed MSVC instances are stored in `state.json` files within a `Packages/_Instances` directory. The default location for this is `%PROGRAMDATA%\Microsoft\VisualStudio\Packages\_Instances`. However, it is possible for the Packages directory to be put somewhere else. In that case, the registry value `HKLM\SOFTWARE\Microsoft\VisualStudio\Setup\CachePath` is set and contains the path to the Packages directory.

Previously, WindowsSdk did not check that registry value. After this commit, the registry value `HKLM\SOFTWARE\Microsoft\VisualStudio\Setup\CachePath` is checked first, which matches what ISetupEnumInstances does (according to a Procmon log).
2024-05-09 22:22:41 -07:00
Garfield Lee
e69caaa39f
lib/std/os/windows/kernel32: add signature for SetConsoleMode (#18715)
- From lib/libc/include/any-windows-any/wincon.h#L235
- See also https://learn.microsoft.com/en-us/windows/console/setconsolemode
- Also add DISABLE_NEWLINE_AUTO_RETURN constant which will be used by SetConsoleMode in lib/std/os/windows.

Co-authored-by: Kexy Biscuit <kexybiscuit@biscuitt.in>
2024-05-09 16:38:39 -07:00
Karl Bohlmark
6eb17a034a fix integer overflow in IoUring buffer ring size calculation 2024-05-09 16:00:01 -07:00
Pavel Verigo
d4d1efeb3e std.compress.flate: fix panic when reading into empty buffer 2024-05-09 15:51:42 -07:00
Andrew Kelley
68629fedef
Merge pull request #19918 from ziglang/xros
Add support for VisionOS
2024-05-09 15:45:42 -07:00
february cozzocrea
c9ad1b5199 aro translate-c: support for record types added 2024-05-09 13:46:50 -07:00
Jakub Konka
2e1fc0dd14 handle visionos target OS tag in the compiler
* rename .xros to .visionos as agreed in the tracking issue
* add support for VisionOS platform in the MachO linker
2024-05-09 15:04:15 +02:00
Andrew Kelley
98a30acad6 libcxxabi patch: respect NDEBUG
zig patch: respect NDEBUG. Otherwise the file path makes it into the
binary, causing non-reproducible builds.
2024-05-08 19:37:30 -07:00
Andrew Kelley
e89d6fc503 fix wrong int alignment for i65..i127 on x86 arch 2024-05-08 19:37:30 -07:00
Andrew Kelley
126c9a34af restructure unit test to be easier to debug 2024-05-08 19:37:29 -07:00
Andrew Kelley
0b31e2ab27 std.Target: add spirv to toCoffTarget 2024-05-08 19:37:29 -07:00
Andrew Kelley
b7799ef322 std.Target.maxIntAlignment: move to compiler implementation
This should not be a public API, and the x86 backend does not support
the value 16.
2024-05-08 19:37:29 -07:00
Andrew Kelley
f6f0fefd8b libc++: patch tz impl to crash on windows instead of FTBFS 2024-05-08 19:37:29 -07:00
Andrew Kelley
3c21db6392 update detectAMDProcessor to detect znver4 2024-05-08 19:37:29 -07:00
Andrew Kelley
06ee65af9e libcxx: update to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42

This adds the flag `-D_LIBCPP_HARDENING_MODE` which is determined based
on the Zig optimization mode.

This commit also fixes libunwind, libcxx, and libcxxabi to properly
report sub compilation errors.
2024-05-08 19:37:29 -07:00
Andrew Kelley
bc6ebc6f25 libcxxabi: update to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:29 -07:00
Andrew Kelley
6295415da7 libunwind: update to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:29 -07:00
Andrew Kelley
a6856ef6d2 LLVM 18 uses 16 byte alignment for x86_64 i128 2024-05-08 19:37:28 -07:00
Andrew Kelley
d34fae26d5 LLVM 18 std lib updates and fixes
* some manual fixes to generated CPU features code. In the future it
  would be nice to make the script do those automatically.

* add to various target OS switches. Some of the values I was unsure of
  and added TODO panics, for example in the case of spirv CPU arch.
2024-05-08 19:37:28 -07:00
Andrew Kelley
109ec72924 update CPU features to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:28 -07:00
Andrew Kelley
243ae3a6cb update for LLVM 18 new target data
New OSs:
* XROS
* Serenity
* Vulkan

Removed OSs:
* Ananas
* CloudABI
* Minix
* Contiki

New CPUs:
* spirv

The removed stuff is removed from LLVM but not Zig.
2024-05-08 19:37:28 -07:00
Andrew Kelley
70c85b1bf1 update C language headers to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:28 -07:00
Andrew Kelley
6bc0cef607
Merge pull request #19826 from jacobly0/outdirarg
Run: add output directory arguments
2024-05-08 19:36:11 -07:00
Jacob Young
67455c5e70 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-07 05:23:29 -04:00
Jacob Young
dee9f82f69 Run: add output directory arguments
This allows running commands that take an output directory argument. The
main thing that was needed for this feature was generated file subpaths,
to allow access to the files in a generated directory. Additionally, a
minor change was required to so that the correct directory is created
for output directory args.
2024-05-05 15:58:08 -04:00
Jacob Young
e3424332d3 Build: cleanup
* `doc/langref` formatting
 * upgrade `.{ .path = "..." }` to `b.path("...")`
 * avoid using arguments named `self`
 * make `Build.Step.Id` usage more consistent
 * add `Build.pathResolve`
 * use `pathJoin` and `pathResolve` everywhere
 * make sure `Build.LazyPath.getPath2` returns an absolute path
2024-05-05 09:42:51 -04:00
Jacob Young
d582575aba Run: add lazy path file inputs
This replaces `extra_file_dependencies` with support for lazy paths.

Also assert output file basenames are not empty, avoid improper use of
field default values, ensure stored strings are duplicated, and
prefer `ArrayListUnmanaged` to discourage misuse of direct field access
which wouldn't add step dependencies.
2024-05-05 09:42:51 -04:00
mlugg
db890dbae7 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-04 22:03:56 +01:00
Andrew Kelley
16d368d0d2 introduce std.process.raiseFileDescriptorLimit 2024-05-03 21:03:29 -07:00
Andrew Kelley
a72292513e add std.Thread.Pool.spawnWg
This function accepts a WaitGroup parameter and manages the reference
counting therein. It also is infallible.

The existing `spawn` function is still handy when the job wants to
further schedule more tasks.
2024-05-03 20:58:02 -07:00
Jonathan Marler
a96b78c170 add std.zip and support zip files in build.zig.zon
fixes #17408

Helpful reviewers/testers include Joshe Wolfe, Auguste Rame, Andrew
Kelley and Jacob Young.

Co-authored-by: Joel Gustafson <joelg@mit.edu>
2024-05-03 16:58:53 -04:00
Ryan Liptak
b86c4bde64 Rename Dir.writeFile2 -> Dir.writeFile and update all callsites
writeFile was deprecated in favor of writeFile2 in f645022d16. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-05-03 13:29:22 -07:00
Ryan Liptak
a52f12afc9 Delete compile errors for deprecated decls 2024-05-03 13:27:30 -07:00
Travis Staloch
44db92d1ca std.StaticStringMap: bump eval branch quota
closes #19803 by changing quota from (30 * N) to (10 * N * log2(N)) where
N = kvs_list.len

* adds reported adversarial test case
* update doc comment of getLongestPrefix()
2024-05-02 22:09:03 -07:00
Ryan Liptak
ea9d817a90 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-02 22:08:00 -07:00
reokodoku
8ea4283d83 Change std.os to std.posix in error messages 2024-05-03 07:49:03 +03:00
Igor Anić
d841f84b8b
std.tar: fix finding tar root_dir (#19829)
For issue #19820.
2024-05-01 12:03:05 -07:00
Jacob Young
e8dd79ca67 cbe: fix ub with integer @abs 2024-04-30 22:09:54 -07:00
Andrew Kelley
a69788ba79 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-04-30 21:13:49 -07:00
Andrew Kelley
fc45e5b39c
Merge pull request #19784 from tiehuis/simplify-hash-crc32
std.hash.crc: simplify api
2024-04-29 00:45:17 -07:00
clickingbuttons
8a36a1f913
std.crypto.hash.sha2: cleanup add add more docs (#19744)
* std.crypto.hash.sha2: generalize sha512 truncation

Replace `Sha512224`, `Sha512256`, and `Sha512T224` with
`fn Sha512Truncated(digest_bits: comptime_int)`.

This required refactoring `Sha2x64(comptime params)` to
`Sha2x64(comptime iv: [8]u64, digest_bits: comptime_int)`
for user-specified `digest_bits`.

I left #19697 alone but added a compile-time check that digest_bits is
divisible by 8.

Remove docs which restate type name. Add module docs and reference where
IVs come from.

* std.crypto.sha2: make Sha512_224 and Sha512_256 pub

* make generic type implementation detail, add comments

* fix iv

* address @jedisct1 feedback

* fix typo

* renaming

* add truncation clarifying comment and Sha259T192 tests
2024-04-28 22:22:09 +02:00
Marc Tiehuis
5f0ecafa0d std.hash.crc: update legacy crc usage in std 2024-04-28 21:12:55 +12:00
Marc Tiehuis
ef5618fcd5 std.hash.crc: simplify api
This removes the two original implementations in favour of the single
generic one based on the Algorithm type. Previously we had three, very
similar implementations which was somewhat confusing when knowing what
one should actually be used.

The previous polynomials all have equivalent variants available when
using the Algorithm type.
2024-04-28 21:12:01 +12:00
Nameless
aecd9cc6d1 std.posix.iovec: use .base and .len instead of .iov_base and .iov_len 2024-04-28 00:20:30 -07:00
Andrew Kelley
9d64332a59
Merge pull request #19698 from squeek502/windows-batbadbut
std.process.Child: Mitigate arbitrary command execution vulnerability on Windows (BatBadBut)
2024-04-24 13:49:43 -07:00
Ryan Liptak
a0f1825c53 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:44:09 -07:00
IntegratedQuantum
1a6485d111
Clarify the blocking behavior of RwLock.lockShared(). (#19752) 2024-04-24 10:41:13 -05:00
Sean
f6f7a47aad 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-23 17:57:56 -07:00
Eric Joldasov
857c1d4ff2 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:21:01 -07:00
clickingbuttons
7cf3167e98
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 20:29:36 +00:00
Ryan Liptak
422464d540 std.process.Child: Mitigate arbitrary command execution vulnerability on Windows (BatBadBut)
> Note: This first part is mostly a rephrasing of https://flatt.tech/research/posts/batbadbut-you-cant-securely-execute-commands-on-windows/
> See that article for more details

On Windows, it is possible to execute `.bat`/`.cmd` scripts via CreateProcessW. When this happens, `CreateProcessW` will (under-the-hood) spawn a `cmd.exe` process with the path to the script and the args like so:

    cmd.exe /c script.bat arg1 arg2

This is a problem because:

- `cmd.exe` has its own, separate, parsing/escaping rules for arguments
- Environment variables in arguments will be expanded before the `cmd.exe` parsing rules are applied

Together, this means that (1) maliciously constructed arguments can lead to arbitrary command execution via the APIs in `std.process.Child` and (2) escaping according to the rules of `cmd.exe` is not enough on its own.

A basic example argv field that reproduces the vulnerability (this will erroneously spawn `calc.exe`):

    .argv = &.{ "test.bat", "\"&calc.exe" },

And one that takes advantage of environment variable expansion to still spawn calc.exe even if the args are properly escaped for `cmd.exe`:

    .argv = &.{ "test.bat", "%CMDCMDLINE:~-1%&calc.exe" },

(note: if these spawned e.g. `test.exe` instead of `test.bat`, they wouldn't be vulnerable; it's only `.bat`/`.cmd` scripts that are vulnerable since they go through `cmd.exe`)

Zig allows passing `.bat`/`.cmd` scripts as `argv[0]` via `std.process.Child`, so the Zig API is affected by this vulnerability. Note also that Zig will search `PATH` for `.bat`/`.cmd` scripts, so spawning something like `foo` may end up executing `foo.bat` somewhere in the PATH (the PATH searching of Zig matches the behavior of cmd.exe).

> Side note to keep in mind: On Windows, the extension is significant in terms of how Windows will try to execute the command. If the extension is not `.bat`/`.cmd`, we know that it will not attempt to be executed as a `.bat`/`.cmd` script (and vice versa). This means that we can just look at the extension to know if we are trying to execute a `.bat`/`.cmd` script.

---

This general class of problem has been documented before in 2011 here:

https://learn.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way

and the course of action it suggests for escaping when executing .bat/.cmd files is:

- Escape first using the non-cmd.exe rules
- Then escape all cmd.exe 'metacharacters' (`(`, `)`, `%`, `!`, `^`, `"`, `<`, `>`, `&`, and `|`) with `^`

However, escaping with ^ on its own is insufficient because it does not stop cmd.exe from expanding environment variables. For example:

```
args.bat %PATH%
```

escaped with ^ (and wrapped in quotes that are also escaped), it *will* stop cmd.exe from expanding `%PATH%`:

```
> args.bat ^"^%PATH^%^"
"%PATH%"
```

but it will still try to expand `%PATH^%`:

```
set PATH^^=123
> args.bat ^"^%PATH^%^"
"123"
```

The goal is to stop *all* environment variable expansion, so this won't work.

Another problem with the ^ approach is that it does not seem to allow all possible command lines to round trip through cmd.exe (as far as I can tell at least).

One known example:

```
args.bat ^"\^"key^=value\^"^"
```

where args.bat is:

```
@echo %1 %2 %3 %4 %5 %6 %7 %8 %9
```

will print

```
"\"key value\""
```

(it will turn the `=` into a space for an unknown reason; other minor variations do roundtrip, e.g. `\^"key^=value\^"`, `^"key^=value^"`, so it's unclear what's going on)

It may actually be possible to escape with ^ such that every possible command line round trips correctly, but it's probably not worth the effort to figure it out, since the suggested mitigation for BatBadBut has better roundtripping and leads to less garbled command lines overall.

---

Ultimately, the mitigation used here is the same as the one suggested in:

https://flatt.tech/research/posts/batbadbut-you-cant-securely-execute-commands-on-windows/

The mitigation steps are reproduced here, noted with one deviation that Zig makes (following Rust's lead):

1. Replace percent sign (%) with %%cd:~,%.
2. Replace the backslash (\) in front of the double quote (") with two backslashes (\\).
3. Replace the double quote (") with two double quotes ("").
4. ~~Remove newline characters (\n).~~
  - Instead, `\n`, `\r`, and NUL are disallowed and will trigger `error.InvalidBatchScriptArg` if they are found in `argv`. These three characters do not roundtrip through a `.bat` file and therefore are of dubious/no use. It's unclear to me if `\n` in particular is relevant to the BatBadBut vulnerability (I wasn't able to find a reproduction with \n and the post doesn't mention anything about it except in the suggested mitigation steps); it just seems to act as a 'end of arguments' marker and therefore anything after the `\n` is lost (and same with NUL). `\r` seems to be stripped from the command line arguments when passed through a `.bat`/`.cmd`, so that is also disallowed to ensure that `argv` can always fully roundtrip through `.bat`/`.cmd`.
5. Enclose the argument with double quotes (").

The escaped command line is then run as something like:

    cmd.exe /d /e:ON /v:OFF /c "foo.bat arg1 arg2"

Note: Previously, we would pass `foo.bat arg1 arg2` as the command line and the path to `foo.bat` as the app name and let CreateProcessW handle the `cmd.exe` spawning for us, but because we need to pass `/e:ON` and `/v:OFF` to cmd.exe to ensure the mitigation is effective, that is no longer tenable. Instead, we now get the full path to `cmd.exe` and use that as the app name when executing `.bat`/`.cmd` files.

---

A standalone test has also been added that tests two things:

1. Known reproductions of the vulnerability are tested to ensure that they do not reproduce the vulnerability
2. Randomly generated command line arguments roundtrip when passed to a `.bat` file and then are passed from the `.bat` file to a `.exe`. This fuzz test is as thorough as possible--it tests that things like arbitrary Unicode codepoints and unpaired surrogates roundtrip successfully.

Note: In order for the `CreateProcessW` -> `.bat` -> `.exe` roundtripping to succeed, the .exe must split the arguments using the post-2008 C runtime argv splitting implementation, see https://github.com/ziglang/zig/pull/19655 for details on when that change was made in Zig.
2024-04-23 03:21:51 -07:00
Ryan Liptak
84f4c5d9cc std.unicode: Fix ArrayList functions when using populated ArrayLists
ensureTotalCapacityPrecise only satisfies the assumptions made in the ArrayListImpl functions (that there's already enough capacity for the entire converted string if it's all ASCII) when the ArrayList has no items, otherwise it would hit illegal behavior.
2024-04-23 03:20:38 -07:00
Carl Åstholm
e8f28cda9e std.Build: Install Windows DLLs to <prefix>/bin/ by default
Windows does not support RPATH and only searches for DLLs in a small
number of predetermined paths by default, with one of them being the
directory from which the application loaded.

Installing both executables and DLLs to `bin/` by default helps ensure
that the executable can find any DLL artifacts it has linked to.
DLL import libraries are still installed to `lib/`.

These defaults match CMake's behavior.
2024-04-22 17:12:18 -07:00
clickingbuttons
c947e79d73 std.meta: give TagPayloadByName unreachable a better @compileError message 2024-04-23 01:50:10 +03:00
Travis Staloch
8af59d1f98 ComptimeStringMap: return a regular struct and optimize
this patch renames ComptimeStringMap to StaticStringMap, makes it
accept only a single type parameter, and return a known struct type
instead of an anonymous struct.  initial motivation for these changes
was to reduce the 'very long type names' issue described here
https://github.com/ziglang/zig/pull/19682.

this breaks the previous API.  users will now need to write:
`const map = std.StaticStringMap(T).initComptime(kvs_list);`

* move `kvs_list` param from type param to an `initComptime()` param
* new public methods
  * `keys()`, `values()` helpers
  * `init(allocator)`, `deinit(allocator)` for runtime data
  * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure
     these belong but have left in for now incase they are deemed useful
* performance notes:
  * i posted some benchmarking results here:
    https://github.com/travisstaloch/comptime-string-map-revised/issues/1
  * i noticed a speedup reducing the size of the struct from 48 to 32
    bytes and thus use u32s instead of usize for all length fields
  * i noticed speedup storing KVs as a struct of arrays
  * latest benchmark shows these wall_time improvements for
    debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full
    output in link above.
2024-04-22 15:31:41 -07:00
Frank Denis
fefdbca6e6 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-22 15:27:05 -07:00
Jared Baur
c352845e88 Fix usage of unexpectedErrno
`unexpectedErrno` comes from `std.posix`, not `std.os`.
2024-04-20 19:37:41 -07:00
Frank Denis
d8764ec770 Rename der_encoded_max_length to der_encoded_length_max
The `length_min`/`length_max` convention is used everywhere else in
`std.crypto.*` so be consistent.
2024-04-20 16:27:56 -07:00
Linus Groh
7789e87230 std.fs.Dir.openDir: use wasi libc API when -lc
Same as #19680 but for directories.
2024-04-20 15:42:44 -07:00
Jacob Young
c7ffdbcd41 Revert "disable flaky std.fs test"
This reverts commit d080622cc3.

Workaround applied to CI.
2024-04-20 06:08:26 -04:00
Andrew Kelley
d080622cc3 disable flaky std.fs test
Tracked by #17134
2024-04-19 19:01:13 -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
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
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 105db13536.

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
Liviu Dudau
a0de077600 std.zig.system.linux: Use arm.zig detection for AArch64 CPU features
When building zig natively from source on an RK3588 SoC board, the
generated stage3 compiler will use unsupported 'sha256h.4s' instructions
due to mis-identified CPU features. This happens when trying to
compile a new project generated with "zig init"

$ ~/devel/zig/build/stage3/bin/zig build
thread 919 panic: Illegal instruction at address 0x1fdc0c4
/home/dliviu/devel/zig/lib/std/crypto/sha2.zig:223:29: 0x1fdc0c4 in round (zig)
                            asm volatile (
                            ^
/home/dliviu/devel/zig/lib/std/crypto/sha2.zig:168:20: 0x1fdca87 in final (zig)
            d.round(&d.buf);
                   ^
/home/dliviu/devel/zig/lib/std/crypto/sha2.zig:180:20: 0x1c8bb33 in finalResult (zig)
            d.final(&result);
                   ^
/mnt/home/dliviu/devel/zig/src/Package/Fetch.zig:754:49: 0x1a3a8eb in relativePathDigest (zig)
    return Manifest.hexDigest(hasher.finalResult());
                                                ^
/mnt/home/dliviu/devel/zig/src/main.zig:5128:53: 0x1a37413 in cmdBuild (zig)
                    Package.Fetch.relativePathDigest(build_mod.root, global_cache_directory),
                                                    ^
???:?:?: 0xff09ffffffffffff in ??? (???)
Unwind information for `???:0xff09ffffffffffff` was not available, trace may be incomplete

???:?:?: 0x3f7f137 in ??? (???)
Aborted (core dumped)

system/linux.zig parses "/proc/cpuinfo" to determine the CPU features, but it
seems to generate the wrong set of features from:

$ cat /proc/cpuinfo
processor	: 0
BogoMIPS	: 48.00
Features	: fp asimd evtstrm crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x2
CPU part	: 0xd05
CPU revision	: 0
.....
processor	: 4
BogoMIPS	: 48.00
Features	: fp asimd evtstrm crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x4
CPU part	: 0xd0b
CPU revision	: 0
.....

To fix this, use the Linux kernel way of reading the feature registers as documented
here: https://www.kernel.org/doc/html/latest/arch/arm64/cpu-feature-registers.html

arm.zig already has the code to parse the feature register values, we just need to
collect them in an array and pass them for identification.

Signed-off-by: Liviu Dudau <liviu@dudau.co.uk>
2024-04-17 15:06:48 -07:00
mlugg
03ad862197
compiler: un-implement #19634
This commit reverts the handling of partially-undefined values in
bitcasting to transform these bits into an arbitrary numeric value,
like happens on `master` today.

As @andrewrk rightly points out, #19634 has unfortunate consequences
for the standard library, and likely requires more thought. To avoid
a major breaking change, it has been decided to revert this design
decision for now, and make a more informed decision further down the
line.
2024-04-17 13:41:25 +01:00
mlugg
d0e74ffe52
compiler: rework comptime pointer representation and access
We've got a big one here! This commit reworks how we represent pointers
in the InternPool, and rewrites the logic for loading and storing from
them at comptime.

Firstly, the pointer representation. Previously, pointers were
represented in a highly structured manner: pointers to fields, array
elements, etc, were explicitly represented. This works well for simple
cases, but is quite difficult to handle in the cases of unusual
reinterpretations, pointer casts, offsets, etc. Therefore, pointers are
now represented in a more "flat" manner. For types without well-defined
layouts -- such as comptime-only types, automatic-layout aggregates, and
so on -- we still use this "hierarchical" structure. However, for types
with well-defined layouts, we use a byte offset associated with the
pointer. This allows the comptime pointer access logic to deal with
reinterpreted pointers far more gracefully, because the "base address"
of a pointer -- for instance a `field` -- is a single value which
pointer accesses cannot exceed since the parent has undefined layout.
This strategy is also more useful to most backends -- see the updated
logic in `codegen.zig` and `codegen/llvm.zig`. For backends which do
prefer a chain of field and elements accesses for lowering pointer
values, such as SPIR-V, there is a helpful function in `Value` which
creates a strategy to derive a pointer value using ideally only field
and element accesses. This is actually more correct than the previous
logic, since it correctly handles pointer casts which, after the dust
has settled, end up referring exactly to an aggregate field or array
element.

In terms of the pointer access code, it has been rewritten from the
ground up. The old logic had become rather a mess of special cases being
added whenever bugs were hit, and was still riddled with bugs. The new
logic was written to handle the "difficult" cases correctly, the most
notable of which is restructuring of a comptime-only array (for
instance, converting a `[3][2]comptime_int` to a `[2][3]comptime_int`.
Currently, the logic for loading and storing work somewhat differently,
but a future change will likely improve the loading logic to bring it
more in line with the store strategy. As far as I can tell, the rewrite
has fixed all bugs exposed by #19414.

As a part of this, the comptime bitcast logic has also been rewritten.
Previously, bitcasts simply worked by serializing the entire value into
an in-memory buffer, then deserializing it. This strategy has two key
weaknesses: pointers, and undefined values. Representations of these
values at comptime cannot be easily serialized/deserialized whilst
preserving data, which means many bitcasts would become runtime-known if
pointers were involved, or would turn `undefined` values into `0xAA`.
The new logic works by "flattening" the datastructure to be cast into a
sequence of bit-packed atomic values, and then "unflattening" it; using
serialization when necessary, but with special handling for `undefined`
values and for pointers which align in virtual memory. The resulting
code is definitely slower -- more on this later -- but it is correct.

The pointer access and bitcast logic required some helper functions and
types which are not generally useful elsewhere, so I opted to split them
into separate files `Sema/comptime_ptr_access.zig` and
`Sema/bitcast.zig`, with simple re-exports in `Sema.zig` for their small
public APIs.

Whilst working on this branch, I caught various unrelated bugs with
transitive Sema errors, and with the handling of `undefined` values.
These bugs have been fixed, and corresponding behavior test added.

In terms of performance, I do anticipate that this commit will regress
performance somewhat, because the new pointer access and bitcast logic
is necessarily more complex. I have not yet taken performance
measurements, but will do shortly, and post the results in this PR. If
the performance regression is severe, I will do work to to optimize the
new logic before merge.

Resolves: #19452
Resolves: #19460
2024-04-17 13:41:25 +01:00
Andrew Kelley
a2b834e8c7
Merge pull request #19654 from jacobly0/wasi-ver
Target: add wasi os version
2024-04-15 16:14:22 -07:00
Andrew Kelley
b78b2689ed
Merge pull request #19655 from squeek502/windows-argv-post-2008
ArgIteratorWindows: Match post-2008 C runtime rather than `CommandLineToArgvW`
2024-04-15 15:28:33 -07:00
Alex Kladov
ff18103ef6 std: improve std.once tests
* fix UB when Thread.spawn fails, and we try to join uninitialized
  threads (through new `thread_count` variable).
* make sure that the tests pins down synchronization guarantees: in the
  main thread, we can observe `1` due to synchronization from
  `Thread.join()`. To make sure that once uses Acq/Rel, and not just
  relaxed, we should also additionally check that each thread observes
  1, regardless of whether it was the one to call once.
2024-04-15 15:24:30 -07:00
Jakub Konka
1e5075f812 lib/std/Build/Step/CheckObject: dump section as string 2024-04-15 18:06:44 +02:00
Linus Groh
d483ba7250 zig init: Replace deprecated LazyPath.path with Build.path() 2024-04-15 16:55:04 +03:00
jd
d23a8e83d4 std.Build.Step.ConfigHeader: better error message 2024-04-15 04:10:13 -07:00
Ryan Liptak
f4c4c04f1c ArgIteratorWindows: Match post-2008 C runtime rather than CommandLineToArgvW
On Windows, the command line arguments of a program are a single WTF-16 encoded string and it's up to the program to split it into an array of strings. In C/C++, the entry point of the C runtime takes care of splitting the command line and passing argc/argv to the main function.

https://github.com/ziglang/zig/pull/18309 updated ArgIteratorWindows to match the behavior of CommandLineToArgvW, but it turns out that CommandLineToArgvW's behavior does not match the behavior of the C runtime post-2008. In 2008, the C runtime argv splitting changed how it handles consecutive double quotes within a quoted argument (it's now considered an escaped quote, e.g. `"foo""bar"` post-2008 would get parsed into `foo"bar`), and the rules around argv[0] were also changed.

This commit makes ArgIteratorWindows match the behavior of the post-2008 C runtime, and adds a standalone test that verifies the behavior matches both the MSVC and MinGW argv splitting exactly in all cases (it checks that randomly generated command line strings get split the same way).

The motivation here is roughly the same as when the same change was made in Rust (https://github.com/rust-lang/rust/pull/87580), that is (paraphrased):

- Consistent behavior between Zig and modern C/C++ programs
- Allows users to escape double quotes in a way that can be more straightforward

Additionally, the suggested mitigation for BatBadBut (https://flatt.tech/research/posts/batbadbut-you-cant-securely-execute-commands-on-windows/) relies on the post-2008 argv splitting behavior for roundtripping of the arguments given to `cmd.exe`. Note: it's not necessary for the suggested mitigation to work, but it is necessary for the suggested escaping to be parsed back into the intended argv by ArgIteratorWindows after being run through a `.bat` file.
2024-04-15 02:09:48 -07:00
Jacob Young
425e38b6e0 WindowsSdk: fix for new x86_64-windows CI 2024-04-14 21:26:08 -04:00
Andrew Kelley
36060a774e fix namespacing of std.fs.Dir.Walker.Entry 2024-04-14 18:08:42 -07:00
Andrew Kelley
10106660e9 std.fs.Dir.Walker: maintain a null byte in path names 2024-04-14 17:59:43 -07:00
Jacob Young
60d5001ac8 wasi: change default os version to 0.1.0
This version represents "WASI Preview 1".

Closes #19581
2024-04-14 18:43:52 -04:00
Jacob Young
533f54c68e Target: cleanup 2024-04-14 15:33:46 -04:00
Frank Denis
e45bdc6bd6
std.crypto.pcurves.*: simpler, smaller, faster u64 addition with carry (#19644)
signature/s:

Algorithm        Before     After
---------------+---------+-------
ecdsa-p256        3707       4396
ecdsa-p384        1067       1332
ecdsa-secp256k1   4490       5147

Add ECDSA to the benchmark by the way.
2024-04-14 01:13:22 +02:00
Andrew Kelley
a59ad719d2 std.Build.Step.ConfigHeader: better error message 2024-04-13 05:14:08 -07:00
Andrew Kelley
54d1a529f6
Merge pull request #19637 from ziglang/http-host-port
std.http.Client: omit port in http host header sometimes
2024-04-13 03:39:35 -07:00
Андрей Краевский
7cc0e6d4cd
std: fix big int llshr to respect aliasing (#19612) 2024-04-13 03:06:23 -07:00
Andrew Kelley
0a3dff8125 Revert "std.http.Client: always omit port when it matches default"
This reverts commit db0a42b558c64eac2b4e41d02b078931b0c63af8, but keeps
the changes to std/Uri.zig.
2024-04-12 22:37:07 -07:00
Andrew Kelley
6deb3e3986 std.http.Client: always omit port when it matches default
This makes the host http header have the port if and only if it differs
from the defaults based on the protocol.

This is an alternate implementation that closes #19624.
2024-04-12 22:37:07 -07:00
Andrew Kelley
419753f45e std.http.Client: pass port to server based on user input
This makes the host http header have the port if and only if the URI
provided by the API user included it.

Closes #19624
2024-04-12 22:37:07 -07:00
Jacob Young
f1c0f42cdd cbe: fix optional codegen
Also reduce ctype pool string memory usage, remove self assignments, and
enable more warnings.
2024-04-13 01:35:20 -04:00
Andrew Kelley
10ff81c264
Merge pull request #19623 from ziglang/LazyPath
std.Build.LazyPath: upgrade API usages of source-relative path
2024-04-11 23:35:51 -07:00
Andrew Kelley
3bafc4400a std.debug.panic: pass the args
Why was this passing null? These values are available and useful.
2024-04-11 23:33:38 -07:00
Jeremia Dominguez
0ac15b9726 Document lazy dependency in init build.zig.zon
Also added the same description to doc/build.zig.zon.md
2024-04-11 14:56:07 -07:00
Brandon Black
271d896446 std.hash.crc: get rid of usingnamespace
This flips things around such that std/hash/crc.zig is generated
by the catalog-based generation tool, and the real code that used
to be in that file is moved out to std/hash/crc/impl.zig.  The
generated tests are moved to std/hash/crc/test.zig.  By going this
route, we eliminate the need for usingnamespace without changing
anything for callers of these interfaces.  The Crc32 tests are
simply added to the fixed part of the generated output and
compactified a bit.

This was the second-to-last usage of usingnamespace left in std.
2024-04-11 14:42:04 -07:00
leap123
786876c05e Fix stack iterator on UEFI
Don't know why UEFI wasn't excluded but freestanding is, probably an oversight since I want to have detailed debug info on my panic function on my Headstart bootloader.
2024-04-11 14:21:15 -07:00
Andrew Kelley
499a202a13 std.Build: revert the breaking changes only
The previous commit deleted the deprecated API and then made all the
follow-up changes; this commit reverts only the breaking API changes.
This commit can be reverted once 0.12.0 is tagged.
2024-04-11 14:09:58 -07:00
Andrew Kelley
b30ad74908 remove deprecated LazyPath.path union tag 2024-04-11 14:02:47 -07:00
andrewkraevskii
f7a76bdfe3 autodoc: fix tokenizer 2024-04-10 20:44:10 -07:00
Andrew Kelley
7fb5a0b18b introduce std.Build.path; deprecate LazyPath.relative
This adds the *std.Build owner to LazyPath so that lazy paths returned
from a dependency can be used in the application without friction or
footguns.

closes #19313
2024-04-10 15:02:20 -07:00
Jacob Young
c4587dc9f4 Uri: propagate per-component encoding
This allows `std.Uri.resolve_inplace` to properly preserve the fact
that `new` is already escaped but `base` may not be.  I originally tried
just moving `raw_uri` around, but it made uri resolution unmanagably
complicated, so I instead added per-component information to `Uri` which
allows extra allocations to be avoided when constructing uris with
components from different sources, and in some cases, deferring the work
all the way to when the uri is printed, where an allocator may not even
be needed.

Closes #19587
2024-04-10 02:11:54 -07:00
Andrew Kelley
215de3ee67
Merge pull request #19500 from ianic/package_filter_errors
package manager: filter unpack errors on paths excluded by manifest
2024-04-09 13:22:48 -07:00
Andrew Kelley
fc17402919
std.crypto.Certificate: support 3072 bits RSA certificate (#19591)
Used by musicbrainz.org API.
2024-04-09 12:16:45 -07:00
Frank Denis
9d27f34d04
crypto.sha3: implement constructions from NIST SP 800-185 (#19533)
https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf

This adds useful standard SHA3-based constructions from the
NIST SP 800-185 document:

- cSHAKE: similar to the SHAKE extensible hash function, but
with the addition of a context parameter.
- KMAC: SHAKE-based authentication / keyed XOF
- TupleHash: unambiguous hashing of tuples

These are required by recent protocols and specifications.

They also offer properties that none of the currently available
constructions in the stdlib offer, especially the ability to safely
hash tuples.

Other keyed hash functions/XOFs will fall back to using HMAC, which
is suboptimal from a performance perspective, but fine from a
security perspective.
2024-04-09 12:16:19 -07:00
Igor Anić
3d5a9237f7 fetch: use empty string instead of null for root_dir
Make it consistent with Cache.Path sub_path.
Remove null check in many locations.
2024-04-09 15:00:22 +02:00
Jacob Young
7611d90ba0 InternPool: remove slice from byte aggregate keys
This deletes a ton of lookups and avoids many UAF bugs.

Closes #19485
2024-04-08 13:24:08 -04:00
Jacob Young
3f1f05011e haiku: fix abi and dynamic linker detection 2024-04-08 13:20:14 -04:00
Jacob Young
fcdb7027e9 haiku: fix linking issues 2024-04-08 13:20:14 -04:00
Jacob Young
0c83fa2fd0 haiku: fix directory iteration 2024-04-08 13:20:14 -04:00
Andrew Kelley
fbb38a7682 std.Build: fix regression in Step.ConfigHeader
Commit 0b7123f41d regressed the
`include_path` option of ConfigHeader which is intended to set the path,
including subdirectories, that C code would pass to an include
directive.

For example if it passes

    .include_path = "config/config.h",

Then the C code should be able to have

    #include "config/config.h"

This regressed https://github.com/andrewrk/nasm/ but this commit fixes
it.
2024-04-08 07:11:18 -07:00
Ian Johnson
6dcbad780c
Autodoc: fix Markdown indented lists (#19577)
Previously, indentation was not being handled correctly in some cases,
causing examples such as `std.json.WriteStream` to be rendered with
improper list nesting.

Additionally, some more test cases have been added to ensure
indentation (or lack of indentation) is handled correctly in some other
constructs.
2024-04-08 09:49:22 +00:00
Andrew Kelley
355cceebc7
Merge pull request #18920 from castholm/fmtId
`std.zig.fmtId`: conditionally escape primitives/`_` (breaking)
2024-04-07 19:22:35 -07:00
Andrew Kelley
1b27146792
Merge pull request #18590 from castholm/move-standalone-test-cases
std.Build: Remove `anonymousDependency`
2024-04-07 16:08:23 -07:00
Carl Åstholm
e5bf1a5d50 Make std.Build.dependencyInner private 2024-04-07 16:06:20 -07:00
Carl Åstholm
ef90d3af54 Remove std.Build.anonymousDependency 2024-04-07 16:06:19 -07:00
Carl Åstholm
09f1bbe11b std.Build: Remove unused c_std field
This field has not been referenced by compile steps since
e76ce2c1d0, all the way back in 2019.
To specify the language standard, pass `-std=[value]` as a regular
C flag instead.
2024-04-07 16:06:15 -07:00
Carl Åstholm
05126fc4c5 std.Build: add dependencyFromBuildZig 2024-04-07 15:54:30 -07:00
Andrew Kelley
e204a6edb8
Merge pull request #18988 from castholm/lazy-build-zig
std.Build: add `lazyImport` (`@import` for lazy dependencies)
2024-04-07 15:43:54 -07:00
Carl Åstholm
2465c328aa Use @TypeOf instead of std.meta in test_runner.zig
This might fix a CI failure for powerpc64le-linux-musl.
2024-04-07 21:16:29 +02:00
Carl Åstholm
eee5400b7d Account for dependency boundaries when duping headers
This is a temporary workaround that can be revered if/when 'path'
lazy paths are updated to encode which build root they are relative to.
2024-04-07 15:34:47 +02:00
Carl Åstholm
d99e44a157 Document added/updated functions
Also renames `addHeaders` to `addHeadersDirectory` for clarity.
2024-04-07 15:34:47 +02:00
Carl Åstholm
5af4e91e00 Oops, forgot to dupe installations in installLibraryHeaders
Added test coverage for `installLibraryHeaders`
2024-04-07 15:34:47 +02:00
Carl Åstholm
8ce3a8b604 WriteFile.addCopyDirectory should include all files by default 2024-04-07 15:34:47 +02:00
Carl Åstholm
e16db29887 Implement WriteFile.addCopyDirectory 2024-04-07 15:34:47 +02:00