From 81a61c8ecd7a970dc96a6068cf8587fd81ebd6e4 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Wed, 18 Oct 2023 18:00:50 -0700 Subject: Sync resinator with upstream and fix INCLUDE env var handling The INCLUDE variable being used during `.rc` preprocessing was an accidental regression in https://github.com/ziglang/zig/pull/17412. Closes #17585. resinator changes: source_mapping: Protect against NUL bytes in #line filenames lex: Avoid recalculating column on every tab stop within string literals Proper error handling for failing to open cwd instead of `catch unreachable` Use platform-specific delimiter for INCLUDE env var parsing --- src/Compilation.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 8032e67943..5f9448c50f 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -4755,6 +4755,10 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 }; defer options.deinit(); + // We never want to read the INCLUDE environment variable, so + // unconditionally set `ignore_include_env_var` to true + options.ignore_include_env_var = true; + var argv = std.ArrayList([]const u8).init(comp.gpa); defer argv.deinit(); -- cgit v1.2.3 From 8ec04b567e3f37b82b870b6c595419905cbfcafd Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Wed, 18 Oct 2023 18:12:22 -0700 Subject: Error if an .rc file uses the 'preprocess only' or 'no preprocess' flags --- lib/std/Build/Step/Compile.zig | 2 ++ src/Compilation.zig | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Compilation.zig') diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index 90e20c10c3..c6070adc4f 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -243,6 +243,8 @@ pub const RcSourceFile = struct { file: LazyPath, /// Any option that rc.exe accepts will work here, with the exception of: /// - `/fo`: The output filename is set by the build system + /// - `/p`: Only running the preprocessor is not supported in this context + /// - `/:no-preprocess` (non-standard option): Not supported in this context /// - Any MUI-related option /// https://learn.microsoft.com/en-us/windows/win32/menurc/using-rc-the-rc-command-line- /// diff --git a/src/Compilation.zig b/src/Compilation.zig index 5f9448c50f..6d32876384 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -4759,11 +4759,17 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 // unconditionally set `ignore_include_env_var` to true options.ignore_include_env_var = true; + if (options.preprocess != .yes) { + return comp.failWin32Resource(win32_resource, "the '{s}' option is not supported in this context", .{switch (options.preprocess) { + .no => "/:no-preprocess", + .only => "/p", + .yes => unreachable, + }}); + } + var argv = std.ArrayList([]const u8).init(comp.gpa); defer argv.deinit(); - // TODO: support options.preprocess == .no and .only - // alternatively, error if those options are used try argv.appendSlice(&[_][]const u8{ self_exe_path, "clang" }); try resinator.preprocess.appendClangArgs(arena, &argv, options, .{ -- cgit v1.2.3