test-cases: fix incorrectly linking libc when backend is llvm

Now link_libc=1 must be used to link with libc, instead of the test
harness assuming that using the llvm backend means additionally linking
with libc.
This commit is contained in:
Andrew Kelley 2023-03-13 18:24:17 -07:00
parent 1dbb616e73
commit 171977dc1c
4 changed files with 8 additions and 2 deletions

View File

@ -9,7 +9,8 @@ pub fn main() void {
// run
// backend=llvm
// target=x86_64-linux-gnu
// link_libc=1
//
// f64: 2.000000
// f32: 10.000000
//
//

View File

@ -14,4 +14,5 @@ fn foo(comptime info: std.builtin.Type) !void {
// run
// is_test=1
// backend=llvm
//

View File

@ -7,6 +7,7 @@ pub fn main() void {
// run
// backend=llvm
// target=x86_64-linux,x86_64-macos
// link_libc=1
//
// hello world!
//

View File

@ -382,6 +382,7 @@ fn addFromDirInner(
const backends = try manifest.getConfigForKeyAlloc(ctx.arena, "backend", Backend);
const targets = try manifest.getConfigForKeyAlloc(ctx.arena, "target", CrossTarget);
const is_test = try manifest.getConfigForKeyAssertSingle("is_test", bool);
const link_libc = try manifest.getConfigForKeyAssertSingle("link_libc", bool);
const output_mode = try manifest.getConfigForKeyAssertSingle("output_mode", std.builtin.OutputMode);
var cases = std.ArrayList(usize).init(ctx.arena);
@ -397,7 +398,7 @@ fn addFromDirInner(
.updates = std.ArrayList(Cases.Update).init(ctx.cases.allocator),
.is_test = is_test,
.output_mode = output_mode,
.link_libc = backend == .llvm,
.link_libc = link_libc,
.deps = std.ArrayList(DepModule).init(ctx.cases.allocator),
});
try cases.append(next);
@ -745,6 +746,8 @@ const TestManifestConfigDefaults = struct {
};
} else if (std.mem.eql(u8, key, "is_test")) {
return "0";
} else if (std.mem.eql(u8, key, "link_libc")) {
return "0";
} else unreachable;
}
};