Commit graph

519 commits

Author SHA1 Message Date
dweiller
94e0c85b6b update dump-cov for alignment and writergate changes 2025-07-15 23:57:56 +02:00
Ali Cheraghi
f43f89a705 spirv: snake-case the spec 2025-07-14 15:16:17 +02:00
Linus Groh
eb37552536 Remove numerous things deprecated during the 0.14 release cycle
Basically everything that has a direct replacement or no uses left.

Notable omissions:

- std.ArrayHashMap: Too much fallout, needs a separate cleanup.
- std.debug.runtime_safety: Too much fallout.
- std.heap.GeneralPurposeAllocator: Lots of references to it remain, not
  a simple find and replace as "debug allocator" is not equivalent to
  "general purpose allocator".
- std.io.Reader: Is being reworked at the moment.
- std.unicode.utf8Decode(): No replacement, needs a new API first.
- Manifest backwards compat options: Removal would break test data used
  by TestFetchBuilder.
- panic handler needs to be a namespace: Many tests still rely on it
  being a function, needs a separate cleanup.
2025-07-11 08:17:43 +02:00
Andrew Kelley
b0395531d3 update autodocs and langref to new API 2025-07-07 22:43:53 -07:00
Andrew Kelley
d8e26275f2 update standalone and incremental tests to new API 2025-07-07 22:43:53 -07:00
Andrew Kelley
34f64432b0 remove usingnamespace from the language
closes #20663
2025-07-07 13:39:48 -07:00
Andrew Kelley
40d11cc25a remove async and await keywords
Also remove `@frameSize`, closing #3654.

While the other machinery might remain depending on #23446, it is
settled that there will not be `async`/ `await` keywords in the
language.
2025-07-07 13:39:16 -07:00
Ali Cheraghi
1df79ab895 remove spirv cpu arch 2025-06-23 06:03:03 +02:00
Jacob Young
917640810e Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it
consistently shows up in profiles of the compiler.
2025-06-19 11:45:06 -04:00
mlugg
b5f73f8a7b
compiler: rework emit paths and cache modes
Previously, various doc comments heavily disagreed with the
implementation on both what lives where on the filesystem at what time,
and how that was represented in code. Notably, the combination of emit
paths outside the cache and `disable_lld_caching` created a kind of
ad-hoc "cache disable" mechanism -- which didn't actually *work* very
well, 'most everything still ended up in this cache. There was also a
long-standing issue where building using the LLVM backend would put a
random object file in your cwd.

This commit reworks how emit paths are specified in
`Compilation.CreateOptions`, how they are represented internally, and
how the cache usage is specified.

There are now 3 options for `Compilation.CacheMode`:
* `.none`: do not use the cache. The paths we have to emit to are
  relative to the compiler cwd (they're either user-specified, or
  defaults inferred from the root name). If we create any temporary
  files (e.g. the ZCU object when using the LLVM backend) they are
  emitted to a directory in `local_cache/tmp/`, which is deleted once
  the update finishes.
* `.whole`: cache the compilation based on all inputs, including file
  contents. All emit paths are computed by the compiler (and will be
  stored as relative to the local cache directory); it is a CLI error to
  specify an explicit emit path. Artifacts (including temporary files)
  are written to a directory under `local_cache/tmp/`, which is later
  renamed to an appropriate `local_cache/o/`. The caller (who is using
  `--listen`; e.g. the build system) learns the name of this directory,
  and can get the artifacts from it.
* `.incremental`: similar to `.whole`, but Zig source file contents, and
  anything else which incremental compilation can handle changes for, is
  not included in the cache manifest. We don't need to do the dance
  where the output directory is initially in `tmp/`, because our digest
  is computed entirely from CLI inputs.

To be clear, the difference between `CacheMode.whole` and
`CacheMode.incremental` is unchanged. `CacheMode.none` is new
(previously it was sort of poorly imitated with `CacheMode.whole`). The
defined behavior for temporary/intermediate files is new.

