mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
zig test: forward target CLI args to zig run when using -ofmt=c
Previously, if you used `zig test -ofmt=c -target foobar` then Zig would try to compile the generated C code with the native target instead of "foobar". With this change, `--test-cmd` with e.g. QEMU still won't work, but at least the binary will get compiled for the correct target.
This commit is contained in:
parent
8caed48460
commit
9b54c9dee8
11
src/main.zig
11
src/main.zig
@ -3021,6 +3021,17 @@ fn buildOutputType(
|
||||
try test_exec_args.append(self_exe_path);
|
||||
try test_exec_args.append("run");
|
||||
if (link_libc) try test_exec_args.append("-lc");
|
||||
if (!mem.eql(u8, target_arch_os_abi, "native")) {
|
||||
try test_exec_args.append("-target");
|
||||
try test_exec_args.append(target_arch_os_abi);
|
||||
}
|
||||
if (target_mcpu) |mcpu| {
|
||||
try test_exec_args.append(try std.fmt.allocPrint(arena, "-mcpu={s}", .{mcpu}));
|
||||
}
|
||||
if (target_dynamic_linker) |dl| {
|
||||
try test_exec_args.append("--dynamic-linker");
|
||||
try test_exec_args.append(dl);
|
||||
}
|
||||
try test_exec_args.append(c_code_path);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user