Skip to content

Commit 8c976e4

Browse files
committed
Fix loglevel and pylibbpf import in codegen
1 parent 60737d9 commit 8c976e4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pythonbpf/codegen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import subprocess
1616
import inspect
1717
from pathlib import Path
18-
from pylibbpf import BpfProgram
18+
from pylibbpf import BpfObject
1919
import tempfile
2020
from logging import Logger
2121
import logging
@@ -158,15 +158,17 @@ def _run_llc(ll_file, obj_file):
158158
return False
159159

160160

161-
def compile(loglevel=logging.INFO) -> bool:
161+
def compile(loglevel=logging.WARNING) -> bool:
162162
# Look one level up the stack to the caller of this function
163163
caller_frame = inspect.stack()[1]
164164
caller_file = Path(caller_frame.filename).resolve()
165165

166166
ll_file = Path("/tmp") / caller_file.with_suffix(".ll").name
167167
o_file = caller_file.with_suffix(".o")
168168

169-
compile_to_ir(str(caller_file), str(ll_file), loglevel=loglevel)
169+
_, structs_sym_tab, maps_sym_tab = compile_to_ir(
170+
str(caller_file), str(ll_file), loglevel=loglevel
171+
)
170172

171173
if not _run_llc(ll_file, o_file):
172174
logger.error("Compilation to object file failed.")
@@ -176,7 +178,7 @@ def compile(loglevel=logging.INFO) -> bool:
176178
return True
177179

178180

179-
def BPF(loglevel=logging.INFO) -> BpfProgram:
181+
def BPF(loglevel=logging.WARNING) -> BpfObject:
180182
caller_frame = inspect.stack()[1]
181183
src = inspect.getsource(caller_frame.frame)
182184
with tempfile.NamedTemporaryFile(
@@ -194,6 +196,4 @@ def BPF(loglevel=logging.INFO) -> BpfProgram:
194196
)
195197
_run_llc(str(inter.name), str(obj_file.name))
196198

197-
return BpfProgram(
198-
str(obj_file.name), structs=structs_sym_tab, maps=maps_sym_tab
199-
)
199+
return BpfObject(str(obj_file.name), structs=structs_sym_tab)

0 commit comments

Comments
 (0)