Commit Graph

30351 Commits

Author SHA1 Message Date
Alex Rønne Petersen 8268d7be52 process_headers: Add arc-linux-gnu. 2024-08-07 01:07:09 -07:00
Jakub Dóka a6486492be std.crypto.ecdsa: use separate function for null seed (#20953)
Due to the `std.crypto.ecdsa.KeyPair.create` taking and optional of seed, even if the seed is generated, cross-compiling to the environments without standard random source (eg. wasm) (`std.crypto.random.bytes`) will fail to compile.

This commit changes the API of the problematic function and moves the random seed generation to a new utility function.
2024-08-07 01:06:15 -07:00
Alex Rønne Petersen ebd0c6ffd0 std.zig.target: Add arc-linux-gnu.
https://lists.gnu.org/archive/html/info-gnu/2020-08/msg00002.html
2024-08-07 01:03:22 -07:00
Ryan Liptak 304519da27 Make Type.intAbiAlignment match LLVM alignment for x86-windows target
During the LLVM 18 upgrade, two changes were made that changed `@alignOf(u64)` to 4 for the x86-windows target:

- `Type.maxIntAlignment` was made to return 16 for x86 (200e06b). Before that commit, `maxIntAlignment` was 8 for windows/uefi and 4 for everything else
- `Type.intAbiAlignment` was made to return 4 for 33...64 (7e1cba7 + e89d6fc). Before those commits, `intAbiAlignment` would return 8, since the maxIntAlignment for x86-windows was 8 (and for other targets, the `maxIntAlignment` of 4 would clamp the `intAbiAlignment` to 4)

`src/codegen/llvm.zig` has its own alignment calculations that no longer match the values returned from the `Type` functions. For the x86-windows target, this loop:

https://github.com/ziglang/zig/blob/ddcb7b1c11f88c4ae150b36807033060a469dcb5/src/codegen/llvm.zig#L558-L567

when the `size` is 64 will set `abi` and `pref` to 64 (meaning an align of 8 bytes), which doesn't match the `Type` alignment of 4.

This commit makes `Type.intAbiAlignment` match the alignment calculated in `codegen/llvm.zig`.

Fixes #20047
Fixes #20466
Fixes #20469
2024-08-07 00:59:46 -07:00
Alex Rønne Petersen 00097c3bb8 std.Target: Some corrections and additions to charSignedness().
Sourced from GCC backends and some manual testing with clang.
2024-08-07 00:56:02 -07:00
Kyle Schwarz a60810b5a3 cmake: add ZIG_EXTRA_BUILD_ARGS option 2024-08-06 19:28:48 -07:00
Alex Rønne Petersen e9b5377b8e musl: Disable warnings in all compilations.
This is what upstream's configure does.

Previously, we only disabled warnings in some musl compilations, with `rcrt1.o`
notably being one for which we didn't. This resulted in a warning in `dlstart.c`
which is included in `rcrt1.c`. So let's just be consistent and disable warnings
for all musl code.

Closes #13385.
2024-08-06 15:00:47 -07:00
Andrew Kelley c8a226a429 Merge pull request #20960 from alexrp/size-align-fixes
`std.Target`: A bunch of C type size/alignment fixes
2024-08-06 14:55:15 -07:00
Andrew Kelley de1fb19909 Merge pull request #20951 from ehaas/c-size-and-align-check
tools: Add tool for checking size and alignment of C types
2024-08-06 13:06:28 -07:00
Alex Rønne Petersen ef502daafe std.Target: Handle mesa3d in c_type_bit_size(). 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen 23b5a6c71e std.Target: Treat spirv as identical to spirv64 for ABI size/alignment purposes.
This is arbitrary since spirv (as opposed to spirv32/spirv64) refers to the
version with logical memory layout, i.e. no 'real' pointers. This change at
least matches what clang does.
2024-08-06 20:17:03 +02:00
Alex Rønne Petersen 231f322a65 std.Target: Fix C long double size for ve (16, not 8). 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen 7b47ebe576 std.Target: Fix C long double size for sparc32 (8, not 16). 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen eef499812c std.Target: Fix C long double size for amdhsa, amdpal, and mesa3d (8, not 16). 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen a1d3e56763 std.Target: Fix C long double size for opencl (8, not 16).
This value was correct for the old SPIR, but not for SPIR-V.
2024-08-06 20:17:03 +02:00
Alex Rønne Petersen 606d011acf std.Target: Fix C long long size for opencl (8, not 16).
This value was correct for the old SPIR, but not for SPIR-V.
2024-08-06 20:17:03 +02:00
Alex Rønne Petersen 5dd66cd964 std.Target: Fix C type alignment calculation for ve. 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen e678862520 std.Target: Fix C type alignment calculation for sparc64. 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen 98153c8d81 std.Target: Fix C type alignment calculation for loongarch64. 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen 29321ca4a2 std.Target: Fix C type alignment calculation for spirv32. 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen e67388c2e5 std.Target: Fix C type alignment calculation for dxil. 2024-08-06 20:17:03 +02:00
Alex Rønne Petersen db8f00e277 std.Target: Fix ptrBitWidth_cpu_abi() for sparc32.
CPU feature set has nothing to do with ABI choice; the pointer bit width is
determined only by looking at the choice of sparc vs sparc64.
2024-08-06 20:17:03 +02:00
Alex Rønne Petersen ab154be7f0 std.Target: Fix ptrBitWidth_cpu_abi() for dxil (64-bit, not 32-bit).
The DXIL documentation claims 32-bit pointers:

https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#memory-accesses

Despite this, Clang considers pointers 64-bit when targeting it.
2024-08-06 20:17:03 +02:00
Evan Haas 679ad36fa0 generate_c_size_and_align_checks: add __alignof check 2024-08-06 07:06:57 -07:00
Evan Haas b2dd0a669a generate_c_size_and_align_checks: print failed condition in _Static_assert 2024-08-06 07:03:00 -07:00
Evan Haas 8daf7673a5 test: Add generate_c_size_and_align_checks.zig to standalone build test 2024-08-05 13:15:05 -07:00
Andrew Kelley ddcb7b1c11 Merge pull request #20949 from ziglang/update-glibc-abilists
glibc: update abilists file
2024-08-05 13:10:55 -07:00
Evan Haas 4bdf04654e tools: Add tool for checking size and alignment of C types
Prints _Static_asserts for the size and alignment of all the basic built-in C
types. The output can be run through a compiler for the specified target to
verify that Zig's values are the same as those used by a C compiler for the
target.
2024-08-05 12:56:40 -07:00
ippsav 724804a4e0 Rewrite generate_linux_syscalls.zig (#20895)
refactors the syscall generation tool aiming to reduce code duplication for both the table based arches and the ones generated using a preprocessor.
2024-08-05 10:43:47 -07:00
Andrew Kelley d6945eeba9 Revert "glibc: Add a temporary hack in abilists loading due to sparcel removal."
This reverts commit 62a01851d9.

No longer needed with the abilists update.
2024-08-05 09:53:37 -07:00
Andrew Kelley 1b88c6a8a2 glibc: update abilists file
updated for glibc 2.40, and adds arc, csky, and m68k
2024-08-05 09:53:37 -07:00
Andrew Kelley fab5df4028 Merge pull request #20934 from alexrp/sparc32-leon3
`std.Target`: Bump baseline CPU for sparc32 to v9; add `sparcv9-linux-gnu` to `process_headers.zig`
2024-08-05 09:52:52 -07:00
Alex Rønne Petersen 388248ad33 std.zig.target: Set minimum glibc version for csky to 2.29.
https://lists.gnu.org/archive/html/info-gnu/2019-01/msg00018.html
2024-08-05 09:49:47 -07:00
Alex Rønne Petersen 27775f1a9e std.Target: Use v9 as the baseline CPU for sparc32.
It is impossible to even build projects like glibc when targeting a generic
SPARC v8 CPU; LEON3 is effectively considered the baseline for `sparc-linux-gnu`
now, particularly due to it supporting a CASA instruction similar to the one in
SPARC v9. However, it's slightly incompatible with SPARC v9 due to having a
different ASI tag, so resulting binaries would not be portable to regular SPARC
CPUs. So, as the least bad option, make v9 the baseline for sparc32.
2024-08-05 12:20:41 +02:00
Alex Rønne Petersen 4ba9a6f44c process_headers: Add sparcv9-linux-gnu for glibc.
This is 32-bit SPARC targeting the v8 ABI but v9 CPU.
2024-08-05 12:19:22 +02:00
Fri3dNstuff a655c15c40 std.sort: Remove key argument from binary-search-like functions (#20927)
closes #20110
2024-08-04 22:02:15 +00:00
YANG Xudong ea847535fc Add loongarch 64 to gen_stubs.zig. 2024-08-04 12:04:39 -07:00
Linus Groh a18293214d std.Target: Specify dynamic linker and C type sizes for serenity 2024-08-04 12:03:43 -07:00
Andrew Kelley a931bfada5 Merge pull request #20908 from ziglang/reorg-std.debug-again
std.debug: reorg and clarify API goals
2024-08-02 17:10:41 -07:00
Andrew Kelley 9e2668cd2e Merge pull request #20906 from alexrp/repro-windows
`ci`: Add stage3/4 diff to Linux (aarch64) and windows (aarch64, x86_64) release scripts.
2024-08-02 15:37:23 -07:00
Andrew Kelley 6d606cc38b reintroduce std.Dwarf.abi.supportsUnwinding
There are two concepts here: one for whether dwarf supports unwinding on
that target, and another for whether the Zig standard library
implements it yet.
2024-08-02 14:15:03 -07:00
Andrew Kelley 975c185b92 fix compilation on powerpc GNU systems
...which have a ucontext_t but not a PC register. The current stack
unwinding implementation does not yet support this architecture.

Also fix name of `std.debug.SelfInfo.openSelf` to remove redundancy.

Also removed this hook into root providing an "openSelfDebugInfo"
function. Sorry, this debugging code is not of sufficient quality to
offer a plugin API right now.
2024-08-02 14:14:59 -07:00
Alex Rønne Petersen 76ebae2ee0 ci: Add stage3/4 diff to aarch64-linux-release script. 2024-08-02 09:56:54 +02:00
Alex Rønne Petersen 6def9cee00 ci: Add stage3/4 diff to (aarch64,x86_64)-windows-release scripts. 2024-08-02 09:56:37 +02:00
Andrew Kelley 48d584e3a3 std.debug: reorg and clarify API goals
After this commit:

`std.debug.SelfInfo` is a cross-platform abstraction for the current
executable's own debug information, with a goal of minimal code bloat
and compilation speed penalty.

`std.debug.Dwarf` does not assume the current executable is itself the
thing being debugged, however, it does assume the debug info has the
same CPU architecture and OS as the current executable. It is planned to
remove this limitation.
2024-08-01 23:11:59 -07:00
Andrew Kelley 290966c249 std.debug: rename Info to SelfInfo
This code has the hard-coded goal of supporting the executable's own
debug information and makes design choices along that goal, such as
memory-mapping the inputs, using dl_iterate_phdr, and doing conditional
compilation on the host target.

A more general-purpose implementation of debug information may be able
to share code with this, but there are some fundamental
incompatibilities. For example, the "SelfInfo" implementation wants to
avoid bloating the binary with PDB on POSIX systems, and likewise DWARF
on Windows systems, while a general-purpose implementation needs to
support both PDB and DWARF from the same binary. It might, for example,
inspect the debug information from a cross-compiled binary.

`SourceLocation` now lives at `std.debug.SourceLocation` and is
documented.

Deprecate `std.debug.runtime_safety` because it returns the optimization
mode of the standard library, when the caller probably wants to use the
optimization mode of their own module.

`std.pdb.Pdb` is moved to `std.debug.Pdb`, mirroring the recent
extraction of `std.debug.Dwarf` from `std.dwarf`.

I have no idea why we have both Module (with a Windows-specific
definition) and WindowsModule. I left some passive aggressive doc
comments to express my frustration.
2024-08-01 22:11:35 -07:00
Andrew Kelley ab0253f662 std.debug.Info: rename ModuleDebugInfo to Module 2024-08-01 22:11:29 -07:00
Andrew Kelley 1ba6b56c81 std.debug.Info: extract to separate file 2024-08-01 22:11:23 -07:00
Andrew Kelley 2e26cf83cf Merge pull request #20903 from ziglang/dwarf-reorg
std: dwarf namespace reorg + bonus commits
2024-08-01 21:25:40 -07:00
Andrew Kelley e5b46eab3b std: dwarf namespace reorg
std.debug.Dwarf is the parsing/decoding logic. std.dwarf remains the
unopinionated types and bits alone.

If you look at this diff you can see a lot less redundancy in
namespaces.
2024-08-01 13:56:12 -07:00