140 Commits

Author SHA1 Message Date
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
Fri3dNstuff
a655c15c40
std.sort: Remove key argument from binary-search-like functions (#20927)
closes #20110
2024-08-04 22:02:15 +00: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
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
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
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
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
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
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
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
David Rubin
1a7d89a84d
riscv: clean up and unify encoding logic 2024-07-26 04:19:13 -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
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
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
33c7984183 add std.testing.random_seed
closes #17609
2024-07-23 11:43:12 -07:00
Alex Rønne Petersen
be9841335e
std.Target.Os: Rename lv2 to ps3.
It is very non-obvious that this is what lv2 refers to, and we already use ps4
and ps5 to refer to the later models, so let's just be consistent.
2024-07-21 22:38:30 +02:00
Alex Rønne Petersen
db8bc4770c
std.Target: Remove the tce/tcele arch tags.
There is no obvious reason why this would be relevant for Zig to target. I
rather question the value of LLVM even having target triple code for this, too.

See: https://blog.llvm.org/2010/06/tce-project-co-design-of-application.html
See: https://github.com/cpc/llvmtce
2024-07-21 22:38:30 +02:00
Alex Rønne Petersen
21cc5a2044
std.Target: Remove the shave arch tag.
This was added as an architecture to LLVM's target triple parser and the Clang
driver in 2015. No backend ever materialized as far as I can see (same for GCC).
In 2016, other code referring to it started using "Myriad" instead. Ultimately,
all code related to it that isn't in the target triple parser was removed. It
seems to be a real product, just... literally no one seems to know anything
about the ISA. I figure after almost a decade with no public ISA documentation
to speak of, and no LLVM backend to reference, it's probably safe to assume that
we're not going to learn much about this ISA, making it useless for Zig.

See: 1b5767f72b
See: 84a7564b28
See: 8cfe9d8f2a
2024-07-21 22:38:30 +02:00
Alex Rønne Petersen
f1e0c35db4
std.Target: Remove hsail/hsail64 arch tags.
This seems to just be dead.

See: https://github.com/search?q=repo%3Allvm%2Fllvm-project%20hsail&type=code
See: https://github.com/HSAFoundation/HSAIL-Tools/commits/master
2024-07-21 22:38:30 +02:00
Alex Rønne Petersen
67a052df81
std.Target: Remove amdil/amdil64 arch tags.
This is really obscure and no one is 100% sure what it is. It seems to be old
and unused. My suspicion is that it's just an old term for "AMDGPU" before it
was upstreamed to LLVM.

See: https://github.com/search?q=repo%3Allvm%2Fllvm-project+amdil&type=code
2024-07-21 22:38:30 +02:00
Alex Rønne Petersen
c825b567b2
std.Target: Remove the r600 arch tag.
These are quite old GPUs, and it is unlikely that Zig will ever be able to
target them.

See: https://en.wikipedia.org/wiki/Radeon_HD_2000_series
2024-07-21 22:38:30 +02:00
Alex Rønne Petersen
9848623e62
std.Target: Remove the renderscript32/renderscript64 arch tags.
It's dead: https://developer.android.com/guide/topics/renderscript/migrate
2024-07-21 22:38:30 +02:00
Will Lillis
7e76818132
fix(fmt): pointer type syntax to index (take 2) (#20336)
* Change main token for many-item and c style pointers from asterisk to l brace, update main token in c translation
2024-07-21 01:55:52 -07:00
Andrew Kelley
5f78e28899 test runner: disable stderr printing for riscv64
Make it a little easier for contributors to see CI failures in the logs.
2024-07-20 19:16:00 -07:00
Alex Rønne Petersen
5e82e90dbf
std.Target: Remove coreclr ABI specifier.
This was added to LLVM in 2015 for the LLILC project, which was discontinued in
~2018, and subsequently archived in 2022.

933b58d00f
2024-07-20 05:08:16 +02:00
Alex Rønne Petersen
af8205e25e
std.Target: Remove nacl OS specifier and le32/le64 arch specifiers.
Native Client is dead.

https://developer.chrome.com/docs/native-client
2024-07-20 05:08:16 +02:00