authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-11 20:10:15+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-11 20:10:15+02:00
log78d6f1c56aa3bca72c3f336b89626982631da2e7
treeec59467f38b6837cd4e9f938d8d12e95b3f50c89
parent5e2b025f69ec0e811975c67b0eda5f11594225b9
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

mingw: Fix def file preprocessing.

This needs to actually set the target on the aro.Compilation so that we get the expected target-specific preprocessor macros defined.

1 files changed, 3 insertions(+), 10 deletions(-)

src/libs/mingw.zig+3-10
......@@ -295,18 +295,12 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
295295 "o", &digest, final_def_basename,
296296 });
297297
298 const target_defines = switch (target.cpu.arch) {
299 .thumb => "#define DEF_ARM32\n",
300 .aarch64 => "#define DEF_ARM64\n",
301 .x86 => "#define DEF_I386\n",
302 .x86_64 => "#define DEF_X64\n",
303 else => unreachable,
304 };
305
306298 const aro = @import("aro");
307299 var aro_comp = aro.Compilation.init(gpa, std.fs.cwd());
308300 defer aro_comp.deinit();
309301
302 aro_comp.target = target;
303
310304 const include_dir = try comp.dirs.zig_lib.join(arena, &.{ "libc", "mingw", "def-include" });
311305
312306 if (comp.verbose_cc) print: {
......@@ -321,7 +315,6 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
321315 try aro_comp.include_dirs.append(gpa, include_dir);
322316
323317 const builtin_macros = try aro_comp.generateBuiltinMacros(.include_system_defines);
324 const user_macros = try aro_comp.addSourceFromBuffer("<command line>", target_defines);
325318 const def_file_source = try aro_comp.addSourceFromPath(def_file_path);
326319
327320 var pp = aro.Preprocessor.init(&aro_comp);
......@@ -329,7 +322,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
329322 pp.linemarkers = .none;
330323 pp.preserve_whitespace = true;
331324
332 try pp.preprocessSources(&.{ def_file_source, builtin_macros, user_macros });
325 try pp.preprocessSources(&.{ def_file_source, builtin_macros });
333326
334327 for (aro_comp.diagnostics.list.items) |diagnostic| {
335328 if (diagnostic.kind == .@"fatal error" or diagnostic.kind == .@"error") {