Find Python3 in default env PATH for ACPO

Sync https://gitee.com/openeuler/llvm-project/pulls/102
This commit is contained in:
eastb233 2024-11-20 15:23:49 +08:00
parent 7e2834bd03
commit f941e83ab1
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,34 @@
From d4cfa4fd4496735ea45afcd2b0cfb3607cadd1c9 Mon Sep 17 00:00:00 2001
From: yinrun <lvyinrun@huawei.com>
Date: Thu, 17 Oct 2024 18:47:40 +0800
Subject: [PATCH] Find Python3 in default env PATH for ACPO
Enable the use of user python version, avoid the wrong version of python without AI infra.
---
llvm/lib/Analysis/ACPOMLInterface.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Analysis/ACPOMLInterface.cpp b/llvm/lib/Analysis/ACPOMLInterface.cpp
index f48eb46638e3..7d84bd5112d6 100644
--- a/llvm/lib/Analysis/ACPOMLInterface.cpp
+++ b/llvm/lib/Analysis/ACPOMLInterface.cpp
@@ -146,7 +146,15 @@ ACPOMLPythonInterface::ACPOMLPythonInterface() : NextID{0} {
}
int32_t PID = (int32_t) llvm::sys::Process::getProcessId();
- std::string ExecPython = "/usr/bin/python3";
+ std::string ExecPython;
+ llvm::ErrorOr<std::string> Res = llvm::sys::findProgramByName("python3");
+ if (std::error_code EC = Res.getError()) {
+ LLVM_DEBUG(dbgs() << "python3 could not be found, error_code " << EC.value() << "\n");
+ return;
+ } else {
+ ExecPython = Res.get();
+ LLVM_DEBUG(dbgs() << "python3 version found in " << ExecPython << "\n");
+ }
std::string
PythonScript = *Env + "/" + std::string(ACPO_ML_PYTHON_INTERFACE_PY);
std::string PIDStr = std::to_string(PID);
--
2.38.1.windows.1

View File

@ -47,7 +47,7 @@
Name: %{pkg_name} Name: %{pkg_name}
Version: %{maj_ver}.%{min_ver}.%{patch_ver} Version: %{maj_ver}.%{min_ver}.%{patch_ver}
Release: 27 Release: 28
Summary: The Low Level Virtual Machine Summary: The Low Level Virtual Machine
License: NCSA License: NCSA
@ -90,6 +90,7 @@ Patch29: 0029-SimplifyLibCalls-Merge-sqrt-into-the-power-of-exp-79.patch
Patch30: 0030-LICM-Solve-runtime-error-caused-by-the-signal-functi.patch Patch30: 0030-LICM-Solve-runtime-error-caused-by-the-signal-functi.patch
Patch31: 0031-ACPO-ACPO-Infrastructure.patch Patch31: 0031-ACPO-ACPO-Infrastructure.patch
Patch32: 0032-ACPO-Introduce-MLInliner-using-ACPO-infrastructure.patch Patch32: 0032-ACPO-Introduce-MLInliner-using-ACPO-infrastructure.patch
Patch33: 0033-Find-Python3-in-default-env-PATH-for-ACPO.patch
BuildRequires: binutils-devel BuildRequires: binutils-devel
BuildRequires: cmake BuildRequires: cmake
@ -389,6 +390,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake
%{install_includedir}/llvm-gmock %{install_includedir}/llvm-gmock
%changelog %changelog
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-28
- Find Python3 in default env PATH for ACPO
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-27 * Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-27
- ACPO Infrastructure for ML integration into LLVM compiler - ACPO Infrastructure for ML integration into LLVM compiler