Commit Graph

27987 Commits

Author SHA1 Message Date
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
mlugg
9eda6ccefc InternPool: use separate key for slices
This change eliminates some problematic recursive logic in InternPool,
and provides a safer API.
2024-02-02 11:02:03 +00:00
Andrew Kelley
5a3ae38f3b std: remove garbage being printed to stderr during unit tests 2024-02-01 18:05:14 -07:00
mlugg
8944935499 std: eliminate some uses of usingnamespace
This eliminates some simple usages of `usingnamespace` in the standard
library. This construct may in future be removed from the language, and
is generally an inappropriate way to formulate code. It is also
problematic for incremental compilation, which may not initially support
projects using it.

I wasn't entirely sure what the appropriate namespacing for the types in
`std.os.uefi.tables` would be, so I ofted to preserve the current
namespacing, meaning this is not a breaking change. It's possible some
of the moved types should instead be namespaced under `BootServices`
etc, but this can be a future enhancement.
2024-02-01 20:30:42 +00:00
Andrew Kelley
776cd673f2
Merge pull request #18746 from jacobly0/http-auth
http: support basic access authentication
2024-01-31 21:03:40 -08:00
Jakub Konka
788a0409af
Merge pull request #18761 from ziglang/macho-fixes
macho: misc fixes and improvements
2024-01-31 15:21:59 +01:00
Jacob Young
c1e7d0c08f http: optimize allocations for proxy basic authorization 2024-01-31 15:00:27 +01:00
Jacob Young
a111f805cd http: avoid allocator use when encoding basic authorization 2024-01-31 15:00:27 +01:00
Jacob Young
82b37ea024 http: support basic access authentication 2024-01-31 12:05:12 +01:00
Jakub Konka
d4966517f6 x86_64+macho: emit .got instead of .got_load relocs 2024-01-31 09:33:49 +01:00
Jakub Konka
1ee628a3e0 macho: improve error msg when relaxing GOT fails 2024-01-31 09:33:39 +01:00
danielsan901998
d7a27bf803 Use mem.zeroes for empty union initializer list 2024-01-31 06:38:44 +02:00
Gustavo C. Viegas
fc48bbdf90 std.Build.Step.TranslateC: fix use of outdated Module in createModule 2024-01-31 02:46:05 +02:00
Jakub Konka
f63f4508d2 macho: fix parsing versions from TBDs if parsed as floats 2024-01-30 20:56:20 +01:00
Jakub Konka
b8490c05c1 macho: improve weak-ref symbols handling 2024-01-30 13:56:08 +01:00
Pavel Verigo
a2ad8517ee
Sema: fix union init with zero size field 2024-01-30 12:20:23 +02:00
Jiacai Liu
1b5cbf0d08
fix(autodoc): avoid panic when module not found (#18699) 2024-01-29 21:43:11 -05:00
Constantin Pestka
e460ba66a5
std: add docs about return value of submit() (#18721)
being misleading if used alongside with IORING_SETUP_SQPOLL
2024-01-29 21:26:52 -05:00
Krzysztof Wolicki
d8981dc493
std.os: fix chdirZ to compile on Windows (#18695) 2024-01-29 21:19:07 -05:00
Veikka Tuominen
7d75c3d3b8 llvm: ensure returned undef is 0xaa bytes when runtime safety is enabled
Closes #13178
2024-01-29 17:35:07 -08:00
Jacob Young
4dfca01de4 gzip: implement compression 2024-01-29 14:30:23 -08:00
Ian Johnson
27d2d8e81f Apply cflags from pkg-config to all dependent modules
Closes #18628

This commit splits the arguments obtained from pkg-config into two
groups, cflags and libs, and consistently applies the cflags to each
individual module linking the library while applying the libs only once
for each compilation.
2024-01-29 14:08:41 -08:00
SuperAuguste
a479fd3132 Fix some comptime packed struct issues
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2024-01-29 13:09:17 -08:00
Andrew Kelley
f4f8036ec0
Merge pull request #18729 from Vexu/fixes
Fix some generic{Reader,Writer} related issues
2024-01-29 13:07:37 -08:00
Jakub Konka
3e939e6153
Merge pull request #18722 from ziglang/macho-debug-info
macho: reinstate DWARF in self-hosted x86_64-macho
2024-01-29 20:33:54 +01:00
Veikka Tuominen
f93a36c091 llvm: revert bad array access optimization
Closes #18723
2024-01-29 08:43:27 -08:00