Commit Graph

10870 Commits

Author SHA1 Message Date
Alex Rønne Petersen
8161e61548 std.os.linux.start_pie: Add support for the new RELR relocation format. 2024-08-11 20:27:09 -07:00
Andrew Kelley
61dac74128
Merge pull request #20985 from alexrp/gpu-nonsense
Follow-up on `std.Target` GPU changes in #20960
2024-08-11 20:23:28 -07:00
Alex Rønne Petersen
6316fd9535 std.Target: Add goff and xcoff to ObjectFormat.
Also improve the docs a bit, and handle driverkit and dxil in default().
2024-08-11 20:21:28 -07:00
Linus Groh
4ef956ef14 std.Target: Rename c_type_* functions to camel case
From https://ziglang.org/documentation/master/#Names:

> If `x` is otherwise callable, then `x` should be `camelCase`.
2024-08-12 00:36:51 +01:00
Linus Groh
fd434fcd38 std.Target: Rename feature_set_fns to FeatureSetFns
From https://ziglang.org/documentation/master/#Names:

> If `x` is callable, and `x`'s return type is `type`, then `x` should
> be `TitleCase`.
2024-08-12 00:34:59 +01:00
Andrew Kelley
531cd177e8
Merge pull request #21021 from alexrp/target-os-versions
`std.Target`: Bump some minimum/maximum OS versions, and switch from SunOS to Solaris version numbers
2024-08-10 22:58:41 -07:00
Alex Rønne Petersen
8f917870a6
std.Target: Bump maximum supported versions of all Apple OSs.
https://support.apple.com/en-us/HT201222
2024-08-10 20:24:22 +02:00
Alex Rønne Petersen
b99777940e
std.Target: Bump maximum supported OpenBSD version to 7.5. 2024-08-10 20:24:21 +02:00
Alex Rønne Petersen
d7e19f7f8e
std.Target: Bump minimum supported OpenBSD version to 7.3.
Per 0.13.0 release notes: https://ziglang.org/download/0.13.0/release-notes.html#Tier-2-Support
2024-08-10 20:24:20 +02:00
Alex Rønne Petersen
8088027e72
std.Target: Bump minimum supported Windows version to win10.
Per 0.13.0 release notes: https://ziglang.org/download/0.13.0/release-notes.html
2024-08-10 20:24:19 +02:00
Alex Rønne Petersen
fa51e84a87
std.Target: Use Solaris version instead of SunOS version for solaris OS tag.
The latter is not a very useful number: https://en.wikipedia.org/wiki/Oracle_Solaris#Version_history
2024-08-10 20:24:18 +02:00
YANG Xudong
6d54f20c47
loongarch: add __clear_cache builtin implementation (#21008) 2024-08-10 01:24:01 -07:00
Andrew Kelley
54151428e5 std.crypto: better names for everything in utils
std.crypto has quite a few instances of breaking naming conventions.
This is the beginning of an effort to address that.

Deprecates `std.crypto.utils`.
2024-08-09 19:47:06 -07:00
Alex Rønne Petersen
ae5bf2faab std.os.linux: Retranslate and port some ioctl-related types and values. 2024-08-09 13:10:51 -07:00
Andrew Kelley
71a27ebd84
Merge pull request #21004 from alexrp/linux-6.10
Linux 6.10 headers/syscalls
2024-08-09 13:08:39 -07:00
Andrew Kelley
eb17fe85a5
Merge pull request #21006 from ziglang/fuzz
fuzzing: more optimized and correct management of 8-bit PC counters
2024-08-09 12:50:48 -07:00
Andrew Kelley
9f46abf598
Merge pull request #20993 from alexrp/glibc-2-40
glibc 2.40
2024-08-08 21:48:54 -07:00
Andrew Kelley
f6f1ecf0f9 more optimized and correct management of 8-bit PC counters
* Upgrade from u8 to usize element types.
  - WebAssembly assumes u64. It should probably try to be target-aware
    instead.
* Move the covered PC bits to after the header so it goes on the same
  page with the other rapidly changing memory (the header stats).

depends on the semantics of accepted proposal #19755

closes #20994
2024-08-08 21:46:36 -07:00
Andrew Kelley
4e32edbff5 fuzzing: comptime assertions to protect the ABI
compile errors are nice
2024-08-08 21:46:36 -07:00
YANG Xudong
a9b65b6fd4
std: add loongarch64 support (#20915)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-09 00:30:57 +00:00
Alex Rønne Petersen
10949a6914
std.Target: Update default max Linux version to 6.10.3. 2024-08-09 00:34:54 +02:00
Alex Rønne Petersen
3a1d4dd19e
Update Linux syscalls to 6.10. 2024-08-09 00:34:52 +02:00
Alex Rønne Petersen
c62a2ad2ec
Update Linux kernel headers to 6.10. 2024-08-08 23:39:00 +02:00
John Benediktsson
a854ce3021
std.hash_map: adding a rehash() method (#19923)
see #17851
2024-08-08 11:59:22 -07:00
Andrew Kelley
8031251c33
Merge pull request #20997 from xxxbxxx/debuglink
std.debug.Dwarf: improve loading debug symbol from separate files
2024-08-08 11:06:14 -07:00
Andrew Kelley
cf87a1a7cf language: add module name field to @src
closes #20963
2024-08-08 07:47:14 -07:00
Jan Hendrik Farr
ca012e5b69 std.posix: read on timerfd can return error.Canceled 2024-08-08 01:12:26 -07:00
Andrew Kelley
468b976f63
Merge pull request #20975 from squeek502/cpu-features-update
update_cpu_features: Fixes and updates
2024-08-07 22:48:57 -07:00
Xavier Bouchoux
cbdf9bf5ee std.debug.Dwarf: try to load the debuginfo from the debuginfod cache.
The previous mecanism for linux distributions to delivers debug info into `/usr/lib/debug` no longer seems in use.
the current mecanism often is using `debuginfod` (https://sourceware.org/elfutils/Debuginfod.html)

This commit only tries to load already available debuginfo but does not try to make any download requests.
the user can manually run `debuginfod-find debuginfo PATH` to populate the cache.
2024-08-08 07:28:59 +02:00
Xavier Bouchoux
7e966de45e std.debug.Dwarf: fix loading external debuginfo in the ".debuglink" case.
- look up the debuglink file in the directory of the executable file (instead of the cwd)
 - fix parsing of debuglink section (the 4-byte alignement is within the file, unrelated to the in-memory address)
2024-08-08 07:15:00 +02:00
Alex Rønne Petersen
21ff35590c
Update glibc start files to 2.40. 2024-08-08 04:41:04 +02:00
Alex Rønne Petersen
0b76be3a01
Update glibc headers to 2.40. 2024-08-08 04:41:04 +02:00
Andrew Kelley
7a7421c749
Merge pull request #20973 from ziglang/fix-json-utf8
std.json: fix partial strings getting dropped when multi-byte codepoints span input buffers
2024-08-07 18:37:49 -07:00
Alex Rønne Petersen
bf47cb4379
std.Target: Fix C type alignment calculation for spirv. 2024-08-08 02:41:17 +02:00
Alex Rønne Petersen
1b6b8813cf
Revert "std.Target: Fix ptrBitWidth_cpu_abi() for dxil (64-bit, not 32-bit)."
This reverts commit ab154be7f0.
2024-08-08 02:03:17 +02:00
Alex Rønne Petersen
d415efd68f
Revert "std.Target: Fix C type alignment calculation for dxil."
This reverts commit e67388c2e5.
2024-08-08 02:02:50 +02:00
Alex Rønne Petersen
ecf2069e30
Revert "std.Target: Fix C long long size for opencl (8, not 16)."
This reverts commit 606d011acf.
2024-08-08 02:02:33 +02:00
Alex Rønne Petersen
93e983489b
Revert "std.Target: Fix C long double size for opencl (8, not 16)."
This reverts commit a1d3e56763.
2024-08-08 02:02:22 +02:00
Alex Rønne Petersen
1e1cd1f02c
Revert "std.Target: Fix C long double size for amdhsa, amdpal, and mesa3d (8, not 16)."
This reverts commit eef499812c.
2024-08-08 02:02:11 +02:00
Andrew Kelley
4381bac792 build runner: output hint when no --port provided 2024-08-07 16:55:46 -07:00
YANG Xudong
b8705ed652
loongarch: various architecture specific fixes (#20912) 2024-08-07 13:06:29 -07:00
Pat Tullmann
4d6429fc4f POSIX link() syscall only takes two arguments (no flags)
The signature is documented as:

   int link(const char *, const char *);

(see https://man7.org/linux/man-pages/man2/link.2.html or https://man.netbsd.org/link.2)

And its not some Linux extension, the [syscall
implementation](21b136cc63/fs/namei.c (L4794-L4797))
only expects two arguments too.

It probably *should* have a flags parameter, but its too late now.

I am a bit surprised that linking glibc or musl against code that invokes
a 'link' with three parameters doesn't fail (at least, I couldn't get any
local test cases to trigger a compile or link error).

The test case in std/posix/test.zig is currently disabled, but if I
manually enable it, it works with this change.
2024-08-07 13:05:42 -07:00
Jeffrey C. Ollie
979fd12be9 Add getppid to std.c and std.os.linux.
The std lib is missing getppid, this patch adds it.
2024-08-07 13:03:21 -07:00
Andrew Kelley
0e99f517f2
Merge pull request #20958 from ziglang/fuzz
introduce a fuzz testing web interface
2024-08-07 11:55:30 -07:00
Ryan Liptak
e912411fbe Run update_cpu_features against LLVM 18.1.8
- RISCV unaligned-scalar-mem was added in LLVM 18.1.6
- Fixes arm v9_5a confusion
2024-08-07 09:03:05 -07:00
Josh Wolfe
a805454dea fix partial strings getting dropped when multi-byte codepoints span input buffers 2024-08-07 06:29:34 -04:00
Josh Wolfe
8bec737ca2 fix tests actually checking string contents 2024-08-07 06:29:34 -04:00
Alex Rønne Petersen
f9f8942008 std.os.linux: Move clone() here and stop exporting it. 2024-08-07 01:19:51 -07:00
Andrew Kelley
75f78bfb77
Merge pull request #20922 from alexrp/vdso
`std.os.linux`: Fix VDSO for mips, add VDSO for riscv
2024-08-07 01:18:35 -07:00
Andrew Kelley
cd5f673cae
Merge pull request #20909 from alexrp/glibc-riscv
Support building glibc for riscv32/riscv64
2024-08-07 01:14:54 -07:00
Andrew Kelley
8184912a98
Merge pull request #20925 from alexrp/windows-tls
`std`: Some Windows TLS cleanup and fixes
2024-08-07 01:12:11 -07:00
Alex Rønne Petersen
c0681d6b6e start: Add sparc32 support. 2024-08-07 01:09:18 -07:00
Alex Rønne Petersen
8cbf091a9a std.os.linux.start_pie: Add sparc/sparc64 support. 2024-08-07 01:09:06 -07:00
Andrew Kelley
b071b10ce8
Merge pull request #20894 from alexrp/target-cleanup-4
`std.Target`: Minor rework to some `isArch()` functions, fix some related issues throughout `std`
2024-08-07 01:08:44 -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
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
Andrew Kelley
2a651eab45 build runner: --fuzz not yet supported on Windows 2024-08-07 00:48:32 -07:00
Andrew Kelley
40edd11516 std.debug: fix compile errors on windows and macos 2024-08-07 00:48:32 -07:00
Andrew Kelley
8dae629c4f update branch for latest std.sort changes 2024-08-07 00:48:32 -07:00
Andrew Kelley
529df8c007 libfuzzer: fix looking at wrong memory for pc counters
this fix bypasses the slice bounds, reading garbage data for up to the
last 7 bits (which are technically supposed to be ignored). that's going
to need to be fixed, let's fix that along with switching from byte elems
to usize elems.
2024-08-07 00:48:32 -07:00
Andrew Kelley
5f5a7b53a4 wasm zig source rendering: fix annotation location off-by-one 2024-08-07 00:48:32 -07:00
Andrew Kelley
1484f174ea fuzzer web ui: fail scrolling into view gracefully 2024-08-07 00:48:32 -07:00
Andrew Kelley
bfc2ee03e5 fuzzer web ui: resolve cwd in sources.tar
because the wasm code needs to string match against debug information
2024-08-07 00:48:32 -07:00
Andrew Kelley
38227e9289 fuzzer web UI: render PCs with red or green depending on coverage 2024-08-07 00:48:32 -07:00
Andrew Kelley
3d48602c99 fuzzer web UI: annotated PCs in source view 2024-08-07 00:48:32 -07:00
Andrew Kelley
ef4c2193fc fuzzer web UI: navigate by source location index
This will help scroll the point of interest into view
2024-08-07 00:48:32 -07:00
Andrew Kelley
db69641061 fuzzing web ui: make entry point links clickable 2024-08-07 00:48:32 -07:00
Andrew Kelley
e64a00950e fuzzer web ui: introduce entry points
so you can have somewhere to start browsing
2024-08-07 00:48:32 -07:00
Andrew Kelley
6e6164f8a6 fuzzer web ui: add coverage stat 2024-08-07 00:48:32 -07:00
Andrew Kelley
f56d113503 fuzzer web ui: render stats 2024-08-07 00:48:32 -07:00
Andrew Kelley
dec7e45f7c fuzzer web UI: receive coverage information
* libfuzzer: track unique runs instead of deduplicated runs
  - easier for consumers to notice when to recheck the covered bits.
* move common definitions to `std.Build.Fuzz.abi`.

build runner sends all the information needed to fuzzer web interface
client needed in order to display inline coverage information along with
source code.
2024-08-07 00:48:32 -07:00
Andrew Kelley
22925636f7 std.debug.Coverage: use extern structs
helps the serialization use case
2024-08-07 00:48:32 -07:00
Andrew Kelley
b9fd0eeca6 add std.http.WebSocket 2024-08-07 00:48:32 -07:00
Andrew Kelley
d36c182748 std.posix: add some more void bits
prevents unnecessary compilation errors on wasm32-freestanding
2024-08-07 00:48:32 -07:00
Andrew Kelley
517cfb0dd1 fuzzing: progress towards web UI
* libfuzzer: close file after mmap
* fuzzer/main.js: connect with EventSource and debug dump the messages.
  currently this prints how many fuzzer runs have been attempted to
  console.log.
* extract some `std.debug.Info` logic into `std.debug.Coverage`.
  Prepares for consolidation across multiple different executables which
  share source files, and makes it possible to send all the
  PC/SourceLocation mapping data with 4 memcpy'd arrays.
* std.Build.Fuzz:
  - spawn a thread to watch the message queue and signal event
    subscribers.
  - track coverage map data
  - respond to /events URL with EventSource messages on a timer
2024-08-07 00:48:32 -07:00
Andrew Kelley
53aa9d75a9 std.debug.Info.resolveSourceLocations: O(N) implementation 2024-08-07 00:48:32 -07:00
Andrew Kelley
c2ab4614b6 std.Debug.Info: remove std.Progress integration
it's too fast to need it now
2024-08-07 00:48:32 -07:00
Andrew Kelley
1792258dc8 std.debug.Dwarf: precompute .debug_line table
yields a 60x speedup for resolveSourceLocations in debug builds
2024-08-07 00:48:32 -07:00
Andrew Kelley
66954e8330 std.debug.FixedBufferReader is fine
it does not need to be deprecated
2024-08-07 00:48:32 -07:00
Andrew Kelley
de47acd732 code coverage dumping tool basic implementation
* std.debug.Dwarf: add `sortCompileUnits` along with a field to track
  the state for the purpose of assertions and correct API usage.
  This makes batch lookups faster.
  - in the future, findCompileUnit should be enhanced to rely on sorted
    compile units as well.
* implement `std.debug.Dwarf.resolveSourceLocations` as well as
  `std.debug.Info.resolveSourceLocations`. It's still pretty slow, since
  it calls getLineNumberInfo for each array element, repeating a lot of
  work unnecessarily.
* integrate these APIs with `std.Progress` to understand what is taking
  so long.

The output I'm seeing from this tool shows a lot of missing source
locations. In particular, the main area of interest is missing for my
tokenizer fuzzing example.
2024-08-07 00:48:32 -07:00
Andrew Kelley
2e12b45d8b introduce tool for dumping coverage file
with debug info resolved.

begin efforts of providing `std.debug.Info`, a cross-platform
abstraction for loading debug information into an in-memory format that
supports queries such as "what is the source location of this virtual
memory address?"

Unlike `std.debug.SelfInfo`, this API does not assume the debug
information in question happens to match the host CPU architecture, OS,
or other target properties.
2024-08-07 00:48:32 -07:00
Andrew Kelley
107b272766 fuzzer: share zig to html rendering with autodocs 2024-08-07 00:48:32 -07:00
Andrew Kelley
e0ffac4e3c introduce a web interface for fuzzing
* new .zig-cache subdirectory: 'v'
  - stores coverage information with filename of hash of PCs that want
    coverage. This hash is a hex encoding of the 64-bit coverage ID.
* build runner
  * fixed bug in file system inputs when a compile step has an
    overridden zig_lib_dir field set.
  * set some std lib options optimized for the build runner
    - no side channel mitigations
    - no Transport Layer Security
    - no crypto fork safety
  * add a --port CLI arg for choosing the port the fuzzing web interface
    listens on. it defaults to choosing a random open port.
  * introduce a web server, and serve a basic single page application
    - shares wasm code with autodocs
    - assets are created live on request, for convenient development
      experience. main.wasm is properly cached if nothing changes.
    - sources.tar comes from file system inputs (introduced with the
      `--watch` feature)
  * receives coverage ID from test runner and sends it on a thread-safe
    queue to the WebServer.
* test runner
  - takes a zig cache directory argument now, for where to put coverage
    information.
  - sends coverage ID to parent process
* fuzzer
  - puts its logs (in debug mode) in .zig-cache/tmp/libfuzzer.log
  - computes coverage_id and makes it available with
    `fuzzer_coverage_id` exported function.
  - the memory-mapped coverage file is now namespaced by the coverage id
    in hex encoding, in `.zig-cache/v`
* tokenizer
  - add a fuzz test to check that several properties are upheld
2024-08-07 00:48:32 -07:00
Andrew Kelley
ffc050e055 fuzzer: log errors and move deduplicated runs to shared mem 2024-08-07 00:48:32 -07:00
Andrew Kelley
97643c1ecc fuzzer: track code coverage from all runs
When a unique run is encountered, track it in a bit set memory-mapped
into the fuzz directory so it can be observed by other processes, even
while the fuzzer is running.
2024-08-07 00:48:32 -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
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
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
Fri3dNstuff
a655c15c40
std.sort: Remove key argument from binary-search-like functions (#20927)
closes #20110
2024-08-04 22:02:15 +00:00
Linus Groh
a18293214d std.Target: Specify dynamic linker and C type sizes for serenity 2024-08-04 12:03:43 -07:00
Alex Rønne Petersen
cb1fffb29e
std.os.windows.tls: Set AddressOfCallBacks to &__xl_a + 1.
`__xl_a` is just a global variable containing a null function pointer. There's
nothing magical about it or its name at all.

The section names used on `__xl_a` and `__xl_b` (`.CRT$XLA` and `.CRT$XLZ`) are
the real magic here. The compiler emits TLS variables into `.CRT$XL<x>`
sections, where `x` is an uppercase letter between A and Z (exclusive). The
linker then sorts those sections alphabetically (due to the `$`), and the result
is a neat array of TLS initialization callbacks between `__xl_a` and `__xl_z`.

That array is null-terminated, though! Normally, `__xl_z` serves as the null
terminator; however, by pointing `AddressesOfCallBacks` to `__xl_a`, which just
contains a null function pointer, we've effectively made it so that the PE
loader will just immediately stop invoking TLS callbacks. Fix that by pointing
to the first actual TLS callback instead (or `__xl_z` if there are none).
2024-08-03 20:55:00 +02:00
Alex Rønne Petersen
1d8fca0060
std.os.windows.tls: Only define _tls_array when targeting MSVC.
LLVM does not use it when emitting code for the MinGW ABI.
2024-08-03 20:48:48 +02:00
Alex Rønne Petersen
0f1db90198
std.os.windows.tls: Slightly improve type safety. 2024-08-03 20:48:48 +02:00
Alex Rønne Petersen
c2fcdc21c2
std.os.windows.tls: Change type of _tls_start/_tls_end to *anyopaque.
If they're typed as `u8`, they can be aligned to anything. We want at least
pointer size alignment.
2024-08-03 20:47:08 +02:00
Alex Rønne Petersen
8056a85151
std: Move start_windows_tls.zig to os/windows/tls.zig.
Just to be consistent with Linux.
2024-08-03 20:35:08 +02:00
Alex Rønne Petersen
0ad97b4122
std.os.linux: Add VDSO definition for riscv32/riscv64. 2024-08-03 18:49:12 +02:00
Alex Rønne Petersen
64e119124f
std.os.linux: Fix CGT_SYM for mips/mips64. 2024-08-03 18:48:53 +02:00
Alex Rønne Petersen
d71076c982
std.os.linux: Replace @hasDecl() with != void check for VDSO.
If there is a VDSO, it will have clock_gettime(). The main thing we're concerned
about is architectures that don't have a VDSO at all, of which there are a few.
2024-08-03 18:46:04 +02: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
Tristan Ross
3ebb880663
glibc: Replace ilp32/lp64 headers with ilp32d/lp64d.
The former are soft float; the latter are hard float. We primarily care about
hard float here.

Signed-off-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-02 09:54:08 +02:00
Alex Rønne Petersen
635a3d87de
glibc: Change riscv32-linux-gnuilp32 target triple to riscv32-linux-gnu.
This target triple was weird on multiple levels:

* The `ilp32` ABI is the soft float ABI. This is not the main ABI we want to
  support on RISC-V; rather, we want `ilp32d`.
* `gnuilp32` is a bespoke tag that was introduced in Zig. The rest of the world
  just uses `gnu` for RISC-V target triples.
* `gnu_ilp32` is already the name of an ILP32 ABI used on AArch64. `gnuilp32` is
  too easy to confuse with this.
* We don't use this convention for `riscv64-linux-gnu`.
* Supporting all RISC-V ABIs with this convention will result in combinatorial
  explosion; see #20690.
2024-08-02 09:54:08 +02:00
Alex Rønne Petersen
3c2733de6e
std.Target: Use a saner default dynamic linker path for riscv.
The vast majority of Linux systems will be running these ABIs.
2024-08-02 09:54:08 +02:00
Alex Rønne Petersen
948bc91d12
std.Target.VersionRange: Make default() respect the minimum glibc version. 2024-08-02 09:54:08 +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
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
Andrew Kelley
377274ee9a std.debug.DebugInfo: rename to std.debug.Info
avoiding redundancy in the fully qualified namespace
2024-08-01 13:47:42 -07:00
Andrew Kelley
12d0c9a2fc add std.fs.Dir.Handle
mirrors std.fs.File.Handle
2024-08-01 13:47:23 -07:00
Andrew Kelley
5c6f5e6cf2 test runner: avoid spawning progress thread when instrumented
because it causes unwanted concurrent accesses to pc tracking
2024-08-01 13:47:09 -07:00
Alex Rønne Petersen
7d88bd0b9c
std.simd: Fix an isARM() check to use isArmOrThumb() instead.
Thumb can have NEON instructions too.
2024-08-01 20:58:08 +02:00
Alex Rønne Petersen
a9c7818512
start: Fix an isARM() check to use isArmOrThumb() instead. 2024-08-01 20:58:08 +02:00
Alex Rønne Petersen
f7d07b44d1
std.os.linux: Fix arm check in fadvise() to also include thumb. 2024-08-01 20:58:08 +02:00
Alex Rønne Petersen
a2868147b1
std.os.linux: Fix require_aligned_register_pair to check isMIPS32().
Only 32-bit architectures need this.
2024-08-01 20:58:08 +02:00
Alex Rønne Petersen
5a97045644
std.Target: Add isMIPS32()/isMIPS64() functions. 2024-08-01 20:58:08 +02:00
Alex Rønne Petersen
e5c75479c2
std.Target: Rework isPPC()/isPPC64() functions.
* Rename isPPC() -> isPowerPC32().
* Rename isPPC64() -> isPowerPC64().
* Add new isPowerPC() function which covers both.

There was confusion even in the standard library about what isPPC() meant. This
change makes these functions work how I think most people actually expect them
to work, and makes them consistent with isMIPS(), isSPARC(), etc.

I chose to rename from PPC to PowerPC because 1) it's more consistent with the
other functions, and 2) it'll cause loud rather than silent breakage for anyone
who might have been depending on isPPC() while misunderstanding it.
2024-08-01 20:58:05 +02:00
Alex Rønne Petersen
5e08d00862
std.Target: Add Arch.isLoongArch() function. 2024-08-01 13:11:21 +02:00
Alex Rønne Petersen
624fa8523a std.os.linux: Unbreak the build
Happened because I wrote #20869 before #20870.
2024-08-01 13:05:26 +02:00
Andrew Kelley
7a0da805a8
Merge pull request #20797 from alexrp/start-more-arches
`start`: Add POSIX arc, csky, and hexagon support
2024-08-01 01:34:33 -07:00
Andrew Kelley
8f7cbaa4c0
Merge pull request #20870 from alexrp/target-cleanup-3
`std.Target`: Remove more dead OS/architecture tags
2024-08-01 01:32:32 -07:00
Andrew Kelley
f17f73b4fa
Merge pull request #20869 from alexrp/linux-syscalls
`std.os.linux`: Add syscall enums for all remaining architectures
2024-08-01 01:21:10 -07:00
Andrew Kelley
91163b44dd
Merge pull request #20857 from alexrp/tls-porting
`std.os.linux.tls`: Refactor, improve documentation, fix a bug, and port to more architectures
2024-08-01 01:15:17 -07:00
Andrew Kelley
16dde6d260
Merge pull request #20772 from alexrp/linux-audit
`std.os.linux.AUDIT`: Rewrite ARCH in terms of std.elf.EM.
2024-08-01 01:09:22 -07:00
Alex Rønne Petersen
8d5eaadb05 std.Target: Handle loongarch in Os.Tag.archName(). 2024-08-01 01:08:20 -07:00
Alex Rønne Petersen
f03d54f069 std.atomic: Don't lie to the compiler about memory clobbers in spinLoopHint(). 2024-08-01 01:07:56 -07:00
Alex Rønne Petersen
604e87a958 std.Target: Use hexagonv60 as the baseline CPU model for hexagon. 2024-08-01 01:01:24 -07:00
Andrew Kelley
9c22a6b3ad
Merge pull request #20823 from alexrp/start-pie-mips-ppc
`std.os.linux.start_pie`: Add mips and powerpc support
2024-08-01 00:57:10 -07:00
Andrew Kelley
63aa85e7af
Merge pull request #20872 from alexrp/riscv-gp
start: Initialize `gp` to `__global_pointer$` on riscv.
2024-08-01 00:47:05 -07:00
Jakub Konka
8ea323822b
Merge pull request #20884 from Rexicon226/riscv 2024-08-01 07:17:40 +02:00
Andrew Kelley
eb1a199dff
Merge pull request #20885 from ziglang/simplify-tokenizer
std.zig.tokenizer: simplification and spec conformance
2024-07-31 19:52:34 -07:00
Andrew Kelley
059856acfc
Merge pull request #20878 from tiehuis/std-math-complex-fixes
std.math.complex fixes
2024-07-31 19:19:27 -07:00
Andrew Kelley
c2b8afcac9 tokenizer: tabs and carriage returns spec conformance 2024-07-31 16:57:42 -07:00
Andrew Kelley
a7029496d1 remove hard tabs from source code
these are illegal according to the spec
2024-07-31 16:57:42 -07:00
Andrew Kelley
377e8579f9 std.zig.tokenizer: simplify
I pointed a fuzzer at the tokenizer and it crashed immediately. Upon
inspection, I was dissatisfied with the implementation. This commit
removes several mechanisms:
* Removes the "invalid byte" compile error note.
* Dramatically simplifies tokenizer recovery by making recovery always
  occur at newlines, and never otherwise.
* Removes UTF-8 validation.
* Moves some character validation logic to `std.zig.parseCharLiteral`.

Removing UTF-8 validation is a regression of #663, however, the existing
implementation was already buggy. When adding this functionality back,
it must be fuzz-tested while checking the property that it matches an
independent Unicode validation implementation on the same file. While
we're at it, fuzzing should check the other properties of that proposal,
such as no ASCII control characters existing inside the source code.

Other changes included in this commit:

* Deprecate `std.unicode.utf8Decode` and its WTF-8 counterpart. This
  function has an awkward API that is too easy to misuse.
* Make `utf8Decode2` and friends use arrays as parameters, eliminating a
  runtime assertion in favor of using the type system.

After this commit, the crash found by fuzzing, which was
"\x07\xd5\x80\xc3=o\xda|a\xfc{\x9a\xec\x91\xdf\x0f\\\x1a^\xbe;\x8c\xbf\xee\xea"
no longer causes a crash. However, I did not feel the need to add this
test case because the simplified logic eradicates most crashes of this
nature.
2024-07-31 16:57:42 -07:00
David Rubin
2b8a71489a
start: remove riscv condition 2024-07-31 13:40:00 -07:00
Evan Haas
1cc74f3cae
aro_translate_c: fix formatting 2024-07-31 10:33:44 -07:00
Evan Haas
aa5a1105e8
aro_translate_c: do not translate atomic types 2024-07-31 10:04:21 -07:00
Evan Haas
b3f5769930
aro_translate_c: handle opaque struct defs in prototypes 2024-07-31 09:35:07 -07:00
Evan Haas
6a103d87f6
aro_translate_c: basic typedef support 2024-07-31 09:35:07 -07:00
Evan Haas
055077f9dd
aro_translate_c: improve record translation
Move field record decl translation into `transType` instead of `transDecl`
2024-07-31 09:35:07 -07:00
Evan Haas
c57fcd1db5
aro_translate_c: demote functions with bodies to extern
Translating statements is currently not supported; demoting to extern is
better than crashing.
2024-07-31 09:35:07 -07:00
Evan Haas
4300a9c417
aro_translate_c: Make function decls public 2024-07-31 09:35:07 -07:00
Evan Haas
5cc9e18277
aro_translate_c: Translate enum types 2024-07-31 09:35:07 -07:00
Evan Haas
2f2f35105e
aro_translate_c: translate pointer types 2024-07-31 09:35:07 -07:00
Evan Haas
e32cde2568
aro_translate_c: translate incomplete arrays 2024-07-31 09:35:07 -07:00
Evan Haas
da3822f4c2
aro_translate_c: Translate array types 2024-07-31 09:35:07 -07:00
Evan Haas
236567de8d
aro_translate_c: Emit compile errors instead of panicking for var decls 2024-07-31 09:35:07 -07:00
Alex Rønne Petersen
653eb75355
start: Disable the gp initialization code for the self-hosted riscv64 backend. 2024-07-31 02:06:57 +02:00
Alex Rønne Petersen
982510f8d5
start: Initialize gp to __global_pointer$ on riscv. 2024-07-31 02:05:17 +02:00
YANG Xudong
a69d403cb2 std: fix long double size for loongarch. 2024-07-30 15:21:14 -07:00
YANG Xudong
2fb813c61f
std: set standard dynamic linker path for loongarch64 on linux. (#20726) 2024-07-30 15:20:56 -07:00
Alex Rønne Petersen
2e719f3239
std.os.linux.start_pie: Use a 64-bit displacement for s390x.
Not likely to be necessary ever, but might as well be 100% correct.
2024-07-30 18:02:40 +02:00
Alex Rønne Petersen
52519f79e0
std.os.linux.start_pie: Apply MIPS local GOT relocations. 2024-07-30 18:02:36 +02:00
Alex Rønne Petersen
78e581b86f
start: Copy the mips64 comment about gp to the mips32 code.
Also, don't incorrectly claim that it's only needed for dynamic linking/PIC.
2024-07-30 17:58:22 +02:00
Alex Rønne Petersen
108c682df0
start: Add POSIX csky support. 2024-07-30 17:47:46 +02:00
Marc Tiehuis
843885512d std.math.complex: fix cosh/tanh 2024-07-30 20:31:22 +12:00
Alex Rønne Petersen
c377316420
std.Target: Add tce/tcele to the comment listing omitted architectures. 2024-07-30 06:30:26 +02:00
Alex Rønne Petersen
b49b7501cf
std.Target: Remove cloudabi OS tag.
It's discontinued in favor of WASI.

https://github.com/NuxiNL/cloudlibc
2024-07-30 06:30:26 +02:00
Alex Rønne Petersen
ef06e4b6e4
std.Target: Remove ananas OS tag.
This is a fairly small hobby OS that has not seen development in 2 years. Our
current policy is that hobby OSs should use the `other` tag.

https://github.com/zhmu/ananas
2024-07-30 06:30:25 +02:00
Alex Rønne Petersen
c8ca05e93a
std.Target: Remove sparcel architecture tag.
What is `sparcel`, you might ask? Good question!

If you take a peek in the SPARC v8 manual, §2.2, it is quite explicit that SPARC
v8 is a big-endian architecture. No little-endian or mixed-endian support to be
found here.

On the other hand, the SPARC v9 manual, in §3.2.1.2, states that it has support
for mixed-endian operation, with big-endian mode being the default.

Ok, so `sparcel` must just be referring to SPARC v9 running in little-endian
mode, surely?

Nope:

* 40b4fd7a3e/llvm/lib/Target/Sparc/SparcTargetMachine.cpp (L226)
* 40b4fd7a3e/llvm/lib/Target/Sparc/SparcTargetMachine.cpp (L104)

So, `sparcel` in LLVM is referring to some sort of fantastical little-endian
SPARC v8 architecture. I've scoured the internet and I can find absolutely no
evidence that such a thing exists or has ever existed. In fact, I can find no
evidence that a little-endian implementation of SPARC v9 ever existed, either.
Or any SPARC version, actually!

The support was added here: https://reviews.llvm.org/D8741

Notably, there is no mention whatsoever of what CPU this might be referring to,
and no justification given for the "but some are little" comment added in the
patch.

My best guess is that this might have been some private exercise in creating a
little-endian version of SPARC that never saw the light of day. Given that SPARC
v8 explicitly doesn't support little-endian operation (let alone little-endian
instruction encoding!), and no CPU is known to be implemented as such, I think
it's very reasonable for us to just remove this support.
2024-07-30 06:30:25 +02:00
Alex Rønne Petersen
1e9278d718
std.Target: Remove spir/spir64 architecture tags.
These were for very old OpenCL have been long abandoned in favor of SPIR-V.

* https://github.com/KhronosGroup/SPIR
* https://github.com/KhronosGroup/SPIR-Tools
2024-07-30 06:30:25 +02:00
Marc Tiehuis
0fda2f31aa std.math.complex: tighten existing test bounds 2024-07-30 16:30:20 +12:00
Marc Tiehuis
2bd7af63d7 std.math.complex: fix acosh/atan/cosh/sqrt
Some of these are upstream changes since the original port, others are
translation errors.
2024-07-30 15:38:00 +12:00
Andrew Kelley
f219286573
Merge pull request #20852 from ziglang/init-array-start-code
start code: implement __init_array_start, __init_array_end
2024-07-29 18:40:27 -07:00
Alex Rønne Petersen
36332a4fdc
std.os.linux.tls: Add csky support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
9abe3aeeea
std.os.linux.tls: Add arc support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
e6fe7a329a
std.os.linux.tls: Add hexagon support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
d2b21d5823
std.os.linux.tls: Add s390x support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
9db992bd9b
std.os.linux.tls: Add loongarch support. 2024-07-30 02:33:15 +02:00
Alex Rønne Petersen
44d4656dfc
std.os.linux.tls: Add m68k support. 2024-07-30 02:32:55 +02:00
Alex Rønne Petersen
37275c0f69
std.os.linux.tls: Fix layout computation for the modified Variant I. 2024-07-30 02:32:32 +02:00
Alex Rønne Petersen
b52e054261
std.os.linux.tls: Refactor and improve documentation.
* Elaborate on the sub-variants of Variant I.
* Clarify the use of the TCB term.
* Rename a bunch of stuff to be more accurate/descriptive.
* Follow Zig's style around namespacing more.
* Use a structure for the ABI TCB.

No functional change intended.
2024-07-30 02:32:32 +02:00
Alex Rønne Petersen
876383cb2a
std.os.linux: Hook up newly added syscall enums. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
7e0f9c45f2
std.os.linux: Adjust for rename of mips syscall enums. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
e77b3ff74f
std.os.linux.syscalls: Regenerate based on Linux v6.7. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
ce5063e188
std.os.linux.AUDIT: Rewrite ARCH in terms of std.elf.EM.
Closes #20743.
2024-07-30 01:30:35 +02:00
Alex Rønne Petersen
b2d568e813
std.elf.EM: Add missing MICROBLAZE value. 2024-07-30 01:29:38 +02:00
Alex Rønne Petersen
2386bfe854
std.os.linux.start_pie: Rewrite relocate() to avoid jump tables and libcalls.
The code would cause LLVM to emit a jump table for the switch in the loop over
the dynamic tags. That jump table was far enough away that the compiler decided
to go through the GOT, which would of course break at this early stage as we
haven't applied MIPS's local GOT relocations yet, nor can we until we've walked
through the _DYNAMIC array.

The first attempt at rewriting this used code like this:

    var sorted_dynv = [_]elf.Addr{0} ** elf.DT_NUM;

But this is also problematic as it results in a memcpy() call. Instead, we
explicitly initialize it to undefined and use a loop of volatile stores to
clear it.
2024-07-30 01:26:10 +02:00
Alex Rønne Petersen
68cebde186
std.os.linux.start_pie: Inline the getDynamicSymbol() function.
On MIPS, this call will require a relocation, which we can't do until after PIE
relocations have been applied.
2024-07-30 01:26:10 +02:00
Alex Rønne Petersen
5633767b20
std.os.linux.start_pie: Add powerpc and powerpc64 support.
Closes #20305.
2024-07-30 01:26:09 +02:00
Alex Rønne Petersen
adfbd8a98b
std.os.linux.start_pie: Add mips and mips64 support. 2024-07-30 01:24:55 +02:00
Andrew Kelley
38e0f049c5
Merge pull request #20389 from alexrp/riscv32
Some `riscv32-linux` porting work
2024-07-29 16:13:35 -07:00
Ryan Liptak
efde3ed04a Fix compile error due to GetModuleFileNameW binding change
In https://github.com/ziglang/zig/pull/19641, this binding changed from `[*]u16` to `LPWSTR` which made it a sentinel-terminated pointer. This introduced a compiler error in the `std.os.windows.GetModuleFileNameW` wrapper since it takes a `[*]u16` pointer. This commit changes the binding back to what it was before instead of introducing a breaking change to `std.os.windows.GetModuleFileNameW`

Related: https://github.com/ziglang/zig/issues/20858
2024-07-29 16:06:36 -07:00
Andrew Kelley
d60c100eb6
Merge pull request #20865 from ehaas/aro-translate-c-static-assert
Aro translate c: Render error diagnostics properly and ignore _Static_assert decls during translation
2024-07-29 15:28:31 -07:00
Alex Rønne Petersen
f7cebf21c9 c: Handle armeb and thumbeb in clone(). 2024-07-29 13:24:29 -07:00
Andrew Kelley
7342017404
Merge pull request #20822 from alexrp/start-mips-fixes
`start`: A handful of MIPS fixes
2024-07-29 12:02:59 -07:00
Andrew Kelley
3f2d1b17fc disable the new code for self-hosted riscv backend 2024-07-29 11:38:11 -07:00
Evan Haas
699e103717
aro_translate_c: Add a more helpful error message for error.StreamTooLong 2024-07-29 10:25:55 -07:00
Evan Haas
5d8e56c2eb
aro_translate_c: do not translate _Static_assert declarations
This does not completely ignore static asserts - they are validated by aro
during parsing; any failures will render an error and non-zero exit code.

Emit a warning comment that _Static_asserts are not translated - this
matches the behavior of the existing clang-based translate-c.

Aro currently does not store source locations for _Static_assert
declarations so I've hard-coded token index 0 for now.
2024-07-29 10:25:55 -07:00
Evan Haas
d7b9bbecaf
aro_translate_c: Render errors properly
The error count is not set until the diagnostics are actually rendered
2024-07-29 10:25:55 -07:00
Alex Rønne Petersen
d633b35f35
start: Always inline the call to std.os.linux.pie.relocate().
At this stage, we're not ready to make calls yet on some architectures (e.g. MIPS).
2024-07-29 10:08:34 +02:00
Alex Rønne Petersen
d6c637c36b
start: Set std.os.linux.elf_aux_maybe after PIE relocations.
Accesses to this global variable can require relocations on some platforms (e.g.
MIPS). If we do it before PIE relocations have been applied, we'll crash.
2024-07-29 10:05:28 +02:00
Alex Rønne Petersen
e33af8e902
start: Perform the posixCallMainAndExit() call with jalr on mips.
It's actually important for the ABI that r25 (t9) contains the address of the
called function, so that this standard prologue sequence works:

    lui $2, %hi(_gp_disp)
    addiu $2, $2, %lo(_gp_disp)
    addu $gp, $2, $t9

(This is a bit similar to the ToC situation on powerpc that was fixed in
7bc78967b400322a0fc5651f37a1b0428c37fb9d.)
2024-07-29 10:05:25 +02:00
Alex Rønne Petersen
77fc3b88fb
start: Set up the gp register on mips and mips64. 2024-07-29 10:04:54 +02:00
Alex Rønne Petersen
13945548fc
std.fs: Rework to always use statx() instead of fstat()/fstatat() on Linux.
statx() is strictly superior to stat() and friends. We can do this because the
standard library declares Linux 4.19 to be the minimum version supported in
std.Target. This is also necessary on riscv32 where there is only statx().

While here, I improved std.fs.File.metadata() to gather as much information as
possible when calling statx() since that is the expectation from this particular
API.
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
4e5068c35c
std: Stop supporting Linux/glibc versions older than declared in std.Target. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
6eb9cb6f28
std.os.linux.tls: Handle riscv32 in setThreadPointer(). 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
aeb3abc7e6
std.os.linux.start_pie: Handle riscv32 in getDynamicSymbol(). 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
43410cdfe9
std.os.linux: Remove the sparc64 workaround in fadvise().
This does not seem to be needed anymore, and it's unclear if it was ever truly
needed or if it was just there to deal with a QEMU/strace bug.

See: https://github.com/ziglang/zig/pull/8301#issuecomment-2184995749
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
890433e292
std.os.linux: Define timespec as kernel_timespec (64-bit) for riscv32.
This is kind of a hack because the timespec in UAPI headers is actually still
32-bit while __kernel_timespec is 64-bit. But, importantly, all the syscalls
take __kernel_timespec from the get-go (because riscv32 support is so recent).

Defining our timespec this way will allow all the syscall wrappers in
std.os.linux to do the right thing for riscv32. For other 32-bit architectures,
we have to use the 64-bit time syscalls explicitly to solve the Y2038 problem.
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
cafce8c767
std.os.linux.test: Partially skip statx() test on riscv32.
No fstatat(), so there's no point doing the rest of it.
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
7532a8a584
std.os.linux: Add riscv32 support. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
2d1ee678eb
std.os.linux: Some adjustments after syscall generation strategy changes. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
4e7c3cca91
std.os.linux.syscalls: Regenerate based on Linux v6.7.
loongarch64 syscalls not updated because it seems like that kernel port hasn't
been working for a year or so:

    In file included from arch/loongarch/include/uapi/asm/unistd.h:5:
    include/uapi/asm-generic/unistd.h:2:10: fatal error: 'asm/bitsperlong.h' file not found

That file is just missing from the tree. 🤷
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
a59ab5ffa5
std.Thread: Add some syscall comments to LinuxThreadImpl.ThreadCompletion.freeAndExit(). 2024-07-29 09:50:40 +02:00
Alex Rønne Petersen
b83d10214b
std.Thread: Implement LinuxThreadImpl.ThreadCompletion.freeAndExit() for riscv32. 2024-07-29 09:50:09 +02:00
Alex Rønne Petersen
b958225e68
c: Implement clone() for riscv32-linux. 2024-07-29 09:50:09 +02:00
Alex Rønne Petersen
8b176ab303
start: Implement _start() for riscv32. 2024-07-29 09:50:09 +02:00
Alex Rønne Petersen
e74c368962
std.zig.target: Set the minimum glibc for riscv32 to 2.33.
Relevant release notes:

* https://sourceware.org/legacy-ml/libc-announce/2018/msg00000.html
* https://sourceware.org/pipermail/libc-announce/2021/000030.html

Note that the supported ISAs/ABIs are explicitly listed in each, and only 2.33
actually supports the 32-bit ones.
2024-07-29 09:50:09 +02:00
Alex Rønne Petersen
c31409baa9
std.Target.Abi: Handle a few more GNU ABIs in isGnu().
Importantly, this ensures that the compiler understands that these ABIs need glibc.
2024-07-29 09:50:09 +02:00
Alex Rønne Petersen
9d23e711ef
std.atomic: Implement specialized spinLoopHint() for more architectures. 2024-07-29 09:41:47 +02:00
Alex Rønne Petersen
5b68595255
std.atomic: Define specialized cache_line values for more architectures. 2024-07-29 09:41:24 +02:00
Andrew Kelley
728024f9f3 start code: implement __init_array_start, __init_array_end 2024-07-28 23:54:49 -07:00
Andrew Kelley
390c7d84b2
Merge pull request #19833 from tealsnow/posix-INVAL
std.posix: handle INVAL in openZ, openatZ and openatWasi
2024-07-28 22:29:31 -07:00
matt ettler
ed7f11ffa7 chore: correct non-standard comments.
Comments throughout the codebase start with a space.
This commit corrects comments that do not adhere to this
norm.
2024-07-28 21:34:14 -07:00
Sammy James
00d6ea4764 Add libcpp option to test options 2024-07-28 20:40:53 -07:00
Andrew Kelley
3a0da431db
Merge pull request #20667 from jayrod246/windows-watch
Build Runner: Initial Implementation for File System Watching on Windows
2024-07-28 20:35:18 -07:00
poypoyan
939fcce5ef
std.mem.readVarInt: fix for 8-bits and below (Reloaded) (#20513) 2024-07-28 20:26:36 -07:00
Andrew Kelley
08e83fee57
Merge pull request #20297 from sno2/wtf8-conversion-buffer-overflows
std: fix buffer overflows from improper WTF encoding
2024-07-28 20:24:31 -07:00
Carter Snook
219acaa1d6 std.fs.Dir: Refactor atomicSymLink from std.fs
Deprecates std.fs.atomicSymLink and removes the allocator requirement
from the new std.fs.Dir.atomicSymLink. Replaces the two usages of this
within std.

I did not include the TODOs from the original code that were based
off of `switch (err) { ..., else => return err }` not having correct
inference that cases handled in `...` are impossible in the error
union return type because these are not specified in many places but
I can add them back if wanted.

Thank you @squeek502 for help with fixing buffer overflows!
2024-07-28 20:08:52 -07:00
Cheng Sheng
4a77c7f258
Condense and extend std.Treap's traversal functionalities. (#20002)
The core functionalities are now in two general functions
`extremeInSubtreeOnDirection()` and `nextOnDirection()` so all the other
traversing functions (`getMin()`, `getMax()`, and `InorderIterator`) are
all just trivial calls to these core functions.

The added two functions `Node.next()` and `Node.prev()` are also just
trivial calls to these.

* std.Treap traversal direction: use u1 instead of usize.

* Treap: fix getMin() and getMax(), and add tests for them.
2024-07-28 19:47:55 -07:00
Alex Rønne Petersen
d1d95294fd std.Target.Cpu.Arch: Remove the aarch64_32 tag.
This is a misfeature that we inherited from LLVM:

* https://reviews.llvm.org/D61259
* https://reviews.llvm.org/D61939

(`aarch64_32` and `arm64_32` are equivalent.)

I truly have no idea why this triple passed review in LLVM. It is, to date, the
*only* tag in the architecture component that is not, in fact, an architecture.
In reality, it is just an ILP32 ABI for AArch64 (*not* AArch32).

The triples that use `aarch64_32` look like `aarch64_32-apple-watchos`. Yes,
that triple is exactly what you think; it has no ABI component. They really,
seriously did this.

Since only Apple could come up with silliness like this, it should come as no
surprise that no one else uses `aarch64_32`. Later on, a GNU ILP32 ABI for
AArch64 was developed, and support was added to LLVM:

* https://reviews.llvm.org/D94143
* https://reviews.llvm.org/D104931

Here, sanity seems to have prevailed, and a triple using this ABI looks like
`aarch64-linux-gnu_ilp32` as you would expect.

As can be seen from the diffs in this commit, there was plenty of confusion
throughout the Zig codebase about what exactly `aarch64_32` was. So let's just
remove it. In its place, we'll use `aarch64-watchos-ilp32`,
`aarch64-linux-gnuilp32`, and so on. We'll then translate these appropriately
when talking to LLVM. Hence, this commit adds the `ilp32` ABI tag (we already
have `gnuilp32`).
2024-07-28 19:44:52 -07:00
Ketan Reynolds
0403c4b05c std.posix: handle INVAL in openatWasi
In accordance with https://github.com/ziglang/zig/pull/19833#issuecomment-2089262607
2024-07-28 19:01:55 -07:00
Ketan Reynolds
b4e7b6fdba std.posix: handle INVAL in openZ and openatZ
Contributes to #15607

Although the case is not handled in `openatWasi` (as I could not get a
working wasi environment to test the change) I have added a FIXME
addressing it and linking to the issue.
2024-07-28 19:01:55 -07:00
Matthew Ettler
d30d37e356
feat(std.os.uefi.protocol): add Serial IO 2024-07-28 12:37:53 +00:00
Jakub Konka
91c17979f1
Merge pull request #20807 from Rexicon226/riscv
riscv: more backend progress
2024-07-28 11:34:23 +02:00
Linus Groh
a84951465b translate-c: Use mangled name for local extern in condition/loop 2024-07-28 02:58:49 +03:00
Jarrod Meyer
2de0e2eca3 Watch.zig: add initial windows implementation 2024-07-27 11:32:43 -04:00
Jarrod Meyer
2b8f444dde windows: reintroduce ReadDirectoryChangesW
- additionally, introduces FileNotifyChangeFilter to improve use/readability
2024-07-27 11:32:43 -04:00
Jarrod Meyer
9323a00067 windows: add Timeout status result for GetQueuedCompletionStatus 2024-07-27 11:32:43 -04:00
Jarrod Meyer
7434accc3d windows: make the WaitForMultipleObjectsEx assertion inclusive
- additionally, the parameter must be nonzero: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjects
2024-07-27 11:32:43 -04:00
Alex Rønne Petersen
66b71273a2 std.os.linux: Fix default value for perf_event_attr.clockid field.
Closes #20810.
2024-07-26 18:21:10 -07:00
Andrew Kelley
eab934814f docs: ArrayHashMap: warn against the shrink footgun 2024-07-26 15:24:25 -07:00
David Rubin
c20def73af
riscv: workarounds for riscv threading 2024-07-26 14:53:50 -07:00
Karim Mk
3b3c9d2081 Fix typo in init files. 2024-07-26 14:33:59 -07:00
Andrew Kelley
5d3a1cfdf5 update init template
* add fuzz example
* explain that you might want to delete main.zig or root.zig
2024-07-26 12:18:23 -07:00
kcbanner
2a0238e5e3 zig.h: fixup pointer atomic load definitions 2024-07-26 10:42:10 -04:00
Jakub Konka
1240134c8b
Merge pull request #20788 from alexrp/elf-dt
`std.elf`: Add some definitions for the newer RELR relocations
2024-07-26 15:02:19 +02:00
David Rubin
7ff5709e1b
riscv: implement lr/sr loop logic for non-native atomics 2024-07-26 04:19:57 -07:00
David Rubin
a1f6a8ef90
riscv: airAsm rewrite
with this rewrite we can call functions inside of
inline assembly, enabling us to use the default start.zig logic

all that's left is to implement lr/sc loops for atomically manipulating
1 and 2 byte values, after which we can use the segfault handler logic.
2024-07-26 04:19:55 -07:00
David Rubin
1a7d89a84d
riscv: clean up and unify encoding logic 2024-07-26 04:19:13 -07:00
David Rubin
ba58b7b881
heap: create a work-around page-allocator
the risc-v backend doesn't have `@cmpxchg*` implemented and so it can't use the hint that the current page-allocator uses.
this work-around branch can be removed when I implement the atomic built-in.
2024-07-26 04:05:41 -07:00
David Rubin
c78ebeb44c
riscv: implement ptr_slice_ptr_ptr
just one step closer to allocation
2024-07-26 04:05:40 -07:00
David Rubin
8d30fc45c4
riscv: implement more operators
we can run `std.debug.print` now, with both run-time strings and integers!
2024-07-26 04:05:39 -07:00
Andrew Kelley
f2bf6c1b11
Merge pull request #20776 from alexrp/start-pie-more-arches
`std.os.linux.start_pie`: Add arc, csky, and hexagon support (and arm variants)
2024-07-25 19:33:54 -07:00
Alex Rønne Petersen
2458e53e73 std.zig.target: Handle m68k in muslArchName(). 2024-07-25 19:31:39 -07:00
Andrew Kelley
688c2df646 fuzzer: use the cmp values
seems to provide better scoring
2024-07-25 18:52:21 -07:00
Andrew Kelley
6a63372053 fuzzer: basic implementation
just some experimentation. I didn't expect this to be effective so
quickly but it already can find a comparison made with mem.eql
2024-07-25 18:52:21 -07:00
Andrew Kelley
a3c74aca99 add --debug-rt CLI arg to the compiler + bonus edits
The flag makes compiler_rt and libfuzzer be in debug mode.

Also:
* fuzzer: override debug logs and disable debug logs for frequently
  called functions
* std.Build.Fuzz: fix bug of rerunning the old unit test binary
* report errors from rebuilding the unit tests better
* link.Elf: additionally add tsan lib and fuzzer lib to the hash
2024-07-25 18:52:21 -07:00
Andrew Kelley
90dfd86ebe test runner: always report fuzz tests
This way they can be smoke tested.
2024-07-25 18:52:21 -07:00
Andrew Kelley
b501adccbe std.Build.Fuzz: fix progress node hierarchy 2024-07-25 18:52:21 -07:00
Andrew Kelley
7366b4b9e2 test runner: handle start_fuzzing message 2024-07-25 18:52:21 -07:00
Andrew Kelley
bce3b1efb0 build runner sends a start_fuzzing message to test runner 2024-07-25 18:52:21 -07:00
Andrew Kelley
711ed56ce3 build runner: extract logic to std.Build.Fuzz 2024-07-25 18:52:21 -07:00
Andrew Kelley
047640383e add --fuzz CLI argument to zig build
This flag makes the build runner rebuild unit tests after the pipeline
finishes, if it finds any unit tests.

I did not make this integrate with file system watching yet.

The test runner is updated to detect which tests are fuzz tests.

Run step is updated to track which test indexes are fuzz tests.
2024-07-25 18:52:20 -07:00
Andrew Kelley
6f3767862d implement std.testing.fuzzInput
For now this returns a dummy fuzz input.
2024-07-25 18:52:20 -07:00
Andrew Kelley
5058beb179 implement std.testing.fuzzInput
for the -fno-fuzz case. The other case will take more work in libfuzzer.
2024-07-25 18:52:20 -07:00
Eugene-Dash
81a172a506
Add std.json.ParseOptions.parse_numbers to preserve float precision (#20744) 2024-07-25 20:55:06 -04:00
Alex Rønne Petersen
389ce984b5
start: Add POSIX arc support. 2024-07-26 02:32:19 +02:00
Alex Rønne Petersen
7c98a65ae4
start: Add POSIX hexagon support. 2024-07-26 02:32:16 +02:00
Andrew Kelley
ed847b85c2
Merge pull request #20777 from alexrp/start-abi-hardening
`start`: Harden against program interpreters that don't adhere fully to the ABI
2024-07-25 16:29:08 -07:00
Alex Rønne Petersen
d0557a699e
std.elf: Add Elf32_Relr and Elf64_Relr definitions. 2024-07-26 00:40:41 +02:00
Julian Vesper
3344ed8b8f aarch64: reenable tests that are no longer regressed
Closes #12012
2024-07-25 20:23:23 +03:00
Alex Rønne Petersen
c009264f5b
std.elf: Add some newer dynamic tag types. 2024-07-25 18:55:08 +02:00
Andrew Kelley
94f4f9c4ef add sub-compilation cache inputs to parents in whole mode
closes #20782
2024-07-24 19:40:54 -07:00
Alex Rønne Petersen
fff5ce053f
start: Align the stack on sparc64 just in case.
The kernel does this as required, but we cannot trust dynamic linkers to do it.
2024-07-25 00:55:52 +02:00
Alex Rønne Petersen
ebefee6088
start: Fix mips stack alignment value (should be 8, not 16). 2024-07-25 00:55:36 +02:00
Alex Rønne Petersen
5478b0eb38
start: Simplify mips and mips64 startup code.
Switches from using r1 as a temporary to r2. That way, we don't have to set the
`noat` assembler option. (r1 is the scratch register used by the assembler's
pseudoinstructions; the assembler warns when code uses that register explicitly
without `noat` set.)
2024-07-25 00:55:00 +02:00
Alex Rønne Petersen
be56c67b14 std.coff: Add missing entries to MachineType.
Sources:

* https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
* 88a28aa575/include/winnt.h (L2720-L2758)
2024-07-24 15:02:55 -07:00
Alex Rønne Petersen
47c0464e86
start: Explicitly clear the link register on mips and mips64 just in case.
The kernel does this as required, but we cannot trust dynamic linkers to do it.
2024-07-24 21:56:54 +02:00
Alex Rønne Petersen
1b13d7477d
start: Properly escape percent signs in the s390x inline asm.
Silly mistake in 8ffc41f747.
2024-07-24 21:56:54 +02:00
Alex Rønne Petersen
ce81525f3f
start: Align the stack on s390x just in case.
The kernel does this as required, but we cannot trust dynamic linkers to do it.
2024-07-24 21:56:54 +02:00
Alex Rønne Petersen
52653ec82b
start: Align the stack on powerpc just in case.
The kernel does this as required, but we cannot trust dynamic linkers to do it.
2024-07-24 21:56:54 +02:00
Alex Rønne Petersen
714e743393
start: Align the stack on aarch64 just in case.
The kernel does this as required, but we cannot trust dynamic linkers to do it.
2024-07-24 21:56:52 +02:00
Alex Rønne Petersen
38c492bb53
std.os.linux.start_pie: Add hexagon support. 2024-07-24 20:12:38 +02:00
Alex Rønne Petersen
a0b2b987c8
std.os.linux.start_pie: Add arc support. 2024-07-24 20:12:38 +02:00
Alex Rønne Petersen
bc054a713e
std.os.linux.start_pie: Add csky support. 2024-07-24 20:12:38 +02:00
Alex Rønne Petersen
2dabb7ec77
std.os.linux.start_pie: Handle armeb, thumb, thumbeb, and aarch64_be too. 2024-07-24 20:12:38 +02:00
Alex Rønne Petersen
9771390f89
start: Simplify the sparc64 inline asm a bit. 2024-07-24 20:12:14 +02:00
Alex Rønne Petersen
58e38ff1f8
start: Add a comment explaining the sparc64 stack bias. 2024-07-24 20:12:14 +02:00
Alex Rønne Petersen
5c96192c19
start: Add a comment explaining our paranoid stance on ABI guarantees. 2024-07-24 20:12:14 +02:00
Andrew Kelley
4de8bba648
Merge pull request #20749 from alexrp/start-pie
`std.os.linux.start_pie`: Implement `getDynamicSymbol()` for loongarch64, m68k, and s390x
2024-07-24 10:27:20 -07:00
Alex Rønne Petersen
557c4f04c2 start: Handle loongarch32 together with loongarch64.
Nothing bitness-specific about this startup code.
2024-07-24 10:25:51 -07:00
Andrew Kelley
75cf7fca90
Merge pull request #20767 from ziglang/emit-options
add "trace pc guard" as optional additional coverage instrumentation
2024-07-24 07:36:21 -07:00
Lucas Santos
1e74904aa2 Replace some dynamic functions with static ones.
PR [19271](https://github.com/ziglang/zig/pull/19271) added some static function implementations from kernel32, but some parts of the library still used the dynamically loaded versions.
2024-07-24 01:04:38 -07:00
Andrew Kelley
fa95c89a71
Merge pull request #20758 from pavelverigo/stage2-wasm-compiler-rt-test-pass
stage2-wasm: pass compiler_rt test suite
2024-07-23 20:42:25 -07:00
Andrew Kelley
399f4fe7d6
Merge pull request #20719 from alexrp/misc-porting
`std.os.linux`: A handful of random porting fixes, mostly for `armeb` and `thumbeb`
2024-07-23 20:04:26 -07:00
Andrew Kelley
26d2a7960e default "trace pc guard" coverage off
* Add -f(no-)sanitize-coverage-trace-pc-guard CLI flag which defaults to
  off. This value lowers to TracePCGuard = true (LLVM backend) and -Xclang
  -fsanitize-coverage-trace-pc-guard. These settings are not
  automatically included with -ffuzz.
* Add `Build.Step.Compile` flag for sanitize_coverage_trace_pc_guard
  with appropriate documentation.
* Add `zig cc` integration for the respective flags.
* Avoid crashing in ELF linker code when -ffuzz -femit-llvm-ir used
  together.
2024-07-23 17:30:53 -07:00
Alex Rønne Petersen
1c6bee0834
std.os.linux.start_pie: Add s390x support. 2024-07-24 00:28:08 +02:00
Alex Rønne Petersen
6fac71ec74
std.os.linux.start_pie: Add m68k support. 2024-07-24 00:28:07 +02:00
Alex Rønne Petersen
1fd45766a7
std.os.linux.start_pie: Add loongarch support. 2024-07-24 00:27:46 +02:00
Frank Denis
2e8acdf6fa
Fix compilation issues in crypto.bccrypt and poly1305 (#20756) 2024-07-23 19:45:24 +00:00
Alex Rønne Petersen
be1e1fa180 std.Build.Step.Run: Fix invocation syntax for Wasmtime 14+.
https://github.com/bytecodealliance/wasmtime/issues/7384
2024-07-23 12:39:40 -07:00
Alex Rønne Petersen
2d4fc1bb7a
std.os.linux.tls: Fix setThreadPointer() for armeb and thumbeb. 2024-07-23 21:17:29 +02:00
Alex Rønne Petersen
0473457b68
std.os.linux.tls: Set some constants correctly for powerpcle. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
c631110f5c
std.os.linux.tls: Set tls_tcb_size correctly for thumbeb. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
d694ddd279
std.os.linux.tls: Set tls_variant correctly for thumbeb. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
d2d325a862
std.os.linux.AUDIT: Fix s390x; add loongarch64 and xtensa. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
93311d6bca
std.os.linux: Also define O for armeb and thumbeb. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
92bc802033
std.os.linux: Also define MAP for armeb and thumbeb. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
fcbb192b49
std.os.linux: Define (MIN)SIGSTKSZ for all supported Linux architectures. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
b21de4de5e
std.os.linux: Define syscalls for armeb and thumbeb too. 2024-07-23 21:14:19 +02:00
Alex Rønne Petersen
b3e82b899f
std.os.linux: Import arch bits for armeb and thumbeb too. 2024-07-23 21:14:19 +02:00
Andrew Kelley
718f8d5314
Merge pull request #20706 from alexrp/sigaction-nosys
`std.posix`: Make `sigaction()` infallible
2024-07-23 11:49:43 -07:00
Pat Tullmann
e8503ecb65 Default std.posix.system.ucontext_t is void
PR https://github.com/ziglang/zig/pull/20679 ("std.c reorganization")
switched feature-detection code to use "T != void" checks in place of
"@hasDecl".  However, the std.posix.system struct is empty, so
compile-time feature detection against symbols in there (specifically
`std.posix.system.ucontext_t` in this case), fail at compile time on
freestanding targets.

This PR adds a void ucontext_t into the std.posix.system default.

This PR also adds pseudo-"freestanding" variation of the StackIterator
"unwind" test.  It is sort of hacky (its freestanding, but assumes it can
invoke a Linux exit syscall), but it does detect this problem.

Fixes #20710
2024-07-23 11:47:29 -07:00
Andrew Kelley
33c7984183 add std.testing.random_seed
closes #17609
2024-07-23 11:43:12 -07:00
Andrew Kelley
6f3e9939d0
Merge pull request #20725 from ziglang/fuzz
initial support for integrated fuzzing
2024-07-23 11:39:19 -07:00
Ryan Liptak
ac2459327f autodoc: Preserve whitespace in inline code spans
Fixes #20754
2024-07-23 10:02:54 -07:00
Pavel Verigo
8fd1f01f2a compiler_rt: disable test for stage2_wasm 2024-07-23 17:10:36 +02:00
Andrew Kelley
8a8a7ba35b
Merge pull request #20733 from alexrp/start-porting
`start`: Add startup code for loongarch64, m68k, and s390x
2024-07-22 18:25:24 -07:00
Veikka Tuominen
05a8c4796f
Merge pull request #18962 from fifty-six/master
std.builtin.panic(uefi): usability improvements
2024-07-23 04:06:30 +03:00
Frank Denis
d2c9a51d1e
Fix function definition: ChaCha20With64BitNonce counter is u64 (#20734)
Fixes #20732
2024-07-22 23:04:32 +00:00
Andrew Kelley
ae09f9bbce std.mem: delete workaround now that zig1.wasm is updated 2024-07-22 14:26:17 -07:00
Andrew Kelley
dbbe2f1094 libfuzzer: log all the libcalls to stderr 2024-07-22 14:26:17 -07:00
Andrew Kelley
bde8c4a46a update start code to use @disableInstrumentation
This prevents it from trying to access thread local storage before it
has set up thread local storage, particularly when code coverage
instrumentation is enabled.
2024-07-22 14:26:17 -07:00
Pavel Verigo
0c6aa44bc3 compiler_rt: wasm miss float exceptions 2024-07-22 23:22:01 +02:00
Andrew Kelley
25198810c8 add new builtin: @disableInstrumentation
This is needed to ensure that start code does not try to access thread
local storage before it has set up thread local storage.
2024-07-22 13:07:02 -07:00
Andrew Kelley
7930efc60b libfuzzer: implement enough symbols for hello world 2024-07-22 13:07:02 -07:00
Andrew Kelley
7802cf9814 avoid depending on a zig1.wasm update 2024-07-22 13:07:02 -07:00
Andrew Kelley
1741b821c3 add the build system API for enabling fuzzing 2024-07-22 13:07:02 -07:00
Andrew Kelley
54b7e144b1 initial support for integrated fuzzing
* Add the `-ffuzz` and `-fno-fuzz` CLI arguments.
* Detect fuzz testing flags from zig cc.
* Set the correct clang flags when fuzz testing is requested. It can be
  combined with TSAN and UBSAN.
* Compilation: build fuzzer library when needed which is currently an
  empty zig file.
* Add optforfuzzing to every function in the llvm backend for modules
  that have requested fuzzing.
* In ZigLLVMTargetMachineEmitToFile, add the optimization passes for
  sanitizer coverage.
* std.mem.eql uses a naive implementation optimized for fuzzing when
  builtin.fuzz is true.

Tracked by #20702
2024-07-22 13:07:02 -07:00
Andrew Kelley
eac7fd4da5
Merge pull request #20556 from McSinyx/setpgid
Allow setting PGID in std.process.Child.spawn
2024-07-22 11:17:18 -07:00
Yusuf Bham
22d964fe22 std.builtin.panic(uefi): stack allocate panic message
In the case that the allocator is unavailable (OOM, etc.), we can
possibly still output the panic message - so now we stack allocate the
message and copy it to the exit data for passing to boot services.
2024-07-22 16:23:10 +03:00
Yusuf Bham
c16aeda8a6 std.builtin.panic(uefi): also output to con_out 2024-07-22 16:23:10 +03:00
Alex Rønne Petersen
8ffc41f747
start: Add POSIX s390x startup code. 2024-07-22 14:39:55 +02:00
Alex Rønne Petersen
c53673276b
start: Add POSIX loongarch64 startup code. 2024-07-22 14:39:55 +02:00
Alex Rønne Petersen
1fa5ca24fe
start: Add POSIX m68k startup code. 2024-07-22 14:39:55 +02:00
Alex Rønne Petersen
142209444a
start: Pass _start() into its own inline asm as an operand. 2024-07-22 14:39:53 +02:00
Andrew Kelley
b149d8f747
Merge pull request #20718 from alexrp/start-gv
`start`: Avoid going through the argc_argv_ptr global variable
2024-07-22 00:24:50 -07:00
Nguyễn Gia Phong
759ab41d72
Allow setting PGID in std.process.Child.spawn 2024-07-22 11:50:00 +09:00
Nguyễn Gia Phong
d6fa71cd67
std: Wrap setpgid on POSIX 2024-07-22 11:49:55 +09:00