fix windows targets for test platforms

This commit is contained in:
Luke Boswell 2025-12-16 23:12:39 +11:00
parent 9e79f3f924
commit 2edc1f4c86
3 changed files with 32 additions and 2 deletions

View file

@ -31,6 +31,12 @@ const glibc_cross_targets = [_]CrossTarget{
.{ .name = "arm64glibc", .query = .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .gnu } },
};
/// Windows cross-compile targets
const windows_cross_targets = [_]CrossTarget{
.{ .name = "x64win", .query = .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .msvc } },
.{ .name = "arm64win", .query = .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .msvc } },
};
/// All Linux cross-compile targets (musl + glibc)
const linux_cross_targets = musl_cross_targets ++ glibc_cross_targets;
@ -1231,8 +1237,9 @@ fn createTestPlatformHostLib(
configureBackend(lib, target);
lib.root_module.addImport("builtins", roc_modules.builtins);
lib.root_module.addImport("build_options", roc_modules.build_options);
// Force bundle compiler-rt to resolve runtime symbols like __main
lib.bundle_compiler_rt = true;
// Don't bundle compiler-rt in host libraries - roc_shim provides it
// Bundling it here causes duplicate symbol errors on Windows
lib.bundle_compiler_rt = false;
return lib;
}
@ -1427,6 +1434,25 @@ fn setupTestPlatforms(
}
}
// Cross-compile for Windows targets
for (windows_cross_targets) |cross_target| {
const cross_resolved_target = b.resolveTargetQuery(cross_target.query);
for (all_test_platform_dirs) |platform_dir| {
const copy_step = buildAndCopyTestPlatformHostLib(
b,
platform_dir,
cross_resolved_target,
cross_target.name,
optimize,
roc_modules,
strip,
omit_frame_pointer,
);
clear_cache_step.dependOn(&copy_step.step);
}
}
// Build the wasm test platform host for wasm32-freestanding
{
const wasm_target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding, .abi = .none });

View file

@ -18,6 +18,8 @@ platform ""
arm64musl: ["crt1.o", "libhost.a", app, "libc.a"],
x64glibc: ["Scrt1.o", "crti.o", "libhost.a", app, "crtn.o", "libc.so"],
arm64glibc: ["Scrt1.o", "crti.o", "libhost.a", app, "crtn.o", "libc.so"],
x64win: ["host.lib", app],
arm64win: ["host.lib", app],
}
}

View file

@ -15,6 +15,8 @@ platform ""
arm64musl: ["crt1.o", "libhost.a", app, "libc.a"],
x64glibc: ["Scrt1.o", "crti.o", "libhost.a", app, "crtn.o", "libc.so"],
arm64glibc: ["Scrt1.o", "crti.o", "libhost.a", app, "crtn.o", "libc.so"],
x64win: ["host.lib", app],
arm64win: ["host.lib", app],
}
}