retry
This commit is contained in:
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -17,15 +17,21 @@ jobs:
|
||||
with:
|
||||
version: master # pin to a specific version once stable
|
||||
|
||||
- name: Download LLVM 18
|
||||
run: |
|
||||
Invoke-WebRequest -Uri "https://github.com/vovkos/llvm-package-windows/releases/download/llvm-18.1.8/llvm-18.1.8-windows-amd64-msvc17-msvcrt.7z" -OutFile "$env:TEMP\llvm.7z"
|
||||
7z x "$env:TEMP\llvm.7z" -oC:\LLVM
|
||||
|
||||
- name: Verify LLVM
|
||||
run: |
|
||||
& "C:\Program Files\LLVM\bin\llvm-config.exe" --version
|
||||
Get-ChildItem C:\LLVM -Recurse -Name "*.lib" | Select-Object -First 5
|
||||
Get-ChildItem C:\LLVM -Directory
|
||||
|
||||
- name: Build
|
||||
run: zig build -Dstatic-llvm -Dllvm-prefix="C:\Program Files\LLVM"
|
||||
run: zig build -Dstatic-llvm -Dllvm-prefix="C:\LLVM\llvm-18.1.8-windows-amd64-msvc17-msvcrt"
|
||||
|
||||
- name: Test
|
||||
run: zig build test -Dstatic-llvm -Dllvm-prefix="C:\Program Files\LLVM"
|
||||
run: zig build test -Dstatic-llvm -Dllvm-prefix="C:\LLVM\llvm-18.1.8-windows-amd64-msvc17-msvcrt"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
55
build.zig
55
build.zig
@@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const math = @import("math");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
@@ -27,21 +28,49 @@ pub fn build(b: *std.Build) void {
|
||||
});
|
||||
|
||||
if (static_llvm) {
|
||||
// Query llvm-config for the static libraries needed
|
||||
const libs_raw = std.mem.trim(u8, b.run(&.{ llvm_config, "--libs", "--link-static" }), " \t\n\r");
|
||||
var libs_it = std.mem.tokenizeAny(u8, libs_raw, " \t\n\r");
|
||||
while (libs_it.next()) |flag| {
|
||||
if (flag.len > 2 and std.mem.startsWith(u8, flag, "-l")) {
|
||||
mod.linkSystemLibrary(flag[2..], .{ .preferred_link_mode = .static });
|
||||
if (builtin.os.tag == .windows) {
|
||||
// Windows: no llvm-config available; enumerate LLVM .lib files directly
|
||||
var dir = std.fs.openDirAbsolute(lib_dir, .{ .iterate = true }) catch
|
||||
@panic("Cannot open LLVM lib directory");
|
||||
defer dir.close();
|
||||
var it = dir.iterate();
|
||||
while (it.next() catch null) |entry| {
|
||||
if (entry.kind == .file and
|
||||
std.mem.startsWith(u8, entry.name, "LLVM") and
|
||||
std.mem.endsWith(u8, entry.name, ".lib"))
|
||||
{
|
||||
mod.linkSystemLibrary(
|
||||
entry.name[0 .. entry.name.len - 4],
|
||||
.{ .preferred_link_mode = .static },
|
||||
);
|
||||
}
|
||||
}
|
||||
// Windows system libraries LLVM depends on
|
||||
const win_syslibs = [_][]const u8{
|
||||
"advapi32", "shell32", "ole32", "uuid",
|
||||
"psapi", "version", "ntdll", "ws2_32",
|
||||
"dbghelp",
|
||||
};
|
||||
for (&win_syslibs) |syslib| {
|
||||
mod.linkSystemLibrary(syslib, .{});
|
||||
}
|
||||
} else {
|
||||
// Unix: query llvm-config for the static libraries needed
|
||||
const libs_raw = std.mem.trim(u8, b.run(&.{ llvm_config, "--libs", "--link-static" }), " \t\n\r");
|
||||
var libs_it = std.mem.tokenizeAny(u8, libs_raw, " \t\n\r");
|
||||
while (libs_it.next()) |flag| {
|
||||
if (flag.len > 2 and std.mem.startsWith(u8, flag, "-l")) {
|
||||
mod.linkSystemLibrary(flag[2..], .{ .preferred_link_mode = .static });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// System libraries LLVM depends on (zlib, zstd, curses, etc.)
|
||||
const syslibs_raw = std.mem.trim(u8, b.run(&.{ llvm_config, "--system-libs", "--link-static" }), " \t\n\r");
|
||||
var syslibs_it = std.mem.tokenizeAny(u8, syslibs_raw, " \t\n\r");
|
||||
while (syslibs_it.next()) |flag| {
|
||||
if (flag.len > 2 and std.mem.startsWith(u8, flag, "-l")) {
|
||||
mod.linkSystemLibrary(flag[2..], .{});
|
||||
// System libraries LLVM depends on (zlib, zstd, curses, etc.)
|
||||
const syslibs_raw = std.mem.trim(u8, b.run(&.{ llvm_config, "--system-libs", "--link-static" }), " \t\n\r");
|
||||
var syslibs_it = std.mem.tokenizeAny(u8, syslibs_raw, " \t\n\r");
|
||||
while (syslibs_it.next()) |flag| {
|
||||
if (flag.len > 2 and std.mem.startsWith(u8, flag, "-l")) {
|
||||
mod.linkSystemLibrary(flag[2..], .{});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user