This commit is contained in:
Andrew Kelley 2025-07-07 11:38:15 -07:00
parent a59c35cbf8
commit aa52bb8327
17 changed files with 35 additions and 35 deletions

View File

@ -572,7 +572,7 @@ pub fn appendZigProcessFlags(
try zig_args.append(switch (unwind_tables) { try zig_args.append(switch (unwind_tables) {
.none => "-fno-unwind-tables", .none => "-fno-unwind-tables",
.sync => "-funwind-tables", .sync => "-funwind-tables",
.@"async" => "-fasync-unwind-tables", .async => "-fasync-unwind-tables",
}); });
} }

View File

@ -1691,7 +1691,7 @@ pub const Cpu = struct {
pub fn fromCallingConvention(cc: std.builtin.CallingConvention.Tag) []const Arch { pub fn fromCallingConvention(cc: std.builtin.CallingConvention.Tag) []const Arch {
return switch (cc) { return switch (cc) {
.auto, .auto,
.@"async", .async,
.naked, .naked,
.@"inline", .@"inline",
=> unreachable, => unreachable,

View File

@ -246,7 +246,7 @@ pub const CallingConvention = union(enum(u8)) {
/// The calling convention of a function that can be called with `async` syntax. An `async` call /// The calling convention of a function that can be called with `async` syntax. An `async` call
/// of a runtime-known function must target a function with this calling convention. /// of a runtime-known function must target a function with this calling convention.
/// Comptime-known functions with other calling conventions may be coerced to this one. /// Comptime-known functions with other calling conventions may be coerced to this one.
@"async", async,
/// Functions with this calling convention have no prologue or epilogue, making the function /// Functions with this calling convention have no prologue or epilogue, making the function
/// uncallable in regular Zig code. This can be useful when integrating with assembly. /// uncallable in regular Zig code. This can be useful when integrating with assembly.
@ -849,7 +849,7 @@ pub const LinkMode = enum {
pub const UnwindTables = enum { pub const UnwindTables = enum {
none, none,
sync, sync,
@"async", async,
}; };
/// This data structure is used by the Zig language code generation and /// This data structure is used by the Zig language code generation and

View File

@ -1521,9 +1521,9 @@ pub const Attribute = union(Kind) {
pub const UwTable = enum(u32) { pub const UwTable = enum(u32) {
none, none,
sync, sync,
@"async", async,
pub const default = UwTable.@"async"; pub const default = UwTable.async;
}; };
pub const VScaleRange = packed struct(u32) { pub const VScaleRange = packed struct(u32) {

View File

@ -6466,7 +6466,7 @@ pub fn addCCArgs(
try argv.append("-fno-asynchronous-unwind-tables"); try argv.append("-fno-asynchronous-unwind-tables");
try argv.append("-funwind-tables"); try argv.append("-funwind-tables");
}, },
.@"async" => try argv.append("-fasynchronous-unwind-tables"), .async => try argv.append("-fasynchronous-unwind-tables"),
} }
try argv.append("-nostdinc"); try argv.append("-nostdinc");

View File

@ -26687,7 +26687,7 @@ fn explainWhyTypeIsNotExtern(
} }
switch (ty.fnCallingConvention(zcu)) { switch (ty.fnCallingConvention(zcu)) {
.auto => try sema.errNote(src_loc, msg, "extern function must specify calling convention", .{}), .auto => try sema.errNote(src_loc, msg, "extern function must specify calling convention", .{}),
.@"async" => try sema.errNote(src_loc, msg, "async function cannot be extern", .{}), .async => try sema.errNote(src_loc, msg, "async function cannot be extern", .{}),
.@"inline" => try sema.errNote(src_loc, msg, "inline function cannot be extern", .{}), .@"inline" => try sema.errNote(src_loc, msg, "inline function cannot be extern", .{}),
else => return, else => return,
} }

View File

@ -382,7 +382,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
} }
} }
switch (fn_info.cc) { switch (fn_info.cc) {
.auto, .@"async", .naked, .@"inline" => try writer.print("callconv(.{}) ", .{std.zig.fmtId(@tagName(fn_info.cc))}), .auto, .async, .naked, .@"inline" => try writer.print("callconv(.{}) ", .{std.zig.fmtId(@tagName(fn_info.cc))}),
else => try writer.print("callconv({any}) ", .{fn_info.cc}), else => try writer.print("callconv({any}) ", .{fn_info.cc}),
} }
} }

