0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib
Ryan Liptak 723085b9bf Build: fetch pending lazy dependencies and retry when artifact/etc is not found
Before the changes in this commit, the intention was to gather all pending lazy dependencies of all package scripts, and then only handle fetching after the root package script exits. However, that's not always feasible, since it's possible for a lazy dependency to depend on a lazy dependency, which means that the first fetch-and-retry can only know about the root's lazy dependencies. Then, during the second attempt at configuring, the root package script will see its lazy dependency as available, but in reality that dependency's package script may return error.LazyDependencyNeeded, which won't matter until *after* the root package script has finished running. Therefore, the root package script will continue running as if its lazy dependency is fully available, when in reality it has requested a fetch-and-retry.

This means that something like an `artifact` call in the root package script that depends on a lazy dependency of a lazy dependency will fail after the first fetch-and-retry, because the necessary remaining pending lazy dependencies would only get fetched once the root script finished.

In case it's helpful, the reproduction looks something like this:

root
└─ child1 (.lazy = true, gotten in root's build.zig via either `dependency` or `try dependencyLazy`)
   └─ child2 (.lazy = true, gotten in child1's build.zig via `try dependencyLazy`)

To fix this, whenever an artifact/module/etc is looked up and not found while there are pending lazy dependencies, we now immediately exit, fetch, and retry, since that artifact/module/etc could only exist after one of those pending lazy dependencies is made available (i.e. the dependency's configuration stopped part-way due to a missing lazy dependency).

Before (fails):

> zig build
debug(fetch): FileNotFound: zig-pkg\zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN
debug(fetch): FileNotFound: C:\Users\Ryan\AppData\Local\zig\p/zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN.tar.gz
debug: configuration cache incomplete_manifest
info: fetching lazy dependency zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN
debug(fetch): FileNotFound: zig-pkg\zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN
debug(fetch): FileNotFound: C:\Users\Ryan\AppData\Local\zig\p/zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN.tar.gz
debug(fetch): FileNotFound: zig-pkg\zig_test_repo2-0.0.0-eVW_ihsPAAAmwffTitFedoK7HGHiRfQTshvARXs0-qJx
debug(fetch): FileNotFound: C:\Users\Ryan\AppData\Local\zig\p/zig_test_repo2-0.0.0-eVW_ihsPAAAmwffTitFedoK7HGHiRfQTshvARXs0-qJx.tar.gz
debug: configuration cache incomplete_manifest
panic: unable to find artifact "zig_test_repo1_lib"

After (succeeds):

> zig build
debug(fetch): FileNotFound: zig-pkg\zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN
debug(fetch): FileNotFound: C:\Users\Ryan\AppData\Local\zig\p/zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN.tar.gz
debug: configuration cache incomplete_manifest
info: fetching lazy dependency zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN
debug(fetch): FileNotFound: zig-pkg\zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN
debug(fetch): FileNotFound: C:\Users\Ryan\AppData\Local\zig\p/zig_test_repo1-0.0.0-FuDjYawXAAAK0sFpnAa7IPMoTJpCs44sgfKP7ZBi3oAN.tar.gz
debug(fetch): FileNotFound: zig-pkg\zig_test_repo2-0.0.0-eVW_ihsPAAAmwffTitFedoK7HGHiRfQTshvARXs0-qJx
debug(fetch): FileNotFound: C:\Users\Ryan\AppData\Local\zig\p/zig_test_repo2-0.0.0-eVW_ihsPAAAmwffTitFedoK7HGHiRfQTshvARXs0-qJx.tar.gz
debug: configuration cache incomplete_manifest
info: fetching lazy dependency zig_test_repo2-0.0.0-eVW_ihsPAAAmwffTitFedoK7HGHiRfQTshvARXs0-qJx
debug(fetch): FileNotFound: zig-pkg\zig_test_repo2-0.0.0-eVW_ihsPAAAmwffTitFedoK7HGHiRfQTshvARXs0-qJx
debug(fetch): FileNotFound: C:\Users\Ryan\AppData\Local\zig\p/zig_test_repo2-0.0.0-eVW_ihsPAAAmwffTitFedoK7HGHiRfQTshvARXs0-qJx.tar.gz
debug: configuration cache incomplete_manifest
History 2026-10-24 23:10:20 +02:00
..
build-web Remove deprecated aliases of ArrayList and update usage sites. 2026-10-17 19:29:37 +02:00
c Implement partially ordered operator precedence 2026-10-22 12:21:43 +02:00
compiler Merge pull request 'ArrayList: remove usages of Managed from std/zig/llvm, lib/compiler/Maker, docs/wasm/markdown' (#37385) from Der_Teufel/zig:arraylist-managed into master 2026-10-24 23:07:01 +02:00
compiler_rt compiler-rt: fix f80 conversions for subnormal destination 2026-10-24 13:42:01 +02:00
docs Remove usages of array_list.Managed in docs/wasm/markdown 2026-10-23 10:09:54 +02:00
include zig cc: update intrinsic headers to LLVM 23 2026-10-07 00:30:51 +02:00
init default to LLVM and ReleaseSafe for fuzzing 2026-10-09 10:14:16 +02:00
libc link: read the Darwin SDK version from Version 2026-10-23 02:15:09 +02:00
libcxx libcxx: fix OpenBSD build failure due to missing __get_locale_encoding() 2026-10-07 00:30:52 +02:00
libcxxabi libcxx: add serenity support 2026-10-07 00:30:52 +02:00
libtsan libtsan: update to LLVM 23 2026-10-07 00:30:51 +02:00
libunwind libunwind: update to LLVM 23 2026-10-07 00:30:51 +02:00
lldb lldb/pretty_printers.py: support new MultiArrayList.pointer_stability 2026-10-21 10:04:01 -07:00
std Build: fetch pending lazy dependencies and retry when artifact/etc is not found 2026-10-24 23:10:20 +02:00
c.zig feat(libzigc): add common implementations of pthread_spin_* 2026-04-21 09:03:06 +02:00
compiler_rt.zig compiler_rt: support targets where c_longdouble is not a valid type 2026-10-20 15:45:44 -04:00
fuzzer.zig Change usages of fmt.bufPrint* to mem.print* (#36263) 2026-09-01 02:21:28 +02:00
ubsan_rt.zig std: support loongarch backend 2026-08-09 11:10:26 +08:00
zig.h x86_64: llvm 23 changed the windows abi :( 2026-10-07 00:30:52 +02:00