authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-06-17 20:07:43-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-06-17 20:07:43-07:00
loga851256a988f01e8fd9a6c84a9bac499e81f407d
tree798cf02fbeea50d6f22cc01523ff60a29febaf91
parenta20f7a9dd613d31dbc9caf663a263be7fc9df6a5

mingw: Only preprocess .def.in files

The .def files don't have any preprocessor commands so running them through the preprocessor is useless work.

2 files changed, 23 insertions(+), 16 deletions(-)

src/libs/mingw.zig+21-16
......@@ -226,6 +226,8 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
226226 },
227227 else => |e| return e,
228228 };
229 // Only .def.in files need preprocessing
230 const def_needs_preprocessing = mem.endsWith(u8, def_file_path, ".def.in");
229231
230232 const target = comp.getTarget();
231233
......@@ -292,22 +294,25 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
292294 }
293295
294296 const members = members: {
295 const input = pp: {
296 var aw: Io.Writer.Allocating = .init(gpa);
297 errdefer aw.deinit();
298
299 var pp_arena = std.heap.ArenaAllocator.init(gpa);
300 defer pp_arena.deinit();
301 var pp: Preprocessor = .{
302 .io = io,
303 .arena = pp_arena.allocator(),
304 .include_dir = include_dir,
305 .target = target,
306 };
307 try pp.preprocess(def_file_path);
308 try pp.prettyPrintTokens(&aw.writer);
309
310 break :pp try aw.toOwnedSliceSentinel(0);
297 const input = switch (def_needs_preprocessing) {
298 true => pp: {
299 var aw: Io.Writer.Allocating = .init(gpa);
300 errdefer aw.deinit();
301
302 var pp_arena = std.heap.ArenaAllocator.init(gpa);
303 defer pp_arena.deinit();
304 var pp: Preprocessor = .{
305 .io = io,
306 .arena = pp_arena.allocator(),
307 .include_dir = include_dir,
308 .target = target,
309 };
310 try pp.preprocess(def_file_path);
311 try pp.prettyPrintTokens(&aw.writer);
312
313 break :pp try aw.toOwnedSliceSentinel(0);
314 },
315 false => try Io.Dir.cwd().readFileAllocOptions(io, def_file_path, gpa, .unlimited, .of(u8), 0),
311316 };
312317 defer gpa.free(input);
313318
tools/check_mingw.zig+2
......@@ -28,6 +28,8 @@ pub fn main(init: std.process.Init) !void {
2828
2929 while (try walker.next(io)) |entry| {
3030 if (entry.kind != .file) continue;
31 // Only .def.in files need preprocessing
32 if (!std.mem.endsWith(u8, entry.basename, ".def.in")) continue;
3133
3234 var fail = false;
3335 for (&targets) |*target| {