From 9d864d1c8ac31a633ad93cb4767fc97c00f267e0 Mon Sep 17 00:00:00 2001 From: Yufeng Jiang Date: Tue, 21 Nov 2023 13:52:40 +0100 Subject: [PATCH 1/6] add a SubCommitInteractionGraphPlot function --- .../plots/blame_interaction_graph_plots.py | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/varats/varats/plots/blame_interaction_graph_plots.py b/varats/varats/plots/blame_interaction_graph_plots.py index 7d06288a7..6b81fa168 100644 --- a/varats/varats/plots/blame_interaction_graph_plots.py +++ b/varats/varats/plots/blame_interaction_graph_plots.py @@ -1,5 +1,5 @@ """Module for BlameInteractionGraph plots.""" - +import subprocess import typing as tp from datetime import datetime from pathlib import Path @@ -280,6 +280,72 @@ def generate(self) -> tp.List[Plot]: ) +class SubCommitInteractionGraphPlot(Plot, plot_name='sub-cig_plot'): + + def is_submodule_change(self, commit_hash): + # Get the change information of the specified commit + subprocess.run(['git', 'checkout', commit_hash], check=True) + submodule_status = subprocess.run(['git', 'submodule', 'status'], capture_output=True, text=True) + + # Check if the output contains submodule changes + return "+Subproject" in submodule_status.stdout + def plot(self, view_mode: bool) -> None: + project_name = self.plot_kwargs["case_study"].project_name + commit_map = get_commit_map(project_name) + short_revision = ShortCommitHash(self.plot_kwargs["revision"]) + revision = commit_map.convert_to_full_or_warn(short_revision) + + cig = create_blame_interaction_graph( + project_name, revision, BlameReportExperiment + ).commit_interaction_graph() + nx.set_node_attributes( + cig, + {node: cig.nodes[node]["commit"].commit_hash for node in cig.nodes}, + "label" + ) + + # Find nodes representing commits that changed submodules + submodule_commit_nodes = [node for node in cig.nodes if + self.is_submodule_change(cig.nodes[node]["commit"].commit_hash)] + + # Color those nodes red + node_colors = ['red' if node in submodule_commit_nodes else 'blue' for node in cig.nodes] + + # Find nodes pointed to by red nodes + blue_nodes = set() + for node in submodule_commit_nodes: + blue_nodes.update(cig.successors(node)) + + # Color those nodes blue + for node in blue_nodes: + node_colors[node] = 'blue' + + # Draw the graph + pos = nx.spring_layout(cig) # You can choose a different layout if needed + nx.draw(cig, pos, with_labels=True, node_color=node_colors, font_color='white') + plt.show() + + + + def calc_missing_revisions( + self, boundary_gradient: float + ) -> tp.Set[FullCommitHash]: + raise UnsupportedOperation + + +class SubCIGPlotGenerator( + PlotGenerator, + generator_name="sub-cig-plot", + options=[REQUIRE_CASE_STUDY, REQUIRE_REVISION] +): + """Generates a plot for a submodule's commit interaction graph.""" + + def generate(self) -> tp.List[Plot]: + return [ + SubCommitInteractionGraphPlot(self.plot_config, **self.plot_kwargs) + ] + + class CommitInteractionGraphNodeDegreePlot(Plot, plot_name='cig_node_degrees'): """ Plot node degrees of a commit interaction graph. From e0cb15dcf110c63e5d6d2e875547e415ea8463a4 Mon Sep 17 00:00:00 2001 From: Yufeng Jiang Date: Tue, 28 Nov 2023 13:32:01 +0100 Subject: [PATCH 2/6] add some function to find submodule commits --- .../plots/blame_interaction_graph_plots.py | 114 ++++++++++++++---- 1 file changed, 91 insertions(+), 23 deletions(-) diff --git a/varats/varats/plots/blame_interaction_graph_plots.py b/varats/varats/plots/blame_interaction_graph_plots.py index 6b81fa168..498533c96 100644 --- a/varats/varats/plots/blame_interaction_graph_plots.py +++ b/varats/varats/plots/blame_interaction_graph_plots.py @@ -1,4 +1,5 @@ """Module for BlameInteractionGraph plots.""" +import configparser import subprocess import typing as tp from datetime import datetime @@ -9,6 +10,7 @@ import networkx as nx import pandas as pd import plotly.offline as offply +import pygit2 from varats.data.reports.blame_interaction_graph import ( create_blame_interaction_graph, @@ -18,7 +20,7 @@ CAIGNodeAttrs, ) from varats.experiments.vara.blame_report_experiment import ( - BlameReportExperiment, + BlameReportExperiment, BlameReportExperimentRegion, ) from varats.mapping.commit_map import get_commit_map from varats.paper_mgmt.case_study import ( @@ -64,7 +66,7 @@ def save(self, plot_dir: Path, filetype: str = 'svg') -> None: revision = commit_map.convert_to_full_or_warn(short_revision) cig = create_blame_interaction_graph( - project_name, revision, BlameReportExperiment + project_name, revision, BlameReportExperimentRegion ).commit_interaction_graph() nx.set_node_attributes( cig, @@ -109,7 +111,7 @@ def _prepare_cig_plotly( NodeTy, NodeTy, EdgeInfoTy]]]: commit_lookup = create_commit_lookup_helper(project_name) cig = create_blame_interaction_graph( - project_name, revision, BlameReportExperiment + project_name, revision, BlameReportExperimentRegion ).commit_interaction_graph() def filter_nodes(node: CommitRepoPair) -> bool: @@ -280,15 +282,79 @@ def generate(self) -> tp.List[Plot]: ) -class SubCommitInteractionGraphPlot(Plot, plot_name='sub-cig_plot'): +def get_gitmodules_info(): + repo = pygit2.Repository(REPO_PATH) + # Get the .gitmodules blob object + commit = repo[repo.head.target] + tree = commit.tree + gitmodules_entry = tree[".gitmodules"] + gitmodules_blob = repo[gitmodules_entry.oid] + + # Parse the .gitmodules file contents + gitmodules_data = gitmodules_blob.data + gitmodules_config = configparser.ConfigParser() + gitmodules_config.read_string(gitmodules_data.decode('utf-8')) + + # Collect the submodule path and URL information + submodules = [] + for section in gitmodules_config.sections(): + if section.startswith('submodule '): + submodule_name = section[len('submodule '):] + submodule_path = gitmodules_config.get(section, 'path') + submodule_url = gitmodules_config.get(section, 'url') + submodules.append((submodule_name, submodule_path, submodule_url)) + + return submodules + + +def pull_commit_history_information(submodules): + + # Get the tree object for the specified commit + repo = pygit2.Repository(REPO_PATH) + + commits = [] + i = 0 + for submodule in submodules: + walker = repo.walk(repo.head.target, pygit2.GIT_SORT_TOPOLOGICAL | pygit2.GIT_SORT_REVERSE) + subdirectory_path = submodule[1] + for commit in walker: + # Initialize a flag to check if the 'third_party' has changes in this commit + # has_changes = False + # Compare the tree of this commit with its parent + if len(commit.parents) == 0: + continue + diff = repo.diff(commit.parents[0], commit) + # Loop through all patches in the diff + files_changed = [patch.delta.new_file.path for patch in diff] + if any([file.startswith(subdirectory_path) for file in files_changed]): + i += 1 + print(i) # total 1864 times commits is for third party + commits.append({ + 'author_name': commit.author.name, + 'author_email': commit.author.email, + # 'message': commit.message, + 'commit_hash': commit.hex, + 'commit_time': datetime.datetime.fromtimestamp(commit.commit_time) + # 'changed_folder': get_change_folder(commit) + }) + + df = pd.DataFrame(commits) + # df.to_csv(TASK_PATH + 'openssl_commit_history2.csv', index=False) + + return df + + +class SubCommitInteractionGraphPlot(Plot, plot_name='sub-cig-plot'): + submodule_info = get_gitmodules_info() + df = pull_commit_history_information(submodule_info) def is_submodule_change(self, commit_hash): - # Get the change information of the specified commit - subprocess.run(['git', 'checkout', commit_hash], check=True) - submodule_status = subprocess.run(['git', 'submodule', 'status'], capture_output=True, text=True) + for index, row in self.df.iterrows(): + if row['commit_hash'] == commit_hash: + return True + else: + return False - # Check if the output contains submodule changes - return "+Subproject" in submodule_status.stdout def plot(self, view_mode: bool) -> None: project_name = self.plot_kwargs["case_study"].project_name commit_map = get_commit_map(project_name) @@ -296,7 +362,7 @@ def plot(self, view_mode: bool) -> None: revision = commit_map.convert_to_full_or_warn(short_revision) cig = create_blame_interaction_graph( - project_name, revision, BlameReportExperiment + project_name, revision, BlameReportExperimentRegion ).commit_interaction_graph() nx.set_node_attributes( cig, @@ -308,22 +374,24 @@ def plot(self, view_mode: bool) -> None: submodule_commit_nodes = [node for node in cig.nodes if self.is_submodule_change(cig.nodes[node]["commit"].commit_hash)] - # Color those nodes red - node_colors = ['red' if node in submodule_commit_nodes else 'blue' for node in cig.nodes] + # Count the number of unique authors for main repository and submodule changes + main_repo_authors = set() + submodule_change_authors = set() + + for node in cig.nodes: + commit_info = cig.nodes[node]["commit"] + author = commit_info.author_name # Assuming the existence of the author_name attribute, modify as needed + + main_repo_authors.add(author) - # Find nodes pointed to by red nodes - blue_nodes = set() - for node in submodule_commit_nodes: - blue_nodes.update(cig.successors(node)) + if node in submodule_commit_nodes: + submodule_change_authors.add(author) - # Color those nodes blue - for node in blue_nodes: - node_colors[node] = 'blue' + main_repo_author_count = len(main_repo_authors) + submodule_change_author_count = len(submodule_change_authors) - # Draw the graph - pos = nx.spring_layout(cig) # You can choose a different layout if needed - nx.draw(cig, pos, with_labels=True, node_color=node_colors, font_color='white') - plt.show() + print(f"Main Repository Authors: {main_repo_author_count}") + print(f"Authors with Submodule Changes: {submodule_change_author_count}") From 8ff6eb0465614b52dedfd722f37a796dc4e56f32 Mon Sep 17 00:00:00 2001 From: Yufeng Jiang Date: Wed, 8 May 2024 10:53:00 +0200 Subject: [PATCH 3/6] bcc, ompi, crun added --- varats-core/varats/project/project_domain.py | 2 + varats/varats/projects/c_projects/bcc.py | 121 +++++++++++++++++++ varats/varats/projects/c_projects/crun.py | 72 +++++++++++ varats/varats/projects/c_projects/ompi.py | 100 +++++++++++++++ varats/varats/tools/bb_config.py | 3 + 5 files changed, 298 insertions(+) create mode 100644 varats/varats/projects/c_projects/bcc.py create mode 100644 varats/varats/projects/c_projects/crun.py create mode 100644 varats/varats/projects/c_projects/ompi.py diff --git a/varats-core/varats/project/project_domain.py b/varats-core/varats/project/project_domain.py index 071ed9605..dcf78d864 100644 --- a/varats-core/varats/project/project_domain.py +++ b/varats-core/varats/project/project_domain.py @@ -31,6 +31,8 @@ class ProjectDomains(Enum): UNIX_TOOLS = "UNIX utils" VERSION_CONTROL = "Version control" WEB_TOOLS = "Web tools" + RUNTIME = "Runtime" + MPI = "Message Passing Interface" def __str__(self) -> str: return str(self.value) diff --git a/varats/varats/projects/c_projects/bcc.py b/varats/varats/projects/c_projects/bcc.py new file mode 100644 index 000000000..4e9ca5de5 --- /dev/null +++ b/varats/varats/projects/c_projects/bcc.py @@ -0,0 +1,121 @@ +"""Project file for the bcc.""" +import typing as tp + +import benchbuild as bb +from benchbuild.utils.cmd import make, mkdir, cmake, sudo +from benchbuild.utils.settings import get_number_of_jobs +from plumbum import local + +from varats.containers.containers import get_base_image, ImageBase +from varats.paper.paper_config import ( + project_filter_generator, + PaperConfigSpecificGit, +) +from varats.project.project_domain import ProjectDomains +from varats.project.project_util import ( + ProjectBinaryWrapper, + BinaryType, + verify_binaries, + get_local_project_git_path, +) +from varats.project.varats_project import VProject +from varats.utils.git_util import ShortCommitHash, RevisionBinaryMap +from varats.utils.settings import bb_cfg + + +class Bcc(VProject): + + NAME = 'bcc' + GROUP = 'c_projects' + DOMAIN = ProjectDomains.UNIX_TOOLS + + SOURCE = [ + PaperConfigSpecificGit( + project_name="bcc", + remote="https://github.com/iovisor/bcc", + local="bcc", + refspec="origin/HEAD", + limit=None, + shallow=False + ), + bb.source.GitSubmodule( + remote="https://github.com/libbpf/libbpf.git", + local="bcc/src/cc/libbpf", + refspec="origin/HEAD", + limit=None, + shallow=False, + version_filter=project_filter_generator("bcc") + ), + bb.source.GitSubmodule( + remote="https://github.com/libbpf/bpftool", + local="bcc/libbpf-tools/bpftool", + refspec="origin/HEAD", + limit=None, + shallow=False, + version_filter=project_filter_generator("bcc") + ), + bb.source.GitSubmodule( + remote="https://github.com/libbpf/blazesym", + local="bcc/ibbpf-tools/blazesym", + refspec="origin/HEAD", + limit=None, + shallow=False, + version_filter=project_filter_generator("bcc") + ) + ] + + @staticmethod + def binaries_for_revision( + revision: ShortCommitHash + ) -> tp.List[ProjectBinaryWrapper]: + binary_map = RevisionBinaryMap(get_local_project_git_path(Bcc.NAME)) + + binary_map.specify_binary("build/bcc", BinaryType.EXECUTABLE) + + return binary_map[revision] + + # def compile(self) -> None: + # bcc_source = local.path(self.source_of_primary) + # compiler = bb.compiler.cc(self) + # with local.cwd(bcc_source): + # with local.env(CC=str(compiler)): + # # 使用 CMake 来配置项目 + # bb.watch(local["mkdir"])("-p", "build") # 创建构建目录 + # with local.cwd("build"): + # bb.watch(local["cmake"])("..", "-DCMAKE_BUILD_TYPE=Release") + # # 根据需要添加其他CMake配置选项,如指定编译器或禁用特定特性 + # + # # 在构建目录下执行 make + # with local.cwd("build"): + # bb.watch(cmake)("-j", get_number_of_jobs(bb_cfg())) + # + # # 校验编译后的二进制文件 + # verify_binaries(self) + + def compile(self) -> None: + bcc_source = local.path(self.source_of_primary) + compiler = bb.compiler.cc(self) + with local.cwd(bcc_source): + with local.env(CC=str(compiler)): + # 创建构建目录 + mkdir("-p", "build") + with local.cwd("build"): + # 设置 LLVM 的路径 + llvm_path = "/lib/llvm-14/lib/cmake/llvm/" + # 使用 CMake 配置项目,并指定 LLVM 的路径 + bb.watch(local["cmake"])("..", "-DCMAKE_BUILD_TYPE=Release", f"-DLLVM_DIR={llvm_path}") + # 执行编译 + bb.watch(local["make"])("-j", get_number_of_jobs(bb_cfg())) + # 执行安装(需要管理员权限) + bb.watch(local["sudo"][local["make"]["install"]])() + + # 配置 Python 绑定 + bb.watch(local["cmake"])("..", "-DPYTHON_CMD=python3") + + # 构建并安装 Python 绑定 + with local.cwd("src/python"): + bb.watch(local["make"])() + bb.watch(local["sudo"][local["make"]["install"]])() + + # 校验编译后的二进制文件 + verify_binaries(self) diff --git a/varats/varats/projects/c_projects/crun.py b/varats/varats/projects/c_projects/crun.py new file mode 100644 index 000000000..fb41967b8 --- /dev/null +++ b/varats/varats/projects/c_projects/crun.py @@ -0,0 +1,72 @@ +"""Project file for the Crun.""" +import typing as tp + +import benchbuild as bb +from benchbuild.utils.cmd import make +from benchbuild.utils.settings import get_number_of_jobs +from plumbum import local + +from varats.containers.containers import get_base_image, ImageBase +from varats.paper.paper_config import ( + project_filter_generator, + PaperConfigSpecificGit, +) +from varats.project.project_domain import ProjectDomains +from varats.project.project_util import ( + ProjectBinaryWrapper, + BinaryType, + verify_binaries, + get_local_project_git_path, +) +from varats.project.varats_project import VProject +from varats.utils.git_util import ShortCommitHash, RevisionBinaryMap +from varats.utils.settings import bb_cfg + + +class Crun(VProject): + + NAME = 'crun' + GROUP = 'c_projects' + DOMAIN = ProjectDomains.RUNTIME + + SOURCE = [ + PaperConfigSpecificGit( + project_name="crun", + remote="https://github.com/containers/crun", + local="crun", + refspec="origin/HEAD", + limit=None, + shallow=False + ), + bb.source.GitSubmodule( + remote="https://github.com/containers/libocispec.git", + local="crun/libocispec", + refspec="origin/HEAD", + limit=None, + shallow=False, + version_filter=project_filter_generator("crun") + ) + ] + + @staticmethod + def binaries_for_revision( + revision: ShortCommitHash + ) -> tp.List[ProjectBinaryWrapper]: + binary_map = RevisionBinaryMap(get_local_project_git_path(Crun.NAME)) + + binary_map.specify_binary("crun", BinaryType.EXECUTABLE) + + return binary_map[revision] + + def compile(self) -> None: + crun_source = local.path(self.source_of_primary) + compiler = bb.compiler.cc(self) + with local.cwd(crun_source): + with local.env(CC=str(compiler)): + bb.watch(local["./autogen.sh"])() + bb.watch(local["./configure"])("--disable-gcc-warnings") + + bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) + + verify_binaries(self) + diff --git a/varats/varats/projects/c_projects/ompi.py b/varats/varats/projects/c_projects/ompi.py new file mode 100644 index 000000000..6611df83d --- /dev/null +++ b/varats/varats/projects/c_projects/ompi.py @@ -0,0 +1,100 @@ +"""Project file for the open-mpi.""" +import typing as tp + +import benchbuild as bb +from benchbuild.utils.cmd import make, mkdir +from benchbuild.utils.settings import get_number_of_jobs +from plumbum import local + +from varats.containers.containers import get_base_image, ImageBase +from varats.paper.paper_config import ( + project_filter_generator, + PaperConfigSpecificGit, +) +from varats.project.project_domain import ProjectDomains +from varats.project.project_util import ( + ProjectBinaryWrapper, + BinaryType, + verify_binaries, + get_local_project_git_path, +) +from varats.project.varats_project import VProject +from varats.utils.git_util import ShortCommitHash, RevisionBinaryMap +from varats.utils.settings import bb_cfg + + +class Ompi(VProject): + + NAME = 'ompi' + GROUP = 'c_projects' + DOMAIN = ProjectDomains.MPI + + SOURCE = [ + PaperConfigSpecificGit( + project_name="ompi", + remote="https://github.com/open-mpi/ompi", + local="ompi", + refspec="origin/HEAD", + limit=None, + shallow=False + ), + bb.source.GitSubmodule( + remote="https://github.com/openpmix/prrte.git", + local="ompi/3rd-party/prrte", + refspec="heads/master", + limit=None, + shallow=False, + version_filter=project_filter_generator("ompi") + ), + bb.source.GitSubmodule( + remote="https://github.com/openpmix/openpmix.git", + local="ompi/3rd-party/openpmix", + refspec="heads/master", + limit=None, + shallow=False, + version_filter=project_filter_generator("ompi") + ), + bb.source.GitSubmodule( + remote="https://github.com/open-mpi/oac", + local="ompi/config/oac", + refspec="origin/HEAD", + limit=None, + shallow=False, + version_filter=project_filter_generator("ompi") + ) + ] + + @staticmethod + def binaries_for_revision( + revision: ShortCommitHash + ) -> tp.List[ProjectBinaryWrapper]: + binary_map = RevisionBinaryMap(get_local_project_git_path(Ompi.NAME)) + + binary_map.specify_binary("ompi/ompi", BinaryType.EXECUTABLE) + + return binary_map[revision] + + + def compile(self) -> None: + ompi_source = local.path(self.source_of_primary) + compiler = bb.compiler.cc(self) + with local.cwd(ompi_source): + with local.env(CC=str(compiler)): + # bb.watch(local["./autogen.pl"])() + # bb.watch(local["./configure"])("--disable-gcc-warnings") + try: + bb.watch(local["./autogen.pl"])() + bb.watch(local["./configure"])("--disable-gcc-warnings") + except Exception as e: + print(f"配置过程中出现错误: {e}") + # 输出config.log的内容以便调试 + config_log_path = ompi_source / "config.log" + if config_log_path.is_file(): + with open(config_log_path, "r") as log_file: + print(log_file.read()) + return + + bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) + + verify_binaries(self) + diff --git a/varats/varats/tools/bb_config.py b/varats/varats/tools/bb_config.py index 482f8ae02..150da6be1 100644 --- a/varats/varats/tools/bb_config.py +++ b/varats/varats/tools/bb_config.py @@ -66,6 +66,9 @@ def update_projects( 'varats.projects.c_projects.vim', 'varats.projects.c_projects.x264', 'varats.projects.c_projects.xz', + 'varats.projects.c_projects.bcc', + 'varats.projects.c_projects.crun', + 'varats.projects.c_projects.ompi', 'varats.projects.cpp_projects.clasp', 'varats.projects.cpp_projects.fast_downward', 'varats.projects.cpp_projects.libzmq', From 0fbc79dc266156ee39648f21fd80076ea93d6faa Mon Sep 17 00:00:00 2001 From: Yufeng Jiang Date: Fri, 10 May 2024 10:05:09 +0200 Subject: [PATCH 4/6] Modified compile of ompi and bcc --- varats/varats/projects/c_projects/bcc.py | 55 +++++++---------------- varats/varats/projects/c_projects/ompi.py | 6 +-- 2 files changed, 18 insertions(+), 43 deletions(-) diff --git a/varats/varats/projects/c_projects/bcc.py b/varats/varats/projects/c_projects/bcc.py index 4e9ca5de5..d1c4fdefd 100644 --- a/varats/varats/projects/c_projects/bcc.py +++ b/varats/varats/projects/c_projects/bcc.py @@ -70,52 +70,27 @@ def binaries_for_revision( ) -> tp.List[ProjectBinaryWrapper]: binary_map = RevisionBinaryMap(get_local_project_git_path(Bcc.NAME)) - binary_map.specify_binary("build/bcc", BinaryType.EXECUTABLE) + binary_map.specify_binary("build/src/cc/libbcc.so.0.30.0", BinaryType.SHARED_LIBRARY) return binary_map[revision] - # def compile(self) -> None: - # bcc_source = local.path(self.source_of_primary) - # compiler = bb.compiler.cc(self) - # with local.cwd(bcc_source): - # with local.env(CC=str(compiler)): - # # 使用 CMake 来配置项目 - # bb.watch(local["mkdir"])("-p", "build") # 创建构建目录 - # with local.cwd("build"): - # bb.watch(local["cmake"])("..", "-DCMAKE_BUILD_TYPE=Release") - # # 根据需要添加其他CMake配置选项,如指定编译器或禁用特定特性 - # - # # 在构建目录下执行 make - # with local.cwd("build"): - # bb.watch(cmake)("-j", get_number_of_jobs(bb_cfg())) - # - # # 校验编译后的二进制文件 - # verify_binaries(self) - def compile(self) -> None: + """Compile the BCC project.""" bcc_source = local.path(self.source_of_primary) - compiler = bb.compiler.cc(self) - with local.cwd(bcc_source): - with local.env(CC=str(compiler)): - # 创建构建目录 - mkdir("-p", "build") - with local.cwd("build"): - # 设置 LLVM 的路径 - llvm_path = "/lib/llvm-14/lib/cmake/llvm/" - # 使用 CMake 配置项目,并指定 LLVM 的路径 - bb.watch(local["cmake"])("..", "-DCMAKE_BUILD_TYPE=Release", f"-DLLVM_DIR={llvm_path}") - # 执行编译 - bb.watch(local["make"])("-j", get_number_of_jobs(bb_cfg())) - # 执行安装(需要管理员权限) - bb.watch(local["sudo"][local["make"]["install"]])() + mkdir("-p", bcc_source / "build") - # 配置 Python 绑定 - bb.watch(local["cmake"])("..", "-DPYTHON_CMD=python3") + cc_compiler = bb.compiler.cc(self) + with local.cwd(bcc_source / 'build'): + with local.env(CC=str(cc_compiler)): + llvm_path = "/lib/llvm-14/lib/cmake/llvm/" + bb.watch(cmake)("..", "-DCMAKE_BUILD_TYPE=Release", f"-DLLVM_DIR={llvm_path}", + "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", + "-DCMAKE_C_FLAGS=-fPIE", "-DCMAKE_CXX_FLAGS=-fPIE", + "-DCMAKE_EXE_LINKER_FLAGS=-pie" + ) # Configuring the project - # 构建并安装 Python 绑定 - with local.cwd("src/python"): - bb.watch(local["make"])() - bb.watch(local["sudo"][local["make"]["install"]])() + # Compiling the project with make, specifying the number of jobs + bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) - # 校验编译后的二进制文件 verify_binaries(self) + diff --git a/varats/varats/projects/c_projects/ompi.py b/varats/varats/projects/c_projects/ompi.py index 6611df83d..adacd712d 100644 --- a/varats/varats/projects/c_projects/ompi.py +++ b/varats/varats/projects/c_projects/ompi.py @@ -70,7 +70,7 @@ def binaries_for_revision( ) -> tp.List[ProjectBinaryWrapper]: binary_map = RevisionBinaryMap(get_local_project_git_path(Ompi.NAME)) - binary_map.specify_binary("ompi/ompi", BinaryType.EXECUTABLE) + binary_map.specify_binary("/opt/openmpi/", BinaryType.EXECUTABLE) return binary_map[revision] @@ -86,8 +86,8 @@ def compile(self) -> None: bb.watch(local["./autogen.pl"])() bb.watch(local["./configure"])("--disable-gcc-warnings") except Exception as e: - print(f"配置过程中出现错误: {e}") - # 输出config.log的内容以便调试 + print(f"An error occurred during configuration: {e}") + # Output the contents of config.log for debugging config_log_path = ompi_source / "config.log" if config_log_path.is_file(): with open(config_log_path, "r") as log_file: From 5e19816d298881fe78b25734b624a4560c6c0902 Mon Sep 17 00:00:00 2001 From: Yufeng Jiang Date: Fri, 10 May 2024 13:19:37 +0200 Subject: [PATCH 5/6] Modified compile of bcc --- varats/varats/projects/c_projects/bcc.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/varats/varats/projects/c_projects/bcc.py b/varats/varats/projects/c_projects/bcc.py index d1c4fdefd..709ec06ae 100644 --- a/varats/varats/projects/c_projects/bcc.py +++ b/varats/varats/projects/c_projects/bcc.py @@ -70,7 +70,7 @@ def binaries_for_revision( ) -> tp.List[ProjectBinaryWrapper]: binary_map = RevisionBinaryMap(get_local_project_git_path(Bcc.NAME)) - binary_map.specify_binary("build/src/cc/libbcc.so.0.30.0", BinaryType.SHARED_LIBRARY) + binary_map.specify_binary("build/src/cc/libbcc.so", BinaryType.SHARED_LIBRARY) return binary_map[revision] @@ -83,14 +83,18 @@ def compile(self) -> None: with local.cwd(bcc_source / 'build'): with local.env(CC=str(cc_compiler)): llvm_path = "/lib/llvm-14/lib/cmake/llvm/" - bb.watch(cmake)("..", "-DCMAKE_BUILD_TYPE=Release", f"-DLLVM_DIR={llvm_path}", - "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", + bb.watch(cmake)("..", + # "-DCMAKE_BUILD_TYPE=Release", + f"-DLLVM_DIR={llvm_path}", + # "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DCMAKE_C_FLAGS=-fPIE", "-DCMAKE_CXX_FLAGS=-fPIE", - "-DCMAKE_EXE_LINKER_FLAGS=-pie" + # "-DCMAKE_EXE_LINKER_FLAGS=-pie" ) # Configuring the project + # Compiling the project with make, specifying the number of jobs + bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) - # Compiling the project with make, specifying the number of jobs - bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) - + with local.cwd(bcc_source): verify_binaries(self) + + From 9ca09e87f5e5a91c24a1140fc55d5b0406b84778 Mon Sep 17 00:00:00 2001 From: Yufeng Jiang Date: Wed, 22 May 2024 13:29:26 +0200 Subject: [PATCH 6/6] New modifications to bcc and ompi compilation --- varats/varats/projects/c_projects/bcc.py | 7 +++--- varats/varats/projects/c_projects/ompi.py | 29 +++++++++-------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/varats/varats/projects/c_projects/bcc.py b/varats/varats/projects/c_projects/bcc.py index 709ec06ae..2db00ba1a 100644 --- a/varats/varats/projects/c_projects/bcc.py +++ b/varats/varats/projects/c_projects/bcc.py @@ -80,12 +80,13 @@ def compile(self) -> None: mkdir("-p", bcc_source / "build") cc_compiler = bb.compiler.cc(self) + cxx_compiler = bb.compiler.cxx(self) with local.cwd(bcc_source / 'build'): - with local.env(CC=str(cc_compiler)): - llvm_path = "/lib/llvm-14/lib/cmake/llvm/" + with local.env(CC=str(cc_compiler), CXX=cxx_compiler): + # llvm_path = "/lib/llvm-14/lib/cmake/llvm/" bb.watch(cmake)("..", # "-DCMAKE_BUILD_TYPE=Release", - f"-DLLVM_DIR={llvm_path}", + # f"-DLLVM_DIR={llvm_path}", # "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DCMAKE_C_FLAGS=-fPIE", "-DCMAKE_CXX_FLAGS=-fPIE", # "-DCMAKE_EXE_LINKER_FLAGS=-pie" diff --git a/varats/varats/projects/c_projects/ompi.py b/varats/varats/projects/c_projects/ompi.py index adacd712d..0945666db 100644 --- a/varats/varats/projects/c_projects/ompi.py +++ b/varats/varats/projects/c_projects/ompi.py @@ -70,31 +70,24 @@ def binaries_for_revision( ) -> tp.List[ProjectBinaryWrapper]: binary_map = RevisionBinaryMap(get_local_project_git_path(Ompi.NAME)) - binary_map.specify_binary("/opt/openmpi/", BinaryType.EXECUTABLE) + binary_map.specify_binary("build/ompi", BinaryType.EXECUTABLE) return binary_map[revision] def compile(self) -> None: ompi_source = local.path(self.source_of_primary) - compiler = bb.compiler.cc(self) - with local.cwd(ompi_source): - with local.env(CC=str(compiler)): - # bb.watch(local["./autogen.pl"])() - # bb.watch(local["./configure"])("--disable-gcc-warnings") - try: - bb.watch(local["./autogen.pl"])() - bb.watch(local["./configure"])("--disable-gcc-warnings") - except Exception as e: - print(f"An error occurred during configuration: {e}") - # Output the contents of config.log for debugging - config_log_path = ompi_source / "config.log" - if config_log_path.is_file(): - with open(config_log_path, "r") as log_file: - print(log_file.read()) - return + mkdir("-p", ompi_source / "build") - bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) + cc_compiler = bb.compiler.cc(self) + cxx_compiler = bb.compiler.cxx(self) + with local.cwd(ompi_source): + with local.env(CC=str(cc_compiler), CXX=cxx_compiler): + bb.watch(local["./autogen.pl"])() + with local.cwd(ompi_source / "build"): + bb.watch(local["../configure"])("--disable-mpi-fortran") + bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) + with local.cwd(ompi_source): verify_binaries(self)