From c0435f14076280d1011f9122d6845ce638b409c8 Mon Sep 17 00:00:00 2001 From: doupengda Date: Fri, 25 Apr 2025 14:38:23 +0800 Subject: [PATCH] fix larchintrin.h not found error for loongarch64 --- ...in.h-not-found-error-for-loongarch64.patch | 60 +++++++++++++++++++ bcc.spec | 7 ++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 0001-fix-larchintrin.h-not-found-error-for-loongarch64.patch diff --git a/0001-fix-larchintrin.h-not-found-error-for-loongarch64.patch b/0001-fix-larchintrin.h-not-found-error-for-loongarch64.patch new file mode 100644 index 0000000..fc4ef89 --- /dev/null +++ b/0001-fix-larchintrin.h-not-found-error-for-loongarch64.patch @@ -0,0 +1,60 @@ +From be2ed7456877f1e29cc55d92ad0b571b2394e2ee Mon Sep 17 00:00:00 2001 +From: doupengda +Date: Fri, 25 Apr 2025 06:31:36 +0000 +Subject: [PATCH] fix larchintrin.h not found error for loongarch64 + +--- + src/python/bcc/__init__.py | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py +index 8bc8551..78aa8c2 100644 +--- a/src/python/bcc/__init__.py ++++ b/src/python/bcc/__init__.py +@@ -22,6 +22,7 @@ import re + import errno + import sys + import platform ++import subprocess + + from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE + from .table import Table, PerfEventArray, RingBuf, BPF_MAP_TYPE_QUEUE, BPF_MAP_TYPE_STACK +@@ -455,6 +456,35 @@ class BPF(object): + if gcc_include_path_str: + cflags.append("-I" + gcc_include_path_str) + ++ # Fix 'larchintrin.h' file not found error for loongarch64 ++ architecture = platform.machine() ++ if architecture == 'loongarch64': ++ ++ # get clang include path ++ try: ++ clang_include_path_output = subprocess.check_output(['clang', '-print-file-name=include'], stderr=subprocess.STDOUT) ++ clang_include_path_str = clang_include_path_output.decode('utf-8').strip('\n') ++ if not os.path.exists(clang_include_path_str): ++ clang_include_path_str = False ++ except Exception as e: ++ clang_include_path_str = False ++ ++ # get gcc include path ++ try: ++ gcc_include_path_output = subprocess.check_output(['gcc', '-print-file-name=include'], stderr=subprocess.STDOUT) ++ gcc_include_path_str = gcc_include_path_output.decode('utf-8').strip('\n') ++ if not os.path.exists(gcc_include_path_str): ++ gcc_include_path_str = False ++ except Exception as e: ++ gcc_include_path_str = False ++ ++ # add clang and gcc include path for cflags ++ if clang_include_path_str: ++ cflags.append("-I" + clang_include_path_str) ++ ++ if gcc_include_path_str: ++ cflags.append("-I" + gcc_include_path_str) ++ + self.kprobe_fds = {} + self.uprobe_fds = {} + self.tracepoint_fds = {} +-- +2.41.0 + diff --git a/bcc.spec b/bcc.spec index ab58f01..6725cb6 100644 --- a/bcc.spec +++ b/bcc.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 %ifarch loongarch64 %bcond_without ignore_lua %bcond_with libbpf_tools @@ -16,6 +16,8 @@ License: Apache-2.0 URL: https://github.com/iovisor/bcc Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch1000: 0001-fix-larchintrin.h-not-found-error-for-loongarch64.patch + BuildRequires: cmake >= 2.8.12 llvm-devel clang-devel llvm-googletest BuildRequires: flex bison python3-setuptools BuildRequires: elfutils-libelf-devel elfutils-debuginfod-client-devel @@ -191,6 +193,9 @@ install -p libbpf-tools/tmp-install/bin/* %{buildroot}/%{_sbindir}/ %endif %changelog +* Fri Apr 25 2025 doupengda - 0.32.0-2 +- fix larchintrin.h not found error for loongarch64 + * Wed Feb 19 2025 Zhao Hang - 0.32.0-1 - Update to 0.32.0-1 from 0.30.0-1 - Migrated to SPDX license -- Gitee