`.none` is used for direct CLI invocations like `zig build-exe foo.zig`.
The other cache modes are reserved for `--listen`, and the cache mode in
use is currently just based on the presence of the `-fincremental` flag.

There are two cases in which `CacheMode.whole` is used despite there
being no `--listen` flag: `zig test` and `zig run`. Unless an explicit
`-femit-bin=xxx` argument is passed on the CLI, these subcommands will
use `CacheMode.whole`, so that they can put the output somewhere without
polluting the cwd (plus, caching is potentially more useful for direct
usage of these subcommands).

Users of `--listen` (such as the build system) can now use
`std.zig.EmitArtifact.cacheName` to find out what an output will be
named. This avoids having to synchronize logic between the compiler and
all users of `--listen`.
2025-06-12 13:55:40 +01:00
Andrew Kelley
a59d18779f langref: global assembly test depends on llvm
see #24046
2025-06-06 23:42:14 -07:00
Alex Rønne Petersen
9d534790eb std.Target: Introduce Cpu convenience functions for feature tests.
Before:

* std.Target.arm.featureSetHas(target.cpu.features, .has_v7)
* std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov })
* std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory })

After:

* target.cpu.has(.arm, .has_v7)
* target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov })
* target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-06-05 06:12:00 +02:00
Alex Rønne Petersen
3b2bef8a95
Merge pull request #24025 from alexrp/glibc-deduplication
`libc`: Merge header directories for glibc and NetBSD libc where applicable
2025-06-04 05:14:21 +02:00
Jacob Young
b483defc5a Legalize: implement scalarization of binary operations 2025-05-31 18:54:28 -04:00
Alex Rønne Petersen
dc760492a4
process_headers: Merge header directories for some targets.
These are almost entirely identical, with these exceptions:

* lib/libc/include/csky-linux-{gnueabi,gnueabihf}
    * gnu/{lib-names,stubs}.h will need manual patching for float ABI.
* lib/libc/include/{powerpc-linux-{gnueabi,gnueabihf},{powerpc64,powerpc64le}-linux-gnu}
    * bits/long-double.h will need manual patching for long double ABI.
2025-05-29 23:38:28 +02:00
Ali Cheraghi
4bf1e4d198 target: auto-generated spirv features 2025-05-21 15:26:18 +03:30
Alex Rønne Petersen
d000e53b29
Merge pull request #23923 from alexrp/compiler-rt-symbols
Use hidden visibility in compiler-rt and libzigc except when testing
2025-05-20 07:48:35 +02:00
Alex Rønne Petersen
b27c5fbbde
Merge pull request #23913 from alexrp/netbsd-libc
Support dynamically-linked NetBSD libc when cross-compiling
2025-05-20 07:46:08 +02:00
Alex Rønne Petersen
90fb2d9754
compiler-rt: Fix some exports to respect the common linkage and visibility. 2025-05-19 00:22:03 +02:00
mlugg
a0792e743f
incr-check: normalize path separators in file names in errors 2025-05-18 17:10:04 +01:00
mlugg
ed7335ce57
incr-check: support basic modules
Allow specifying modules which the root module depends on. More complex
graphs cannot currently be specified.
2025-05-18 17:10:04 +01:00
Alex Rønne Petersen
90911b39d5
update_netbsd_libc: Add tool for updating NetBSD libc startup code. 2025-05-17 04:41:27 +02:00
Alex Rønne Petersen
4371e695ef
process_headers: Add NetBSD libc support. 2025-05-17 04:41:27 +02:00
mlugg
8e72a25285 doctest: handle relative paths correctly
Evaluate all child processes in the temporary directory, and use
`std.fs.path.relative` to make every other path relative to that child
cwd instead of our cwd.

Resolves: #22119
2025-05-16 22:42:29 +01:00
Alex Rønne Petersen
bc3c50c21e
Merge pull request #23700 from sorairolake/rename-trims
chore(std.mem): Rename `trimLeft` and `trimRight` to `trimStart` and `trimEnd`
2025-05-12 17:11:52 +02:00
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