Commit graph

27962 commits

Author SHA1 Message Date
Robin Voetter
2f815853dc
spirv: shlWithOverflow 2024-02-04 19:09:26 +01:00
Robin Voetter
15cf5f88c1
spirv: vectors for air not 2024-02-04 19:09:25 +01:00
Robin Voetter
403c6262bb
spirv: use new vector stuff for arithOp and shift 2024-02-04 19:09:18 +01:00
Robin Voetter
cb9e20da00
spirv: element-wise operation helper 2024-02-04 19:09:00 +01:00
Robin Voetter
747f4ae3f5
spirv: sh[rl](_exact)? 2024-02-04 19:08:59 +01:00
Robin Voetter
3ef5b80d2c
std: use simple eqlBytes for spirv
The SPIR-V backend doesn't support the advanced
eqlBytes yet, and when it does, it likely that it
will be detrimental.
2024-02-04 19:08:57 +01:00
Jakub Konka
a1b607acb5 macho: sanitize Zig sections segment names before emitting a relocatable
As reported by jacobly, the Apple system linker matches sections to
segments by name and not by flags causing Zig's executable section
ending up in a segment with incorrect permission flags.
2024-02-04 18:05:38 +01:00
Andrew Kelley
3c7970dc4e
Merge pull request #18801 from jacobly0/fix-cache-retry
Cache: fix logic for retrying cache hits
2024-02-04 01:45:37 -08:00
Andrew Kelley
d3fc2648cc
Merge pull request #18778 from ziglang/system-package-mode
Implement system package mode and lazy dependencies
2024-02-04 01:44:12 -08:00
Jakub Konka
9bf97b8494
Merge pull request #18793 from ziglang/macho-zig-object
macho: emit relocatable with self-hosted x86_64 backend
2024-02-04 09:12:59 +01:00
Jacob Young
5b803aecfb bootstrap.c: allow overriding the host triple 2024-02-03 22:34:59 -05:00
Jacob Young
8fa7635419 stage1: implement fd_fdstat_get
I thought this might be needed, so may as well keep the implementation.
2024-02-04 03:48:29 +01:00
Jacob Young
26cb72086a Cache: fix logic for retrying cache hits
Fixes potentially #16149
2024-02-04 03:48:29 +01:00
lockbox
a65bc8d071 fix typo in wasm atomic opcodes doc comment 2024-02-04 00:25:05 +01:00
Chadwain Holness
6030855097
std.fmt: fix formatting slices of structs with custom formatting
`hasMethod` doesn't make sense for pointers to more than one item.
2024-02-03 21:47:55 +00:00
David Rubin
122387943b
Fix OOB when enum field out of order in different file 2024-02-03 19:52:05 +00:00
David Rubin
eb4024036d
Add error hint when looping over ErrorUnion 2024-02-03 19:16:27 +00:00
Jakub Konka
ca86dc61dd test/link/macho: test for signals only when running on the host 2024-02-03 19:36:52 +01:00
Jakub Konka
4ebd0036fd test/link/macho: add some smoke tests for self-hosted MachO 2024-02-03 17:57:35 +01:00
Jakub Konka
7641561f2d macho: refactor section/segment handle tracking logic 2024-02-03 16:57:15 +01:00
Jakub Konka
1ad545c97b macho: refactor growSection logic; remove -r limitation for ZigObject 2024-02-03 15:55:32 +01:00
Jakub Konka
0a0f90f949 macho: migrate thunks to use new relative addressing mechanism 2024-02-03 10:52:29 +01:00
Jakub Konka
aa1aa98863 macho: fix remaining references to Atom.value 2024-02-03 09:28:37 +01:00
Jakub Konka
dc6db3b309 macho: minor fixes and sanitize input *_zig segment/sections names 2024-02-03 09:28:34 +01:00
Jakub Konka
9fc1685c1c macho: make atom address relative wrt defining section 2024-02-03 09:28:30 +01:00
Jakub Konka
e10a2018a7 macho: emit relocs for ZigObject 2024-02-03 09:28:25 +01:00
Jakub Konka
dc222c9ba5 macho: use findFreeSpace for all sections 2024-02-03 09:28:19 +01:00
Jakub Konka
c5155170b2 macho: allocating space in .o 2024-02-03 09:28:12 +01:00
Jakub Konka
88a4bd6cf6 macho: pre-alloc sections in -r mode 2024-02-03 09:25:42 +01:00
Jakub Konka
352941b030 macho: emit incomplete object file 2024-02-03 09:25:41 +01:00
Andrew Kelley
3dad7312b2 CLI: use dummy http client when bootstrapping
Prevents unnecessary depedency on networking when bootstrapping zig.
2024-02-02 20:43:01 -07:00
Andrew Kelley
18091b4406 std.Build: use a runtime panic for wrong dependency API
This makes it easier to debug and avoids a false positive compile error
in the build script.
2024-02-02 20:43:01 -07:00
Andrew Kelley
a17505c711 zig build: avoid using stdout for communication with runner
Pass the required lazy dependencies from the build runner to the parent
process via a tmp file instead of stdout. I'll reproduce this comment to
explain it:

