[Sync] Sync patch from openeuler/pin-gcc-client
This commit is contained in:
parent
20585f562b
commit
8c8f013cae
37
0011-Fix-BUILD-errors.patch
Normal file
37
0011-Fix-BUILD-errors.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
From 767bc6e10b7286ba22a2a1c0129d978abf094d44 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?=E9=83=91=E6=99=A8=E5=8D=89?= <zhengchenhui1@huawei.com>
|
||||||
|
Date: Thu, 7 Sep 2023 10:52:04 +0800
|
||||||
|
Subject: [PATCH 1/2] Fix BUILD errors
|
||||||
|
|
||||||
|
---
|
||||||
|
CMakeLists.txt | 1 +
|
||||||
|
lib/PluginClient/PluginLog.cpp | 1 +
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index fcd737b..a0df8c8 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -33,6 +33,7 @@ include(TableGen)
|
||||||
|
include(AddLLVM)
|
||||||
|
include(AddMLIR)
|
||||||
|
|
||||||
|
+include_directories(${GRPC_INCLUDE_DIR})
|
||||||
|
include_directories(${LLVM_INCLUDE_DIRS})
|
||||||
|
include_directories(${MLIR_INCLUDE_DIRS})
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||||
|
diff --git a/lib/PluginClient/PluginLog.cpp b/lib/PluginClient/PluginLog.cpp
|
||||||
|
index 7ace548..c9320a5 100644
|
||||||
|
--- a/lib/PluginClient/PluginLog.cpp
|
||||||
|
+++ b/lib/PluginClient/PluginLog.cpp
|
||||||
|
@@ -27,6 +27,7 @@
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <csignal>
|
||||||
|
+#include <unistd.h>
|
||||||
|
#include "PluginClient/PluginLog.h"
|
||||||
|
|
||||||
|
namespace PinClient {
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
216
0012-PluginClient-Update-transfer-command.patch
Normal file
216
0012-PluginClient-Update-transfer-command.patch
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
From b622cc8d95f4ef8bd417d94974e9ff83104beab9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
|
||||||
|
Date: Sat, 2 Sep 2023 15:59:19 +0800
|
||||||
|
Subject: [PATCH 2/2] [PluginClient] Update transfer command.
|
||||||
|
|
||||||
|
---
|
||||||
|
include/PluginAPI/BasicPluginOpsAPI.h | 1 +
|
||||||
|
include/PluginAPI/PluginClientAPI.h | 1 +
|
||||||
|
lib/PluginAPI/PluginClientAPI.cpp | 3 ++
|
||||||
|
lib/PluginClient/PluginClient.cpp | 78 +++++++++++++++++++++++++--
|
||||||
|
lib/Translate/GimpleToPluginOps.cpp | 11 ++--
|
||||||
|
5 files changed, 87 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/include/PluginAPI/BasicPluginOpsAPI.h b/include/PluginAPI/BasicPluginOpsAPI.h
|
||||||
|
index 22da8df..37bd73d 100644
|
||||||
|
--- a/include/PluginAPI/BasicPluginOpsAPI.h
|
||||||
|
+++ b/include/PluginAPI/BasicPluginOpsAPI.h
|
||||||
|
@@ -48,6 +48,7 @@ public:
|
||||||
|
virtual string FuncName(int64_t gccDataAddr) = 0;
|
||||||
|
virtual int GetDeclSourceLine(uint64_t gccDataAddr) = 0;
|
||||||
|
virtual int GetDeclSourceColumn(uint64_t gccDataAddr) = 0;
|
||||||
|
+ virtual void ShutdownCompile() = 0;
|
||||||
|
|
||||||
|
// CGnode
|
||||||
|
virtual vector<uint64_t> GetCGnodeIDs() = 0;
|
||||||
|
diff --git a/include/PluginAPI/PluginClientAPI.h b/include/PluginAPI/PluginClientAPI.h
|
||||||
|
index 26ef71d..43e7154 100644
|
||||||
|
--- a/include/PluginAPI/PluginClientAPI.h
|
||||||
|
+++ b/include/PluginAPI/PluginClientAPI.h
|
||||||
|
@@ -38,6 +38,7 @@ public:
|
||||||
|
string FuncName(int64_t gccDataAddr) override;
|
||||||
|
int GetDeclSourceLine(uint64_t gccDataAddr) override;
|
||||||
|
int GetDeclSourceColumn(uint64_t gccDataAddr) override;
|
||||||
|
+ void ShutdownCompile() override;
|
||||||
|
|
||||||
|
uint64_t CreateBlock(uint64_t, uint64_t) override;
|
||||||
|
void DeleteBlock(uint64_t, uint64_t) override;
|
||||||
|
diff --git a/lib/PluginAPI/PluginClientAPI.cpp b/lib/PluginAPI/PluginClientAPI.cpp
|
||||||
|
index 95e9ab3..55f46f7 100644
|
||||||
|
--- a/lib/PluginAPI/PluginClientAPI.cpp
|
||||||
|
+++ b/lib/PluginAPI/PluginClientAPI.cpp
|
||||||
|
@@ -17,6 +17,7 @@
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PluginAPI/PluginClientAPI.h"
|
||||||
|
+#include <unistd.h>
|
||||||
|
|
||||||
|
namespace PluginAPI {
|
||||||
|
|
||||||
|
@@ -92,6 +93,8 @@ vector<FunctionOp> PluginClientAPI::GetAllFunc()
|
||||||
|
return gimpleConversion.GetAllFunction();
|
||||||
|
}
|
||||||
|
|
||||||
|
+void PluginClientAPI::ShutdownCompile() { _exit(0); }
|
||||||
|
+
|
||||||
|
vector<uint64_t> PluginClientAPI::GetFunctions()
|
||||||
|
{
|
||||||
|
return gimpleConversion.GetFunctionIDs();
|
||||||
|
diff --git a/lib/PluginClient/PluginClient.cpp b/lib/PluginClient/PluginClient.cpp
|
||||||
|
index c9f3cb7..cf3036d 100644
|
||||||
|
--- a/lib/PluginClient/PluginClient.cpp
|
||||||
|
+++ b/lib/PluginClient/PluginClient.cpp
|
||||||
|
@@ -25,6 +25,10 @@
|
||||||
|
#include "Dialect/PluginTypes.h"
|
||||||
|
#include "PluginAPI/PluginClientAPI.h"
|
||||||
|
|
||||||
|
+#include "gcc-plugin.h"
|
||||||
|
+#include "plugin-version.h"
|
||||||
|
+#include "toplev.h"
|
||||||
|
+#include "opts.h"
|
||||||
|
namespace PinClient {
|
||||||
|
using namespace mlir::Plugin;
|
||||||
|
using namespace mlir;
|
||||||
|
@@ -344,6 +348,16 @@ void SetDeclAlignResult(PluginClient *client, Json::Value& root, string& result)
|
||||||
|
client->ReceiveSendMsg("VoidResult", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void ShutdownCompile(PluginClient *client, Json::Value& root, string& result)
|
||||||
|
+{
|
||||||
|
+ // Load our Dialect in this MLIR Context.
|
||||||
|
+ mlir::MLIRContext context;
|
||||||
|
+ context.getOrLoadDialect<PluginDialect>();
|
||||||
|
+ PluginAPI::PluginClientAPI clientAPI(context);
|
||||||
|
+ clientAPI.ShutdownCompile();
|
||||||
|
+ client->ReceiveSendMsg("VoidResult", result);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void SetUserAlignResult(PluginClient *client, Json::Value& root, string& result)
|
||||||
|
{
|
||||||
|
/// Json格式
|
||||||
|
@@ -1335,6 +1349,7 @@ std::map<string, GetResultFunc> g_getResultFunc = {
|
||||||
|
{"IsDomInfoAvailable", IsDomInfoAvailableResult},
|
||||||
|
{"GetCurrentDefFromSSA", GetCurrentDefFromSSAResult},
|
||||||
|
{"SetCurrentDefInSSA", SetCurrentDefInSSAResult},
|
||||||
|
+ {"ShutdownCompile", ShutdownCompile},
|
||||||
|
{"CopySSAOp", CopySSAOpResult},
|
||||||
|
{"CreateSSAOp", CreateSSAOpResult},
|
||||||
|
{"CreateNewDef", CreateNewDefResult},
|
||||||
|
@@ -1543,7 +1558,12 @@ static bool WaitServer(const string& port)
|
||||||
|
mode_t mask = umask(0);
|
||||||
|
mode_t mode = 0666; // 权限是rwrwrw,跨进程时,其他用户也要可以访问
|
||||||
|
string semFile = "wait_server_startup" + port;
|
||||||
|
- sem_t *sem = sem_open(semFile.c_str(), O_CREAT, mode, 0);
|
||||||
|
+ sem_t *sem = sem_open(semFile.c_str(), O_CREAT | O_EXCL, mode, 0);
|
||||||
|
+ // Semaphore exception handling.
|
||||||
|
+ if (sem == SEM_FAILED) {
|
||||||
|
+ sem_unlink(semFile.c_str());
|
||||||
|
+ sem = sem_open(semFile.c_str(), O_CREAT, mode, 0);
|
||||||
|
+ }
|
||||||
|
umask(mask);
|
||||||
|
int i = 0;
|
||||||
|
for (; i < cnt; i++) {
|
||||||
|
@@ -1561,11 +1581,60 @@ static bool WaitServer(const string& port)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
+bool ExecuteWithCommand(string serverPath, string port, string level)
|
||||||
|
+{
|
||||||
|
+ string inputFile (main_input_filename);
|
||||||
|
+ string cwd = get_current_dir_name();
|
||||||
|
+
|
||||||
|
+ string outputName="";
|
||||||
|
+ for (int i = 0; i< save_decoded_options_count; ++i) {
|
||||||
|
+ if (!strcmp(save_decoded_options[i].canonical_option[0],"-o")) {
|
||||||
|
+ outputName = save_decoded_options[i].canonical_option[1];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ string common_opt = "";
|
||||||
|
+ for (int i = 0; i< save_decoded_options_count; ++i) {
|
||||||
|
+ if (!strcmp(save_decoded_options[i].canonical_option[0],"-I") ||
|
||||||
|
+ !strcmp(save_decoded_options[i].canonical_option[0],"-D")) {
|
||||||
|
+ common_opt.append(save_decoded_options[i].canonical_option[0]);
|
||||||
|
+ common_opt.append(save_decoded_options[i].canonical_option[1]);
|
||||||
|
+ common_opt.append(" ");
|
||||||
|
+ }
|
||||||
|
+ if (!strcmp(save_decoded_options[i].canonical_option[0],"-std=gnu90")) {
|
||||||
|
+ common_opt.append(" -std=gnu90 ");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ string extra_opt = "";
|
||||||
|
+ for (int i = 0; i< save_decoded_options_count; ++i) {
|
||||||
|
+ if (strcmp(save_decoded_options[i].canonical_option[0],"-I") &&
|
||||||
|
+ strcmp(save_decoded_options[i].canonical_option[0],"-D") &&
|
||||||
|
+ strcmp(save_decoded_options[i].canonical_option[0],"-o")) {
|
||||||
|
+ extra_opt.append(save_decoded_options[i].canonical_option[0]);
|
||||||
|
+ extra_opt.append(" ");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (execl(serverPath.c_str(), port.c_str(), level.c_str(),
|
||||||
|
+ inputFile.c_str(), cwd.c_str(), common_opt.c_str(), extra_opt.c_str(), outputName.c_str(), NULL) == -1)
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int PluginClient::ServerStart(pid_t& pid)
|
||||||
|
{
|
||||||
|
if (!grpcPort.FindUnusedPort()) {
|
||||||
|
- LOGE("cannot find port for grpc,port 40001-65535 all used!\n");
|
||||||
|
- return -1;
|
||||||
|
+ // Rectify the fault that the port number is not released
|
||||||
|
+ // because the client is abnormal.
|
||||||
|
+ LOGW("cannot find port for grpc, try again!\n");
|
||||||
|
+ if (!grpcPort.FindUnusedPort()) {
|
||||||
|
+ LOGE("cannot find port for grpc,port 40001-65534 all used!\n");
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
@@ -1575,7 +1644,8 @@ int PluginClient::ServerStart(pid_t& pid)
|
||||||
|
if (pid == 0) {
|
||||||
|
LOGI("start plugin server!\n");
|
||||||
|
string serverPath = input.GetServerPath();
|
||||||
|
- if (execl(serverPath.c_str(), port.c_str(), std::to_string(input.GetLogLevel()).c_str(), NULL) == -1) {
|
||||||
|
+ string level = std::to_string(input.GetLogLevel());
|
||||||
|
+ if (ExecuteWithCommand(serverPath, port, level)) {
|
||||||
|
DeleteGrpcPort();
|
||||||
|
LOGE("server start fail! please check serverPath:%s\n", serverPath.c_str());
|
||||||
|
ret = -1;
|
||||||
|
diff --git a/lib/Translate/GimpleToPluginOps.cpp b/lib/Translate/GimpleToPluginOps.cpp
|
||||||
|
index 80d4e87..4617c78 100644
|
||||||
|
--- a/lib/Translate/GimpleToPluginOps.cpp
|
||||||
|
+++ b/lib/Translate/GimpleToPluginOps.cpp
|
||||||
|
@@ -1505,9 +1505,14 @@ Value GimpleToPluginOps::TreeToValue(uint64_t treeId)
|
||||||
|
unsigned HOST_WIDE_INT uinit = tree_to_uhwi(t);
|
||||||
|
initAttr = builder.getI64IntegerAttr(uinit);
|
||||||
|
} else {
|
||||||
|
- abort();
|
||||||
|
+ wide_int val = wi::to_wide(t);
|
||||||
|
+ if (wi::neg_p(val, TYPE_SIGN(TREE_TYPE(t)))) {
|
||||||
|
+ val = -val;
|
||||||
|
+ }
|
||||||
|
+ signed HOST_WIDE_INT init = val.to_shwi();
|
||||||
|
+ initAttr = builder.getI64IntegerAttr(init);
|
||||||
|
}
|
||||||
|
- GetTreeAttr(treeId, readOnly, rPluginType);
|
||||||
|
+ GetTreeAttr(treeId, readOnly, rPluginType);
|
||||||
|
opValue = builder.create<ConstOp>(
|
||||||
|
builder.getUnknownLoc(), treeId, IDefineCode::IntCST,
|
||||||
|
readOnly, initAttr, rPluginType);
|
||||||
|
@@ -1887,4 +1892,4 @@ Value GimpleToPluginOps::MakeSsaName(mlir::Type type)
|
||||||
|
return TreeToValue(retId);
|
||||||
|
}
|
||||||
|
|
||||||
|
-} // namespace PluginIR
|
||||||
|
\ No newline at end of file
|
||||||
|
+} // namespace PluginIR
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: pin-gcc-client
|
Name: pin-gcc-client
|
||||||
Version: 0.4.1
|
Version: 0.4.1
|
||||||
Release: 8
|
Release: 9
|
||||||
Summary: A Pin (Plug-IN framework) client is implemented based on GCC plugin and can execute the compiler optimization pass in GCC.
|
Summary: A Pin (Plug-IN framework) client is implemented based on GCC plugin and can execute the compiler optimization pass in GCC.
|
||||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
||||||
URL: https://gitee.com/src-openeuler/pin-gcc-client
|
URL: https://gitee.com/src-openeuler/pin-gcc-client
|
||||||
@ -20,6 +20,8 @@ Patch7: 0007-Pin-gcc-client-Fix-VectorType.patch
|
|||||||
Patch8: 0008-Pin-gcc-client-Fix-struct-self-contained-CallOp-Tree.patch
|
Patch8: 0008-Pin-gcc-client-Fix-struct-self-contained-CallOp-Tree.patch
|
||||||
Patch9: 0009-Pin-gcc-client-Fix-TreeToValue-VAR_DECL-and-ARRAY_TY.patch
|
Patch9: 0009-Pin-gcc-client-Fix-TreeToValue-VAR_DECL-and-ARRAY_TY.patch
|
||||||
Patch10: 0010-PluginClient-Fix-the-bug-during-multi-process-compil.patch
|
Patch10: 0010-PluginClient-Fix-the-bug-during-multi-process-compil.patch
|
||||||
|
Patch11: 0011-Fix-BUILD-errors.patch
|
||||||
|
Patch12: 0012-PluginClient-Update-transfer-command.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
A Pin (Plug-IN framework) client is implemented based on GCC plugin and can execute the compiler optimization pass in GCC.
|
A Pin (Plug-IN framework) client is implemented based on GCC plugin and can execute the compiler optimization pass in GCC.
|
||||||
@ -62,6 +64,12 @@ find %{_libdir} -type f -name "*.so" -exec strip "{}" ";"
|
|||||||
%config(noreplace) /etc/ld.so.conf.d/%{name}-%{_arch}.conf
|
%config(noreplace) /etc/ld.so.conf.d/%{name}-%{_arch}.conf
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Sep 19 2023 dingguangya <dingguangya1@huawei.com> - 0.4.1-9
|
||||||
|
- Type:SPEC
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:Sync patch from openeuler/pin-gcc-client
|
||||||
|
|
||||||
* Tue May 09 2023 shenbowen <shenbowen@xfusion.com> - 0.4.1-8
|
* Tue May 09 2023 shenbowen <shenbowen@xfusion.com> - 0.4.1-8
|
||||||
- Type:SPEC
|
- Type:SPEC
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user