aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-06-17 10:03:30 +0100
committermlugg <mlugg@mlugg.co.uk>2025-06-17 11:06:39 +0100
commita92427bf275bc85d4a0c5f086bbb8156f00f2b6c (patch)
tree113d0e92db16e89870c6256a36567733a35dbbfa /src/codegen.zig
parent561fdd0ed3d93a373f126f4df01caf813ad32fec (diff)
downloadzig-a92427bf275bc85d4a0c5f086bbb8156f00f2b6c.tar.gz
zig-a92427bf275bc85d4a0c5f086bbb8156f00f2b6c.zip
Build.Cache.Path: fix `resolvePosix` empty `sub_path`
This function is sometimes used to assume a canonical representation of a path. However, when the `Path` referred to `root_dir` itself, this function previously resolved `sub_path` to ".", which is incorrect; per doc comments, it should set `sub_path` to "". This fix ultimately didn't solve what I was trying to solve, though I'm still PRing it, because it's still *correct*. The background to this commit is quite interesting and worth briefly discussing. I originally worked on this to try and fix a bug in the build system, where if the root package (i.e. the one you `zig build`) depends on package X which itself depends back on the root package (through a `.path` dependency), invalid dependency modules are generated. I hit this case working on ziglang/translate-c, which wants to depend on "examples" (similar to the Zig compiler's "standalone" test cases) which themselves depend back on the translate-c package. However, after this patch just turned that error into another, I realised that this case simply cannot work, because `std.Build` needs to eagerly execute build scripts at `dependency` calls to learn which artifacts, modules, etc, exist. ...at least, that's how the build system is currently designed. One can imagine a world where `dependency` sort of "queues" the call, `artifact` and `module` etc just pretend that the thing exists, and all configure functions are called non-recursively by the runner. The downside is that it becomes impossible to query state set by a dependency's configure script. For instance, if a dependency exposes an artifact, it would become impossible to get that artifact's resolved target in the configure phase. However, as well as allowing recursive package imports (which are certainly kinda nifty), it would also make lazy dependencies far more useful! Right now, lazy dependencies only really work if you use options (`std.Build.option`) to block their usage, since any call to `lazyDependency` causes the dependency to be fetched. However, if we made this change, lazy dependencies could be made far more versatile by only fetching them *if the final step plan requires them*. I'm not 100% sure if this is a good idea or not, but I might open an issue for it soon.
Diffstat (limited to 'src/codegen.zig')
0 files changed, 0 insertions, 0 deletions