The `zig build` parent process needs a way to obtain results from the
configuration phase of the child process. In the future, the make phase
will be executed in a separate process than the configure phase, and we
can then use stdout from the configuration phase for this purpose.

However, currently, both phases are in the same process, and Run Step
provides API for making the runned subprocesses inherit stdout and stderr
which means these streams are not available for passing metadata back
to the parent.

Until make and configure phases are separated into different processes,
the strategy is to choose a temporary file name ahead of time, and then
read this file in the parent to obtain the results, in the case the child
exits with code 3.

This commit also extracts some common logic from the loop that rebuilds
the build runner so that it does not run again when the build runner is
rebuilt.
2024-02-02 20:43:01 -07:00
Andrew Kelley
996e61f813 Compilation: delete clang diag files afterwards
After parsing diagnostics files from clang we don't have any more use
for those tmp files. Delete them to reduce clutter and disk usage.
2024-02-02 20:43:01 -07:00
Andrew Kelley
d753c3a121 CLI: implement 'zig build' lazy dependency fetching
This makes `zig build` notice when lazy dependencies were missing, fetch
them, and then rebuild the build runner and run it again.
2024-02-02 20:43:01 -07:00
Andrew Kelley
252f4ab2a5 build system: implement lazy dependencies, part 1
Build manifest files support `lazy: true` for dependency sections.
This causes the auto-generated dependencies.zig to have 2 more
possibilities:
1. It communicates whether a dependency is lazy or not.
2. The dependency might be acknowledged, but missing due to being lazy
   and not fetched.

Lazy dependencies are not fetched by default, but if they are already
fetched then they are provided to the build script.

The build runner reports the set of missing lazy dependenices that are
required to the parent process via stdout and indicates the situation
with exit code 3.

std.Build now has a `lazyDependency` function. I'll let the doc comments
speak for themselves:

When this function is called, it means that the current build does, in
fact, require this dependency. If the dependency is already fetched, it
proceeds in the same manner as `dependency`. However if the dependency
was not fetched, then when the build script is finished running, the
build will not proceed to the make phase. Instead, the parent process
will additionally fetch all the lazy dependencies that were actually
required by running the build script, rebuild the build script, and then
run it again.
In other words, if this function returns `null` it means that the only
purpose of completing the configure phase is to find out all the other
lazy dependencies that are also required.
It is allowed to use this function for non-lazy dependencies, in which
case it will never return `null`. This allows toggling laziness via
build.zig.zon without changing build.zig logic.

