Skip to content

Commit 5ce4474

Browse files
debug info versioning
1 parent e218e48 commit 5ce4474

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

pythonbpf/codegen.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,21 @@ def compile_to_ir(filename: str, output: str):
5252
frame_pointer = module.add_metadata([ir.Constant(ir.IntType(32), 7),
5353
"frame-pointer",
5454
ir.Constant(ir.IntType(32), 2)])
55+
# Add Debug Info Version (3 = DWARF v3, which LLVM expects)
56+
debug_info_version = module.add_metadata([ir.Constant(ir.IntType(32), 2),
57+
"Debug Info Version",
58+
ir.Constant(ir.IntType(32), 3)])
59+
60+
# Add explicit DWARF version (4 is common, works with LLVM BPF backend)
61+
dwarf_version = module.add_metadata([ir.Constant(ir.IntType(32), 2),
62+
"Dwarf Version",
63+
ir.Constant(ir.IntType(32), 4)])
64+
5565
module.add_named_metadata("llvm.module.flags", wchar_size)
5666
module.add_named_metadata("llvm.module.flags", frame_pointer)
67+
module.add_named_metadata("llvm.module.flags", debug_info_version)
68+
module.add_named_metadata("llvm.module.flags", dwarf_version)
69+
5770
module.add_named_metadata("llvm.ident", ["llvmlite PythonBPF v0.0.0"])
5871

5972
with open(output, "w") as f:

0 commit comments

Comments
 (0)