Skip to content

Commit 97dad71

Browse files
committed
rc compilation: Do not use addCCArgs to setup .rc preprocessor argv
- Almost all of the args it adds are irrelevant to the .rc preprocessor - Some of the args it adds are detrimental to the .rc preprocessor, e.g. _DEBUG/NDEBUG should not be defined during .rc preprocessing Instead, we manually add the few relevant args that addCCArgs would usually handle.
1 parent 7f8b771 commit 97dad71

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Compilation.zig

+19-1
Original file line numberDiff line numberDiff line change
@@ -4528,7 +4528,25 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
45284528
});
45294529

45304530
const out_dep_path = try std.fmt.allocPrint(arena, "{s}.d", .{out_rcpp_path});
4531-
try comp.addCCArgs(arena, &argv, .rc, out_dep_path);
4531+
// addCCArgs is not used here because:
4532+
// - Almost all of the args it adds are irrelevant to the .rc preprocessor
4533+
// - Some of the args it adds are detrimental to the .rc preprocessor,
4534+
// e.g. _DEBUG/NDEBUG should not be defined during .rc preprocessing
4535+
//
4536+
// Instead, we manually add the few relevant args that addCCArgs would usually handle.
4537+
try argv.append("--no-default-config");
4538+
if (!comp.clang_passthrough_mode) {
4539+
// Make stderr more easily parseable.
4540+
try argv.append("-fno-caret-diagnostics");
4541+
}
4542+
const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, comp.getTarget());
4543+
try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
4544+
try argv.append("-nostdinc");
4545+
for (comp.rc_include_dir_list) |include_dir| {
4546+
try argv.append("-isystem");
4547+
try argv.append(include_dir);
4548+
}
4549+
try argv.appendSlice(&[_][]const u8{ "-MD", "-MV", "-MF", out_dep_path });
45324550

45334551
if (comp.verbose_cc) {
45344552
dump_argv(argv.items);

0 commit comments

Comments
 (0)