Skip to content

Commit e9747a9

Browse files
zhangzikang01dkruces
authored andcommitted
Fix larchintrin.h not found error for loongarch64
Signed-off-by: zhangzikang01 <[email protected]>
1 parent 5c55c74 commit e9747a9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/python/bcc/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,31 @@ def __init__(self, src_file=b"", hdr_file=b"", text=None, debug=0,
430430

431431
assert not (text and src_file)
432432

433+
# Fix 'larchintrin.h' file not found error for loongarch64
434+
architecture = platform.machine()
435+
if architecture == 'loongarch64':
436+
# get clang include path
437+
try:
438+
clang_include_path_output = subprocess.check_output(['clang', '-print-file-name=include'], stderr=subprocess.STDOUT)
439+
clang_include_path_str = clang_include_path_output.decode('utf-8').strip('\n')
440+
if not os.path.exists(clang_include_path_str):
441+
clang_include_path_str = False
442+
except Exception as e:
443+
clang_include_path_str = False
444+
# get gcc include path
445+
try:
446+
gcc_include_path_output = subprocess.check_output(['gcc', '-print-file-name=include'], stderr=subprocess.STDOUT)
447+
gcc_include_path_str = gcc_include_path_output.decode('utf-8').strip('\n')
448+
if not os.path.exists(gcc_include_path_str):
449+
gcc_include_path_str = False
450+
except Exception as e:
451+
gcc_include_path_str = False
452+
# add clang and gcc include path for cflags
453+
if clang_include_path_str:
454+
cflags.append("-I" + clang_include_path_str)
455+
if gcc_include_path_str:
456+
cflags.append("-I" + gcc_include_path_str)
457+
433458
self.kprobe_fds = {}
434459
self.uprobe_fds = {}
435460
self.tracepoint_fds = {}

0 commit comments

Comments
 (0)