Commit Graph

15075 Commits

Author SHA1 Message Date
Alex Rønne Petersen 9536d65230 main: Don't pass --seed for zig run. 2024-07-25 19:30:13 -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 3256df2ff8 llvm: always include instrumentation function attributes 2024-07-25 18:52:20 -07:00
Alex Rønne Petersen 1c35e73b61 llvm: Don't emit safety memset() for stores of undef in Debug with safety off.
Before, this code:

    @setRuntimeSafety(false);
    var arr: [38]elf.Addr = undefined;

would emit a call to memset() in the output code in Debug mode, while in all the
release modes, LLVM optimized the memset() out as expected. Emitting the call in
Debug mode is problematic in some contexts, e.g. in std.os.linux.start_pie where
we are not yet ready to correctly perform calls because relocations haven't been
applied yet, or in the early stages of a dynamic linker, etc.
2024-07-25 18:04:50 -07:00
Andrew Kelley b22357b88b Merge pull request #20783 from ziglang/cache-fix
build compiler_rt and fuzzer in parallel; fix false positive cache hits
2024-07-25 07:12:39 -07:00
Jacob Young 18685e928d main: avoid sending an empty file system inputs message
When all compiler inputs are invalid paths, there could be errors yet no
valid file system inputs.

Closes #20713
2024-07-25 03:59:30 -07:00
Andrew Kelley 94f4f9c4ef add sub-compilation cache inputs to parents in whole mode
closes #20782
2024-07-24 19:40:54 -07:00
Andrew Kelley 4135cc9d0b CLI: better error message when build runner cannot be spawned 2024-07-24 19:40:38 -07:00
Andrew Kelley 3844b91db7 Compilation: build compiler_rt and fuzzer in parallel
With the rest of the pipeline.

Tracked by #9188
2024-07-24 18:24:00 -07:00
Jacob Young f4f5b2bc41 llvm: force TargetOptions.UseInitArray to true
The `TargetOptions` default constructor initializes all `bool`s to
`false`, yet clang defaults to setting this option to `true`.  Since
recent glibc versions on linux do not appear to support this being set
to `false`, just changing the default for now unless a use case for
making it configurable is found.
2024-07-24 15:24:17 -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
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 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
Andrew Kelley 33d4742456 LLVM: more fine-grained sancov emit options
Exposes sanitizer coverage flags to the target machine emit function.
Makes it easier to change sancov options without rebuilding the C++
files.

This also enables PCTable = true for sancov which is needed by AFL, and
adds the corresponding Clang flag.
2024-07-23 16:04:58 -07:00
Jakub Konka 7aaebd1774 Merge pull request #20751 from Rexicon226/riscv-eflags
elf: add riscv eflag collisions
2024-07-23 22:29:57 +02:00
Pavel Verigo ba8522e6c7 stage2-wasm: fix bigint div and trunc 2024-07-23 21:17:04 +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
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
Pavel Verigo d71312d104 stage2-wasm: mul_sat 32 bits <=, i64, i128 2024-07-23 17:06:18 +02:00
Jakub Konka f1af53f68e macho: use pread syscall when loading tapi file
This avoids mixing preads with reads which do not mix well especially
on Windows.
2024-07-23 10:33:02 +02:00
David Rubin 782a9d16c7 elf: add riscv eflag collisions 2024-07-22 18:01:26 -07:00
Andrew Kelley 61ad1be6bd fix macho linker integration with libfuzzer 2024-07-22 14:26:17 -07:00
Andrew Kelley 1cb994899d Compilation: fix regression in addCCArgs
`-fno-sanitize=function` must come after `-fsanitize=undefined` or it
has no effect.
2024-07-22 14:26:17 -07:00
Andrew Kelley 105b91d30f ZigLLVMTargetMachineEmitToFile: make sancov enable the options 2024-07-22 14:26:17 -07: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 b9225aea78 add libfuzzer to linking 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
Jakub Konka 7c37c55161 macho: fix 32bit compilation issues 2024-07-22 17:32:43 +02:00
David Rubin fcff82feb2 dev: add riscv64-linux support 2024-07-22 05:50:48 -07:00
Jakub Konka 8541119e9b macho: handle empty string in ZigObject.getString 2024-07-22 13:35:55 +02:00
Jakub Konka 96fa29b90f macho: write sections in parallel in -r mode 2024-07-22 12:06:02 +02:00
Jakub Konka 7e5a2673ac macho: calc section sizes in parallel in -r mode 2024-07-22 12:06:02 +02:00
Jakub Konka 06a0da3e8a macho: cache string len 2024-07-22 12:06:02 +02:00
Jakub Konka 79fefec599 add more tracy hooks 2024-07-22 12:06:02 +02:00
Jakub Konka 2b84592858 macho: run more things in parallel 2024-07-22 12:06:02 +02:00
Jakub Konka 5d9fd5bcde macho: remove stale code 2024-07-22 12:06:02 +02:00
Jakub Konka 617f89f082 macho: parse input files in parallel 2024-07-22 12:06:02 +02:00
Jakub Konka cba3389d90 macho: redo input file parsing in prep for multithreading 2024-07-22 12:05:56 +02:00
Andrew Kelley 179a6e61e8 Merge pull request #20708 from alexrp/target-cleanup-2
`std.Target`: Remove more dead architecture tags.
2024-07-21 19:24:04 -07:00
Bogdan Romanyuk 42d9017feb Sema: fix OOB access in coerceTupleToStruct (#19620)
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2024-07-21 23:56:04 +00: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: https://github.com/llvm/llvm-project/commit/1b5767f72b5a037ca8f1802d737de97f8d92263d
See: https://github.com/llvm/llvm-project/commit/84a7564b28360843ee9afec5d3823c89623eb6a5
See: https://github.com/llvm/llvm-project/commit/8cfe9d8f2ad3a52ba7fd5841d3939aa810536e16
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
Alex Rønne Petersen 2cced8903e std.posix: Consider invalid signal numbers to sigaction() to be programmer error.
The set of signals that cannot have their action changed is documented in POSIX,
and any additional, non-standard signals are documented by the specific OS. I
see no valid reason why EINVAL should be considered an unpredictable error here.
2024-07-21 22:38:09 +02:00
Andrew Kelley f303c3943f Revert "Merge pull request #20380 from tau-dev/master"
This reverts commit 397be0c9cc, reversing
changes made to 18d412ab2f.

Caused test failures in master branch.
2024-07-21 02:44:58 -07:00