Subject: [PATCH bazel-zig-cc] fix Windows host support with relative paths

From: Fabian Hahn <[email-masked]>
Date: Wed, 28 Sep 2022 17:38:11 +0100

v1.0.0-rc1 indeed broke Windows host support, but it was trivial to fix.
Also, the massive speedups gained from bazel not redownloading zig
multiple times more than made up for it, this was actually way worse on
Windows than I've ever experienced it to be on Linux (could take up to
10 minutes on first bazel run...). Also very cool to see that we're now
friendly to remote caches. Fantastic work everyone!

I've tested v1.0.0-rc1 with my minimal patch below on Windows and
everything is working fine. If we can add this then from my side v1.0.0
is good to go. Nice milestone indeed.

Best,
Fabian

---
 toolchain/defs.bzl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl
index 0aba0fb..487271f 100644
--- a/toolchain/defs.bzl
+++ b/toolchain/defs.bzl
@@ -93,15 +93,15 @@ _ZIG_TOOLS = [
     "wasm-ld",  # WebAssembly
 ]
 
-# TODO: ZIG_LIB_DIR equivalent in powershell?
 _ZIG_TOOL_WRAPPER_WINDOWS_CACHE_KNOWN = """@echo off
+set ZIG_LIB_DIR=external\\zig_sdk\\lib
 set ZIG_LOCAL_CACHE_DIR={cache_prefix}\\bazel-zig-cc
 set ZIG_GLOBAL_CACHE_DIR=%ZIG_LOCAL_CACHE_DIR%
 "{zig}" "{zig_tool}" %*
 """
 
-# TODO: ZIG_LIB_DIR equivalent in powershell?
 _ZIG_TOOL_WRAPPER_WINDOWS_CACHE_GUESS = """@echo off
+set ZIG_LIB_DIR=external\\zig_sdk\\lib
 if exist "%TMP%\\*" goto :usertmp
 set ZIG_LOCAL_CACHE_DIR=C:\\Temp\\bazel-zig-cc
 goto zig
-- 
2.25.1

---

From: "builds.sr.ht" <[email-masked]>
Date: Wed, 28 Sep 2022 17:26:51 +0000

bazel-zig-cc/patches/.build.yml: SUCCESS in 48m21s

[fix Windows host support with relative paths][0] from [Fabian Hahn][1]

[0]: https://lists.sr.ht/~motiejus/bazel-zig-cc/patches/35663
[1]: mailto:[email-masked]

✓ #852370 SUCCESS bazel-zig-cc/patches/.build.yml https://builds.sr.ht/~motiejus/job/852370

---

From: Motiejus Jakštys <[email-masked]>
Date: Wed, 28 Sep 2022 20:38:53 +0300

Hi Fabian,

>  set ZIG_GLOBAL_CACHE_DIR=%ZIG_LOCAL_CACHE_DIR%

See the logic of Linux:

if [ -d external/zig_sdk/lib ]; then
    export ZIG_LIB_DIR=external/zig_sdk/lib
else
    export ZIG_LIB_DIR="$(dirname "$0")/../lib"
fi

It should set ZIG_LIB_DIR to external/zig_sdk/lib iff the directory
exists. It may not exist if build tools change working directory
before invoking zig cc. Hello Go!

Can you update the patch to add this?

Motiejus