Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate the build runner process from the configure process #20981

Open
andrewrk opened this issue Aug 7, 2024 · 3 comments
Open

separate the build runner process from the configure process #20981

andrewrk opened this issue Aug 7, 2024 · 3 comments
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Aug 7, 2024

This is a prerequisite to #14286.

Currently, the build runner process starts from the main() function inside lib/compiler/build_runner.zig and is compiled alongside the user's build.zig logic. The build runner invokes the user's build.zig logic, which is the "configure phase". After the build function returns, the build runner proceeds to execute the build graph, which is the "make" phase.

This issue is to separate the one compilation into two:

  • Configure phase executable which contains only build.zig logic and the build.zig logic of its dependencies.
  • Build runner

The primary motivation for this is to make zig build faster, both in the sense that it will take less time to compile, because only the user's build.zig logic is being recompiled when it changes, and in the sense that the build runner could be built with optimizations enabled, which is starting to become more valuable now that we have introduced --watch and --fuzz.

--debug-runner-optimize=[mode] should be introduced to allow switching the build runner to be compiled in a different optimization mode; this will be helpful when working on a patch to the build runner itself.

The primary challenge for implementing this will be separating out state from std.Build.Step that corresponds to configure phase and that corresponds to make phase. It will be a welcome change, because it will make the API a lot smaller and prevent users from having access to state that is only meant for use by the build runner. The build runner will probably have its own version of each std.Build.Step with different fields and logic.

The other major thing that needs to be done to make this work is serialization of the build graph. The output of the configure process needs to be communicated to the runner process, ideally by using stdout alone.

This constitutes a breaking change. In particular, custom build steps will stop working. Users should switch to using Run steps instead.

If we can't get this fully done in this release cycle, #14941 will be a good first step along the way.

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. breaking Implementing this issue could cause existing code to no longer compile or have different behavior. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Aug 7, 2024
@andrewrk andrewrk added this to the 0.14.0 milestone Aug 7, 2024
@mlugg
Copy link
Member

mlugg commented Aug 7, 2024

This breaking change may also be an opportune time to rename pub fn build to pub fn configure.

@ikskuh
Copy link
Contributor

ikskuh commented Aug 8, 2024

As you've already stated on discord, this will break certain use cases of custom build steps.

I'd consider #20935 a blocker for this as currently we need to fall back to custom build steps to achieve re-running the step when something in the directory changes. Uses cases here are asset bundling for games/websites/...

Also projects like https://github.com/zig-osdev/disk-image-step will suffer from this because of two reasons:

  • Making them do every individual operation as a single run step will bloat the cache directory enormously (disk image size * number of operations), which isn't really great when you have 50 to 100 operations and a disk image size of 1 GB
  • Making it a single run step will break on windows where you only have up to 8192 characters for a command line. This means you have a (theoretical) upper limit of 256 files passed assuming no file has a path longer than 32 chars (which is the length of our cache hash identifiers). This means we need to provide support for somehow passing "argument" files or we need to be able to have a step that allows using LazyPath values to be written to a file with custom information (kinda like filling out a file template or something like that)

matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 23, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 26, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 26, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 27, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
matklad added a commit to tigerbeetle/tigerbeetle that referenced this issue Aug 27, 2024
This moves multiversion from release.zig to build.zig, so that you can
just build a multiversion binary normally, eg:

```
$ ./zig/zig build -Dmultiversion=0.15.6 -Dconfig-release=0.15.7 -Dconfig-release-client-min=0.15.6 -Dtarget=x86_64-linux
$ ./tigerbeetle multiversion ./tigerbeetle
multiversioning.exe_path=./tigerbeetle
multiversioning.absolute_exe_path=/home/matklad/p/tb/work/tigerbeetle
multiversioning.releases_bundled={ 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7 }
...
```

You can pass `-Dmultiversion=latest` to fetch the latest release from
GitHub.

Note that `-Dtarget=aarch64-macos` will build a _universal_ macos image
(this _is_ confusing flag name, but I don't see a  simple non-ambigious
solution here).

As a bonus, multiversion build now should work on any host, and not on
x86_64 linux only.

Implementation wise, the bulk of work happens in
`build_multiversion.zig` program, which is invoked from build.zig as a
custom Run step. Why not encode all that logic direcctly into build.zig?

The main reason is adrewrk, the most famous Zig troll. His favorite way
of trolling Zig developers is by regularly breaking the API of build.zig:

ziglang/zig#14498

The next planned trolling is to separate "configure" and "make" phases
of `build.zig` into physically separate processes, and remove support
for custom steps:

ziglang/zig#20981

In this PR, we are going to troll adrewrk _back_ by fixing our code even
before it gets broken, and by making our custom step a Run step instead.

That being said, it I have split `gh release download` into a separate
step, so that is properly cached.
@andrewrk andrewrk modified the milestones: 0.14.0, 0.15.0 Oct 1, 2024
@alexrp
Copy link
Member

alexrp commented Oct 7, 2024

This might be a silly question based on my very limited understanding of the build runner, so apologies in advance if that's the case.

Would it be possible to achieve the goals of

  1. faster recompilation
  2. configure/make separation

by just doing #14941 and then leaning on linking? That is, compile the build runner and the build script separately so that the build runner object is almost always a cache hit, and then link the two together to create the final build binary. Any communication between the two would then happen via export/extern functions.

Again, I'm not familiar enough with the build runner internals to know if this even makes sense. If it does, though, it seems worth considering since we wouldn't have to open the can of worms that is serialization of build state, and what that means for custom steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

No branches or pull requests

4 participants