Commit Graph

9918 Commits

Author SHA1 Message Date
Alex Rønne Petersen
17f54e8274
std.zig.target: Split powerpc-linux-musl triple into powerpc-linux-musleabi(hf). 2024-09-06 20:11:47 +02:00
Alex Rønne Petersen
c1a70acc91
std.zig.target: Split mips(el)-linux-musl triples into mips(el)-linux-musleabi(hf).
Closes #21184.
2024-09-06 20:11:47 +02:00
Alex Rønne Petersen
a0205fff98
std.DynLib: Prefer std.fs.File.stat() over posix.fstat().
This is necessary for riscv32-linux.
2024-09-06 20:03:15 +02:00
Alex Rønne Petersen
65a6e9eee5
std.posix: Skip a couple of tests that use fstat()/fstatat() on riscv32. 2024-09-06 20:03:15 +02:00
Alex Rønne Petersen
f35015575e
std.time: Use clock_nanosleep() to implement sleep() on Linux.
This fixes the function for riscv32 where the old nanosleep() is not available.
clock_nanosleep() has been available since Linux 2.6 and glibc 2.1 anyway.
2024-09-06 20:03:12 +02:00
Alex Rønne Petersen
8043197995
std.os.linux: Add clock_nanosleep() syscall wrapper. 2024-09-06 20:03:00 +02:00
Andrew Kelley
f29bdd6746
Merge pull request #21263 from alexrp/thumb-fixes
Some fixes for `thumb-linux-*` support
2024-09-06 10:55:45 -07:00
Ian Johnson
3543f28320 std.math.big.int: fix shiftRight sign handling
Closes #21311

