25460 Commits

Author SHA1 Message Date
mlugg
6e2eb208aa
Sema: queue type resolution whem emitting array_elem_val
This type not being resolved was a bug which was being triggered by the
next commit.
2023-08-15 11:42:25 +01:00
Xavier Bouchoux
f7b82ed416 objcopy: fix typo
fixes aecc15391a4c37a4504d29cb7e3179990b180773
the usual last 'harmless' cosmetic ajustement before commit strikes again...
2023-08-15 02:52:38 -07:00
e4m2
9135115573
std.crypto.aead: Consistent decryption tail and doc fixes (#16781)
* Consistent decryption tail for all AEADs

* Remove outdated note

This was previously copied here from another function. There used
to be another comment on the tag verification linking to issue #1776,
but that one was not copied over. As it stands, this note seems fairly
misleading/irrelevant.

* Prettier docs

* Add note about plaintext contents to docs

* Capitalization

* Fixup missing XChaChaPoly docs
2023-08-14 21:39:51 +02:00
mlugg
8f3ccbbe36 Sema: provide source location when analyzing panic handler
The panic handler decl_val was previously given a `unneeded` source
location, which was then added to the reference trace, resulting in a
crash if the source location was used in the reference trace. This
commit makes two trivial changes:

* Don't add unneeded source locations to the ref table (panic in debug, silently ignore in release)
* Pass a real source location when analyzing the panic handler
2023-08-14 11:43:21 -07:00
kcbanner
1054e67f01 dwarf: add missing length check in rowColumns 2023-08-14 11:18:04 -07:00
Krzysztof Wolicki
197d9a9eb3 Autodoc: remove assumption that slice's lhs is always a declRef 2023-08-14 15:44:21 +02:00
Andrew Kelley
a1049d4561
Merge pull request #16773 from Sahnvour/build-stack-frames
std.Build: make number of collected stack frames configurable
2023-08-13 13:54:51 -07:00
Sahnvour
2ceeade99a std.Build: add support for deps .d file in Step.Run 2023-08-13 12:15:47 -07:00
Jacob Young
1c5c3f499a cmake: fix auto-detection of various host targets
Closes #16800
2023-08-13 11:26:10 -07:00
Sahnvour
f43402f883 std.Build: factorize Step stack trace dumping code 2023-08-13 11:25:48 +02:00
Sahnvour
078e330555 std.Build: make number of collected stack frames configurable 2023-08-13 10:56:28 +02:00
Andre Herbst
014d88ef65 libunwind: Remove include for libcxx as its also done in upstream llvm repo 2023-08-12 13:47:09 -07:00
Andrew Kelley
35b85d3ba5
Merge pull request #16783 from squeek502/fs-too-many-parent-dirs
Windows: Fix `TooManyParentDirs` handling for paths that shouldn't be cwd-relative
2023-08-12 10:38:31 -07:00
Andrew Kelley
6b06a696df
Merge pull request #16788 from xxxbxxx/objcopy-step
build/ObjCopy: strip debug info to a separate elf file
2023-08-12 10:30:32 -07:00
snoire
5b51259141 Fix incorrect lib search paths in README
The README contains a typo stating 'zig/lib/' and '../zig/lib/' as the lib search paths. This should be 'lib/zig' and '../lib/zig'.
2023-08-12 10:29:42 -07:00
Andrew Kelley
e4d05358e1
Merge pull request #16787 from jacobly0/as-srclocs
AstGen: create more `@as` with source locations
2023-08-12 10:28:26 -07:00
Xavier Bouchoux
2da28d93de build/ObjCopy: strip debug info to a separate elf file.
example usage:
    if (!strip) {
        b.installArtifact(exe);
    } else {
        const stripped_exe = b.addObjCopy(exe.getEmittedBin(), .{
            .basename = exe.out_filename, // set the name for the debuglink
            .compress_debug = true,
            .strip = .debug_and_symbols,
            .extract_to_separate_file = true,
        });
        b.getInstallStep().dependOn(&b.addInstallBinFile(stripped_exe.getOutput(), exe.out_filename).step);
        b.getInstallStep().dependOn(&b.addInstallBinFile(stripped_exe.getOutputSeparatedDebug().?, b.fmt("{s}.debug", .{exe.out_filename})).step);
    }
2023-08-12 09:54:35 +02:00
Xavier Bouchoux
aecc15391a objcpy: preserve the mode when striping an elf file.
+ clean some @as()
2023-08-12 09:54:20 +02:00
Jacob Young
09b0070e87 AstGen: cleanup @as invasion 2023-08-12 02:22:46 -04:00
Jacob Young
41575fa868 AstGen: fix src loc for invalid switch expression rls coercions 2023-08-12 02:22:26 -04:00
Jacob Young
ce7acf1296 AstGen: fix src loc for invalid coercion in breaks 2023-08-12 01:57:15 -04:00
Jacob Young
2b5bd56a67 AstGen: fix src loc for invalid coercions in tuple literals 2023-08-12 01:57:11 -04:00
Jacob Young
ffc116de78 AstGen: fix src loc for invalid if expression rls coercions
Closes #12509
2023-08-12 01:57:07 -04:00
Ryan Liptak
7e542e788c fs tests: Add a 'non-cwd .. parent' test 2023-08-11 18:58:40 -07:00
Ryan Liptak
3f9294c735 Windows: Fix TooManyParentDirs handling for paths that shouldn't be cwd-relative
Previously, a relative path like `..` would:
- Attempt to be normalized (i.e. remove . and .. without any path resolution), but would error with TooManyParentDirs
- This would make wToPrefixedFileW run it through `RtlGetFullPathName_U` to do the necessary path resolution, but `RtlGetFullPathName_U` always resolves relative paths relative to the CWD

Instead, when TooManyParentDirs occurs, we now look up the path of the passed in `dir` (if it's non-null) and append the relative path to it before giving it to `RtlGetFullPathName_U`. If `dir` is null, then we just give it RtlGetFullPathName_U directly and let it resolve it relative to the CWD.

Closes #16779
2023-08-11 18:58:40 -07:00
mlugg
5e0107fbce Sema: remove redundant addConstant functions
After ff37ccd, interned values are trivial to convert to Air refs, using
`Air.internedToRef`. This made functions like `Sema.addConstant` effectively
redundant. This commit removes `Sema.addConstant` and `Sema.addType`, replacing
them with direct usages of `Air.internedToRef`.

Additionally, a new helper `Module.undefValue` is added, and the following
functions are moved into Module:
* `Sema.addConstUndef` -> `Module.undefRef`
* `Sema.addUnsignedInt` -> `Module.intRef` (now also works for signed types)

The general pattern here is that any `Module.xyzValue` helper may also have a
corresponding `Module.xyzRef` helper, which just wraps the call in
`Air.internedToRef`.
2023-08-11 11:02:24 -07:00
Jacob Young
8b9161179d Sema: avoid deleting runtime side-effects in comptime initializers
Closes #16744
2023-08-11 11:01:47 -07:00
jaina heartles
b835fd90ce std.http.Server: use correct header for Transfer-Encoding 2023-08-10 17:45:37 -07:00
Ali Chraghi
7ab306d1f7 Build.ConfigHeader: render identifiers 2023-08-10 16:17:32 -07:00
Xavier Bouchoux
77dd64b5f4 Sema: fix coerceArrayLike() for vectors with padding
as explainded at https://llvm.org/docs/LangRef.html#vector-type :

"In general vector elements are laid out in memory in the same way as array types.
Such an analogy works fine as long as the vector elements are byte sized.
However, when the elements of the vector aren’t byte sized it gets a bit more complicated.
One way to describe the layout is by describing what happens when a vector such
as <N x iM> is bitcasted to an integer type with N*M bits, and then following the
rules for storing such an integer to memory."

"When <N*M> isn’t evenly divisible by the byte size the exact memory layout
is unspecified (just like it is for an integral type of the same size)."
2023-08-10 16:10:59 -07:00
Matt Knight
9959319d53
Compare user input for multiple dependency build variants (#16600) 2023-08-10 18:32:55 -04:00
Ryan Liptak
a190582b26 fs.Dir.realpathW: Reduce the number of OpenFile calls for directories
`.filter = .any` can be used here to remove an unnecessary extra OpenFile call when getting the path of a directory
2023-08-10 13:25:14 -07:00
Michael Dusan
901457d173 linux: search for system libc++
When linking system llvm/clang/lld, add system libc++ to the searchlist.
This is needed for certain distros (eg. chimera linux).

closes #16754
2023-08-10 13:22:09 -07:00
Andrew Kelley
b820d5df79
Merge pull request #16747 from jacobly0/llvm-wo-libllvm
llvm: enable the backend even when not linked to llvm
2023-08-10 12:02:57 -07:00
Andrew Kelley
275e926cf8
Merge pull request #16604 from mlugg/result-type-shenanigans
Fix RLS issues, fix crash on invalid result type for `@splat`, refactor some bits of generic instantiations
2023-08-10 11:50:01 -07:00
mlugg
f32b9bc776
Sema: add references to generic instantiations
This makes the reference trace appear for generic calls where it
previously did not.

Resolves: #16725
2023-08-10 10:00:37 +01:00
mlugg
2209813bae
cases: modify error wording to match new errors
The changes to result locations and generic calls has caused mild
changes to some compile errors. Some are slightly better, some slightly
worse, but none of the changes are major.
2023-08-10 10:00:37 +01:00
mlugg
7a7d0225d9
Sema: detect invalid field stores in tuple initialization
This bug was exposed by the previous commit, since array_init is now
used for tuple parameters.
2023-08-10 10:00:37 +01:00
mlugg
f2c8fa769a
Sema: refactor generic calls to interleave argument analysis and parameter type resolution
AstGen provides all function call arguments with a result location,
referenced through the call instruction index. The idea is that this
should be the parameter type, but for `anytype` parameters, we use
generic poison, which is required to be handled correctly.

Previously, generic instantiations and inline calls worked by evaluating
all args in advance, before resolving generic parameter types. This
means any generic parameter (not just `anytype` ones) had generic poison
result types. This caused missing result locations in some cases.

Additionally, the generic instantiation logic caused `zirParam` to
analyze the argument types a second time before coercion. This meant
that for nominal types (struct/enum/etc), a *new* type was created,
distinct to the result type which was previously forwarded to the
argument expression.

This commit fixes both of these issues. Generic parameter type
resolution is now interleaved with argument analysis, so that we don't
have unnecessary generic poison types, and generic instantiation logic
now handles parameters itself rather than falling through to the
standard zirParam logic, so avoids duplicating the types.

Resolves: #16566
Resolves: #16258
Resolves: #16753
2023-08-10 10:00:26 +01:00
mlugg
93e53d1e00
compiler: fix crash on invalid result type for @splat
This introduces a new ZIR instruction, `vec_elem_type`.

Co-Authored-By: Ali Chraghi <alichraghi@proton.me>
Resolves: #16567
2023-08-09 19:46:58 +01:00
mlugg
6917a8c258
AstGen: handle ty result location for struct and array init correctly
Well, this was a journey!

The original issue I was trying to fix is covered by the new behavior
test in array.zig: in essence, `ty` and `coerced_ty` result locations
were not correctly propagated.

While fixing this, I noticed a similar bug in struct inits: the type was
propagated to *fields* fine, but the actual struct init was
unnecessarily anonymous, which could lead to unnecessary copies. Note
that the behavior test added in struct.zig was already passing - the bug
here didn't change any easy-to-test behavior - but I figured I'd add it
anyway.

This is a little harder than it seems, because the result type may not
itself be an array/struct type: it could be an optional / error union
wrapper. A new ZIR instruction is introduced to unwrap these.

This is also made a little tricky by the fact that it's possible for
result types to be unknown at the time of semantic analysis (due to
`anytype` parameters), leading to generic poison. In these cases, we
must essentially downgrade to an anonymous initialization.

Fixing these issues exposed *another* bug, related to type resolution in
Sema. That issue is now tracked by #16603. As a temporary workaround for
this bug, a few result locations for builtin function operands have been
disabled in AstGen. This is technically a breaking change, but it's very
minor: I doubt it'll cause any breakage in the wild.
2023-08-09 19:46:55 +01:00
Zachary Raineri
0461a64a93
change uses of std.builtin.Mode to OptimizeMode (#16745)
std.builtin.Mode is deprecated.
2023-08-09 14:39:34 -04:00
Andrew Kelley
72c68f698e
Merge pull request #16752 from jacobly0/generic-srclocs
Sema: fix issues with source locations of generic arguments
2023-08-09 11:38:47 -07:00
mllken
9676a43a5d linux: add setsid 2023-08-09 11:33:06 -07:00
Jacob Young
57470e833e Module: implement span for .call_arg of a @call
Closes #16750
2023-08-09 10:09:17 -04:00
Jacob Young
736df27663 Sema: use the correct decl for generic argument source locations
Closes #16746
2023-08-09 10:09:01 -04:00
Jacob Young
9630379a8e Sema: fix generic method argument source locations 2023-08-09 10:09:01 -04:00
Jacob Young
c4848694d2 llvm: enable even without libllvm linked 2023-08-09 05:47:13 -04:00
Jacob Young
151c06cce4 std.mem.sliceAsBytes: support arrays of zero-bit types
This makes `std.ArrayListUnmanaged(void)` usable.
2023-08-09 05:47:13 -04:00
Jacob Young
66084b6c3f Sema: remove validateRunTimeType
This function does not seem to differ in any interesting way from
`!typeRequiresComptime`, other than the `is_extern` param which is only
used in one place, and some differences did not seem correct anyway.

My reasoning for changing opaque types to be comptime-only is that
`explainWhyTypeIsComptime` is quite happy to explain why they are. :D
2023-08-09 05:46:44 -04:00