Commit Graph

544 Commits

Author SHA1 Message Date
Alex Rønne Petersen 68cd00497f update_freebsd_libc: Add tool for updating FreeBSD libc startup code. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen df719f249d process_headers: Add FreeBSD libc support. 2025-05-10 12:19:26 +02:00
Shun Sakai 5fc4448e45 chore(std.mem): Rename trimLeft and trimRight
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`.
`trimLeft` and `trimRight` functions remain as deprecated aliases for
these new names.
2025-04-27 18:03:59 +09:00
Alex Rønne Petersen b3537d0f4a compiler: Allow configuring UBSan mode at the module level.
* Accept -fsanitize-c=trap|full in addition to the existing form.
* Accept -f(no-)sanitize-trap=undefined in zig cc.
* Change type of std.Build.Module.sanitize_c to std.zig.SanitizeC.
* Add some missing Compilation.Config fields to the cache.

Closes #23216.
2025-04-26 22:54:34 +02:00
Alex Rønne Petersen 99a79f98ec Merge pull request #23572 from alexrp/zig-cc-static-dynamic 2025-04-26 15:05:18 +02:00
mlugg 8c9c24e09b compiler: integrate @compileLog with incremental compilation
Compile log output is now separated based on the `AnalUnit` which
perfomred the `@compileLog` call, so that we can omit the output for
unreferenced ("dead") units. The units are also sorted when collecting
the `ErrorBundle`, so that compile logs are always printed in a
consistent order, like compile errors are. This is important not only
for incremental compilation, but also for parallel analysis.

Resolves: #23609
2025-04-20 18:11:53 +01:00
Alex Rønne Petersen 6a8228603c zig cc: Respect Clang's -static and -dynamic flags.
Before:

    ❯ zig cc main.c -target x86_64-linux-musl && musl-ldd ./a.out
    musl-ldd: ./a.out: Not a valid dynamic program
    ❯ zig cc main.c -target x86_64-linux-musl -static && musl-ldd ./a.out
    musl-ldd: ./a.out: Not a valid dynamic program
    ❯ zig cc main.c -target x86_64-linux-musl -dynamic && musl-ldd ./a.out
    musl-ldd: ./a.out: Not a valid dynamic program

After:

    ❯ zig cc main.c -target x86_64-linux-musl && musl-ldd ./a.out
    musl-ldd: ./a.out: Not a valid dynamic program
    ❯ zig cc main.c -target x86_64-linux-musl -static && musl-ldd ./a.out
    musl-ldd: ./a.out: Not a valid dynamic program
    ❯ zig cc main.c -target x86_64-linux-musl -dynamic && musl-ldd ./a.out
            /lib/ld-musl-x86_64.so.1 (0x72c10019e000)
            libc.so => /lib/ld-musl-x86_64.so.1 (0x72c10019e000)

Closes #11909.
2025-04-14 22:10:08 +02:00
Alex Rønne Petersen 30200edc1e gen_stubs: Add hexagon-linux-musl support. 2025-04-11 02:28:35 +02:00
Alex Rønne Petersen cd58615c17 process_headers: Add hexagon-linux-musl support. 2025-04-11 02:28:35 +02:00
Alex Rønne Petersen c3e88a21fb compiler: Recognize -fno-sanitize=<...> in addition to -fsanitize=<...>. 2025-04-04 06:08:10 +02:00
Alex Rønne Petersen 4de368a1b6 std.Target: Update CPU models/features for LLVM 20.
Closes #21818.
2025-04-04 06:08:09 +02:00
Linus Groh 79460d4a3e Remove uses of deprecated callconv aliases 2025-03-05 03:01:43 +00:00
David Rubin 35b9db3b15 correct some bugs 2025-02-25 11:22:33 -08:00
Alex Rønne Petersen 2404e7f5d6 update_mingw: Add update logic for winpthreads files.
Also rename a few constants for clarity.
2025-02-24 11:58:18 +01:00
Andrew Kelley eb3c7f5706 zig build fmt 2025-02-22 17:09:20 -08:00
Ali Cheraghi d5e1cb3ea2 spirv: ziggify and remove unknown spirv features
`OpCapability` and `OpExtension` now can also be emitted from inline assembly
2025-02-18 18:08:47 +03:30
Ali Cheraghi 1b0c7f51ef target: update spirv features 2025-02-18 18:07:48 +03:30
Alex Rønne Petersen 2fe32ef847 std.Target: Remove Cpu.Arch.propeller2 and use a CPU feature instead. 2025-02-17 19:17:55 +01:00
Alex Rønne Petersen 5248f0a909 update_cpu_features: Handle targets that don't have LLVM data. 2025-02-17 19:17:55 +01:00
Meghan Denny 9142482372 std.ArrayList: popOrNull() -> pop() [v2] (#22720) 2025-02-10 04:21:31 +00:00
mlugg fcf8d5ada2 incr-check: check compile errors against expected
Also modifies all incremental cases using `#expect_error` to include the
errors and notes which are expected.
2025-01-25 09:32:40 +00:00
mlugg 7ef345f342 incr-check: deal with Windows stupidity
The real problem here is that Git for Windows has horrendous defaults
which convert LF to CRLF. However, rather than changing this
configuration on the CI runners, it's worth supporting inexplicable CRLF
in these files so that anyone else cloning Zig on Windows doesn't get
unexpected test failures.
2025-01-25 08:57:20 +00:00
mlugg f47b8de2ad incremental: handle @embedFile
Uses of `@embedFile` register dependencies on the corresponding
`Zcu.EmbedFile`. At the start of every update, we iterate all embedded
files and update them if necessary, and invalidate the dependencies if
they changed.

