| ... | @@ -606,7 +606,6 @@ pub const TestContext = struct { | ... | @@ -606,7 +606,6 @@ pub const TestContext = struct { |
| 606 | output_mode: std.builtin.OutputMode, | 606 | output_mode: std.builtin.OutputMode, |
| 607 | optimize_mode: std.builtin.Mode = .Debug, | 607 | optimize_mode: std.builtin.Mode = .Debug, |
| 608 | updates: std.ArrayList(Update), | 608 | updates: std.ArrayList(Update), |
| 609 | object_format: ?std.Target.ObjectFormat = null, | | |
| 610 | emit_h: bool = false, | 609 | emit_h: bool = false, |
| 611 | is_test: bool = false, | 610 | is_test: bool = false, |
| 612 | expect_exact: bool = false, | 611 | expect_exact: bool = false, |
| ... | @@ -782,12 +781,13 @@ pub const TestContext = struct { | ... | @@ -782,12 +781,13 @@ pub const TestContext = struct { |
| 782 | pub fn exeFromCompiledC(ctx: *TestContext, name: []const u8, target: CrossTarget) *Case { | 781 | pub fn exeFromCompiledC(ctx: *TestContext, name: []const u8, target: CrossTarget) *Case { |
| 783 | const prefixed_name = std.fmt.allocPrint(ctx.arena, "CBE: {s}", .{name}) catch | 782 | const prefixed_name = std.fmt.allocPrint(ctx.arena, "CBE: {s}", .{name}) catch |
| 784 | @panic("out of memory"); | 783 | @panic("out of memory"); |
| | 784 | var target_adjusted = target; |
| | 785 | target_adjusted.ofmt = std.Target.ObjectFormat.c; |
| 785 | ctx.cases.append(Case{ | 786 | ctx.cases.append(Case{ |
| 786 | .name = prefixed_name, | 787 | .name = prefixed_name, |
| 787 | .target = target, | 788 | .target = target_adjusted, |
| 788 | .updates = std.ArrayList(Update).init(ctx.cases.allocator), | 789 | .updates = std.ArrayList(Update).init(ctx.cases.allocator), |
| 789 | .output_mode = .Exe, | 790 | .output_mode = .Exe, |
| 790 | .object_format = .c, | | |
| 791 | .files = std.ArrayList(File).init(ctx.arena), | 791 | .files = std.ArrayList(File).init(ctx.arena), |
| 792 | }) catch @panic("out of memory"); | 792 | }) catch @panic("out of memory"); |
| 793 | return &ctx.cases.items[ctx.cases.items.len - 1]; | 793 | return &ctx.cases.items[ctx.cases.items.len - 1]; |
| ... | @@ -851,12 +851,13 @@ pub const TestContext = struct { | ... | @@ -851,12 +851,13 @@ pub const TestContext = struct { |
| 851 | | 851 | |
| 852 | /// Adds a test case for Zig or ZIR input, producing C code. | 852 | /// Adds a test case for Zig or ZIR input, producing C code. |
| 853 | pub fn addC(ctx: *TestContext, name: []const u8, target: CrossTarget) *Case { | 853 | pub fn addC(ctx: *TestContext, name: []const u8, target: CrossTarget) *Case { |
| | 854 | var target_adjusted = target; |
| | 855 | target_adjusted.ofmt = std.Target.ObjectFormat.c; |
| 854 | ctx.cases.append(Case{ | 856 | ctx.cases.append(Case{ |
| 855 | .name = name, | 857 | .name = name, |
| 856 | .target = target, | 858 | .target = target_adjusted, |
| 857 | .updates = std.ArrayList(Update).init(ctx.cases.allocator), | 859 | .updates = std.ArrayList(Update).init(ctx.cases.allocator), |
| 858 | .output_mode = .Obj, | 860 | .output_mode = .Obj, |
| 859 | .object_format = .c, | | |
| 860 | .files = std.ArrayList(File).init(ctx.arena), | 861 | .files = std.ArrayList(File).init(ctx.arena), |
| 861 | }) catch @panic("out of memory"); | 862 | }) catch @panic("out of memory"); |
| 862 | return &ctx.cases.items[ctx.cases.items.len - 1]; | 863 | return &ctx.cases.items[ctx.cases.items.len - 1]; |
| ... | @@ -1501,7 +1502,6 @@ pub const TestContext = struct { | ... | @@ -1501,7 +1502,6 @@ pub const TestContext = struct { |
| 1501 | .root_name = "test_case", | 1502 | .root_name = "test_case", |
| 1502 | .target = target, | 1503 | .target = target, |
| 1503 | .output_mode = case.output_mode, | 1504 | .output_mode = case.output_mode, |
| 1504 | .object_format = case.object_format, | | |
| 1505 | }); | 1505 | }); |
| 1506 | | 1506 | |
| 1507 | const emit_directory: Compilation.Directory = .{ | 1507 | const emit_directory: Compilation.Directory = .{ |
| ... | @@ -1537,7 +1537,6 @@ pub const TestContext = struct { | ... | @@ -1537,7 +1537,6 @@ pub const TestContext = struct { |
| 1537 | .emit_h = emit_h, | 1537 | .emit_h = emit_h, |
| 1538 | .main_pkg = &main_pkg, | 1538 | .main_pkg = &main_pkg, |
| 1539 | .keep_source_files_loaded = true, | 1539 | .keep_source_files_loaded = true, |
| 1540 | .object_format = case.object_format, | | |
| 1541 | .is_native_os = case.target.isNativeOs(), | 1540 | .is_native_os = case.target.isNativeOs(), |
| 1542 | .is_native_abi = case.target.isNativeAbi(), | 1541 | .is_native_abi = case.target.isNativeAbi(), |
| 1543 | .dynamic_linker = target_info.dynamic_linker.get(), | 1542 | .dynamic_linker = target_info.dynamic_linker.get(), |
| ... | @@ -1782,7 +1781,7 @@ pub const TestContext = struct { | ... | @@ -1782,7 +1781,7 @@ pub const TestContext = struct { |
| 1782 | ".." ++ ss ++ "{s}" ++ ss ++ "{s}", | 1781 | ".." ++ ss ++ "{s}" ++ ss ++ "{s}", |
| 1783 | .{ &tmp.sub_path, bin_name }, | 1782 | .{ &tmp.sub_path, bin_name }, |
| 1784 | ); | 1783 | ); |
| 1785 | if (case.object_format != null and case.object_format.? == .c) { | 1784 | if (case.target.ofmt != null and case.target.ofmt.? == .c) { |
| 1786 | if (host.getExternalExecutor(target_info, .{ .link_libc = true }) != .native) { | 1785 | if (host.getExternalExecutor(target_info, .{ .link_libc = true }) != .native) { |
| 1787 | // We wouldn't be able to run the compiled C code. | 1786 | // We wouldn't be able to run the compiled C code. |
| 1788 | continue :update; // Pass test. | 1787 | continue :update; // Pass test. |