The sign of the result `r` needs to be initialized before the correction
`r.addScalar(r.toConst(), -1)`, or the intended end result could be off
by 2 (depending on the original sign of `r`).
2024-09-06 10:36:12 -07:00
Andrew Kelley
3929cac154
Merge pull request #21257 from mlugg/computed-goto-3
compiler: implement labeled switch/continue
2024-09-04 18:31:28 -07:00
Arwalk
f87dd43c12
stdlib : base64 encode to writer (#20961) 2024-09-04 08:10:12 +00:00
Alex Rønne Petersen
e5ee9c1e43 std.elf: Bring the EM enum up to date.
Based on:

* `include/elf/common.h` in binutils
* `include/uapi/linux/elf-em.h` in Linux
* https://www.sco.com/developers/gabi/latest/ch4.eheader.html

I opted to use the tag naming of binutils because it seems to be by far the most
complete and authoritative source at this point in time.
2024-09-03 17:44:01 -07:00
Michael Dusan
7a4d69983a AstGen: update @errorCast to maybe eval to err
Consequently, `AstGen.ret()` now passes the error code to
`.defer_error_code`. Previously, the error union value was passed.

closes #20371
2024-09-03 22:56:23 +01:00
Alex Rønne Petersen
9bcb0e938c
std.crypto.ml_kem: Reduce test iteration counts from 100 to 10. (#21285)
Closes #21255.
2024-09-02 23:20:48 +00:00
fdfdjfk3
a670f55195
std.fmt.fmtIntSize*: document when precision is ignored 2024-09-02 14:21:59 +03:00
Jeremy Hertel
13da34955c std.hash_map: fix error message in getAutoHashFn 2024-09-02 12:09:10 +03:00
Matthew Lugg
6d2945f1fe
Merge pull request #21264 from mlugg/decl-literals
compiler: implement decl literals
2024-09-02 00:44:11 +01:00
Jeremy Hertel
227fb4875f std.math: rename make_f80 to F80.toFloat and break_f80 to F80.fromFloat 2024-09-02 00:10:22 +03:00
mlugg
2b9af9e825
AstGen: error on unused switch label 2024-09-01 18:31:01 +01:00
mlugg
b7a55cd6c3
AstGen: allow breaking from labeled switch
Also, don't use the special switch lowering for errors if the switch
is labeled; this isn't currently supported. Related: #20627.
2024-09-01 18:31:01 +01:00
mlugg
3b52e5a221
std.zig.render: fix switch rendering 2024-09-01 18:30:31 +01:00
mlugg
0cc8435a83
std.zig: resolve syntactic ambiguity
The parse of `fn foo(a: switch (...) { ... })` was previously handled
incorrectly; `a` was treated as both the parameter name and a label.

The same issue exists for `for` and `while` expressions -- they should
be fixed too, and the grammar amended appropriately. This commit does
not do this: it only aims to avoid introducing regressions from labeled
switch syntax.
2024-09-01 18:30:31 +01:00
mlugg
5e12ca9fe3
compiler: implement labeled switch/continue 2024-09-01 18:30:31 +01:00
mlugg
0b9fccf508
std: deprecate some incorrect default initializations
In favour of newly-added decls, which can be used via decl literals.
2024-09-01 17:34:07 +01:00
mlugg
6e3e23a941
compiler: implement decl literals
Resolves: #9938
2024-09-01 17:34:07 +01:00
mlugg
9e683f0f35
compiler: provide result type to operand of try
This is mainly useful in conjunction with Decl Literals (#9938).

Resolves: #19777
2024-09-01 17:34:07 +01:00
Nico Elbers
cad65307b7 std: make debug.dumpStackPointerAddr compile
Very simply add the format specifier to the print statement.
Since debug.print is hard coded I couldn't come up with a reasonalble
way to add a test, and since this function is simple enough I doubt it's
useful.

fixes one part of #21094
2024-09-01 00:45:31 -07:00
Jeremy Hertel
52fc046907 std.c: fix pthread_mutex_t size for x86_64-linux-gnu 2024-09-01 00:44:09 -07:00
Hila Friedman
a76e98e7d5 remove length assertion from mprotect 2024-08-31 20:59:47 -07:00
Andrew Kelley
96daca7b3b
Merge pull request #21173 from mrjbq7/writeStackTrace
std.debug: remove allocator from std.debug.writeStackTrace()
2024-08-31 20:57:27 -07:00
fn ⌃ ⌥
69e304bd51 std.c.passwd: support macOS and NetBSD 2024-08-31 20:56:27 -07:00
YANG Xudong
67fc44fc6f add qemu-loongarch64 2024-08-31 20:49:24 -07:00
Alex Rønne Petersen
0ecc6332b4
start: Fix arm stack alignment code to work for thumb too. 2024-08-31 03:38:35 +02:00
Alex Rønne Petersen
68bb788df5
std.os.linux: Make nanosleep() a compile error on riscv32.
This should eventually be converted to the void/{} pattern along with the other
syscalls that are compile errors for riscv32.
2024-08-31 03:31:58 +02:00
Alex Rønne Petersen
6364995d3f
std.os.linux: Also use kernel_timespec for riscv32 when libc is linked.
Both glibc and musl use time64 as the base ABI for riscv32. This fixes the
`sleep` test in `std.time` hanging forever due to the libc functions reading
bogus values.
2024-08-31 03:31:58 +02:00
Alex Rønne Petersen
537cb49eb2
std.os.linux: Define the Stat struct for riscv32.
The kernel does define the struct, it just doesn't use it. Yet both glibc and
musl expose it directly as their public stat struct, and std.c takes it from
std.os.linux. So just define it after all.
2024-08-31 03:31:58 +02:00
Alex Rønne Petersen
cb0e6d8aa6 std.os.linux: Fix syscall6() when building for PIC/PIE.
LLVM would run out of registers due to the edi usage. Just extend what we're
already doing for ebp to edi as well.
2024-08-30 14:48:17 -07:00
Andrew Kelley
e4e91a1314
Merge pull request #21224 from alexrp/mips-gnu-fixes
Fix MIPS PIC level and work around an LLVM bug for `mips(el)-linux-gnueabi(hf)`
2024-08-30 14:47:43 -07:00
Andrew Kelley
5d08b7f054
Merge pull request #21178 from alexrp/glibc-thumb
`std.zig.target`: Remove `thumb*-linux-gnueabi*` target triples.
2024-08-30 14:35:30 -07:00
Andrew Kelley
a4cc43c42b
Merge pull request #21174 from alexrp/win-arm
Change `arm-windows-gnu` to `thumb-windows-gnu`, plus some initial port work
2024-08-30 14:34:53 -07:00
mlugg
ba8d3f69ca
std.pdb: obey naming conventions
These names aren't matching any formal specification; they're mostly
just ripped from LLVM code. Therefore, we should definitely follow Zig
naming conventions here.
2024-08-29 23:43:52 +01:00
mlugg
4330c40596
std: avoid field/decl name conflicts
Most of these changes seem like improvements. The PDB thing had a TODO
saying it used to crash; I anticipate it works now, we'll see what CI
does.

The `std.os.uefi` field renames are a notable breaking change.
2024-08-29 20:39:11 +01:00
mlugg
401910a2ca
AstGen: disallow fields and decls from sharing names
This is a mini-proposal which is accepted as part of #9938.

This compiler and standard library need some changes to obey this rule.
2024-08-29 20:39:11 +01:00
Andrew Kelley
13b5cee4cc fuzzing: fix entry address logic
* the pcs list is unsorted
* use the function address

Fixes entry points in ReleaseSafe mode.
2024-08-28 18:07:13 -07:00
Andrew Kelley
1bec824cad LLVM: disable inline 8-bit counters when using trace pc guard 2024-08-28 18:07:13 -07:00
Jacob Young
6a21875ddb
Merge pull request #21230 from jacobly0/stack-trace
Dwarf: fix self-hosted stack traces
2024-08-28 17:39:35 -04:00
Jacob Young
12275cf4b9 Dwarf: fix parsing self-hosted debug info for stack traces 2024-08-28 06:45:17 -04:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Alex Rønne Petersen
a2e691d589
Revert "add a workaround for miscompilation regarding alignment"
This reverts commit 149aa9afb7.
2024-08-28 06:24:05 +02:00
Alex Rønne Petersen
832f74876e
std.builtin: Define VaList for arm, armeb, and thumbeb too. 2024-08-28 03:13:01 +02:00
Alex Rønne Petersen
34c6482403
std.debug: Fix a bitness portability issue in walkStackWindows(). 2024-08-28 03:13:01 +02:00
Alex Rønne Petersen
d702a21bbc
std.os.windows: Define CONTEXT, RUNTIME_FUNCTION, and KNONVOLATILE_CONTEXT_POINTERS for thumb. 2024-08-28 03:13:01 +02:00
Alex Rønne Petersen
2e2441a89d
std.os.windows: Implement teb() for thumb.
6e15604c48/include/winnt.h (L2503)

Closes #4645.
2024-08-28 03:13:01 +02:00
Alex Rønne Petersen
a3990a950d
std.zig.WindowsSdk: Fix various target checks to check for thumb.
Also remove mentions of arm and armeb; these are not relevant for Windows.
2024-08-28 03:08:10 +02:00
Alex Rønne Petersen
1c6642552e
std.zig.target: Change arm-windows-gnu triple to thumb-linux-gnu.
Windows on 32-bit Arm only operates in Thumb-2 mode: https://devblogs.microsoft.com/oldnewthing/20210601-00/?p=105267

Trying to compile for arm-windows-gnu fails in all sorts of ways as neither
LLVM nor MinGW-w64 expect it.
2024-08-28 03:08:10 +02:00
Alex Rønne Petersen
281707acf3 std.zig.target: Remove thumb*-linux-gnueabi* target triples.
Grepping for `NO_THUMB` in glibc suggests that glibc does not actually support
pure Thumb-2 mode. This is the mode that is implied by these target triples;
mixed Arm/Thumb mode should just use the regular `arm*-linux-gnueabi*` triples.
2024-08-28 02:57:31 +02:00
Jacob Young
f289b82d0e Dwarf: implement .eh_frame 2024-08-27 03:55:56 -04:00
mlugg
6808ce27bd
compiler,lib,test,langref: migrate @setCold to @branchHint 2024-08-27 00:44:35 +01:00
mlugg
a3a737e9a6
lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
mlugg
457c94d353
compiler: implement @branchHint, replacing @setCold
Implements the accepted proposal to introduce `@branchHint`. This
builtin is permitted as the first statement of a block if that block is
the direct body of any of the following:

* a function (*not* a `test`)
* either branch of an `if`
* the RHS of a `catch` or `orelse`
* a `switch` prong
* an `or` or `and` expression

It lowers to the ZIR instruction `extended(branch_hint(...))`. When Sema
encounters this instruction, it sets `sema.branch_hint` appropriately,
and `zirCondBr` etc are expected to reset this value as necessary. The
state is on `Sema` rather than `Block` to make it automatically
propagate up non-conditional blocks without special handling. If
`@panic` is reached, the branch hint is set to `.cold` if none was
already set; similarly, error branches get a hint of `.unlikely` if no
hint is explicitly provided. If a condition is comptime-known, `cold`
hints from the taken branch are allowed to propagate up, but other hints
are discarded. This is because a `likely`/`unlikely` hint just indicates
the direction this branch is likely to go, which is redundant
information when the branch is known at comptime; but `cold` hints
indicate that control flow is unlikely to ever reach this branch,
meaning if the branch is always taken from its parent, then the parent
is also unlikely to ever be reached.

This branch information is stored in AIR `cond_br` and `switch_br`. In
addition, `try` and `try_ptr` instructions have variants `try_cold` and
`try_ptr_cold` which indicate that the error case is cold (rather than
just unlikely); this is reachable through e.g. `errdefer unreachable` or
`errdefer @panic("")`.

A new API `unwrapSwitch` is introduced to `Air` to make it more
convenient to access `switch_br` instructions. In time, I plan to update
all AIR instructions to be accessed via an `unwrap` method which returns
a convenient tagged union a la `InternPool.indexToKey`.

The LLVM backend lowers branch hints for conditional branches and
switches as follows:

* If any branch is marked `unpredictable`, the instruction is marked
  `!unpredictable`.
* Any branch which is marked as `cold` gets a
  `llvm.assume(i1 true) [ "cold"() ]` call to mark the code path cold.
* If any branch is marked `likely` or `unlikely`, branch weight metadata
  is attached with `!prof`. Likely branches get a weight of 2000, and
  unlikely branches a weight of 1. In `switch` statements, un-annotated
  branches get a weight of 1000 as a "middle ground" hint, since there
  could be likely *and* unlikely *and* un-annotated branches.

For functions, a `cold` hint corresponds to the `cold` function
attribute, and other hints are currently ignored -- as far as I can tell
LLVM doesn't really have a way to lower them. (Ideally, we would want
the branch hint given in the function to propagate to call sites.)

The compiler and standard library do not yet use this new builtin.

Resolves: #21148
2024-08-27 00:41:49 +01:00
mlugg
f2d7096bb9
compiler: make @export take a pointer
Resolves: #14911
2024-08-27 00:41:04 +01:00
Andrew Kelley
849c31a6cc
Merge pull request #21177 from alexrp/elf-coff-conv
`std.{coff,elf}`: Remove the `{MachineType,EM}.toTargetCpuArch()` functions.
2024-08-25 14:49:53 -07:00
Jari Vetoniemi
2d7c26cc66 ElfDynLib: resolve lib from system paths
Implements the base that should usually work that is
- Check LD_LIBRARY_PATH if the binary is no setuid setgid binary
- Check /lib, /usr/lib, in that order

The missing parts are:
- DT_RPATH and DT_RUNPATH handling from the calling executable
- Reading /etc/ld.so.cache

For more details check man page of dlopen(3)
2024-08-24 05:32:53 -07:00
Prokop Randáček
9374725088
port cachegrind.h to zig (#19241)
* port cachegrind.h to zig
* import cachegrind.zig in valgrind.zig
* Avoid Redundant Names in Fully-Qualified Namespaces
2024-08-23 22:59:30 -07:00
Alex Rønne Petersen
ab69482a5d std.fs: Disable file operations on directories test on WASI.
https://github.com/ziglang/zig/issues/20747
2024-08-23 22:43:03 -07:00
Alex Rønne Petersen
cad69e2c29 std.Target.Query: Fix parse test on ABIs like gnueabi, gnuabi64, etc.
The `zigTriple()` implementation simply returns `gnu` when a glibc version is provided but a more specific ABI isn't.
2024-08-23 22:39:05 -07:00
Andrew Kelley
85747b266a Revert "Smaller memory footprint for BoundedArray (#16299)"
This reverts commit cb5a6be41a.

I deeply apologize for the churn.

This change is problematic given that we do not have ranged integers
(yet? see #3806).

In the meantime, this type needs to be `usize`, matching the length and
index types for all std lib data structures.

Users who want to save memory should not use heap-allocated BoundedArray
values, since it is inherently memory-inefficient. Use a different
memory layout instead.

If #3806 is accepted and implemented, the length value can become an
integer with the appropriate range, without the footgun. If that
proposal is not accepted, len type will remain a usize.
2024-08-23 22:30:10 -07:00
Andrew Kelley
d9e8671d96 fix merge conflict from previous commit 2024-08-23 21:46:36 -07:00
Eric Joldasov
03c297eea6 std.Build: call handleVerbose2 in runAllowFail
Ensures that all runned command are visible when using `--verbose` flag,
for example `pkg-config` from Step.Compile or `git describe` from build.zig.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-08-23 21:45:32 -07:00
Andrew Kelley
9848318725 fix autodocs regression FTBFS
regressed in dffc8c44f9 since there is no
test coverage for the `zig std` command yet.

closes #21180
2024-08-23 19:23:38 -07:00
Alex Rønne Petersen
a69f55a7cc
std.{coff,elf}: Remove the {MachineType,EM}.toTargetCpuArch() functions.
These are fundamentally incapable of producing accurate information for reasons
I've laid out in #20771. Since our only use of these functions is to check that
object files have the correct machine type, and since #21020 made
`std.Target.to{Coff,Elf}Machine()` more accurate, just switch these checks over
to that and compare the machine type tags instead.

Closes #20771.
2024-08-23 19:56:24 +02:00
bilaliscarioth
df6907f601
openbsd: adding EPERM for msync() against hitting a immutable region page (#18701) 2024-08-23 14:28:00 +00:00
Michał Drozd
206e5e4d7d
std.os.linux: Fix bunch of compilation errors (#21138)
* Correct layout of IntInfo according to https://www.kernel.org/doc/html/latest/bpf/btf.html#btf-kind-int

* Fix VFS errors

* Fix std.os.linux.sendmmsg

* Fix std.os.linux.sigismember. Add tests

* Fix futex2 functions
2024-08-23 14:21:19 +00:00
bilaliscarioth
dc72138b91 Update c.zig, openbsd don't have getcontext 2024-08-23 07:19:04 -07:00
Andrew Kelley
60011d28d3
Merge pull request #21137 from Aransentin/af_packet
std.os.linux: Add support for AF_PACKET V3
2024-08-23 00:46:18 -07:00
Andrew Kelley
56119c2cbc
Merge pull request #21118 from alexrp/thread-porting
`std.Thread`: Support hexagon, sparc32, s390x in `freeAndExit()`
2024-08-23 00:41:50 -07:00
John Benediktsson
4adb10df47 std.builtin: removing unused arena allocator in StackTrace.format 2024-08-22 21:23:53 -07:00
John Benediktsson
c690537154 std.debug: remove allocator from std.debug.writeStackTrace() 2024-08-22 21:23:53 -07:00
Andrew Kelley
ee84deda98
Merge pull request #21095 from alexrp/mips64-tests
Get `mips64(el)-linux` working and start testing it
2024-08-22 20:09:08 -07:00
Andrew Kelley
205e17a73c
Merge pull request #21161 from jedisct1/mlkem-update
Update ML-KEM to the final specification
2024-08-22 12:54:40 -07:00
Josh Wolfe
febfcbd49d
std.json.WriteStream supports streaming long values directly to the underlying stream (#21155) 2024-08-22 08:26:14 -04:00
Jacob Young
31220b50b5 Dwarf: cleanup emitted debug info
* reduce iteration cost by not tracking unused entries
 * avoid emitting unused abbrevs to `.debug_abbrev`
 * get the compiler executable passing `llvm-dwarfdump --verify`
 * make it possible to skip `.debug_line` padding much more quickly
2024-08-22 08:44:08 +02:00
Frank Denis
b131b6dd36 Rename the namespace for ml_kem variants of Kyber to nist 2024-08-22 07:54:12 +02:00
Frank Denis
067ae04e0b Update ML-KEM to the final specification
NIST has published the final specification of ML-KEM, which adds
domain separation to the seed used to create the inner secret key.
2024-08-22 01:00:12 +02:00
mlugg
a0b03d7fff
std.Build.Step.TranslateC: propagate target, optimize, link_libc to created module 2024-08-21 19:13:26 +01:00
mlugg
7bbbbf8ffa compiler: fix losing ZIR instructions in main_struct_inst fields 2024-08-21 16:24:57 +01:00
Jens Goldberg
c3214bcd96 Inline the variant union 2024-08-21 10:10:19 +02:00
mlugg
018262d537
std: update eval branch quotas after bdbc485
Also, update `std.math.Log2Int[Ceil]` to more efficient implementations
that don't use up so much damn quota!
2024-08-21 01:30:46 +01:00
mlugg
43fdd061f7
AstGen: incorporate extra information into source hashes
* Indices of referenced captures
* Line and column of `@src()`

The second point aligns with a reversal of the "incremental compilation"
section of https://github.com/ziglang/zig/issues/2029#issuecomment-645793168.
This reversal was already done as #17688 (46a6d50), with the idea to
push incremental compilation down the line. My proposal is to keep it as
comptime-known, and simply re-analyze uses of `@src()` whenever their
line/column change.

I think this decision is reasonable for a few reasons:

* The Zig compiler is quite fast. Occasionally re-analyzing a few
  functions containing `@src()` calls is perfectly acceptable and won't
  noticably impact update times.
* The system described by Andrew in #2029 is currently vaporware.
* The system described by Andrew in #2029 is non-trivial to implement.
  In particular, it requires some way to have backends update a single
  global in certain cases, without re-doing semantic analysis. There is
  no other part of incremental compilation which requires this.
* Having `@src().line` be comptime-known is useful. For instance, #17688
  was justified by broken Tracy integration because the source line
  couldn't be comptime-known.
2024-08-21 01:30:46 +01:00
mlugg
9cf8a7661f
compiler: handle eval branch quota in memoized calls
In a `memoized_call`, store how many backwards braches the call
performs. Add this to `sema.branch_count` when using a memoized call. If
this exceeds the quota, perform a non-memoized call to get a correct
"exceeded X backwards branches" error.

Also, do not memoize calls which do `@setEvalBranchQuota` or similar, as
this affects global state which must apply to the caller.

Change some eval branch quotas so that the compiler itself still builds correctly.

This commit manually changes a file in Aro which is automatically
generated. The sources which generate the file are not in this repo.
Upstream Aro should make the suitable changes on their end before the
next sync of Aro sources into the Zig repo.
2024-08-21 01:26:55 +01:00
Jens Goldberg
6f24c4485c Add tpacket_hdr and tpacket_block variant unions 2024-08-20 10:10:14 +02:00
Ian Johnson
0a70455095 Fix handling of empty XDG environment variables
Closes #21132

According to the XDG Base Directory specification
(https://specifications.freedesktop.org/basedir-spec/latest/#variables),
empty values for these environment variables should be treated the same
as if they are unset. Specifically, for the instances changed in this
commit,

> $XDG_DATA_HOME defines the base directory relative to which
> user-specific data files should be stored. If $XDG_DATA_HOME is either
> not set **or empty**, a default equal to $HOME/.local/share should be
> used.

and

> $XDG_CACHE_HOME defines the base directory relative to which
> user-specific non-essential data files should be stored. If
> $XDG_CACHE_HOME is either not set **or empty**, a default equal to
> $HOME/.cache should be used.

(emphasis mine)

In addition to the case mentioned in the linked issue, all other uses of
XDG environment variables were corrected.
2024-08-19 23:30:14 -07:00
Andrew Kelley
dffc8c44f9
Merge pull request #21115 from Snektron/build-system-asm
compilation and build system fixes
2024-08-19 21:49:29 -07:00
Meghan Denny
7071d1b3c2
std: add native cpu detection for apple m3 (#21116)
* std.c.darwin: add missing CPUFAMILY fields

* std.zig.system.detectNativeCpuAndFeatures: add missing darwin fields

* add comment so the prong isnt lost and easily discoverable during next llvm upgrade
2024-08-19 11:49:02 -07:00
Mohanavel S K
82b676ef79
Added Constants Related To Ioctl (sockios.h) 2024-08-19 20:21:26 +03:00
Robin Voetter
43f73af359
fix various issues related to Path handling in the compiler and std
A compilation build step for which the binary is not required could not
be compiled previously. There were 2 issues that caused this:

- The compiler communicated only the results of the emitted binary and
  did not properly communicate the result if the binary was not emitted.

  This is fixed by communicating the final hash of the artifact path (the
  hash of the corresponding /o/<hash> directory) and communicating this
  instead of the entire path. This changes the zig build --listen protocol
  to communicate hashes instead of paths, and emit_bin_path is accordingly
  renamed to emit_digest.

- There was an error related to the default llvm object path when
  CacheUse.Whole was selected. I'm not really sure why this didn't manifest
  when the binary is also emitted.

  This was fixed by improving the path handling related to flush() and
  emitLlvmObject().

In general, this commit also improves some of the path handling throughout
the compiler and standard library.
2024-08-19 19:09:11 +02:00
Jens Goldberg
1950e52c6c Remove FASTROUTE; invisible to userspace, and collides with USER 2024-08-19 16:19:05 +02:00
Jens Goldberg
af007ec1ff std.os.linux: Add support for AF_PACKET V3 2024-08-19 15:01:58 +02:00
Alex Rønne Petersen
f0d6a211e0 std.Thread: Implement freeAndExit() for hexagon. 2024-08-19 08:38:05 +02:00
Alex Rønne Petersen
8e4feca8ab std.Thread: Implement freeAndExit() for s390x. 2024-08-19 08:38:05 +02:00
Alex Rønne Petersen
0f78f8244f std.Thread: Use zero exit code in freeAndExit() for sparc64. 2024-08-19 08:38:05 +02:00
Alex Rønne Petersen
d79e2822b0 std.Thread: Implement freeAndExit() for sparc32. 2024-08-19 08:38:05 +02:00
mlugg
de49a9a173
Zir: add instructions to fetch std.builtin types
This replaces the constant `Zir.Inst.Ref` tags (and the analagous tags
in `Air.Inst.Ref`, `InternPool.Index`) referring to types in
`std.builtin` with a ZIR instruction `extended(builtin_type(...))` which
instructs Sema to fetch such a type, effectively as if it were a
shorthand for the ZIR for `@import("std").builtin.xyz`.

Previously, this was achieved through constant tags in `Ref`. The
analagous `InternPool` indices began as `simple_type` values, and were
later rewritten to the correct type information. This system was kind of
brittle, and more importantly, isn't compatible with incremental
compilation of std, since incremental compilation relies on the ability
to recreate types at different indices when they change. Replacing the
old system with this instruction slightly increases the size of ZIR, but
it simplifies logic and allows incremental compilation to work correctly
on the standard library.

This shouldn't have a significant impact on ZIR size or compiler
performance, but I will take measurements in the PR to confirm this.
2024-08-18 18:10:59 +01:00
Alex Rønne Petersen
4320611e6d std.debug: Also disable stack traces on mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
812a444d55 std.c: Fix Sigaction struct for glibc on mips/mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
e2a4d7acfc std.c: Fix Stat struct for mips/mips64 on linux. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
ea38009f3d std.os.linux: Fix Stat struct for mips/mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
ed9a502dff std.os.linux: Fix rlimit_resource for mips64; move out of arch bits.
It is usually generic, so no point having it in arch bits.
2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
d4973c9922 std.os.linux: Fix syscall errno value handling for mips.
The kernel sets r7 to 0 (success) or -1 (error), and stores the result in r2.
When r7 is -1 and the result is positive, it needs to be negated to get the
errno value that higher-level code, such as errnoFromSyscall(), expects to see.

The old code was missing the check that r2 is positive, but was also doing the
r7 check incorrectly; since it can only be set to 0 or -1, the blez instruction
would always branch.

In practice, this fix is necessary for e.g. the ENOSYS error to be interpreted
correctly. This manifested as hitting an unreachable branch when calling
process_vm_readv() in std.debug.MemoryAccessor.
2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
bcf41c8594 std.os.linux: Fix E definition for mips64. 2024-08-18 07:27:23 +02:00
mlugg
7f2466e65f std.BoundedArray: add clear() 2024-08-17 18:50:10 -04:00
mlugg
89f02d1c10 std.zig.Zir: fix declaration traversal
The old logic here had bitrotted, largely because there were some
incorrect `else` cases. This is now implemented correctly for all
current ZIR instructions. This prevents instructions being lost in
incremental updates, which is important for updates to be minimal.
2024-08-17 18:50:10 -04:00
Jacob Young
f601aa780e Dwarf: fix and test allowzero pointers 2024-08-17 05:57:45 -04:00
Jacob Young
e9df5ab7f1 std: disable failing debug info test for self-hosted 2024-08-16 16:23:53 -04:00
Jacob Young
ef11bc9899 Dwarf: rework self-hosted debug info from scratch
This is in preparation for incremental and actually being able to debug
executables built by the x86_64 backend.
2024-08-16 15:22:55 -04:00
Andrew Kelley
11176d22f8
Merge pull request #21073 from alexrp/test-changes
`test`: QoL for port work, more mips re-enablement
2024-08-15 22:23:48 -07:00
Andrew Kelley
05c7968920
Merge pull request #21020 from alexrp/target-fixes
`std.Target`: Assorted corrections, plus cleanup around ELF/COFF machine types
2024-08-15 22:13:31 -07:00
Andrew Kelley
b917d778c6
Merge pull request #21056 from alexrp/start-fix-precedence
`start`: Avoid string concatenation in inline asm.
2024-08-15 22:10:59 -07:00
Igor Anić
72bcc3b7a5
std.tar: add writer (#19603)
Simplifies code in docs creation where we used `std.tar.output.Header`.
Writer uses that Header internally and provides higher level interface.
Updates checksum on write, handles long file names, allows setting mtime and file permission mode. Provides handy interface for passing `Dir.WalkerEntry`.
2024-08-15 22:05:53 -07:00
Linus Groh
708414aaf4 std.time.epoch: Fix comments referring to epoch as 1970-10-01 2024-08-15 17:54:27 -07:00
YANG Xudong
8e91c229e1
loongarch: fix asm to set thread pointer (#21086)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-15 15:40:44 -07:00
Alex Rønne Petersen
ab9628dd2c
start: Avoid concatenating strings for inline asm.
For csky, we can just always do the gb initialization. For riscv, the gp code is
temporarily pulled above the main switch until the blocking issue is resolved.
2024-08-15 10:56:32 +02:00
Alex Rønne Petersen
6db9ad7798
std.Target: Return the correct value for 32-bit sparc v9 in toElfMachine(). 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
9b5c992d31
std.Target: Return the correct value for elfiamcu in toElfMachine(). 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
550438653d
std.Target: Pull toCoffMachine()/toElfMachine() up from Arch to Target.
This enables them to give more correct results.

Contributes to #20771.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
b01c595d4a
std.coff: Capitalize MachineType.{Unknown,Thumb} for consistency. 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
ac9ca7d30c
std.coff: Remove MachineType.fromTargetCpuArch().
This does the same thing as std.Target.Cpu.Arch.toCoffMachine(). Just use that.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
65affb1c22
std.Target: Don't match PowerPC in Arch.toCoffMachine().
It's entirely unclear whether this should map to POWERPC or POWERPCFP, and as I
can find no evidence of people producing PE files for PowerPC since Windows NT,
let's just not make a likely-wrong guess. We can revisit this if the need ever
actually arises.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
b24fc35eeb
std.Target: Don't match big endian architectures in Arch.toCoffMachine().
All of these were mapping to types that are little endian. In fact, I can find
no evidence that either Windows or UEFI have ever been used on big endian
systems.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
8516a6ab57
std.Target: Clean up Arch.toCoffMachine(). 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
490b328127
std.Target: Fix Arch.toElfMachine() for mips.
EM_MIPS_RS3_LE is obsolete; all mips targets just use EM_MIPS.

Also, fun fact: EM_MIPS_RS3_LE is actually big endian!
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
6c27cab5b3
std.Target: Fix Arch.toElfMachine() for arc.
The arc tag means ARCv2.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
9246c88031
std.Target: Clean up Arch.toElfMachine(). 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
1e67221f07
std.Target: Change requiresLibC() to return true for aix.
AIX does not have a stable syscall interface; libc is required.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
fc93ab7182
std.Target: Fix isGnuLibC() to handle hurd too. 2024-08-15 10:55:45 +02:00
Alex Rønne Petersen
0def4e0db0
std.Target: Make some functions handle driverkit alongside other Apple OSs.
Reference for versions: https://developer.apple.com/support/xcode
2024-08-15 10:55:45 +02:00
Jacob Young
5d080e25d5 start: fix passing comptime-only value to inline asm
Also fix fmt directive typo.
2024-08-15 04:42:04 -04:00
clickingbuttons
da8fbcc2a9
std.mem.writeVarPackedInt: handle write_size == 0 (#19745)
Also move example comments into tests.
2024-08-15 06:03:29 +00:00
reokodoku
20f4be4cf9 std.os.linux: add mseal syscall 2024-08-14 22:48:13 -07:00
Jarrod Meyer
9be10ea964 Watch.zig: fixes for windows implementation
Using --watch I noticed a couple of issues with my initial attempt. 1) The index I used as 'completion key' was not stable over time, when directories are being added/removed the key no longer corresponds with the intended dir. 2) There exists a race condition in which we receive a completion notification for a directory that was removed. My solution is to generate a key value and associate it with each Directory.
2024-08-14 13:21:01 -07:00
Andrew Kelley
78fb9c0a17
Merge pull request #21031 from linusg/std-target-naming
std.Target: Function naming cleanup
2024-08-14 10:36:24 -07:00
T
eb7f318ea8
langref: clarify functionality of the round builtin (#19503)
A test has also been added to demonstrate the expected behavior.

* std.math: update round doc comment to match the builtin
2024-08-14 10:29:45 -07:00
Andrew Kelley
b7a1ef3e19
Merge pull request #21075 from ziglang/fuzz
fix several debug info bugs
2024-08-14 04:55:32 -07:00
Alex Rønne Petersen
b470d2a7de std.debug: Support sparc32 in StackIterator.init(). 2024-08-13 23:54:20 -07:00
Alex Rønne Petersen
dc77d1b66d std.Thread: Merge riscv32/riscv64 assembly in freeAndExit(). 2024-08-13 23:53:57 -07:00
Andrew Kelley
72768bddcd std.Build.Fuzz.WebServer: sort pcs before source location lookup
Unfortunately, the PCs do not get sorted during linking.
2024-08-13 19:30:22 -07:00
Andrew Kelley
a726e09389 std.debug.Coverage.resolveAddressesDwarf: assert sorted 2024-08-13 19:29:55 -07:00
Andrew Kelley
022bca9b06 std.debug.Dwarf: better source location information
Two fixes here:

Sort by addresses after generating the line table. Debug information in
the wild is not sorted and the rest of the implementation requires this
data to be sorted.

Handle DW.LNE.end_sequence correctly. When I originally wrote this code,
I misunderstood what this opcode was supposed to do. Now I understand
that it marks the *end* of an address range, meaning the current address
does *not* map to the current line information.

This fixes source location information for a big chunk of ReleaseSafe
code.
2024-08-13 18:04:23 -07:00
Andrew Kelley
a9e7fb0e01 avoid a branch in resolveAddressesDwarf 2024-08-13 15:02:53 -07:00
Andrew Kelley
b5398180d6 std.debug.Coverage.resolveAddressesDwarf: fix broken logic
The implementation assumed that compilation units did not overlap, which
is not the case. The new implementation uses .debug_ranges to iterate
over the requested PCs.

This partially resolves #20990. The dump-cov tool is fixed but the same
fix needs to be applied to `std.Build.Fuzz.WebServer` (sorting the PC
list before passing it to be resolved by debug info).

I am observing LLVM emit multiple 8-bit counters for the same PC
addresses when enabling `-fsanitize-coverage=inline-8bit-counters`. This
seems like a bug in LLVM. I can't fathom why that would be desireable.
2024-08-13 15:02:53 -07:00
Alex Rønne Petersen
f1af9eb836
std.zig.system: Support qemu-xtensa in getExternalExecutor(). 2024-08-13 23:30:43 +02:00
Alex Rønne Petersen
8e75ade253
std.zig.system: Support qemu-mipsn32(el) for mips with n32 ABI in getExternalExecutor(). 2024-08-13 23:30:43 +02:00
Alex Rønne Petersen
0e4263893c
std.zig.system: Support qemu-sparc32plus for sparc32 with v9 in getExternalExecutor(). 2024-08-13 23:30:43 +02:00
YANG Xudong
76f062690c add getcontext 2024-08-13 10:11:17 -07:00
Alex Rønne Petersen
e725d1e226 std.Thread: Fix freeAndExit() syscall numbers for mips64.
These just seem to have been copy/pasted from mips32.
2024-08-13 00:56:35 -07:00
Alex Rønne Petersen
d0ae803a77 std.Thread: Fix freeAndExit() assembly for powerpc.
Wrong source/destination register order.
2024-08-13 00:56:14 -07:00
Alex Rønne Petersen
b00f586c3d
std.os.linux: Add clone() implementation for mips64. (#21038)
Only for n64; no handling for n32 yet.

Also remove pointless comment about o32 in mips64 code.
2024-08-12 16:09:52 -07:00
Alex Rønne Petersen
d6f9972594 all: Handle spirv in addition to spirv(32,64) where applicable.
Some of 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-12 16:08:28 -07:00
Alex Rønne Petersen
6d23850108 std.Thread: Explain apparently pointless mips instruction in freeAndExit().
https://git.musl-libc.org/cgit/musl/commit/?id=ce3688eca920aa77549323f84e21f33522397115
2024-08-12 16:07:46 -07:00
Andrew Kelley
f988cea825
Merge pull request #21019 from alexrp/target-os-cleanup
`std.Target`: Remove `minix` and `liteos`, rename `glsl450` to `opengl`, and some minor housekeeping
2024-08-12 16:06:57 -07:00
Alex Rønne Petersen
f7fb261efd std.os.linux.tls: Support sparc32. 2024-08-12 14:22:24 -07:00
Linus Groh
9ef16b36ce std.os.linux: Fix definition of tc_lflag_t on MIPS
Regressed in #21000.
2024-08-12 00:46:28 -07:00
Alex Rønne Petersen
7a41e2f40b std.zig.target: Add missing thumbeb triples. 2024-08-12 00:44:56 -07:00
Alex Rønne Petersen
8af4d65108
std.Target: Remove liteos OS tag.
It has not seen development in 4 years.

https://github.com/LiteOS/LiteOS/commits/master
2024-08-12 08:59:49 +02:00
Alex Rønne Petersen
e211dce6fc
std.Target: Remove minix OS tag.
It has not seen development in 6 years. RIP.

* https://github.com/Stichting-MINIX-Research-Foundation/minix/commits/master
* https://groups.google.com/g/minix3/c/nUG1NwxXXkg
2024-08-12 08:59:49 +02:00
Alex Rønne Petersen
4d4a023042
std.Target: Remove no longer relevant TODO about SPIR-V ABIs. 2024-08-12 08:59:49 +02:00
Alex Rønne Petersen
eb4539a27d
std.Target: Rename glsl450 Arch tag to opengl.
Versions can simply use the normal version range mechanism, or alternatively an
Abi tag if that makes more sense. For now, we only care about 4.5 anyway.
2024-08-12 08:59:47 +02:00
Alex Rønne Petersen
15a3ee1979
std.Target: Remove supportsNewStackCall().
This is literally just isWasm() and has no uses in the repository.
2024-08-12 08:57:10 +02:00
Alex Rønne Petersen
0bb9db3998
std.Target: Add comments explaining the baseline CPUs for hexagon/s390x. 2024-08-12 08:57:10 +02:00
Alex Rønne Petersen
7f7008b5b2
std.Target: Sort Os tags in a hopefully more sensible way. 2024-08-12 08:57:10 +02:00
Alex Rønne Petersen
60bf1a6543
std.Target: Sort Arch tags in a hopefully more sensible way. 2024-08-12 08:57:10 +02:00
Alex Rønne Petersen
25096ed893 std.Target: Some corrections and additions to stackAlignment().
Sourced from LLVM and GCC backends and ABI documents.
2024-08-11 20:28:29 -07:00
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
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
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
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
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
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
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
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
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
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
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