Repository navigation
generate version data file in build phase - #1409
Conversation
|
This looks good. I've also needed to use a few similar hacks to do cache invalidation for steps depending on external stuff. Would be cool if zig's cache supported time to live for its entries. |
|
Hello everyone, sorry for being late, I just did not noticed this update when building ZLS (I thought it was just bad internet). IIUC building now requires access to the Internet during compilation? Gentoo's network sandbox rightfully blocks this access and compiling fails with this error: >>> Compiling source in /tmp/portage/dev-zig/zls-9999/work/zls-9999 ...
* zig-9999 build -Doptimize=ReleaseSafe -Ddata_version=master --verbose
/usr/lib64/zig/9999/bin/zig build-exe /tmp/portage/dev-zig/zls-9999/work/zls-9999/src/config_gen/config_gen.zig --cache-dir /tmp/portage/dev-zig/zls-9999/work/zls-9999/zig-cache --global-cache-dir /tmp/portage/dev-zig/zls-9999/homedir/.cache/zig --name zls_gen --listen=-
steps [2/6] zig build-exe zls_gen Debug native... LLVM Emit Object... /tmp/portage/dev-zig/zls-9999/work/zls-9999/zig-cache/o/b2db62685cbf5fd7e07b8c05d638942b/zls_gen --generate-version-data master --generate-version-data-path /tmp/portage/dev-zig/zls-9999/work/zls-9999/zig-cache/o/1352759e7fc620c17346be54b7670f40/version_data_master_19587.zig
run zls_gen (version_data_master_19587.zig): error: error: failed to download https://raw.githubusercontent.com/ziglang/zig/master/doc/langref.html.in: error.TemporaryNameServerFailure
error: DownloadFailed
/usr/lib64/zig/9999/lib/std/net.zig:45:9: 0x493224 in parseIp (zls_gen)
return error.InvalidIPAddressFormat;
^
/usr/lib64/zig/9999/lib/std/net.zig:75:29: 0x493567 in parseExpectingFamily (zls_gen)
os.AF.UNSPEC => return parseIp(name, port),
^
/usr/lib64/zig/9999/lib/std/net.zig:1414:48: 0x49cc73 in linuxLookupNameFromDns (zls_gen)
if (ap[0].len < 4 or (ap[0][3] & 15) == 2) return error.TemporaryNameServerFailure;
^
/usr/lib64/zig/9999/lib/std/net.zig:1358:5: 0x49e1a2 in linuxLookupNameFromDnsSearch (zls_gen)
return linuxLookupNameFromDns(addrs, canon, name, family, rc, port);
^
/usr/lib64/zig/9999/lib/std/net.zig:996:17: 0x49ef15 in linuxLookupName (zls_gen)
try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);
^
/usr/lib64/zig/9999/lib/std/net.zig:933:9: 0x4419b1 in getAddressList (zls_gen)
try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port);
^
/usr/lib64/zig/9999/lib/std/net.zig:709:18: 0x360a8f in tcpConnectToHost (zls_gen)
const list = try getAddressList(allocator, name, port);
^
/usr/lib64/zig/9999/lib/std/http/Client.zig:888:45: 0x32c104 in connectUnproxied (zls_gen)
error.TemporaryNameServerFailure => return error.TemporaryNameServerFailure,
^
/usr/lib64/zig/9999/lib/std/http/Client.zig:947:9: 0x2e9d16 in connect (zls_gen)
return client.connectUnproxied(host, port, protocol);
^
/usr/lib64/zig/9999/lib/std/http/Client.zig:1012:44: 0x2cfdba in request (zls_gen)
const conn = options.connection orelse try client.connect(host, port, protocol);
^
/tmp/portage/dev-zig/zls-9999/work/zls-9999/src/config_gen/config_gen.zig:949:19: 0x2cf2d5 in httpGET (zls_gen)
var request = try client.request(.GET, uri, .{ .allocator = allocator }, .{});
^
/tmp/portage/dev-zig/zls-9999/work/zls-9999/src/config_gen/config_gen.zig:832:9: 0x2d4d52 in generateVersionDataFile (zls_gen)
return error.DownloadFailed;
^
/tmp/portage/dev-zig/zls-9999/work/zls-9999/src/config_gen/config_gen.zig:1085:9: 0x2de079 in main (zls_gen)
try generateVersionDataFile(gpa, data_version, output_path);
^Previously, I used Again, sorry for not bringing it earlier, I simply didn't know about this change. |
|
I'm also getting this error using nix flakes. |
Instead of having to run
zig build genwhenever builtins get changed so that master.zig is updated, I thought that this could be converted into a build step.I am not entirely satisfied with how the solution ended up in
build.zigbecause caching prevents the version data from being updated whenever the website changes but never caching forces you to always have a internet connection when you build ZLS.What I did is to invalidate the cache once every day based on the current timestamp which feels more like a hacky trick rather than a proper solution.
zls/build.zig
Lines 147 to 153 in b55525e
Some feedback on this would be appreciated. Or just tell me to scrap this idea which is also fine.