Commit graph

11729 commits

Author SHA1 Message Date
Jonathan Marler
77c63ac360 doc: mention zig can't use URLs if their content changes
There's been some proliferation of dependency URLs that reference
mutable data such as links to git branches that can change.  This has
resulted in broken projects, i.e.

* 9eef9de94c/build.zig.zon
* 4b64353e9c

There's also disagreement about whether it's fine for URL's to point to
git branches, i.e.

https://github.com/Not-Nik/raylib-zig/pull/130

This updates the docs to mention that zig won't be able to use URLs if
their content changes.
2024-12-21 18:23:01 -05:00
Jacob Young
06206479a9 Dwarf: remove redundant debug info 2024-12-19 17:10:03 -05:00
mlugg
7408679234
compiler: disallow callconv etc from depending on function parameters
Resolves: #22261
2024-12-18 23:06:35 +00:00
Liam Swayne
f857bf72e2 Add branchHint to std.math.pow
NaN is an unlikely case, and a branchHint `.unlikely` could be appropriate.
2024-12-18 05:30:08 -05:00
Andrew Kelley
4ae101ca85
Merge pull request #22260 from jacobly0/dwarf-cleanup
Dwarf: cleanup
2024-12-18 00:41:44 -05:00
mlugg
98f63990d5
Zir: store declaration column number so Dwarf doesn't need to load the AST
Resolves: #21227
2024-12-17 22:52:30 +00:00
mlugg
afc77f0603
init template: expand slightly, migrate from deprecated std.Build APIs 2024-12-18 01:49:14 +05:00
mlugg
6168b8ef86
std.Build: add API to create Compile steps from existing module
This commit amends `std.Build.ExecutableOptions` etc to have a new
field, `root_module`, which allows artifacts to be created whose root
module is an existing `*Module` rather than a freshly constructed one.
This API can be far more versatile, allowing construction of complex
module graphs before creating any compile steps, and therefore also
allowing easy reuse of modules.

The fields which correspond to module options, such as
`root_source_file`, are all considered deprecated. They may not be
populated at the same time as the `root_module` field. In the next
release cycle, these deprecated fields will be removed, and the
`root_module` field made non-optional.
2024-12-18 01:48:54 +05:00
mlugg
0bb93ca053
std.Build: simplify module dependency handling
At the expense of a slight special case in the build runner, we can make
the handling of dependencies between modules a little shorter and much
easier to follow.

When module and step graphs are being constructed during the "configure"
phase, we do not set up step dependencies triggered by modules. Instead,
after the configure phase, the build runner traverses the whole
step/module graph, starting from the root top-level steps, and
configures all step dependencies implied by modules. The "make" phase
then proceeds as normal. Also, the old `Module.dependencyIterator` logic
is replaced by two separate iterables. `Module.getGraph` takes the root
module of a compilation, and returns all modules in its graph; while
`Step.Compile.getCompileDependencies` takes a `*Step.Compile` and
returns all `*Step.Compile` it depends on, recursively, possibly
excluding dynamic libraries. The old `Module.dependencyIterator`
combined these two functions into one unintuitive iterator; they are now
separated, which in particular helps readability at the usage sites
which only need one or the other.
2024-12-18 01:47:51 +05:00
Eric Joldasov
b83b161f4b
std.Build.Step.TranslateC: propagate target, optimize, link_libc to added module
Will be needed for the future commit with the new API where artifacts
are created from the pre-existing module.
2024-12-18 01:47:51 +05:00
mlugg
3aa8020904
std.Build.Step.Compile.Options: change root_module field type to *Module 2024-12-18 01:47:51 +05:00
mlugg
faafeb51af
std.Build.Step.Compile: change root_module field type to *Module
This commit changes the `root_module` field of `std.Build.Step.Compile`
to be a `*Module` rather than a `Module`. This is a breaking change, but
an incredibly minor one (the full potential extent of the breakage can
be seen in the modified standalone test).

This change will be necessary for an upcoming improvement, so it was
convenient to make it here.
2024-12-18 01:47:50 +05:00
Eric Joldasov
3d393dba6f
std.Build: remove deprecated APIs
These APIs were all deprecated prior to the release of 0.13.0, so can be
safety removed in the current release cycle.

`std.Build`:
* `host` -> `graph.host`

`std.Build.Step.Compile`:
* `setLinkerScriptPath` -> `setLinkerScript`
* `defineCMacro` -> `root_module.addCMacro`
* `linkFrameworkNeeded`-> `root_module.linkFramework`
* `linkFrameworkWeak`-> `root_module.linkFramework`

`std.Build.Step.ObjCopy`:
* `getOutputSource` -> `getOutput`

`std.Build.Step.Options`:
* `addOptionArtifact` -> `addOptionPath`
* `getSource` -> `getOutput`