View File

@ -4453,7 +4453,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
const backend = target_util.zigBackend(target, zcu.comp.config.use_llvm); const backend = target_util.zigBackend(target, zcu.comp.config.use_llvm);
switch (cc) { switch (cc) {
.auto, .@"inline" => return .ok, .auto, .@"inline" => return .ok,
.@"async" => return .{ .bad_backend = backend }, // nothing supports async currently .async => return .{ .bad_backend = backend }, // nothing supports async currently
.naked => {}, // depends only on backend .naked => {}, // depends only on backend
else => for (cc.archs()) |allowed_arch| { else => for (cc.archs()) |allowed_arch| {
if (allowed_arch == target.cpu.arch) break; if (allowed_arch == target.cpu.arch) break;

View File

@ -2758,7 +2758,7 @@ pub const Object = struct {
llvm_arg_i += 1; llvm_arg_i += 1;
} }
if (fn_info.cc == .@"async") { if (fn_info.cc == .async) {
@panic("TODO: LLVM backend lower async function"); @panic("TODO: LLVM backend lower async function");
} }
@ -2910,7 +2910,7 @@ pub const Object = struct {
try attributes.addFnAttr(.nounwind, &o.builder); try attributes.addFnAttr(.nounwind, &o.builder);
if (owner_mod.unwind_tables != .none) { if (owner_mod.unwind_tables != .none) {
try attributes.addFnAttr( try attributes.addFnAttr(
.{ .uwtable = if (owner_mod.unwind_tables == .@"async") .@"async" else .sync }, .{ .uwtable = if (owner_mod.unwind_tables == .async) .async else .sync },
&o.builder, &o.builder,
); );
} }
@ -11871,7 +11871,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s
} }
return switch (cc_tag) { return switch (cc_tag) {
.@"inline" => unreachable, .@"inline" => unreachable,
.auto, .@"async" => .fastcc, .auto, .async => .fastcc,
.naked => .ccc, .naked => .ccc,
.x86_64_sysv => .x86_64_sysvcc, .x86_64_sysv => .x86_64_sysvcc,
.x86_64_win => .win64cc, .x86_64_win => .win64cc,
@ -12379,7 +12379,7 @@ const ParamTypeIterator = struct {
return .byval; return .byval;
} }
}, },
.@"async" => { .async => {
@panic("TODO implement async function lowering in the LLVM backend"); @panic("TODO implement async function lowering in the LLVM backend");
}, },
.x86_64_sysv => return it.nextSystemV(ty), .x86_64_sysv => return it.nextSystemV(ty),
@ -12634,7 +12634,7 @@ fn ccAbiPromoteInt(
) ?std.builtin.Signedness { ) ?std.builtin.Signedness {
const target = zcu.getTarget(); const target = zcu.getTarget();
switch (cc) { switch (cc) {
.auto, .@"inline", .@"async" => return null, .auto, .@"inline", .async => return null,
else => {}, else => {},
} }
const int_info = switch (ty.zigTypeTag(zcu)) { const int_info = switch (ty.zigTypeTag(zcu)) {

View File

@ -325,7 +325,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
// See the `-fno-exceptions` logic for WASI. // See the `-fno-exceptions` logic for WASI.
// The old 32-bit x86 variant of SEH doesn't use tables. // The old 32-bit x86 variant of SEH doesn't use tables.
const unwind_tables: std.builtin.UnwindTables = const unwind_tables: std.builtin.UnwindTables =
if (target.os.tag == .wasi or (target.cpu.arch == .x86 and target.os.tag == .windows)) .none else .@"async"; if (target.os.tag == .wasi or (target.cpu.arch == .x86 and target.os.tag == .windows)) .none else .async;
const config = Compilation.Config.resolve(.{ const config = Compilation.Config.resolve(.{
.output_mode = output_mode, .output_mode = output_mode,

View File

@ -48,7 +48,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
const optimize_mode = comp.compilerRtOptMode(); const optimize_mode = comp.compilerRtOptMode();
const strip = comp.compilerRtStrip(); const strip = comp.compilerRtStrip();
const unwind_tables: std.builtin.UnwindTables = const unwind_tables: std.builtin.UnwindTables =
if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async"; if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .async;
const link_libcpp = target.os.tag.isDarwin(); const link_libcpp = target.os.tag.isDarwin();
const config = Compilation.Config.resolve(.{ const config = Compilation.Config.resolve(.{

View File

@ -29,7 +29,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
const output_mode = .Lib; const output_mode = .Lib;
const target = &comp.root_mod.resolved_target.result; const target = &comp.root_mod.resolved_target.result;
const unwind_tables: std.builtin.UnwindTables = const unwind_tables: std.builtin.UnwindTables =
if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async"; if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .async;
const config = Compilation.Config.resolve(.{ const config = Compilation.Config.resolve(.{
.output_mode = output_mode, .output_mode = output_mode,
.resolved_target = comp.root_mod.resolved_target, .resolved_target = comp.root_mod.resolved_target,

View File

@ -29,7 +29,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
const target = comp.getTarget(); const target = comp.getTarget();
// The old 32-bit x86 variant of SEH doesn't use tables. // The old 32-bit x86 variant of SEH doesn't use tables.
const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch != .x86) .@"async" else .none; const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch != .x86) .async else .none;
switch (crt_file) { switch (crt_file) {
.crt2_o => { .crt2_o => {

View File

@ -3596,7 +3596,7 @@ fn updateLazyType(
// For better or worse, we try to match what Clang emits. // For better or worse, we try to match what Clang emits.
break :cc switch (func_type.cc) { break :cc switch (func_type.cc) {
.@"inline" => .nocall, .@"inline" => .nocall,
.@"async", .auto, .naked => .normal, .async, .auto, .naked => .normal,
.x86_64_sysv => .LLVM_X86_64SysV, .x86_64_sysv => .LLVM_X86_64SysV,
.x86_64_win => .LLVM_Win64, .x86_64_win => .LLVM_Win64,
.x86_64_regcall_v3_sysv => .LLVM_X86RegCall, .x86_64_regcall_v3_sysv => .LLVM_X86RegCall,

View File

@ -1416,7 +1416,7 @@ fn buildOutputType(
} else if (mem.eql(u8, arg, "-funwind-tables")) { } else if (mem.eql(u8, arg, "-funwind-tables")) {
mod_opts.unwind_tables = .sync; mod_opts.unwind_tables = .sync;
} else if (mem.eql(u8, arg, "-fasync-unwind-tables")) { } else if (mem.eql(u8, arg, "-fasync-unwind-tables")) {
mod_opts.unwind_tables = .@"async"; mod_opts.unwind_tables = .async;
} else if (mem.eql(u8, arg, "-fno-unwind-tables")) { } else if (mem.eql(u8, arg, "-fno-unwind-tables")) {
mod_opts.unwind_tables = .none; mod_opts.unwind_tables = .none;
} else if (mem.eql(u8, arg, "-fstack-check")) { } else if (mem.eql(u8, arg, "-fstack-check")) {
@ -2035,15 +2035,15 @@ fn buildOutputType(
.none => { .none => {
mod_opts.unwind_tables = .sync; mod_opts.unwind_tables = .sync;
}, },
.sync, .@"async" => {}, .sync, .async => {},
} else { } else {
mod_opts.unwind_tables = .sync; mod_opts.unwind_tables = .sync;
}, },
.no_unwind_tables => mod_opts.unwind_tables = .none, .no_unwind_tables => mod_opts.unwind_tables = .none,
.asynchronous_unwind_tables => mod_opts.unwind_tables = .@"async", .asynchronous_unwind_tables => mod_opts.unwind_tables = .async,
.no_asynchronous_unwind_tables => if (mod_opts.unwind_tables) |uwt| switch (uwt) { .no_asynchronous_unwind_tables => if (mod_opts.unwind_tables) |uwt| switch (uwt) {
.none, .sync => {}, .none, .sync => {},
.@"async" => { .async => {
mod_opts.unwind_tables = .sync; mod_opts.unwind_tables = .sync;
}, },
} else { } else {
@ -2951,7 +2951,7 @@ fn buildOutputType(
create_module.opts.any_fuzz = true; create_module.opts.any_fuzz = true;
if (mod_opts.unwind_tables) |uwt| switch (uwt) { if (mod_opts.unwind_tables) |uwt| switch (uwt) {
.none => {}, .none => {},
.sync, .@"async" => create_module.opts.any_unwind_tables = true, .sync, .async => create_module.opts.any_unwind_tables = true,
}; };
if (mod_opts.strip == false) if (mod_opts.strip == false)
create_module.opts.any_non_stripped = true; create_module.opts.any_non_stripped = true;
@ -7413,7 +7413,7 @@ fn handleModArg(
create_module.opts.any_fuzz = true; create_module.opts.any_fuzz = true;
if (mod_opts.unwind_tables) |uwt| switch (uwt) { if (mod_opts.unwind_tables) |uwt| switch (uwt) {
.none => {}, .none => {},
.sync, .@"async" => create_module.opts.any_unwind_tables = true, .sync, .async => create_module.opts.any_unwind_tables = true,
}; };
if (mod_opts.strip == false) if (mod_opts.strip == false)
create_module.opts.any_non_stripped = true; create_module.opts.any_non_stripped = true;

View File

@ -483,12 +483,12 @@ pub fn clangSupportsNoImplicitFloatArg(target: *const std.Target) bool {
pub fn defaultUnwindTables(target: *const std.Target, libunwind: bool, libtsan: bool) std.builtin.UnwindTables { pub fn defaultUnwindTables(target: *const std.Target, libunwind: bool, libtsan: bool) std.builtin.UnwindTables {
if (target.os.tag == .windows) { if (target.os.tag == .windows) {
// The old 32-bit x86 variant of SEH doesn't use tables. // The old 32-bit x86 variant of SEH doesn't use tables.
return if (target.cpu.arch != .x86) .@"async" else .none; return if (target.cpu.arch != .x86) .async else .none;
} }
if (target.os.tag.isDarwin()) return .@"async"; if (target.os.tag.isDarwin()) return .async;
if (libunwind) return .@"async"; if (libunwind) return .async;
if (libtsan) return .@"async"; if (libtsan) return .async;
if (std.debug.Dwarf.abi.supportsUnwinding(target)) return .@"async"; if (std.debug.Dwarf.abi.supportsUnwinding(target)) return .async;
return .none; return .none;
} }
@ -815,7 +815,7 @@ pub fn compilerRtIntAbbrev(bits: u16) []const u8 {
pub fn fnCallConvAllowsZigTypes(cc: std.builtin.CallingConvention) bool { pub fn fnCallConvAllowsZigTypes(cc: std.builtin.CallingConvention) bool {
return switch (cc) { return switch (cc) {
.auto, .@"async", .@"inline" => true, .auto, .async, .@"inline" => true,
// For now we want to authorize PTX kernel to use zig objects, even if // For now we want to authorize PTX kernel to use zig objects, even if
// we end up exposing the ABI. The goal is to experiment with more // we end up exposing the ABI. The goal is to experiment with more
// integrated CPU/GPU code. // integrated CPU/GPU code.

View File

@ -29,7 +29,7 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("unwind.zig"), .root_source_file = b.path("unwind.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.unwind_tables = if (target.result.os.tag.isDarwin()) .@"async" else null, .unwind_tables = if (target.result.os.tag.isDarwin()) .async else null,
.omit_frame_pointer = false, .omit_frame_pointer = false,
}), }),
}); });
@ -54,7 +54,7 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("unwind.zig"), .root_source_file = b.path("unwind.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.unwind_tables = .@"async", .unwind_tables = .async,
.omit_frame_pointer = true, .omit_frame_pointer = true,
}), }),
// self-hosted lacks omit_frame_pointer support // self-hosted lacks omit_frame_pointer support
@ -101,7 +101,7 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("shared_lib_unwind.zig"), .root_source_file = b.path("shared_lib_unwind.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.unwind_tables = if (target.result.os.tag.isDarwin()) .@"async" else null, .unwind_tables = if (target.result.os.tag.isDarwin()) .async else null,
.omit_frame_pointer = true, .omit_frame_pointer = true,
}), }),
// zig objcopy doesn't support incremental binaries // zig objcopy doesn't support incremental binaries