345 Commits

Author SHA1 Message Date
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
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
Evan Haas
679ad36fa0
generate_c_size_and_align_checks: add __alignof check 2024-08-06 07:06:57 -07:00
Evan Haas
b2dd0a669a
generate_c_size_and_align_checks: print failed condition in _Static_assert 2024-08-06 07:03:00 -07:00
Evan Haas
4bdf04654e
tools: Add tool for checking size and alignment of C types
Prints _Static_asserts for the size and alignment of all the basic built-in C
types. The output can be run through a compiler for the specified target to
verify that Zig's values are the same as those used by a C compiler for the
target.
2024-08-05 12:56:40 -07:00
ippsav
724804a4e0
Rewrite generate_linux_syscalls.zig (#20895)
refactors the syscall generation tool aiming to reduce code duplication for both the table based arches and the ones generated using a preprocessor.
2024-08-05 10:43:47 -07:00
Andrew Kelley
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
4ba9a6f44c
process_headers: Add sparcv9-linux-gnu for glibc.
This is 32-bit SPARC targeting the v8 ABI but v9 CPU.
2024-08-05 12:19:22 +02:00
YANG Xudong
ea847535fc Add loongarch 64 to gen_stubs.zig. 2024-08-04 12:04:39 -07:00
Alex Rønne Petersen
f29967f46c
generate_linux_syscalls: Skip some reserved syscalls on mips and xtensa. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
264b830964
generate_linux_syscalls: Add generation code for xtensa. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
09914868ea
generate_linux_syscalls: Add generation code for m68k. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
6e7d619dc3
generate_linux_syscalls: Add generation code for s390x. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
4028762a9a
generate_linux_syscalls: Add generation code for mips n32. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
2598aa574b
generate_linux_syscalls: Add generation code for sparc32. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
fb249cf3e1
generate_linux_syscalls: Add generation code for hexagon. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
dd78ee43e4
generate_linux_syscalls: Add generation code for csky. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
2e910f23f9
generate_linux_syscalls: Add generation code for arc. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
94a1fd6e8e
generate_linux_syscalls: Name mips types according to ABI. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
1f9dcff747
generate_linux_syscalls: Don't expose the helper constants on mips/mips64. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
2747fca226
generate_linux_syscalls: Simplify include paths.
Using the tooling includes means we won't run into the asm/bitsperlong.h issue.
2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
c9664cb657
generate_linux_syscalls: Bring loongarch64 generation code in line with other newer ports. 2024-07-30 01:32:47 +02:00
Alex Rønne Petersen
7e74276661
generate_linux_syscalls: Rework generation strategy for newer kernel ports.
If we're going to abuse the preprocessor, we may as well go all the way and have
it generate a convenient format for us. This achieves two things:

1. We no longer need hacks for the arch-specific syscalls.
2. We now generate the correct syscall names for 32-bit platforms.

The latter is because we now resolve __SC_3264, etc.
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
f494a47ca5
generate_linux_syscalls: Add some missing include paths for riscv. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
290609eff5
generate_linux_syscalls: Add riscv32 support. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
0460248900
generate_linux_syscalls: Handle riscv_hwprobe. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
e0b9ebf322
gen_stubs: Add riscv32 handling in a few more places. 2024-07-29 09:50:41 +02: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
645ad1ef72 incr-check: support running the generated binary 2024-07-20 01:06:29 -07:00
Andrew Kelley
9f112ce868 incr-test: running an update 2024-07-20 01:06:29 -07:00
Andrew Kelley
ea2c45227a init incremental compilation check tool 2024-07-20 01:06:29 -07:00
Andrew Kelley
727f1fa743 update update_cpu_features tool to latest std.Progress API
closes #20261
2024-06-11 15:24:57 -07:00
Andrew Kelley
c09f5f3795 glibc: add riscv32 and loongarch64 2024-06-05 22:43:53 -07:00
YANG Xudong
87150468fc generate loongarch64 Linux syscalls 2024-06-05 18:54:14 -04:00
Andrew Kelley
46b2f67905 update musl libc.S to v1.2.5
adds loongarch64 and riscv32
2024-06-04 22:37:28 -07:00
Andrew Kelley
85a46ee520 update musl headers to v1.2.5
adds loongarch64 and riscv32
2024-06-04 16:54:11 -07:00
Carl Åstholm
d74180c373 Replace YES_COLOR with CLICOLOR_FORCE
Instead of introducing YES_COLOR, a completely new standard, into the mix
it might make more sense to instead tag along with the CLICOLOR_FORCE env var,
which dates back to at least 2000 with FreeBSD 4.1.1 and which is
supported by tools like CMake.

<https://bixense.com/clicolors/>
2024-06-02 17:35:34 -04:00
Andrew Kelley
3b77f1ed7e rename zig-cache to .zig-cache
closes #20077
2024-05-29 10:20:15 -07:00
Andrew Kelley
f47824f24d std: restructure child process namespace 2024-05-26 09:31:55 -07:00
Andrew Kelley
21f1e76efe zig cc: update clang CLI data to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:28 -07:00
Andrew Kelley
109ec72924 update CPU features to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:28 -07:00
Ryan Liptak
b86c4bde64 Rename Dir.writeFile2 -> Dir.writeFile and update all callsites
writeFile was deprecated in favor of writeFile2 in f645022d16361865e24582d28f1e62312fbc73bb. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-05-03 13:29:22 -07:00
Marc Tiehuis
ef5618fcd5 std.hash.crc: simplify api
This removes the two original implementations in favour of the single
generic one based on the Algorithm type. Previously we had three, very
similar implementations which was somewhat confusing when knowing what
one should actually be used.

The previous polynomials all have equivalent variants available when
using the Algorithm type.
2024-04-28 21:12:01 +12:00
Andrew Kelley
1b90888f57 migrate langref documentation generation to the build system 2024-04-25 00:09:24 -07:00
Travis Staloch
8af59d1f98 ComptimeStringMap: return a regular struct and optimize
this patch renames ComptimeStringMap to StaticStringMap, makes it
accept only a single type parameter, and return a known struct type
instead of an anonymous struct.  initial motivation for these changes
was to reduce the 'very long type names' issue described here
https://github.com/ziglang/zig/pull/19682.

this breaks the previous API.  users will now need to write:
`const map = std.StaticStringMap(T).initComptime(kvs_list);`

* move `kvs_list` param from type param to an `initComptime()` param
* new public methods
  * `keys()`, `values()` helpers
  * `init(allocator)`, `deinit(allocator)` for runtime data
  * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure
     these belong but have left in for now incase they are deemed useful
* performance notes:
  * i posted some benchmarking results here:
    https://github.com/travisstaloch/comptime-string-map-revised/issues/1
  * i noticed a speedup reducing the size of the struct from 48 to 32
    bytes and thus use u32s instead of usize for all length fields
  * i noticed speedup storing KVs as a struct of arrays
  * latest benchmark shows these wall_time improvements for
    debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full
    output in link above.
2024-04-22 15:31:41 -07:00
Brandon Black
271d896446 std.hash.crc: get rid of usingnamespace
This flips things around such that std/hash/crc.zig is generated
by the catalog-based generation tool, and the real code that used
to be in that file is moved out to std/hash/crc/impl.zig.  The
generated tests are moved to std/hash/crc/test.zig.  By going this
route, we eliminate the need for usingnamespace without changing
anything for callers of these interfaces.  The Crc32 tests are
simply added to the fixed part of the generated output and
compactified a bit.

This was the second-to-last usage of usingnamespace left in std.
2024-04-11 14:42:04 -07:00
Carl Åstholm
4c393c7468 Update usages of fmtId/isValidId
`{}` for decls
`{p}` for enum fields
`{p_}` for struct fields and in contexts following a `.`

Elsewhere, `{p}` was used since it's equivalent to the old behavior.
2024-04-07 14:47:11 +02:00
Jacob Young
5a41704f7e cbe: rewrite CType
Closes #14904
2024-03-30 20:50:48 -04:00
Elaine Gibson
add74427b9 mingw: support -municode 2024-03-27 10:05:57 +00:00