authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2021-08-13 12:52:36-06:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-08-21 20:40:07+03:00
logf28868e8fd4028cad29bd2de8c0aa1c1713c69dd
tree75a4e5013fa1e43749dc3b81ab1abbc743f68528
parent27e321628587fd82b431dbbed1e6ba99e6df24a6

mingw.zig: fix logic to add crt sources

The current version of code uses isARM to check if we are compiling to any arm target then checks the target bit width to either add the 32-bit sources or 64-bit source. However, isARM only returns true for 32-bit targets, and isAARCH64 is for the 64-bit targets. I also replaced the unreachable with a @panic when we receive an unsupported arch because this code is reachable and should turn into an error.

1 files changed, 17 insertions(+), 19 deletions(-)

src/mingw.zig+17-19
......@@ -187,27 +187,25 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
187187 };
188188 }
189189 } else if (target.cpu.arch.isARM()) {
190 if (target.cpu.arch.ptrBitWidth() == 32) {
191 for (mingwex_arm32_src) |dep| {
192 (try c_source_files.addOne()).* = .{
193 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
194 "libc", "mingw", dep,
195 }),
196 .extra_flags = extra_flags,
197 };
198 }
199 } else {
200 for (mingwex_arm64_src) |dep| {
201 (try c_source_files.addOne()).* = .{
202 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
203 "libc", "mingw", dep,
204 }),
205 .extra_flags = extra_flags,
206 };
207 }
190 for (mingwex_arm32_src) |dep| {
191 (try c_source_files.addOne()).* = .{
192 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
193 "libc", "mingw", dep,
194 }),
195 .extra_flags = extra_flags,
196 };
197 }
198 } else if (target.cpu.arch.isAARCH64()) {
199 for (mingwex_arm64_src) |dep| {
200 (try c_source_files.addOne()).* = .{
201 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
202 "libc", "mingw", dep,
203 }),
204 .extra_flags = extra_flags,
205 };
208206 }
209207 } else {
210 unreachable;
208 @panic("unsupported arch");
211209 }
212210 return comp.build_crt_file("mingwex", .Lib, c_source_files.items);
213211 },