`std.Build.Step.Run`:
* `extra_file_dependencies` -> `addFileInput`
* `addDirectorySourceArg` -> `addDirectoryArg`
* `addPrefixedDirectorySourceArg` -> `addPrefixedDirectoryArg`
2024-12-18 01:47:50 +05:00
Andrew Kelley
debba652a3
Merge pull request #22252 from jacobly0/dwarf-deduped-structs
Dwarf: preserve deduped struct navs
2024-12-17 01:26:09 -05:00
Andrew Kelley
e5c188e59a
Merge pull request #22251 from alexrp/remove-cuda
`zig cc`: Remove broken CUDA C/C++ support.
2024-12-17 01:24:46 -05:00
Alex Rønne Petersen
0ef01c5521
std.Target: Incorporate the Abi tag in VersionRange.default().
This is necessary to pick out the correct minimum OS version from the
std.zig.target.available_libcs list.
2024-12-17 05:04:16 +01:00
Alex Rønne Petersen
424f9ba532
std.zig.target: Check OS version for all targets in canBuildLibC().
The old logic only checked it for macOS, but we also need it to be checked for
Linux now.
2024-12-17 05:04:16 +01:00
Alex Rønne Petersen
df235f5163
std.zig.target: Attach a minimum Linux version to each glibc/musl libc entry.
(With the exception of x86 since that was available from the beginning.)

These were determined by analyzing the full, reconstructed Git history of the
Linux kernel here: https://landley.net/kdocs/fullhist
2024-12-17 05:04:14 +01:00
David Rubin
0c457fa7eb add m4 {pro,max} detection 2024-12-16 20:56:29 -05:00
Matthew Lugg
7e8be21363
Merge pull request #22250 from mlugg/zon-ast
compiler: introduce ZonGen and make `ast-check` run it for ZON inputs
2024-12-16 23:01:24 +00:00
Jacob Young
8c0628d0e2 Dwarf: include comptime-only values in debug info 2024-12-16 17:25:52 -05:00
mlugg
c7485d73ac
compiler: introduce ZonGen and make ast-check run it for ZON inputs
Currently, `zig ast-check` fails on ZON files, because it tries to
interpret the file as Zig source code. This commit introduces a new
verification pass, `std.zig.ZonGen`, which applies to an AST in ZON
mode.

Like `AstGen`, this pass also converts the AST into a more helpful
format. Rather than a sequence of instructions like `Zir`, the output
format of `ZonGen` is a new datastructure called `Zoir`. This type is
essentially a simpler form of AST, containing only the information
required for consumers of ZON. It is also far more compact than
`std.zig.Ast`, with the size generally being comparable to the size of
the well-formatted source file.

The emitted `Zoir` is currently not used aside from the `-t` option to
`ast-check` which causes it to be dumped to stdout. However, in future,
it can be used for comptime `@import` of ZON files, as well as for
simpler handling of files like `build.zig.zon`, and even by other parts
of the Zig Standard Library.

Resolves: #22078
2024-12-16 17:02:35 +00:00
mlugg
512cb22d83
std.c.darwin.posix_spawn: fix signature
And change corresponding signature in `DarwinPosixSpawn`.
2024-12-16 14:53:54 +00:00
mlugg
3e9810266b
compiler: add some missing consts
The previous commit exposed some missing `const` qualifiers in a few
places. These mutable slices could have been used to store invalid
values into memory!
2024-12-16 14:53:54 +00:00
Andrew Kelley
d12c0bf909
Merge pull request #22242 from Rexicon226/moar-branch-hint
utilize `@branchHint` more
2024-12-16 07:27:20 -05:00
Alex Rønne Petersen
181330bbd4
zig cc: Remove headers related to GPU offload. 2024-12-16 04:36:57 +01:00
Matthew Lugg
3a0a9aa9b8
Merge pull request #22245 from mlugg/zir-no-doc-comments
compiler: remove doc comments from Zir
2024-12-16 02:48:28 +00:00
David Rubin
0fe17ea12a
hashmap: remove inline from getIndex now that we have @branchHint 2024-12-15 17:20:08 -08:00
mlugg
847c34ac66
compiler: remove doc comments from Zir
This code was left over from the legacy Autodoc implementation. No
component of the compiler pipeline actually requires doc comments, so it
is a waste of time and space to store them in ZIR.
2024-12-15 16:32:55 +00:00
David Rubin
b58916bb7c
correct the hint in XxHash3 2024-12-15 03:40:20 -08:00
Alex Rønne Petersen
6066e7bfd1
std.zig.target: Remove wasm32-freestanding-musl.
This is, at least today, a very broken target: It doesn't actually build either
musl or wasi-libc even if you use -lc. It does give you musl headers, but that's
it. Those headers are not terribly useful, however, without any implementation
code. You can sort of call some math functions because they just so happen to
have implementations in compiler-rt. But that's only true for a small subset,
and I don't think users should be relying on the ABI surface of a library that
is an implementation detail of the compiler.

