21861 Commits

Author SHA1 Message Date
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
Jacob Young
18f05664dc llvm: avoid creating an invalid llvm type
Fixes the following assertion:

```
zig: llvm/lib/IR/Type.cpp:729: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
```
2022-12-18 22:11:26 -05:00
Jacob Young
e96f65db77 llvm: fix lowering pointer to final zero-width field of a comptime value
* Handle a `null` return from `llvmFieldIndex`.
 * Add a behavior test to test this code path.
 * Reword this test name, which incorrectly described how pointers to
   zero-bit fields behave, and instead describe the actual test.
2022-12-18 22:11:26 -05:00
Andrew Kelley
6018a3ad39 add behavior test for empty error set inference
closes #1386
closes #7541
2022-12-18 18:37:12 -07:00
Andrew Kelley
09ee887e9f add behavior test for comptime pointer casting
closes #1150
closes #1292
closes #4093
2022-12-18 18:37:12 -07:00
Andrew Kelley
8f98a2b90f std.compress.deflate: re-enable test on windows
closes #13892
2022-12-18 16:34:09 -07:00
Andrew Kelley
aa44512b85 CI: workaround git bug regarding changed attributes 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
Andrew Kelley
6ed0910d6d Revert "llvm: fix lowering pointer to final zero-width field of a comptime value"
This reverts commit e0bc5f65b98d154b4318027d56f780b55605e33c.

Caused an assertion failure when running the behavior tests:

```
zig: llvm/lib/IR/Type.cpp:729: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
Aborted (core dumped)
```
2022-12-18 13:51:15 -07:00
Veikka Tuominen
40ed6ae846
Merge pull request #13930 from r00ster91/renamings
std.builtin: renamings
2022-12-18 19:33:15 +02:00
Luuk de Gram
8eac2e30c9
wasm-linker: Add caching + more into zld path 2022-12-18 16:41:57 +01:00
Luuk de Gram
dd85092982
wasm-linker: Fix relocations for alias'd atoms
When an atom has one or multiple aliasses, we we could not find the
target atom from the alias'd symbol. This is solved by ensuring that
we also insert each alias symbol in the symbol-atom map.
2022-12-18 16:37:00 +01:00
Jakub Konka
e9e804edc8 Add missing clang opts: -install_name and -undefined 2022-12-18 15:52:51 +01:00
shwqf
11a81e1b29 Call ensureResultUsed before comptime .call is evaluated.
Fixes #12580
2022-12-18 16:04:33 +02:00
Veikka Tuominen
2a5e1426aa update zig1.wasm to builtin.Type field changes 2022-12-18 13:31:38 +01: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
Andrew Kelley
f24c77fc48
Merge pull request #13992 from jacobly0/llvm-zwf
llvm: fix null pointer use when lowering pointer to final zero-width field of a comptime value
2022-12-18 06:50:48 -05: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
e0bc5f65b9 llvm: fix lowering pointer to final zero-width field of a comptime value
* Handle a `null` return from `llvmFieldIndex`.
 * Add a behavior test to test this code path.
 * Reword this test name, which incorrectly described how pointers to
   zero-bit fields behave, and instead describe the actual test.
2022-12-18 02:17:11 -05: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
9cc49548aa langref: remove incorrect use of term 'literal' 2022-12-18 01:55:09 +02:00
zooster
e02e4757b1 compiler_rt: test clzsi2 on zero on CPUs where possible 2022-12-18 01:42:15 +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
Luuk de Gram
2a62dbda0b
wasm-linker: fix type index relocations
Previously we used the relocation index to find the corresponding
symbol that represents the type. However, the index actually
represents the index into the list of types. We solved this by
first retrieving the original type, and then finding its location
in the new list of types. When the atom file is 'null', it means
the type originates from a Zig function pointer or a synthetic
function. In both cases, the final type index was already resolved
and therefore equals to relocation's index value.
2022-12-17 17:17:34 +01: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
Veikka Tuominen
728dd29f1a Type: fix incorrect usage of hasRuntimeBits
Closes #13962
2022-12-17 13:22:09 +02:00
Veikka Tuominen
58caed1c71 Sema: make is_non_{null,err} stricter about types
Closes #13023
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
Jakub Konka
b20a610f03 link-tests: force cross-comp to exclude host differences 2022-12-17 00:53:47 +01: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
Luuk de Gram
476202eec0
wasm-linker: Fix archive symbols parsing
When parsing the table of contents containing the symbols and their
positions we initially used the index within the map to retrieve
the offset. However, during resizing of the underlaying array this
would invalidate those indexes which meant incorrect offsets were
being stored for symbols. We now use the current symbol index
to also get the index into the symbol position instead.
2022-12-16 18:31:24 +01:00