9978 Commits

Author SHA1 Message Date
Alex Rønne Petersen
be8a527eb2
std.os.windows: Deprecate WINAPI in favor of CallingConvention.winapi. 2024-11-02 10:44:18 +01:00
Alex Rønne Petersen
5a6cc552e3
std.os.windows: Fix some incorrect callconv specifiers.
Closes #21869.
2024-11-02 10:44:18 +01:00
Alex Rønne Petersen
82e82b6267
start: Fix callconv for the wWinMainCRTStartup symbol.
This just uses the C calling convention in the vcruntime sources.
2024-11-02 10:44:18 +01:00
Alex Rønne Petersen
8a2d960627
start: Fix a calling convention check to use eql().
Also modernize some callconv uses.

Closes #21813.
2024-11-02 10:44:18 +01:00
Alex Rønne Petersen
baf60426d4
std.Target: Rename amdgpu module to amdgcn.
This was an inconsistency left over from c825b567b26c475e058e074e5d22af006854fab6.
2024-11-02 10:44:14 +01:00
Alex Rønne Petersen
20cdfe9fb6
std.Target: Pick arm_aapcs16_vfp for arm-watchos-* in cCallingConvention().
This is a legacy target, but we should still get it right.
2024-11-02 10:30:48 +01:00
Alex Rønne Petersen
f7da31b1f4
std.builtin: Some minor fixes to CallingConvention doc comments. 2024-11-02 10:30:48 +01:00
Alex Rønne Petersen
e27b4647d8
Merge pull request #21617 from alexrp/target-dyld-stuff
Improve the `DynamicLinker` API and fix `detectAbiAndDynamicLinker()` for non-Linux/Hurd ELF hosts
2024-11-02 10:29:41 +01:00
Alex Rønne Petersen
8abbdb56a4
Merge pull request #21729 from alexrp/target-cpu-baseline
`std.Target.Cpu.Model`: Further refinements to `generic()` and `baseline()`
2024-11-02 10:27:03 +01:00
Alex Rønne Petersen
fccf15fc9f std.Target: Remove armv7k/armv7s.
Like d1d95294fd657f771657ea671a6984b860347fb0, this is more Apple nonsense where
they abused the arch component of the triple to encode what's really an ABI.

