diff --git a/lib/compiler/aro/aro/Driver.zig b/lib/compiler/aro/aro/Driver.zig index 8db4fd8464c5..c92ef15da18e 100644 --- a/lib/compiler/aro/aro/Driver.zig +++ b/lib/compiler/aro/aro/Driver.zig @@ -765,7 +765,7 @@ fn processSource( const fmt_template = "{s}{s}"; const fmt_args = .{ std.fs.path.stem(source.path), - d.comp.target.ofmt.fileExt(d.comp.target.abi, d.comp.target.cpu.arch), + d.comp.target.objFileExt(), }; break :blk d.output_name orelse std.fmt.bufPrint(&name_buf, fmt_template, fmt_args) catch return d.fatal("Filename too long for filesystem: " ++ fmt_template, fmt_args); @@ -781,7 +781,7 @@ fn processSource( const fmt_template = "/tmp/{s}{s}"; const fmt_args = .{ random_name, - d.comp.target.ofmt.fileExt(d.comp.target.abi, d.comp.target.cpu.arch), + d.comp.target.objFileExt(), }; break :blk std.fmt.bufPrint(&name_buf, fmt_template, fmt_args) catch return d.fatal("Filename too long for filesystem: " ++ fmt_template, fmt_args); }; diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 05bfede73a36..b724c08ec29a 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -2045,6 +2045,10 @@ pub fn exeFileExt(target: Target) [:0]const u8 { return target.os.tag.exeFileExt(target.cpu.arch); } +pub fn objFileExt(target: Target) [:0]const u8 { + return target.ofmt.fileExt(target.abi, target.cpu.arch); +} + pub fn staticLibSuffix(target: Target) [:0]const u8 { return target.os.tag.staticLibSuffix(target.abi); } diff --git a/lib/std/zig.zig b/lib/std/zig.zig index 88c020e71b4f..8c68c84abc1e 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -232,7 +232,7 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe .plan9 => switch (options.output_mode) { .Exe => return allocator.dupe(u8, root_name), .Obj => return std.fmt.allocPrint(allocator, "{s}{s}", .{ - root_name, t.ofmt.fileExt(t.abi, t.cpu.arch), + root_name, t.objFileExt(), }), .Lib => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ t.libPrefix(), root_name, diff --git a/src/Compilation.zig b/src/Compilation.zig index f4f9bb1e9c30..4c8f3fefbedd 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -4714,7 +4714,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr c_source_basename[0 .. c_source_basename.len - std.fs.path.extension(c_source_basename).len]; const target = comp.getTarget(); - const o_ext = target.ofmt.fileExt(target.abi, target.cpu.arch); + const o_ext = target.objFileExt(); const digest = if (!comp.disable_c_depfile and try man.hit()) man.final() else blk: { var argv = std.ArrayList([]const u8).init(gpa); defer argv.deinit(); @@ -5972,7 +5972,7 @@ pub const FileExt = enum { .assembly => ".s", .assembly_with_cpp => ".S", .shared_library => target.dynamicLibSuffix(), - .object => target.ofmt.fileExt(target.abi, target.cpu.arch), + .object => target.objFileExt(), .static_library => target.staticLibSuffix(), .zig => ".zig", .def => ".def", diff --git a/tools/docgen.zig b/tools/docgen.zig index a7ebf59984d5..e02a4f39da2b 100644 --- a/tools/docgen.zig +++ b/tools/docgen.zig @@ -14,7 +14,7 @@ const fatal = std.zig.fatal; const max_doc_file_size = 10 * 1024 * 1024; -const obj_ext = builtin.object_format.fileExt(builtin.abi, builtin.cpu.arch); +const obj_ext = builtin.target.objFileExt(); const usage = \\Usage: docgen [options] input output diff --git a/tools/doctest.zig b/tools/doctest.zig index 2b50a89b0a17..0f52bb5bce8c 100644 --- a/tools/doctest.zig +++ b/tools/doctest.zig @@ -107,7 +107,7 @@ fn printOutput( try env_map.put("CLICOLOR_FORCE", "1"); const host = try std.zig.system.resolveTargetQuery(.{}); - const obj_ext = builtin.object_format.fileExt(builtin.abi, builtin.cpu.arch); + const obj_ext = builtin.target.objFileExt(); const print = std.debug.print; var shell_buffer = std.ArrayList(u8).init(arena);