Clearly, a freestanding-capable libc of sorts is a useful thing as evidenced by
newlib, picolibc, etc existing. However, calling it "musl" is misleading when it
isn't actually musl-compatible, nor can it ever be because the musl API surface
is inextricably tied to the Linux kernel. In the discussion on #20690, there was
agreement that once we split up the API and ABI components in the target string,
the API component should be about compatibility, not whether you literally get a
particular implementation of it. Also, we decided that Linux musl and wasi-libc
musl shouldn't use the same API tag precisely because they're not actually
compatible.

(And besides, how would any syscall even be implemented in freestanding? Who or
what would we be calling?)

So I think we should remove this triple for now. If we decide to reintroduce
something like this, especially once #2879 gets going, we should come up with a
bespoke name for it rather than using "musl".
2024-12-15 12:25:12 +01:00
Alex Rønne Petersen
7d4e8be0de
std.Target: Remove special case for wasm in Abi.default().
It'll still pick .musl for os.tag == .wasi.
2024-12-15 11:57:19 +01:00
Alex Rønne Petersen
d5c2f527b4
Merge pull request #22219 from alexrp/arm-big-endian
Add `armeb-linux-*`, `thumbeb-linux-*`, and `aarch64_be-linux-*` to CI
2024-12-15 01:41:46 +01:00
Techatrix
cc82620b2a fix std.zig.Ast.rootDecls on .zon mode Ast 2024-12-14 16:40:40 -05:00
Frank Denis
0fac47cf28
argon2: bail out if m < 8p (#22232)
Fixes #22231
2024-12-14 19:26:55 +00:00
Alex Rønne Petersen
70de2f3a76
Merge pull request #22156 from alexrp/mingw-update
Update MinGW-w64 to dcd7fefc703fb4b12187235386900d34cc13fdc5
2024-12-14 11:30:35 +01:00
Alex Rønne Petersen
13a9bf8629
std.zig.target: Update isLibCLibName() for MinGW dcd7fefc703fb4b12187235386900d34cc13fdc5. 2024-12-14 07:02:14 +01:00
Alex Rønne Petersen
45fff0a511
mingw: Update sources to dcd7fefc703fb4b12187235386900d34cc13fdc5. 2024-12-14 07:02:14 +01:00
Alex Rønne Petersen
87083e8e7e
mingw: Update headers to dcd7fefc703fb4b12187235386900d34cc13fdc5. 2024-12-14 07:02:12 +01:00
gbaraldi
10282eae64 Also export mach_timebase_info_data from darwin 2024-12-14 03:16:34 +01:00
David Rubin
82f35c5186 add branchHint to std.Random.float 2024-12-13 13:24:38 +01:00
Michael Dusan
a68119f8f1 macos: vendored libc: bump to SDK 15.1 2024-12-13 03:55:54 +01:00
Alex Rønne Petersen
499ad89b41
std: Disable some vector-related tests on armeb.
https://github.com/ziglang/zig/issues/22060
2024-12-13 03:13:14 +01:00
Alex Rønne Petersen
620f69c3b4
compiler-rt: Disable __aeabi_drsub test on armeb.
https://github.com/ziglang/zig/issues/22061
2024-12-13 03:13:14 +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
d48611ba67
Merge pull request #22090 from alexrp/glibc-runtime-triples
Add `std.zig.target.glibcRuntimeTriple()` and use it in `std.Build.Step.Run` and `process_headers.zig`
2024-12-12 18:55:15 +01:00
Techatrix
3f7b3daaa0 AstGen: fix analysis when encountering discard of error capture 2024-12-11 18:51:10 -05:00
Nico Elbers
4a3800d78f std.ArrayHashMap fix eql documentation
In cf88cf2657 the eql function provided in
The context of ArrayHashMap was changed to also include the key index,
but this wasn't properly updated in the documentation.

Since a flat `usize` is unintuitive, I've tried to explain the function
of the parameter as best I can based on the original commit.

Finally, I didn't do an extensive search if this eql definition is
incorrectly stated anywhere outside of these 2 spots. But I somewhat
doubt an file outside of `array_hash_map` would
2024-12-11 15:21:56 -05:00
Andrew Kelley
3670910f20
Merge pull request #22202 from ziglang/Cache.hit
std.Build.Cache.hit: more discipline in error handling
2024-12-11 14:57:11 -05:00
Andrew Kelley
7ff42eff91 std.Build.Cache.hit: work around macOS kernel bug
The previous commit cast doubt upon the initial report about macOS
kernel behavior, identifying another reason that ENOENT could be
returned from file creation.

However, it is demonstrable that ENOENT can be returned for both cases:
1. create file race
2. handle refers to deleted directory

This commit re-introduces the workaround for the file creation race on
macOS however it does not unconditionally retry - it first tries again
with O_EXCL to disambiguate the error condition that has occurred.
2024-12-11 11:56:44 -08:00