The CLI for `zig build` detects this situation, but the logic for then
redoing the build process with these extra dependencies fetched is not
yet implemented.
2024-02-02 20:43:01 -07:00
Andrew Kelley
434a6a4f63 std.process.Child: use unreachable instead of @panic
This is how assertions work in zig.
2024-02-02 20:43:01 -07:00
Andrew Kelley
a68defbc65 std.Build: make systemIntegrationOption take a default 2024-02-02 20:43:01 -07:00
Andrew Kelley
ed4ccea7ba build system: implement --system [dir]
This prevents package fetching and enables system_package_mode in the
build system which flips the defaults for system integrations.
2024-02-02 20:43:01 -07:00
Andrew Kelley
22537873f4 build system: implement --release[=mode]
This allows a `zig build` command to specify intention to create a
release build, regardless of what per-project options exist. It also
allows the command to specify a "preferred optimization mode", which is
chosen if the project itself does not choose one (in other words, the
project gets first choice). If neither the build command nor the project
specify a preferred release mode, an error occurs.
2024-02-02 20:43:01 -07:00
Andrew Kelley
f18576afad std.Build.resolveTargetQuery: fix ignoring ofmt for native 2024-02-02 20:43:01 -07:00
Andrew Kelley
2637b57376 std.Build: make system library integrations more general
Before it was named "library" inconsistently.

Now the CLI args are -fsys=[name] and -fno-sys=[name] and it is a more
general-purpose "system integration" which could be a library name or
perhaps a project name such as "ffmpeg" or a binary such as "nasm".
2024-02-02 20:43:01 -07:00
Andrew Kelley
370438943e std.Build: revert moving some fields to Graph
On second thought, let's keep a bunch of these flags how they already
were.

Partial revert of the previous commit.
2024-02-02 20:43:01 -07:00
Andrew Kelley
105db13536 std.Build: implement --host-target, --host-cpu, --host-dynamic-linker
This also makes a long-overdue change of extracting common state from
Build into a shared Graph object.

Getting the semantics right for these flags turned out to be quite
tricky. In the end it works like this:
* The override only happens when the target is fully native, with no
  additional query parameters, such as versions or CPU features added.
* The override affects the resolved Target but leaves the original Query
  unmodified.
* The "is native?" detection logic operates on the original, unmodified
  query. This makes it possible to provide invalid host target
  information, causing confusing errors to occur. Don't do that.

There are some minor breaking changes to std.Build API such as the fact
that `b.zig_exe` is now moved to `b.graph.zig_exe`, as well as a handful
of other similar flags.
2024-02-02 20:43:01 -07:00
Andrew Kelley
bd1d2b0ae2 std.Target.Query: avoid using builtin.target.abi
This value is very likely incorrect. When glibc_version is provided but
no explicit ABI is provided, use the string "gnu" instead.
2024-02-02 20:43:01 -07:00
Andrew Kelley
b3596d72b0 CLI: add --host-target, --host-cpu, and --host-dynamic-linker
These are advanced options that make it possible to simultaneously
target the "host" computer, while overriding assumptions about the host
computer such as what CPU features are available, or what OS version
range to target.

This is useful only for the case of integrating with system package
manager builds which want to pretend the host is also the target.
2024-02-02 20:43:01 -07:00
Andrew Kelley
8f867eaf84 build system: introduce system library integration
* New --help section
* Add b.systemLibraryOption
* Rework the build runner CLI logic a bit
2024-02-02 20:43:01 -07:00
Ryan Liptak
f2e249e920 fs tests: Make path type show up in stack traces of testWithAllSupportedPathTypes
This allows for easier debugging without the need to print out the path type to stderr.

Context: 5a3ae38f3b
2024-02-02 18:03:17 -08:00
Jacob Young
5e791e8e07 tls: support ed25519 signatures
Which were claimed to be supported during the handshake but were not
actually implemented.
2024-02-02 17:27:26 -08:00
Jakub Konka
92deebcd66 cli+build: handle -ObjC flag and route it to MachO linker 2024-02-02 22:00:16 +01:00