Merge pull request #19152 from antlilja/llvm-broken-debug

LLVM: Fail to emit if LLVM encounters broken debug info
This commit is contained in:
Andrew Kelley
2024-03-02 21:43:39 -08:00
committed by GitHub
4 changed files with 38 additions and 2 deletions

View File

@@ -1245,9 +1245,11 @@ pub const Object = struct {
);
defer bitcode_memory_buffer.dispose();
context.enableBrokenDebugInfoCheck();
var module: *llvm.Module = undefined;
if (context.parseBitcodeInContext2(bitcode_memory_buffer, &module).toBool()) {
std.debug.print("Failed to parse bitcode\n", .{});
if (context.parseBitcodeInContext2(bitcode_memory_buffer, &module).toBool() or context.getBrokenDebugInfo()) {
log.err("Failed to parse bitcode", .{});
return error.FailedToEmit;
}
break :emit .{ context, module };

View File

@@ -37,6 +37,12 @@ pub const Context = opaque {
pub const setOptBisectLimit = ZigLLVMSetOptBisectLimit;
extern fn ZigLLVMSetOptBisectLimit(C: *Context, limit: c_int) void;
pub const enableBrokenDebugInfoCheck = ZigLLVMEnableBrokenDebugInfoCheck;
extern fn ZigLLVMEnableBrokenDebugInfoCheck(C: *Context) void;
pub const getBrokenDebugInfo = ZigLLVMGetBrokenDebugInfo;
extern fn ZigLLVMGetBrokenDebugInfo(C: *Context) bool;
};
pub const Module = opaque {