1 Star 0 Fork 57

KarsierOS/clang

forked from src-openEuler/clang 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-add-gcc-compatible-in-BUILD_FOR_OPENEULER.patch 4.12 KB
一键复制 编辑 原始数据 按行查看 历史
liyunfei 提交于 2024-02-05 11:07 . add BUILD_FOR_OPENEULER to clang
From 6503d6b87786e005c0557961aadba739d833f80c Mon Sep 17 00:00:00 2001
From: liyunfei <[email protected]>
Date: Tue, 16 Jan 2024 14:48:53 +0800
Subject: [PATCH] add gcc compatible in BUILD_FOR_OPENEULER
---
clang/include/clang/Driver/Options.td | 14 ++++++++++++++
clang/lib/Driver/Driver.cpp | 8 ++++++++
clang/lib/Driver/ToolChains/Clang.cpp | 11 +++++++++++
3 files changed, 33 insertions(+)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 37e8c56b2d29..d4f7315bf8cb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1786,6 +1786,12 @@ def fmemory_profile_use_EQ : Joined<["-"], "fmemory-profile-use=">,
HelpText<"Use memory profile for profile-guided memory optimization">,
MarshallingInfoString<CodeGenOpts<"MemoryProfileUsePath">>;
+#ifdef BUILD_FOR_OPENEULER
+def fgcc_compatible : Flag<["-"], "fgcc-compatible">, Group<f_Group>,
+ HelpText<"Enable gcc compatibility for openEuler.">;
+def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Group<f_Group>;
+#endif
+
// Begin sanitizer flags. These should all be core options exposed in all driver
// modes.
let Flags = [CC1Option, CoreOption] in {
@@ -5152,6 +5158,14 @@ def falign_jumps_EQ : Joined<["-"], "falign-jumps=">, Group<clang_ignored_gcc_op
// ignore it for now to avoid breaking builds that use it.
def fdiagnostics_show_location_EQ : Joined<["-"], "fdiagnostics-show-location=">, Group<clang_ignored_f_Group>;
+#ifdef BUILD_FOR_OPENEULER
+def flifetime_dse_EQ : Joined<["-"], "flifetime-dse=">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm peephole : BooleanFFlag<"peephole">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm peephole2 : BooleanFFlag<"peephole2">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm aggressive_loop_optiomizations : BooleanFFlag<"aggressive-loop-optiomizations">, Group<clang_ignored_gcc_optimization_f_Group>;
+def flto_partition_EQ : Joined<["-"], "flto-partition=">, Group<clang_ignored_gcc_optimization_f_Group>;
+#endif
+
defm check_new : BoolOption<"f", "check-new",
LangOpts<"CheckNew">, DefaultFalse,
PosFlag<SetTrue, [], "Do not assume C++ operator new may not return NULL">,
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index bdbdad9362e1..87736112fb76 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1491,6 +1491,14 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// Populate the tool chains for the offloading devices, if any.
CreateOffloadingDeviceToolChains(*C, Inputs);
+#ifdef BUILD_FOR_OPENEULER
+ if(C->getArgs().hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false)) {
+ getDiags().setDiagnosticGroupWarningAsError("unused-command-line-argument", 0);
+ getDiags().setDiagnosticGroupWarningAsError("ignored-optimization-argument", 0);
+ }
+#endif
+
// Construct the list of abstract actions to perform for this compilation. On
// MachO targets this uses the driver-driver and universal actions.
if (TC.getTriple().isOSBinFormatMachO())
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 37a07b8f224d..0921e6071d26 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4680,6 +4680,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-triple");
CmdArgs.push_back(Args.MakeArgString(TripleStr));
+#ifdef BUILD_FOR_OPENEULER
+ if (Args.hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false)) {
+ CmdArgs.push_back("-Wno-error=unknown-warning-option");
+ CmdArgs.push_back("-Wno-error=unused-parameter");
+ CmdArgs.push_back("-Wno-error=unused-function");
+ CmdArgs.push_back("-Wno-error=unused-but-set-parameter");
+ CmdArgs.push_back("-Wno-error=unused-but-set-variable");
+ }
+#endif
+
if (const Arg *MJ = Args.getLastArg(options::OPT_MJ)) {
DumpCompilationDatabase(C, MJ->getValue(), TripleStr, Output, Input, Args);
Args.ClaimAllArgs(options::OPT_MJ);
--
Gitee
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/karsier/clang.git
[email protected]:karsier/clang.git
karsier
clang
clang
master

搜索帮助