In order to properly integrate with the lazy analysis model, failed
embed files are now reported by the `AnalUnit` which actually used
`@embedFile`; the filesystem error is stored in the `Zcu.EmbedFile`.

An incremental test is added covering incremental updates to embedded
files, and I have verified locally that dependency invalidation is
working correctly.
2025-01-25 06:07:08 +00:00
Alex Rønne Petersen ea1502974d wasm: Add a nontrapping_bulk_memory_len0 feature.
This will mainly be used when targeting our wasm2c implementation which has no
problem with zero-length bulk memory operations, as a non-standard extension.
2025-01-22 20:56:28 +01:00
Alex Rønne Petersen 280ced66eb std.Target: Define and use lime1 as the baseline CPU model for WebAssembly.
See: https://github.com/WebAssembly/tool-conventions/pull/235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of #21818.
2025-01-22 03:01:05 +01:00
Jacob Young ac1a975f9b x86_64: implement clz and not 2025-01-16 20:42:08 -05:00
Jacob Young af1191ea8b x86_64: rewrite 2025-01-16 20:42:07 -05:00
Jacob Young dde3116e50 Dwarf: implement new incremental line number update API 2025-01-05 02:20:56 +00:00
Andrew Kelley af5e731729 Merge pull request #22280 from jacobly0/stage2-pp
lldb: add more stage2 pretty printers
2024-12-23 15:55:03 -05:00
Alex Rønne Petersen d41052b6dc Merge pull request #22293 from alexrp/macos-header-tool
Some cleanups and fixes for `fetch_them_macos_headers.zig`
2024-12-23 04:44:19 +01:00
Alex Rønne Petersen 1cb798256f fetch_them_macos_headers: Simplify, remove unused code. 2024-12-23 00:09:52 +01:00
Alex Rønne Petersen 1f5315e774 fetch_them_macos_headers: Fix some file names. 2024-12-22 23:39:45 +01:00
Alex Rønne Petersen 9dea0459c1 fetch_them_macos_headers: Remove a TODO we're probably never addressing. 2024-12-22 23:39:45 +01:00
Jacob Young 5776d8f270 lldb: add pretty printer for cau and nav indices 2024-12-20 22:51:20 -05:00
Jacob Young 5c76e08f49 lldb: add pretty printer for intern pool indices 2024-12-20 22:51:20 -05:00
Jacob Young 06206479a9 Dwarf: remove redundant debug info 2024-12-19 17:10:03 -05:00
Jacob Young 5af7404655 lldb: add pretty printer for InternPool.Local.List 2024-12-16 15:11:23 -05:00
Alex Rønne Petersen ee47094a33 Move fetch-them-macos-headers tools to ziglang/zig. 2024-12-14 23:45:18 +01:00
Alex Rønne Petersen ece7bd4b1c update_mingw: Update blacklist to dcd7fefc703fb4b12187235386900d34cc13fdc5. 2024-12-13 03:59:08 +01:00
Alex Rønne Petersen ca3614594a update_mingw: Remove some leftover code.
See 4a2b23c2be.
2024-12-13 03:59:07 +01:00
Alex Rønne Petersen 130f7c2ed8 Merge pull request #22035 from alexrp/unwind-fixes
Better unwind table support + unwind protection in `_start()` and `clone()`
2024-12-13 03:09:24 +01:00
Alex Rønne Petersen 8af82621d7 compiler: Improve the handling of unwind table levels.
The goal here is to support both levels of unwind tables (sync and async) in
zig cc and zig build. Previously, the LLVM backend always used async tables
while zig cc was partially influenced by whatever was Clang's default.
2024-12-11 00:10:15 +01:00
Alex Rønne Petersen 9293e040ec process_headers: Use glibcRuntimeTriple() and muslArchName() from std.zig.target. 2024-11-28 18:49:16 +01:00
David Rubin f36f7d54a7 refactor update_cpu_features.zig
Most of this commit is whitespace changes, moving to use RLS
for assigning the `CpuModel`
2024-11-25 01:11:15 -08:00
David Rubin 9e17e097e5 make crc32 a featdep of sse4.2
To my knowledge there isn't an implementation of `sse4.2` that doesn't have `crc32`.
The Clang driver also sets `crc32` to be implicitly enabled when an explicit `-crc32`
wasn't provided. This matches that behaviour.

