diff --git a/build.zig b/build.zig index 96cf176221..ce753ca692 100644 --- a/build.zig +++ b/build.zig @@ -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(©_step.step); + } + } + // Build the wasm test platform host for wasm32-freestanding { const wasm_target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding, .abi = .none }); diff --git a/test/int/platform/main.roc b/test/int/platform/main.roc index 8e56dfb248..67a0b4de07 100644 --- a/test/int/platform/main.roc +++ b/test/int/platform/main.roc @@ -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], } } diff --git a/test/str/platform/main.roc b/test/str/platform/main.roc index 50d98f7458..8c4eb6cc23 100644 --- a/test/str/platform/main.roc +++ b/test/str/platform/main.roc @@ -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], } }