| ... | ... | @@ -221,14 +221,19 @@ pub fn flush(self: *C, comp: *Compilation, prog_node: *std.Progress.Node) !void |
| 221 | 221 | return self.flushModule(comp, prog_node); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | | fn abiDefine(comp: *Compilation) ?[]const u8 { |
| 225 | | return switch (comp.getTarget().abi) { |
| 226 | | .msvc => "#define ZIG_TARGET_ABI_MSVC\n", |
| 227 | | else => null, |
| 228 | | }; |
| 224 | fn abiDefines(self: *C, target: std.Target) !std.ArrayList(u8) { |
| 225 | var defines = std.ArrayList(u8).init(self.base.allocator); |
| 226 | errdefer defines.deinit(); |
| 227 | const writer = defines.writer(); |
| 228 | switch (target.abi) { |
| 229 | .msvc => try writer.writeAll("#define ZIG_TARGET_ABI_MSVC\n"), |
| 230 | else => {}, |
| 231 | } |
| 232 | try writer.print("#define ZIG_TARGET_MAX_INT_ALIGNMENT {d}\n", .{target.maxIntAlignment()}); |
| 233 | return defines; |
| 229 | 234 | } |
| 230 | 235 | |
| 231 | | pub fn flushModule(self: *C, comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 236 | pub fn flushModule(self: *C, _: *Compilation, prog_node: *std.Progress.Node) !void { |
| 232 | 237 | const tracy = trace(@src()); |
| 233 | 238 | defer tracy.end(); |
| 234 | 239 | |
| ... | ... | @@ -245,12 +250,13 @@ pub fn flushModule(self: *C, comp: *Compilation, prog_node: *std.Progress.Node) |
| 245 | 250 | var f: Flush = .{}; |
| 246 | 251 | defer f.deinit(gpa); |
| 247 | 252 | |
| 248 | | const abi_define = abiDefine(comp); |
| 253 | const abi_defines = try self.abiDefines(module.getTarget()); |
| 254 | defer abi_defines.deinit(); |
| 249 | 255 | |
| 250 | 256 | // Covers defines, zig.h, ctypes, asm, lazy fwd. |
| 251 | 257 | try f.all_buffers.ensureUnusedCapacity(gpa, 5); |
| 252 | 258 | |
| 253 | | if (abi_define) |buf| f.appendBufAssumeCapacity(buf); |
| 259 | f.appendBufAssumeCapacity(abi_defines.items); |
| 254 | 260 | f.appendBufAssumeCapacity(zig_h); |
| 255 | 261 | |
| 256 | 262 | const ctypes_index = f.all_buffers.items.len; |