Handling this correctly in Zig's target triple model would take quite a bit of
work. Fortunately, the last Armv7-based Apple Watch was released in 2017 and
these targets are now considered legacy. By the time Zig hits 1.0, they will be
a distant memory. So just remove them.
2024-11-02 10:25:40 +01:00
Alex Rønne Petersen
ab89af3d39
Merge pull request #21860 from alexrp/llvm-triple-stuff
More support for OS/libc version ranges in `std.Target` and improvements to LLVM target triple construction
2024-11-02 02:00:25 +01:00
Brook Jeynes
a99449d8be
std.c: Added utsname struct definition for .macos (#21873) 2024-11-01 07:57:00 +00:00
Alex Rønne Petersen
3c1ccbdf39
std.Target: Add support for specifying Android API level. 2024-11-01 06:23:59 +01:00
Alex Rønne Petersen
f89982bf53
std.Target: Add semver min/max versions for a bunch of OSs. 2024-11-01 06:23:59 +01:00
Alex Rønne Petersen
ed68083d8f
std.Target: Update known OS max versions. 2024-11-01 06:23:59 +01:00
Alex Rønne Petersen
ace26004a3
std.Target: Remove arch-specific handling for macos in Os.VersionRange.default().
The minimum is now the same for both aarch64 and x86_64.
2024-11-01 06:23:59 +01:00
Alex Rønne Petersen
af48ce6379
std.Target: Sort some OS switches according to the Os enum. 2024-11-01 06:23:59 +01:00
Robin Voetter
ba5f57616f
Merge pull request #21861 from alichraghi/master
spirv: push constants and small fixes
2024-11-01 03:44:37 +01:00
Ali Cheraghi
38345d5909
std.gpu: add instanceIndex 2024-11-01 02:04:27 +03:30
Ali Cheraghi
a1cb9563f6
spirv: Uniform/PushConstant variables
- Rename GPU address spaces to match with SPIR-V spec.
- Emit `Block` Decoration for Uniform/PushConstant variables.
- Don't emit `OpTypeForwardPointer` for non-opencl targets.
  (there's still a false-positive about recursive structs)

Signed-off-by: Ali Cheraghi <alichraghi@proton.me>
2024-11-01 02:03:33 +03:30
mlugg
24babde746
std.mem.asBytes: fix footgun when passing non-single pointer
I was just bitten by this footgun, where I actually wanted
`sliceAsBytes` but unintentionally used `asBytes`, which in practice
ignored all but the first element. Just add a comptime assertion to
trigger a compile error in this case.
2024-10-31 20:42:53 +00:00
mlugg
d11bbde5f9
compiler: remove anonymous struct types, unify all tuples
This commit reworks how anonymous struct literals and tuples work.

Previously, an untyped anonymous struct literal
(e.g. `const x = .{ .a = 123 }`) was given an "anonymous struct type",
which is a special kind of struct which coerces using structural
equivalence. This mechanism was a holdover from before we used
RLS / result types as the primary mechanism of type inference. This
commit changes the language so that the type assigned here is a "normal"
struct type. It uses a form of equivalence based on the AST node and the
type's structure, much like a reified (`@Type`) type.

Additionally, tuples have been simplified. The distinction between
"simple" and "complex" tuple types is eliminated. All tuples, even those
explicitly declared using `struct { ... }` syntax, use structural
equivalence, and do not undergo staged type resolution. Tuples are very
restricted: they cannot have non-`auto` layouts, cannot have aligned
fields, and cannot have default values with the exception of `comptime`
fields. Tuples currently do not have optimized layout, but this can be
changed in the future.

This change simplifies the language, and fixes some problematic
coercions through pointers which led to unintuitive behavior.

Resolves: #16865
2024-10-31 20:42:53 +00:00
Archit Gupta
a916bc7fdd std.fs.File: Fix metadata error check on Linux
On Linux, File.metadata calls the statx syscall directly. As such, the
return value is the error code. Previously, it handled the error with
`posix.errno`, which when libc is linked, treats the return value as a
value set to -1 if there is an error with the error code in errno. If
libc wasn't linked, it would be handled correctly.

In the Linux with libc linked case, this would cause the error result to
always be treated as success (err val != -1), even when an error
occurred.
2024-10-31 14:02:42 +01:00
Simon Ekström
17a87d7341
std.fmt: Fix compile error in Parser.peek() (#20532) 2024-10-30 07:45:23 +00:00
Mario Nachbaur
4661705a0e
std.debug: watchOS: fixes for ilp32 ABI (#21765)
Xcode requires target arm64_32 (aarch64-watchos-ilp32) in order to
build code for Apple Watches. This commit fixes compilation errors
that appear when compiling with that target.
2024-10-29 22:12:57 +01:00
Robin Voetter
3450809e3d
Merge pull request #21826 from Snektron/spirv-vulkan
spirv: vulkan setup
2024-10-29 19:58:51 +01:00
Julian Noble
a03ab9ee01
std.os.windows.WriteFile: Map ERROR_NO_DATA to error.BrokenPipe instead of ERROR_BROKEN_PIPE (#21811)
It appears that ReadFile returns ERROR_BROKEN_PIPE for a broken pipe, but WriteFile returns ERROR_NO_DATA.

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-10-29 15:10:19 +01:00
JonathanHallstrom
5ce17ecfa7 remove unnecessary cast 2024-10-29 01:48:13 +01:00
Bruno Franca dos Reis
cdd8e82f0a
closes #21824 (#21832) 2024-10-28 14:54:02 +00:00
Alex Rønne Petersen
4c336705b9
Merge pull request #21807 from Rexicon226/riscv-interupt
implement new interrupt calling conventions in the llvm backend
2024-10-28 13:51:11 +01:00
David Rubin
6415ff29d7 remove needs_mem_loc
This field isn't used anymore and was related to old RLS
2024-10-28 08:17:31 +00:00
Robin Voetter
9b42bc1ce5
spirv: start.zig support for vulkan
* Use builtin.zig_backend instead of builtin.cpu.arch, the latter
  does not yet compile under VK.
* Don't call regular _start for either opencl or vulkan. We might
  even want to disable these completely.
2024-10-27 14:20:52 +01:00
Alex Rønne Petersen
059f18855f
std.Target: Make DynamicLinker.standard() much stricter.
Its semantics are now documented in terms of DynamicLinker.kind(os.tag).

The idea here is two-fold:

* The term "standard" actually means something; we shouldn't return a valid
  dynamic linker path for a triple for which it hasn't *actually* been
  standardized. That's just incorrect. For example, previously, this function
  would happily return a path for x86_64-linux-androideabi, csky-macos-gnu, or
  aarch64-hurd-msvc, and other such obvious nonsense.
* Callers that use the return value from this function to do host probing (such
  as std.zig.system.detectAbiAndDynamicLinker()) can now do so with greater
  confidence because DynamicLinker.standard() will eagerly reject nonsensical
  target triples.
2024-10-26 22:00:49 +02:00
Alex Rønne Petersen
8818dc6213
std.zig.system: Fix detectAbiAndDynamicLinker() for non-Linux/Hurd ELF hosts.
Since we exclude Abi.none from the list of ABIs to be tested, it means that
Abi.gnu, which happens to be the first in the list, always gets picked for hosts
where the dynamic linker path does not depend on the ABI component of the
triple. Such hosts include all the BSDs, Haiku, Serenity, Solaris, etc.

To fix this, use DynamicLinker.kind() to determine whether this whole exercise
even makes sense. If it doesn't, as is the case on every OS other than Linux and
Hurd, we'll just fall back to Abi.default() which will try to pick a sensible
default based on the arch and OS components. This detection logic still has
plenty of room for improvement, but is at least a notable step up from
confusingly detecting Abi.gnu ~everywhere.

Closes #9089.
2024-10-26 22:00:49 +02:00
Alex Rønne Petersen
27c85e5969
std.Target: Remove hasDynamicLinker() in favor of DynamicLinker.kind().
hasDynamicLinker() was just kind of lying in the case of Darwin platforms for
the benefit of std.zig.system.detectAbiAndDynamicLinker(). A better name would
have been hasElfDynamicLinker() or something. It also got the answer wrong for a
bunch of platforms that don't actually use ELF. Anyway, this was clearly the
wrong layer to do this at, so remove this function and instead use
DynamicLinker.kind() + an isDarwin() check in detectAbiAndDynamicLinker().
2024-10-26 22:00:49 +02:00
Alex Rønne Petersen
f02d25d883
std.Target: Implement DynamicLinker.kind() function.
This helps callers of DynamicLinker.standard() make informed decisions about
the usefulness of the returned value.
2024-10-26 22:00:49 +02:00
Alex Rønne Petersen
79717740bd
std.Target: Pick better baseline CPU models for darwin and ps4/ps5 on x86_64.
These are sourced from getX86TargetCPU() in Clang.
2024-10-26 21:59:59 +02:00
Alex Rønne Petersen
ea987faa85
std.Target: Use explicit baseline CPU models for bpf, m68k, msp430, and xcore.
This makes no difference presently, but if LLVM ever starts modeling features
for these, we would not get them by default for our baseline if we use the
generic model.
2024-10-26 21:59:59 +02:00
Alex Rønne Petersen
e26b64a87d
std.Target: Use mips32r2/mips64r2 as the baseline CPU models for mips/mips64.
This matches Clang's defaults. That also means these CPU models tend to get more
testing, so they're a safer baseline choice. Anecdotally, the oldest MIPS
hardware that I've seen anyone run Zig on was also r2.
2024-10-26 21:59:59 +02:00
Alex Rønne Petersen
385f586605
std.Target: Use sm_52 as the baseline CPU model for nvptx.
This matches Clang's default.
2024-10-26 21:59:59 +02:00
Alex Rønne Petersen
2d22cc9f61
std.Target: Use gfx906 as the baseline CPU model for amdgcn.
This matches Clang's default.
2024-10-26 21:59:59 +02:00
Alex Rønne Petersen
5b7eba95ba
std.Target: Use gfx600 as the generic CPU model for amdgcn.
This is the first model that was actually in the GCN family.
2024-10-26 21:59:59 +02:00
Alex Rønne Petersen
51dc4b0549
std.Target: Use ppc64 as the generic CPU model for powerpc64le.
ppc64le remains the baseline CPU model. Note that there's nothing about little
endian, 64-bit PowerPC that requires the features in the ppc64le model; the
reason it exists is that 64-bit PowerPC wasn't really used in little endian mode
prior to those features being commonplace. That makes the ppc64le model a good
baseline model, but not the right choice for a generic model.
2024-10-26 21:59:59 +02:00
Alex Rønne Petersen
8062bdba9a
std.Target: Use avr1 as the generic CPU model for avr.
avr2 remains the baseline CPU model.
2024-10-26 21:59:58 +02:00
Alex Rønne Petersen
c50fb58307
std.Target: Use v11 as the baseline CPU model for lanai. 2024-10-26 21:59:58 +02:00
Alex Rønne Petersen
73b4cb6314
std.Target: Use ck810 as the baseline CPU model for csky. 2024-10-26 21:59:58 +02:00
Alex Rønne Petersen
8282f3be96
std.Target: Add doc comments for Cpu.Arch.generic() and baseline(). 2024-10-26 21:59:58 +02:00
Nelson Crosby
b1361f237a Fix up Linux xattr syscalls
fgetxattr now doesn't accidentally call lgetxattr,
and argument types are more consistent.
2024-10-26 13:53:07 +02:00
David Rubin
b122b9fbe0
remove default field for RiscvInterruptOptions.Mode 2024-10-25 20:00:43 -07:00
Andrew Kelley
b8795b4d02
Merge pull request #21795 from ziglang/kqueue-watch
Build Runner: Implement File System Watching for kqueue
2024-10-25 04:00:26 -07:00