31987 Commits

Author SHA1 Message Date
Alex Rønne Petersen
130310972d
compiler: Print more information when failing to provide libc. 2024-12-22 22:06:00 +01: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
Matthew Lugg
32354d1190
Merge pull request #22243 from mlugg/better-imc
Sema: disallow unsafe in-memory coercions
2024-12-16 22:59:45 +00: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
mlugg
f154cd1fdc
Sema: disallow unsafe in-memory coercions
The error messages here aren't amazing yet, but this is an improvement
on status quo, because the current behavior allows false negative
compile errors, so effectively miscompiles.

Resolves: #15874
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
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
Alex Rønne Petersen
8f330ab70e mingw: Fix CFLAGS for winpthreads.
It should not use the CRT ones, and it also needs a few flags of its own that I
forgot to add in #22156.

Follow-up fix for #10989.
2024-12-16 01:56:55 +01:00
Andrew Kelley
aa0377794d
Merge pull request #22233 from jacobly0/fix-relocs
Elf.Atom: fix truncated dyn abs relocs
2024-12-15 15:48:24 -05:00
Andrew Kelley
eb5c9317aa
Merge pull request #22240 from alexrp/wasm32-freestanding-musl
Remove `wasm32-freestanding-musl`
2024-12-15 15:47:22 -05: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
Matthew Lugg
12f0c38347
Merge pull request #22239 from mlugg/runtime-store-comptime-only
Sema: disallow runtime stores to pointers with comptime-only element types

Resolves: #22175
2024-12-15 16:04:12 +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
mlugg
72ba7f7e98
Sema: disallow runtime stores to pointers with comptime-only element types 2024-12-15 11:09:04 +00:00
mlugg
b5d3db5fc6
Sema: do not allow coercing undefined to opaque types 2024-12-15 11:09:04 +00: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
Jacob Young
a53a8ab25e Elf: fix shdr size getting out of sync with the actual size 2024-12-14 23:20:15 -05:00
Jacob Young
6d97185bc6 Elf.Atom: fix truncated dyn abs relocs 2024-12-14 23:20:15 -05:00
Alex Rønne Petersen
af89bb05d3
Merge pull request #22224 from alexrp/cc-args
`Compilation`: Clean up `addCCArgs()` + some minor improvements
2024-12-15 04:53:24 +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
Alex Rønne Petersen
ee47094a33 Move fetch-them-macos-headers tools to ziglang/zig. 2024-12-14 23:45:18 +01:00
David Rubin
09a8fa2120 ensure InstMap capacity before remapping error code 2024-12-14 16:41:17 -05:00
Techatrix
cc82620b2a fix std.zig.Ast.rootDecls on .zon mode Ast 2024-12-14 16:40:40 -05:00
Andrew Kelley
13a28345bb
Merge pull request #22222 from ianprime0509/git-sha256
zig fetch: add support for SHA-256 Git repositories
2024-12-14 16:34:47 -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
2c192f8882
mingw: Update sources list to 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
Alex Rønne Petersen
39c4efa2a7
Compilation: Clean up addCCArgs().
The goal of this commit is to get rid of some "unused command line argument"
warnings that Clang would give for various file types previously. This cleanup
also has the side effect of making the order of flags more understandable,
especially as it pertains to include paths.

Since a lot of code was shuffled around in this commit, I recommend reviewing
the old and new versions of the function side-by-side rather than trying to make
sense of the diff.
2024-12-14 06:49:45 +01:00
gbaraldi
10282eae64 Also export mach_timebase_info_data from darwin 2024-12-14 03:16:34 +01:00
Ian Johnson
5217da57fc zig fetch: support SHA-256 Git repositories
Closes #21888
2024-12-13 08:49:45 -05:00
Ian Johnson
62cc81a63a Remove copy of HashedWriter
It was added to the standard library in #18733.
2024-12-13 08:49:45 -05:00
Carl Åstholm
de3db8a1a6 Fix undefined behavior in package extraction code 2024-12-13 08:49:45 -05:00
Carl Åstholm
b352595aa2 Add compiler internals tests
There are several test decls inside `/src` that are not currently being
tested and have bitrotted as a result. This commit revives those tests
and adds the `test-compiler-internals` set of tests which tests
everything reachable from `/src/main.zig`.
2024-12-13 08:49:02 -05:00
David Rubin
82f35c5186 add branchHint to std.Random.float 2024-12-13 13:24:38 +01:00
Alex Rønne Petersen
d74e87aab1
Compilation: Use Clang dependency file for preprocessed assembly files. 2024-12-13 06:48:35 +01:00
Alex Rønne Petersen
12a289c1dd
Compilation: Use a better canonical file extension for header files. 2024-12-13 06:48:35 +01:00
Alex Rønne Petersen
88f324ebe7
Compilation: Override Clang's language type for header files.
Clang seems to treat them as linker input without this.
2024-12-13 06:48:32 +01:00
Alex Rønne Petersen
b6ece854c9
Compilation: Improve classification of various C/C++/Objective-C files. 2024-12-13 05:05:36 +01:00
Alex Rønne Petersen
ece7bd4b1c
update_mingw: Update blacklist to dcd7fefc703fb4b12187235386900d34cc13fdc5. 2024-12-13 03:59:08 +01:00