Skip to content

Commit 78d6f1c

Browse files
committed
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 parent 5e2b025 commit 78d6f1c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/libs/mingw.zig

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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,15 +315,14 @@ 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);
328321
defer pp.deinit();
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") {

0 commit comments

Comments
 (0)