We need this behaviour to compile libraries like `rocksdb` which currently guard against
`crc32` intrinsics by checking for `sse4.2`.
2024-11-25 01:11:15 -08:00
David Rubin bc3ed51b7f cleanup update_cpu_feature.zig
* Cleanup the argument handling logic to allow for optional arguments.
* Add a filter for which `llvm_target` to process.
* Switch to using a threadpool, needed for skipping llvm targets cleanly
  and better distributes the work.
* Remove a seemingly useless piece of logic. I re-ran the script and it gave identical outputs.
2024-11-25 01:11:06 -08:00
Alex Rønne Petersen fc8a4c445d gen_stubs: Require less manual intervention and produce better output.
The tool will now skip over undefined symbols. These can only occur as a result
of building musl without compiler-rt, i.e. -rtlib=none. Thanks to this, it's no
longer necessary to patch Zig's compiler-rt, nor is it necessary to maintain a
symbol blacklist.

See the updated instructions here: https://github.com/ziglang/zig/wiki/Updating-libc#updating-the-libcs-file

Additionally, the tool now produces slightly more compact output by recognizing
symbols that are defined for a single arch, for a family of arches, or only for
arches using 32-bit or 64-bit time as their primary ABI.

Finally, the tool now supports all architectures that we can emit code for, with
the single exception of x86_64-linux-muslx32. (x32 currently fails with a ton of
relocation errors, leading me to believe that it might be an LLVM or LLD bug.)
2024-11-23 03:10:58 +01:00
Alex Rønne Petersen 3054486d1d Merge pull request #21843 from alexrp/callconv-followup
Some follow-up work for #21697
2024-11-03 14:27:09 +01:00
Alex Rønne Petersen baf60426d4 std.Target: Rename amdgpu module to amdgcn.
This was an inconsistency left over from c825b567b2.
2024-11-02 10:44:14 +01:00
Alex Rønne Petersen d61e4ef8b0 generate_linux_syscalls: Generate syscalls for x32.
Also update the syscalls file based on Linux 6.10. No diffs other than x32.
2024-11-02 10:42:53 +01:00