Skip to content

Commit a299a02

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 c2b0b87 commit a299a02

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
@@ -4542,7 +4542,25 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
45424542
});
45434543

45444544
const out_dep_path = try std.fmt.allocPrint(arena, "{s}.d", .{out_rcpp_path});
4545-
try comp.addCCArgs(arena, &argv, .rc, out_dep_path);
4545+
// addCCArgs is not used here because:
4546+
// - Almost all of the args it adds are irrelevant to the .rc preprocessor
4547+
// - Some of the args it adds are detrimental to the .rc preprocessor,
4548+
// e.g. _DEBUG/NDEBUG should not be defined during .rc preprocessing
4549+
//
4550+
// Instead, we manually add the few relevant args that addCCArgs would usually handle.
4551+
try argv.append("--no-default-config");
4552+
if (!comp.clang_passthrough_mode) {
4553+
// Make stderr more easily parseable.
4554+
try argv.append("-fno-caret-diagnostics");
4555+
}
4556+
const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, comp.getTarget());
4557+
try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
4558+
try argv.append("-nostdinc");
4559+
for (comp.rc_include_dir_list) |include_dir| {
4560+
try argv.append("-isystem");
4561+
try argv.append(include_dir);
4562+
}
4563+
try argv.appendSlice(&[_][]const u8{ "-MD", "-MV", "-MF", out_dep_path });
45464564

45474565
if (comp.verbose_cc) {
45484566
dump_argv(argv.items);

0 commit comments

Comments
 (0)