Commit Graph

9946 Commits

Author SHA1 Message Date
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
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
Linus Groh
5769592cdd std.os.uefi: Fix calling convention build error
```
std/os/uefi/protocol/simple_text_input.zig:10:63: error: no field named 'Win64' in enum '@typeInfo(builtin.CallingConvention).@"union".tag_type.?'
std/builtin.zig:169:31: note: enum declared here
std/os/uefi/protocol/simple_text_output.zig:9:64: error: no field named 'Win64' in enum '@typeInfo(builtin.CallingConvention).@"union".tag_type.?'
std/builtin.zig:169:31: note: enum declared here
std/os/uefi/tables/runtime_services.zig:26:86: error: no field named 'Win64' in enum '@typeInfo(builtin.CallingConvention).@"union".tag_type.?'
std/builtin.zig:169:31: note: enum declared here
```
2024-10-25 10:45:55 +02:00
Andrew Kelley
cc671a2d40 std.Build.Watch: implement removing watches for kqueue 2024-10-24 23:31:56 -07:00
Andrew Kelley
8819d8b061 std.Build.Watch: limit to one switch on os tag
DRY
2024-10-24 16:29:02 -07:00
Andrew Kelley
7a46ba73ce implement --watch for kqueue
it doesn't detect and remove no longer watched things yet

it also isn't aware of any file names reported by kqueue. I'm unsure if
that functionality exists.
2024-10-24 16:24:56 -07:00
Andrew Kelley
ba71079837 combine codegen work queue and linker task queue
these tasks have some shared data dependencies so they cannot be done
simultaneously. Future work should untangle these data dependencies so
that more can be done in parallel.

for now this commit ensures correctness by making linker input parsing
and codegen tasks part of the same queue.
2024-10-23 16:27:39 -07:00
Andrew Kelley
3f6b6b1bcd revert macos target version bump 2024-10-23 16:27:38 -07:00
Andrew Kelley
c2898c436f branch fixes 2024-10-23 16:27:38 -07:00
Andrew Kelley
e567abb339 rework linker inputs
* Compilation.objects changes to Compilation.link_inputs which stores
  objects, archives, windows resources, shared objects, and strings
  intended to be put directly into the dynamic section. Order is now
  preserved between all of these kinds of linker inputs. If it is
  determined the order does not matter for a particular kind of linker
  input, that item should be moved to a different array.
* rename system_libs to windows_libs
* untangle library lookup from CLI types
* when doing library lookup, instead of using access syscalls, go ahead
  and open the files and keep the handles around for passing to the
  cache system and the linker.
* during library lookup and cache file hashing, use positioned reads to
  avoid affecting the file seek position.
* library directories are opened in the CLI and converted to Directory
  objects, warnings emitted for those that cannot be opened.
2024-10-23 16:27:38 -07:00
Andrew Kelley
4706ec81d4 introduce a CLI flag to enable .so scripts; default off
The compiler defaults this value to off so that users whose system
shared libraries are all ELF files don't have to pay the cost of
checking every file to find out if it is a text file instead.

When a GNU ld script is encountered, the error message instructs users
about the CLI flag that will immediately solve their problem.
2024-10-23 16:27:38 -07:00
Andrew Kelley
a4cc344aa0 std.Build.Step.Compile: add a way to expect an error message
other than a compile error, specifically
2024-10-23 16:27:38 -07:00
Andrew Kelley
33d07f4b6e
Merge pull request #21779 from ziglang/avoid-data-races
link.MachO: remove buggy multi-threading
2024-10-23 16:27:09 -07:00
Andrew Kelley
78f643c46d
Merge pull request #21758 from kcbanner/dll_storage_class
Add `is_dll_import` to @extern, to support `__declspec(dllimport)` with the MSVC ABI
2024-10-23 15:35:54 -07:00
Andrew Kelley
d210f733f8 std.Progress: fix data race
In end(), the freelist pointer is owned so the bare store would be ok.
However, there is a load in start() that can happen at the same time, if
another start() and end() pair grabs that same index.

