From f941e83ab117546f75fc69b64ecb73c56709689d Mon Sep 17 00:00:00 2001 From: eastb233 Date: Wed, 20 Nov 2024 15:23:49 +0800 Subject: [PATCH] Find Python3 in default env PATH for ACPO Sync https://gitee.com/openeuler/llvm-project/pulls/102 --- ...Python3-in-default-env-PATH-for-ACPO.patch | 34 +++++++++++++++++++ llvm.spec | 6 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 0033-Find-Python3-in-default-env-PATH-for-ACPO.patch diff --git a/0033-Find-Python3-in-default-env-PATH-for-ACPO.patch b/0033-Find-Python3-in-default-env-PATH-for-ACPO.patch new file mode 100644 index 0000000..6c93c96 --- /dev/null +++ b/0033-Find-Python3-in-default-env-PATH-for-ACPO.patch @@ -0,0 +1,34 @@ +From d4cfa4fd4496735ea45afcd2b0cfb3607cadd1c9 Mon Sep 17 00:00:00 2001 +From: yinrun +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 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 + diff --git a/llvm.spec b/llvm.spec index 8b7825f..fabd4ed 100644 --- a/llvm.spec +++ b/llvm.spec @@ -47,7 +47,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 27 +Release: 28 Summary: The Low Level Virtual Machine 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 Patch31: 0031-ACPO-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: cmake @@ -389,6 +390,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake %{install_includedir}/llvm-gmock %changelog +* Wed Nov 20 2024 eastb233 - 17.0.6-28 +- Find Python3 in default env PATH for ACPO + * Wed Nov 20 2024 eastb233 - 17.0.6-27 - ACPO Infrastructure for ML integration into LLVM compiler