| author | |
| committer | |
| log | 471f279cd621cef7c826fe27f1f8d0c585cc76e2 |
| tree | c82e6464d5f39a5b08f48472eff9f776ff8ef413 |
| parent | 0168ed7bf1c7fc5010fa82eaf33ed1b3af817709 |
Also update the standalone test so that this failure would have been detected on any host system.2 files changed, 23 insertions(+), 3 deletions(-)
src/Compilation.zig+13| ... | ... | @@ -4513,6 +4513,19 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 4513 | 4513 | "-fms-compatibility", // Allow things like "header.h" to be resolved relative to the 'root' .rc file, among other things |
| 4514 | 4514 | "-DRC_INVOKED", // https://learn.microsoft.com/en-us/windows/win32/menurc/predefined-macros |
| 4515 | 4515 | }); |
| 4516 | // Using -fms-compatibility and targeting the gnu abi interact in a strange way: | |
| 4517 | // - Targeting the GNU abi stops _MSC_VER from being defined | |
| 4518 | // - Passing -fms-compatibility stops __GNUC__ from being defined | |
| 4519 | // Neither being defined is a problem for things like things like MinGW's | |
| 4520 | // vadefs.h, which will fail during preprocessing if neither are defined. | |
| 4521 | // So, when targeting the GNU abi, we need to force __GNUC__ to be defined. | |
| 4522 | // | |
| 4523 | // TODO: This is a workaround that should be removed if possible. | |
| 4524 | if (comp.getTarget().isGnu()) { | |
| 4525 | // This is the same default gnuc version that Clang uses: | |
| 4526 | // https://github.com/llvm/llvm-project/blob/4b5366c9512aa273a5272af1d833961e1ed156e7/clang/lib/Driver/ToolChains/Clang.cpp#L6738 | |
| 4527 | try argv.append("-fgnuc-version=4.2.1"); | |
| 4528 | } | |
| 4516 | 4529 | for (options.extra_include_paths.items) |extra_include_path| { |
| 4517 | 4530 | try argv.append("--include-directory"); |
| 4518 | 4531 | try argv.append(extra_include_path); |
test/standalone/windows_resources/build.zig+10-3| ... | ... | @@ -11,11 +11,14 @@ pub fn build(b: *std.Build) void { |
| 11 | 11 | .abi = .gnu, |
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | add(b, native_target, test_step); | |
| 15 | add(b, cross_target, test_step); | |
| 14 | add(b, native_target, .any, test_step); | |
| 15 | add(b, cross_target, .any, test_step); | |
| 16 | ||
| 17 | add(b, native_target, .gnu, test_step); | |
| 18 | add(b, cross_target, .gnu, test_step); | |
| 16 | 19 | } |
| 17 | 20 | |
| 18 | fn add(b: *std.Build, target: std.zig.CrossTarget, test_step: *std.Build.Step) void { | |
| 21 | fn add(b: *std.Build, target: std.zig.CrossTarget, rc_includes: enum { any, gnu }, test_step: *std.Build.Step) void { | |
| 19 | 22 | const exe = b.addExecutable(.{ |
| 20 | 23 | .name = "zig_resource_test", |
| 21 | 24 | .root_source_file = .{ .path = "main.zig" }, |
| ... | ... | @@ -26,6 +29,10 @@ fn add(b: *std.Build, target: std.zig.CrossTarget, test_step: *std.Build.Step) v |
| 26 | 29 | .file = .{ .path = "res/zig.rc" }, |
| 27 | 30 | .flags = &.{"/c65001"}, // UTF-8 code page |
| 28 | 31 | }); |
| 32 | exe.rc_includes = switch (rc_includes) { | |
| 33 | .any => .any, | |
| 34 | .gnu => .gnu, | |
| 35 | }; | |
| 29 | 36 | |
| 30 | 37 | _ = exe.getEmittedBin(); |
| 31 | 38 |