Commit Graph

31720 Commits

Author SHA1 Message Date
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 c825b567b2.
2024-11-02 10:44:14 +01:00
Alex Rønne Petersen
a5bc9cbb15
llvm: Fix lowering of gnuilp32 ABI to be gnu_ilp32.
LLVM doesn't even recognize the gnuilp32 spelling as an alternative.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
d61e4ef8b0
generate_linux_syscalls: Generate syscalls for x32.
Also update the syscalls file based on Linux 6.10. No diffs other than x32.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
43878f51d9
glibc: Emit _IO_stdin_used reference in .rodata.
This fixes an X86_64_32 relocation linker error when targeting gnux32.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
50cae505f7
glibc: Fix an LP_SIZE redefinition warning for gnux32. 2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
11915ae48e
std.zig.target: Change mips64(el)-linux-musl triples to -muslabi64.
With this, MIPS triples for musl are in line with glibc triples.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
8baf887f4e
std.zig.target: Add mips64(el)-linux-muslabin32 and x86_64-linux-muslx32. 2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
ec0e6440b1
musl: Update sources from musl 1.2.5.
Adds mipsn32 and x32 sources.

Also remove some useless .in files.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
3ec27ae648
musl: Update headers from musl 1.2.5.
Adds mips64-linux-muslabin32 and x86_64-linux-muslx32 headers.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
94cf5b26f4
process_headers: Add muslabin32 and muslx32 support. 2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
497b502ce4
process_headers: Simplify the code a bit. 2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
270fbbcd86
std.Target: Add muslabin32 and muslabi64 tags to Abi.
Once we upgrade to LLVM 20, these should be lowered verbatim rather than to
simply musl. Similarly, the special case in llvmMachineAbi() should go away.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
8045268698
std.zig.target: Update musl path helpers to support alternative ABIs.
This is needed for muslx32 and muslabin32 support.
2024-11-02 10:38:06 +01:00
Alex Rønne Petersen
533d8ea771
musl: Fix needsCrtiCrtn() for m68k. 2024-11-02 10:38:06 +01:00
Alex Rønne Petersen
243c25007f
musl: Update the list of architectures with time32 compat helpers. 2024-11-02 10:38:06 +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 d1d95294fd, 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
Andrew Kelley
aaf54ce6a7 link.File.Wasm.Archive: simplify
Don't use the reader interface
Avoid unnecessary heap allocations

At first I started working on incorporating the Archive fields into the
Wasm data model, however, I realized a better strategy: simply omit
Archive data from the serialized linker state. Those files can be
trivially reparsed on next compiler process start. If they haven't
changed, great. Otherwise if they have, the prelink phase needs to be
restarted anyway.
2024-11-01 14:41:56 -07:00
Andrew Kelley
d30e287543
Merge pull request #21874 from ziglang/wasm-linker
link.File.Wasm: unify the string tables
2024-11-01 02:16:36 -07: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
c5395f7cd9
llvm: Set OS min version and libc version in ~all cases.
Except Windows, because that just doesn't really fit into LLVM's target triple
format currently.
2024-11-01 06:23:59 +01:00
Alex Rønne Petersen
60c0f522d9
llvm: Set vendor type in LLVM target triple for more OSs.
Annoyingly, LLVM and Clang have various checks throughout that depend on these
vendor types being set.
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
Andrew Kelley
e501cf51a0 link.File.Wasm: unify the string tables
Before, the wasm struct had a string table, the ZigObject had a string
table, and each Object had a string table.

Now there is just the one. This makes for more efficient use of memory
and simplifies logic, particularly with regards to linker state
serialization.

This commit additionally adds significantly more integer type safety.
2024-10-31 22:01:10 -07:00
Andrew Kelley
bf9978a57a link.File.Wasm: conform to naming conventions 2024-10-31 22:01:10 -07:00
Andrew Kelley
2b868bb6dd link.File.Wasm.Archive: remove header field
it's not needed
2024-10-31 22:01:10 -07: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
Matthew Lugg
3f7fac5fff
Merge pull request #21817 from mlugg/no-anon-structs
compiler: remove anonymous struct types, unify all tuples
2024-11-01 01:43:08 +00:00
Ali Cheraghi
38345d5909
std.gpu: add instanceIndex 2024-11-01 02:04:27 +03:30
Ali Cheraghi
c07b3c8279
spirv: decorate arrays stride 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
Andrew Kelley
f2dcfe0e40 link.File.Wasm: parse inputs in compilation pipeline
Primarily, this moves linker input parsing from flush() into the linker
task queue, which is executed simultaneously with the frontend.

I also made it avoid redundantly opening the same archive file N times
for each object file inside. Furthermore, hard code fixed buffer stream
rather than using a generic stream type.

Finally, I fixed the error handling of the Wasm.Archive.parse function.
Please pay attention to this pattern of returning a struct rather than
accepting a mutable struct as an argument. This ensures function-level
atomicity and makes resource management straightforward.

Deletes the file and path fields from Archive and Object.

Removed a well-meaning but ultimately misguided suggestion about how to
think about ZigObject since thinking about it that way has led to
problematic anti-DOD patterns.
2024-10-30 23:43:53 -07:00
Andrew Kelley
f5ade5e207
Merge pull request #21862 from alexrp/llvm-19-api-break
Reduce our exposure to LLVM API breakage
2024-10-30 22:46:40 -07:00
Andrew Kelley
ba2d006634 link.File.Wasm: remove the "files" abstraction
Removes the `files` field from the Wasm linker, storing the ZigObject
as its own field instead using a tagged union.

This removes a layer of indirection when accessing the ZigObject, and
untangles logic so that we can introduce a "pre-link" phase that
prepares the linker state to handle only incremental updates to the
ZigObject and then minimize logic inside flush().

Furthermore, don't make array elements store their own indexes, that's
always a waste.

Flattens some of the file system hierarchy and unifies variable names
for easier refactoring.

Introduces type safety for optional object indexes.
2024-10-30 19:34:58 -07:00
Alex Rønne Petersen
16b87f7082
link: Fix archive format selection for some OSs.
* AIX has its own bespoke format.
* Handle all Apple platforms.
* FreeBSD and OpenBSD both use the GNU format in LLVM.
* Windows has since been switched to the COFF format by default in LLVM.
2024-10-31 01:33:49 +01:00
Alex Rønne Petersen
33715cb28f
mingw: Fix COFF machine type selection for thumb-windows-gnu import libraries. 2024-10-31 01:31:44 +01:00