langref: global assembly test depends on llvm

see #24046
This commit is contained in:
Andrew Kelley 2025-06-04 10:22:51 -07:00
parent 5986bdf868
commit a59d18779f
2 changed files with 45 additions and 1 deletions

View File

@ -19,3 +19,4 @@ test "global assembly" {
// test // test
// target=x86_64-linux // target=x86_64-linux
// llvm=true

View File

@ -168,6 +168,15 @@ fn printOutput(
try build_args.appendSlice(&[_][]const u8{ "-target", triple }); try build_args.appendSlice(&[_][]const u8{ "-target", triple });
try shell_out.print("-target {s} ", .{triple}); try shell_out.print("-target {s} ", .{triple});
} }
if (code.use_llvm) |use_llvm| {
if (use_llvm) {
try build_args.append("-fllvm");
try shell_out.print("-fllvm", .{});
} else {
try build_args.append("-fno-llvm");
try shell_out.print("-fno-llvm", .{});
}
}
if (code.verbose_cimport) { if (code.verbose_cimport) {
try build_args.append("--verbose-cimport"); try build_args.append("--verbose-cimport");
try shell_out.print("--verbose-cimport ", .{}); try shell_out.print("--verbose-cimport ", .{});
@ -224,7 +233,6 @@ fn printOutput(
break :code_block; break :code_block;
} }
} }
const target_query = try std.Target.Query.parse(.{ const target_query = try std.Target.Query.parse(.{
.arch_os_abi = code.target_str orelse "native", .arch_os_abi = code.target_str orelse "native",
}); });
@ -319,6 +327,16 @@ fn printOutput(
}, },
} }
} }
if (code.use_llvm) |use_llvm| {
if (use_llvm) {
try test_args.append("-fllvm");
try shell_out.print("-fllvm", .{});
} else {
try test_args.append("-fno-llvm");
try shell_out.print("-fno-llvm", .{});
}
}
const result = run(arena, &env_map, tmp_dir_path, test_args.items) catch const result = run(arena, &env_map, tmp_dir_path, test_args.items) catch
fatal("test failed", .{}); fatal("test failed", .{});
const escaped_stderr = try escapeHtml(arena, result.stderr); const escaped_stderr = try escapeHtml(arena, result.stderr);
@ -469,6 +487,15 @@ fn printOutput(
try build_args.appendSlice(&[_][]const u8{ "-target", triple }); try build_args.appendSlice(&[_][]const u8{ "-target", triple });
try shell_out.print("-target {s} ", .{triple}); try shell_out.print("-target {s} ", .{triple});
} }
if (code.use_llvm) |use_llvm| {
if (use_llvm) {
try build_args.append("-fllvm");
try shell_out.print("-fllvm", .{});
} else {
try build_args.append("-fno-llvm");
try shell_out.print("-fno-llvm", .{});
}
}
for (code.additional_options) |option| { for (code.additional_options) |option| {
try build_args.append(option); try build_args.append(option);
try shell_out.print("{s} ", .{option}); try shell_out.print("{s} ", .{option});
@ -538,6 +565,15 @@ fn printOutput(
try test_args.appendSlice(&[_][]const u8{ "-target", triple }); try test_args.appendSlice(&[_][]const u8{ "-target", triple });
try shell_out.print("-target {s} ", .{triple}); try shell_out.print("-target {s} ", .{triple});
} }
if (code.use_llvm) |use_llvm| {
if (use_llvm) {
try test_args.append("-fllvm");
try shell_out.print("-fllvm", .{});
} else {
try test_args.append("-fno-llvm");
try shell_out.print("-fno-llvm", .{});
}
}
if (code.link_mode) |link_mode| { if (code.link_mode) |link_mode| {
switch (link_mode) { switch (link_mode) {
.static => { .static => {
@ -827,6 +863,7 @@ const Code = struct {
verbose_cimport: bool, verbose_cimport: bool,
just_check_syntax: bool, just_check_syntax: bool,
additional_options: []const []const u8, additional_options: []const []const u8,
use_llvm: ?bool,
const Id = union(enum) { const Id = union(enum) {
@"test", @"test",
@ -886,6 +923,7 @@ fn parseManifest(arena: Allocator, source_bytes: []const u8) !Code {
var link_libc = false; var link_libc = false;
var disable_cache = false; var disable_cache = false;
var verbose_cimport = false; var verbose_cimport = false;
var use_llvm: ?bool = null;
while (it.next()) |prefixed_line| { while (it.next()) |prefixed_line| {
const line = skipPrefix(prefixed_line); const line = skipPrefix(prefixed_line);
@ -901,6 +939,10 @@ fn parseManifest(arena: Allocator, source_bytes: []const u8) !Code {
try additional_options.append(arena, line["additional_option=".len..]); try additional_options.append(arena, line["additional_option=".len..]);
} else if (mem.startsWith(u8, line, "target=")) { } else if (mem.startsWith(u8, line, "target=")) {
target_str = line["target=".len..]; target_str = line["target=".len..];
} else if (mem.eql(u8, line, "llvm=true")) {
use_llvm = true;
} else if (mem.eql(u8, line, "llvm=false")) {
use_llvm = false;
} else if (mem.eql(u8, line, "link_libc")) { } else if (mem.eql(u8, line, "link_libc")) {
link_libc = true; link_libc = true;
} else if (mem.eql(u8, line, "disable_cache")) { } else if (mem.eql(u8, line, "disable_cache")) {
@ -923,6 +965,7 @@ fn parseManifest(arena: Allocator, source_bytes: []const u8) !Code {
.disable_cache = disable_cache, .disable_cache = disable_cache,
.verbose_cimport = verbose_cimport, .verbose_cimport = verbose_cimport,
.just_check_syntax = just_check_syntax, .just_check_syntax = just_check_syntax,
.use_llvm = use_llvm,
}; };
} }