| ... | @@ -1238,7 +1238,26 @@ pub const Object = struct { | ... | @@ -1238,7 +1238,26 @@ pub const Object = struct { |
| 1238 | if (options.asm_path == null and options.bin_path == null and | 1238 | if (options.asm_path == null and options.bin_path == null and |
| 1239 | options.post_ir_path == null and options.post_bc_path == null) return; | 1239 | options.post_ir_path == null and options.post_bc_path == null) return; |
| 1240 | | 1240 | |
| 1241 | if (!self.builder.useLibLlvm()) unreachable; // caught in Compilation.Config.resolve | 1241 | if (options.post_bc_path) |path| { |
| | 1242 | if (!self.builder.useLibLlvm()) { |
| | 1243 | var arena_allocator = std.heap.ArenaAllocator.init(self.gpa); |
| | 1244 | defer arena_allocator.deinit(); |
| | 1245 | const arena = arena_allocator.allocator(); |
| | 1246 | |
| | 1247 | var file = try std.fs.cwd().createFileZ(path, .{}); |
| | 1248 | defer file.close(); |
| | 1249 | const bitcode = try self.builder.toBitcode(arena); |
| | 1250 | |
| | 1251 | const ptr: [*]const u8 = @ptrCast(bitcode.ptr); |
| | 1252 | try file.writeAll(ptr[0..(bitcode.len * 4)]); |
| | 1253 | return; |
| | 1254 | } |
| | 1255 | } |
| | 1256 | |
| | 1257 | if (!self.builder.useLibLlvm()) { |
| | 1258 | log.err("emitting without libllvm not implemented", .{}); |
| | 1259 | return error.FailedToEmit; |
| | 1260 | } |
| 1242 | | 1261 | |
| 1243 | // Unfortunately, LLVM shits the bed when we ask for both binary and assembly. | 1262 | // Unfortunately, LLVM shits the bed when we ask for both binary and assembly. |
| 1244 | // So we call the entire pipeline multiple times if this is requested. | 1263 | // So we call the entire pipeline multiple times if this is requested. |