Commit graph

6189 commits

Author SHA1 Message Date
Luuk de Gram
4bffe645c6
std: remove hack in test step
This hack was initially introduced as we would export all symbols
unconditionally, including non-function definitions. This would cause
an error from the Wasmtime runtime engine, which this flag would
suppress. As we now properly export symbols, this flag is no longer
needed and any user running into this error can manually include it.

This commit also adds the `--import-symbols` ability to build.zig
2022-12-28 15:57:19 +01:00
Frank Denis
c9e3524d0b
HKDF allow expansion up to, and including <hash size> * 255 bytes (#14051)
Fixes #14050
2022-12-23 21:38:27 +00:00
travisstaloch
581d292381
fix overflow found while fuzzing
* allow file level `union {}` to parse as tuple field

this was found while fuzzing zls.

* before this patch the input `union {}` crashed the parser.  after
  this, it parses correctly just like `struct {}`.
* adds behavior tests for both inputs `struct {}` and `union {}`,
  checking that each becomes a file level tuple field.
2022-12-23 23:10:04 +02:00
Jakub Konka
bb62d5105c
Merge pull request #14049 from ziglang/issue-14045
macho+zld: write code signature padding before committing load commands
2022-12-23 19:07:36 +01:00
Jakub Konka
2cb6db2219 link-tests: add macho strict validation test
Support more operators when running simple arithmetic tests, and
allow for int literals in the program spec.
2022-12-23 14:02:52 +01:00
Ryan Liptak
71668fc4e3 Dir.openDirAccessMaskW: Add ACCESS_DENIED as a possible error
Can occur when trying to open a directory for iteration but the 'List folder contents' permission of the directory is set to 'Deny'.

This was found because it was being triggered during PATH searching in ChildProcess.spawnWindows if a PATH entry did not have 'List folder contents' permission, so this fixes that as well (note: the behavior on hitting this during PATH searching is to treat it as the directory not existing and therefore will fail to find any executables in a directory in the PATH without 'List folder contents' permission; this matches Windows behavior which also fails to find commands in directories that do not have 'List folder contents' permission).
2022-12-22 14:03:05 -05:00
Ganesan Rajagopal
06f70c030a Fix missing pthread_key_t definition on linux
* pthread_key_t should also be available for non-android platforms
* Also change the type to c_uint because Linux pthreadtypes.h typedefs it as "unsigned int"

Partially addresses #13950
2022-12-21 17:00:41 -05:00
Luuk de Gram
0d66112643 wasm: refactor extended instructions
The extended instructions starting with opcode `0xFC` are refactored
to make the work the same as the SIMD instructions. This means a
`Mir` instruction no longer contains a field 'secondary'. Instead,
we use the `payload` field to store the index into the extra list
which contains the extended opcode value. In case of instructions
such as 'memory.fill' which also have an immediate value, such
values will also be stored in the extra list right after the
instruction itself. This makes each `Mir` instruction smaller.
2022-12-21 17:02:53 +01:00
Andrew Kelley
775b0c1347 Revert "c.zig: Add definition for pthread_key_t"
This reverts commit aa3964477f.

This declaration is already provided by operating-system-specific files.
This is not the correct solution to the problem.

See #14013
Reopens #13950
2022-12-20 14:37:05 -07:00
travisstaloch
4aa8462cc9
std.zig: fix integer overflows during parsing
these were found while fuzzing zls.

this patch prevents overflow for the following file contents and adds
tests for them.
	* `enum(u32)` - causes overflow in std.zig.Ast.fullContainerDecl()
	* `*x` - causes overflow in std.zig.Ast.fullPtrType()
	* `**x` - causes overflow in std.zig.Ast.firstToken()
2022-12-20 17:33:40 +02:00
Jakub Konka
3a1295cd6f macho: add missing defs of compact unwind info records 2022-12-20 16:20:48 +01:00
Andrew Kelley
0fb53bd245
Merge pull request #14000 from jacobly0/zero-bit-fields
codegen: fix taking the address of a field in a zero-bit struct
2022-12-19 15:47:31 -05:00
Ryan Liptak
3db8cffa3b spawnWindows: Fix PATH searching when cwd is absolute
Fixes a regression caused by https://github.com/ziglang/zig/pull/13983

From the added comment:

We still search the path if the cwd is absolute because of the
"cwd set in ChildProcess is in effect when choosing the executable path
to match posix semantics" behavior--we don't want to skip searching
the PATH just because we were trying to set the cwd of the child process.
2022-12-19 04:12:46 -05:00
Jacob Young
52e5c66025 llvm: fix use of invalid alignment
* Initialize `big_align` with 1 as 0 is not a valid alignment.
 * Add an assert to `alignForwardGeneric` to catch this issue earlier.
 * Refactor valid alignment checks to call a more descriptive function.
2022-12-18 22:11:26 -05:00
Andrew Kelley
8f98a2b90f std.compress.deflate: re-enable test on windows
closes #13892
2022-12-18 16:34:09 -07:00
Andrew Kelley
e6a4e87f69 update gitattributes and move test data into subdir 2022-12-18 16:28:30 -07:00
Andrew Kelley
aca9c74e80
Merge pull request #13914 from Vexu/variadic
implement defining C variadic functions
2022-12-18 16:24:13 -05:00
Andrew Kelley
d93edadead
Merge pull request #13993 from squeek502/windows-childprocess-perf
`spawnWindows`: Improve worst-case performance considerably + tests
2022-12-18 16:22:19 -05:00
Veikka Tuominen
40ed6ae846
Merge pull request #13930 from r00ster91/renamings
std.builtin: renamings
2022-12-18 19:33:15 +02:00
r00ster91
ceff03f3e9 std.builtin: remove layout field from Type.Enum 2022-12-18 13:31:38 +01:00
Ryan Liptak
0cbc59f227 standalone tests: Add windows spawn test
Tests a decent amount of edge cases dealing with how PATH and PATHEXT searching is handled.
2022-12-18 03:55:28 -08:00
Ryan Liptak
e9c48e6631 spawnWindows: Improve worst-case performance considerably
The name of the game here is to avoid CreateProcessW calls at all costs,
and only ever try calling it when we have a real candidate for execution.
Secondarily, we want to minimize the number of syscalls used when checking
for each PATHEXT-appended version of the app name.

An overview of the technique used:
- Open the search directory for iteration (either cwd or a path from PATH)
- Use NtQueryDirectoryFile with a wildcard filename of `<app name>*` to
  check if anything that could possibly match either the unappended version
  of the app name or any of the versions with a PATHEXT value appended exists.
- If the wildcard NtQueryDirectoryFile call found nothing, we can exit early
  without needing to use PATHEXT at all.

This allows us to use a <open dir, NtQueryDirectoryFile, close dir> sequence
for any directory that doesn't contain any possible matches, instead of having
to use a separate look up for each individual filename combination (unappended +
each PATHEXT appended). For directories where the wildcard *does* match something,
we only need to do a maximum of <number of supported PATHEXT extensions> more
NtQueryDirectoryFile calls.

---

In addition, we now only evaluate the extensions in PATHEXT that we know we can handle (.COM, .EXE, .BAT, .CMD) and ignore the rest.

---

This commit also makes two edge cases match Windows behavior:

- If an app name has the extension .exe and it is attempted to be executed, that is now treated as unrecoverable and InvalidExe is immediately returned no matter where the .exe is (cwd or in the PATH). This matches the behavior of the Windows cmd.exe.
- If the app name contains more than just a filename (e.g. it has path separators), then it is excluded from PATH searching and only does a cwd search. This matches the behavior of Windows cmd.exe.
2022-12-18 02:48:34 -08:00
Ryan Liptak
3ee8c49582 windows: Map EXE_MACHINE_TYPE_MISMATCH to InvalidExe
Seems to happen if the command trying to be executed has the extension .exe and it's an invalid executable.
2022-12-18 02:31:34 -08:00
Jacob Young
0ccdc511ce rand: add pub to next/jump
I specifically needed jump for an application and it doesn't appear to
be exposed in any way.
2022-12-18 01:46:09 -05:00
Ryan Liptak
6e22b63edb windows: Extract RtlEqualUnicodeString usage into to a helper function 2022-12-17 22:06:47 -08:00
Techatrix
4809e0ea7f
fix potential integer underflow in std.zig.Ast.fullCall 2022-12-18 04:59:43 +00:00
Veikka Tuominen
901c3e9636
Merge pull request #13552 from hryx/comparus-tautologicus
Sema: elide integer comparisons with guaranteed outcomes
2022-12-18 01:57:49 +02:00
Evin Yulo
3367f19078 Make std.tz namespace accessible
Closes #13978
2022-12-18 01:41:56 +02:00
Andrew Kelley
11b57470d0
Merge pull request #13983 from squeek502/windows-childprocess-exec-retry
`ChildProcess.spawnWindows`: `PATH` search fixes + optimizations
2022-12-17 18:25:50 -05:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
r00ster91
7350ea3e2d std.builtin: rename Type.Fn's args to params
This was a poor naming choice; these are parameters, not arguments.
Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
2022-12-17 14:11:33 +01:00
r00ster91
20d3fd901e std.builtin: rename Type.Fn.Param's arg_type to type
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17 14:11:33 +01:00
Ryan Liptak
9e8ac2b666 spawnWindows: Don't search PATH if app path is absolute 2022-12-17 03:36:45 -08:00
Ryan Liptak
d3242408d4 spawnWindows: If an exe is found but fails to exec, retry with PATHEXT values appended
This matches `cmd.exe` behavior. For example, if there is only a file named `mycommand` in the cwd but it is a Linux executable, then running the command `mycommand` will result in:

'mycommand' is not recognized as an internal or external command, operable program or batch file.

However, if there is *both* a `mycommand` (that is a Linux executable) and a `mycommand.exe` that is a valid Windows exe, then running the command `mycommand` will successfully run `mycommand.exe`.
2022-12-17 03:36:45 -08:00
Ryan Liptak
5843b7987e Add error.InvalidExe to CreateProcessW error set and handle it in ChildProcess.spawnWindows 2022-12-17 03:36:45 -08:00
Veikka Tuominen
9bb1104e37 implement defining C variadic functions 2022-12-17 13:22:09 +02:00
Steven Kabbes
90477e5c10
std.IndexedSet.iterator: allow iteration on const EnumSet 2022-12-17 11:37:03 +02:00
Jakub Konka
270b6c4c2f
Merge pull request #13964 from ziglang/issue-11737
Misc MachO linker improvements and link-tests refactor
2022-12-17 10:26:56 +01:00
Ryan Liptak
b362cbbc9f ChildProcess.spawnWindows: Drastically reduce the amount of allocation during FileNotFound recovery
Avoid a lot of unnecessary utf8 -> utf16 conversion and use a single ArrayList buffer for all the joined paths instead of a separate allocation for each join
2022-12-16 21:42:39 -08:00
Ryan Liptak
6a1021fb7d ChildProcess.spawnWindows: Fix PATH search when the ext is in the command
For example, if the command is specified as `something.exe`, the retry will now try:

```
C:\some\path\something.exe
C:\some\path\something.exe.COM
C:\some\path\something.exe.EXE
C:\some\path\something.exe.BAT
... etc ...
```

whereas before it would only try the versions with an added extension from `PATHEXT`, which would cause the retry to fail on things that it should find.
2022-12-16 21:42:39 -08:00
yujiri8
68d2f68ed8
zig fmt: fix extra whitespace with multiline strings
Fixes #13937
2022-12-17 00:24:58 +02:00
zooster
8da9cc85af std.meta: remove bitCount 2022-12-17 00:15:47 +02:00
Jakub Konka
9ad24a4aee macho: add uuid link test 2022-12-16 18:31:48 +01:00
Jakub Konka
09dee74414 macho: store LC headers to often updated LINKEDIT sections 2022-12-16 18:05:58 +01:00
Ganesan Rajagopal
aa3964477f c.zig: Add definition for pthread_key_t
Add missing definition for pthread_key_t

Closes #13950
2022-12-16 18:14:12 +02:00
Andrew Kelley
0d92fcf6a5 std.debug: disable sporadically failing test
see tracking issue #13963
2022-12-15 15:56:13 -07:00
Meghan
1704971666
std: make builtin.Type.{Int,Float}.bits a u16 instead of comptime_int 2022-12-15 23:08:51 +02:00
Ivan Velickovic
88b49ed00d std.leb128: Re-enable test for riscv64
These were previously disabled due to a LLVM 14 regression, see
https://github.com/ziglang/zig/issues/12031 for more details. This has been fixed
in LLVM 15.
2022-12-15 09:00:42 -05:00
Ryan Liptak
077b003c50 std.compress: Improve tests, remove reliance on openDirAbsolute
- Previously, some of the compress tests used `@src()` in combination with `dirname` and `openDirAbsolute` to read test files at runtime, which both excludes platforms that `openDirAbsolute` is not implemented for (WASI) and platforms that `SourceLocation.file` is not absolute (this was true for me locally on Windows). Instead of converting the tests to use `fs.cwd().openDir`, they have been converted to use `@embedFile` to avoid any potential problems with the runtime cwd.
- In order to use `@embedFile`, some of the `[]u8` parameters needed to be changed to `[]const u8`; none of them needed to be non-const anyway
- The tests now use `expectEqual` and `expectEqualSlices` where appropriate for better diagnostics
2022-12-15 05:13:21 -05:00
Stevie Hryciw
69b784ff52 std: add CompareOperator.reverse 2022-12-15 00:56:26 -08:00