I don't think this fixes #21663 actually because even if the data race
corrupts the value for `next`, the cmpxchg protects the value from being
stored there.
2024-10-23 13:47:44 -07:00
Matthew Lugg
6bf52b0505
Merge pull request #21697 from mlugg/callconv
Replace `std.builtin.CallingConvention` with a tagged union, eliminating `@setAlignStack`
2024-10-23 16:48:33 +01:00
kcbanner
b87fa93500 Change ExternOptions.dll_storage_class to is_dll_import
It wouldn't make sense to have passe `.export` here, and that was
in fact a compile error - so simply make this a bool instead.
2024-10-22 12:41:35 -04:00
kcbanner
ee25757245 Add support for specifying dll_storage_class in @extern 2024-10-22 12:41:35 -04:00
Mario Nachbaur
9f84f7f921 watchOS: add os to aarch64 architecture
Needed for creating libraries that run both on
physical Apple Watches and the watchOS simulator.
2024-10-21 09:24:24 +02:00
mlugg
830230176d
std: update uses of .Inline callconv 2024-10-19 19:21:33 +01:00
mlugg
bde68fdebc
std.Target: correct C callconv on hardfloat ARM 2024-10-19 19:21:32 +01:00
mlugg
ed862b05ae
std.builtin.CallingConvention: remove deprecated RISC-V privilege mode
See b6cade0703
2024-10-19 19:21:32 +01:00
mlugg
2319d62f21
std.builtin.CallingConvention: include exact architecture tags in comments 2024-10-19 19:15:24 +01:00
mlugg
67580ede5e
std.builtin.CallingConvention: RISC-V PrivilegeLevel -> PrivilegeMode
The RISC-V specification uses these terms a little interchangably, but
"mode" seems more correct here.
2024-10-19 19:15:24 +01:00
mlugg
6657982e56
std.builtin.CallingConvention: don't provide bogus winapi value 2024-10-19 19:15:24 +01:00
mlugg
2d9a167cd2
std.Target: rename defaultCCallingConvention and Cpu.Arch.fromCallconv 2024-10-19 19:15:23 +01:00
mlugg
cbfe00b17d
std.zig.render: fix callconv(.Inline) -> inline fn promotion 2024-10-19 19:15:23 +01:00
mlugg
4be0cf30fc
test: update for CallingConvention changes
This also includes some compiler and std changes to correct error
messages which weren't properly updated before.
2024-10-19 19:15:23 +01:00
mlugg
ec19086aa0
compiler: remove @setAlignStack
This commit finishes implementing #21209 by removing the
`@setAlignStack` builtin in favour of `CallingConvention` payloads. The
x86_64 backend is updated to use the stack alignment given in the
calling convention (the LLVM backend was already updated in a previous
commit).

Resolves: #21209
2024-10-19 19:15:23 +01:00
mlugg
bc797a97b1
std: update for new CallingConvention
The old `CallingConvention` type is replaced with the new
`NewCallingConvention`. References to `NewCallingConvention` in the
compiler are updated accordingly. In addition, a few parts of the
standard library are updated to use the new type correctly.
2024-10-19 19:15:23 +01:00
mlugg
51706af908
compiler: introduce new CallingConvention
This commit begins implementing accepted proposal #21209 by making
`std.builtin.CallingConvention` a tagged union.

The stage1 dance here is a little convoluted. This commit introduces the
new type as `NewCallingConvention`, keeping the old `CallingConvention`
around. The compiler uses `std.builtin.NewCallingConvention`
exclusively, but when fetching the type from `std` when running the
compiler (e.g. with `getBuiltinType`), the name `CallingConvention` is
used. This allows a prior build of Zig to be used to build this commit.
The next commit will update `zig1.wasm`, and then the compiler and
standard library can be updated to completely replace
`CallingConvention` with `NewCallingConvention`.

The second half of #21209 is to remove `@setAlignStack`, which will be
implemented in another commit after updating `zig1.wasm`.
2024-10-19 19:08:59 +01:00
mlugg
097766bba3 compiler: implement @FieldType
Resolves: #21702
2024-10-18 08:50:40 +01:00
Alex Rønne Petersen
ff594eae49 std.Target: Make Abi.default() more smarter.
This builds on 221bd829bc with more research I did
for test/llvm_targets.zig.
2024-10-18 00:10:43 +02:00
Alex Rønne Petersen
d38ed893c6
Merge pull request #21726 from alexrp/target-api
`std.Target`: Some miscellaneous API improvements
2024-10-17 02:49:34 +02:00