Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
c25daedd7c
!168 Add option -fGNU-compatibility
From: @eastb233 
Reviewed-by: @liyunfei33 
Signed-off-by: @liyunfei33
2024-11-22 01:07:20 +00:00
eastb233
657702d041 Add option -fGNU-compatibility
Sync https://gitee.com/openeuler/llvm-project/pulls/108
and https://gitee.com/openeuler/llvm-project/pulls/123
2024-11-21 15:38:40 +08:00
openeuler-ci-bot
e771cbbd01
!151 adopt to new cmake macro
From: @fundawang 
Reviewed-by: @eastb233 
Signed-off-by: @eastb233
2024-11-21 02:16:19 +00:00
Funda Wang
261fc73d96 adopt to new cmake macro 2024-11-20 20:45:43 +08:00
openeuler-ci-bot
201c790be7
!164 [clang] Increase the number of driver diagnostics
From: @eastb233 
Reviewed-by: @liyunfei33 
Signed-off-by: @liyunfei33
2024-11-20 09:28:07 +00:00
eastb233
2193591dd0 [clang] Increase the number of driver diagnostics
Sync https://gitee.com/openeuler/llvm-project/pulls/104
2024-11-20 10:40:31 +08:00
openeuler-ci-bot
09fb721b76
!153 [Backport][Clang][CodeGen] Add __builtin_bcopy
From: @liyunfei33 
Reviewed-by: @eastb233 
Signed-off-by: @eastb233
2024-11-20 02:36:56 +00:00
liyunfei
ff48f15826 [Backport][Clang][CodeGen] Add __builtin_bcopy
Signed-off-by: liyunfei <liyunfei33@huawei.com>
2024-11-20 09:25:37 +08:00
openeuler-ci-bot
bfbe758c11
!155 Handling of option -Wall and -Werror=format=2 override -Wno
From: @xiajingze 
Reviewed-by: @eastb233 
Signed-off-by: @eastb233
2024-11-19 16:22:04 +00:00
xiajingze
b66116b404 Handling of option -Wall and -Werror=format=2 override -Wno
Signed-off-by: xiajingze <xiajingze1@huawei.com>
2024-11-19 19:09:05 +08:00
7 changed files with 492 additions and 15 deletions

View File

@ -0,0 +1,225 @@
From 001e7941bc936847b07da2fdb4b19a8adcba7718 Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
Date: Fri, 19 Jul 2024 10:44:49 +0800
Subject: [PATCH 1/2] Complete -fgcc-compatible option scope
Complete -fgcc-compatible option scope to Langopts and Diagopts
(cherry picked from commit 8881224782ade2afaab4860f3462e44b7d5c2601)
Signed-off-by: wangqiang <wangqiang1@kylinos.cn>
---
clang/include/clang/Basic/DiagnosticOptions.def | 4 ++++
clang/include/clang/Basic/LangOptions.def | 4 ++++
clang/include/clang/Driver/Options.td | 6 ++++--
clang/lib/Driver/ToolChains/Clang.cpp | 2 ++
clang/lib/Frontend/CompilerInvocation.cpp | 15 +++++++++++++--
5 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def
index 6d0c1b14acc1..5253e951d403 100644
--- a/clang/include/clang/Basic/DiagnosticOptions.def
+++ b/clang/include/clang/Basic/DiagnosticOptions.def
@@ -99,6 +99,10 @@ VALUE_DIAGOPT(MessageLength, 32, 0)
DIAGOPT(ShowSafeBufferUsageSuggestions, 1, 0)
+#ifdef BUILD_FOR_OPENEULER
+DIAGOPT(GccCompatible, 1, 0) /// -fgcc-compatible
+#endif
+
#undef DIAGOPT
#undef ENUM_DIAGOPT
#undef VALUE_DIAGOPT
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index f7ec0406f33e..eb62a4951c65 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -468,6 +468,10 @@ LANGOPT(IncrementalExtensions, 1, 0, " True if we want to process statements"
BENIGN_LANGOPT(CheckNew, 1, 0, "Do not assume C++ operator new may not return NULL")
+#ifdef BUILD_FOR_OPENEULER
+LANGOPT(GccCompatible, 1, 0, "Enable gcc compatibility for openEuler.")
+#endif
+
#undef LANGOPT
#undef COMPATIBLE_LANGOPT
#undef BENIGN_LANGOPT
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 71d6ed66ab96..344c8bd49da7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1810,9 +1810,11 @@ def fautotune_rank : Flag<["-"], "fautotune-rank">, Group<f_Group>,
#endif
#ifdef BUILD_FOR_OPENEULER
-def fgcc_compatible : Flag<["-"], "fgcc-compatible">, Group<f_Group>,
+def fgcc_compatible : Flag<["-"], "fgcc-compatible">,
+ Flags<[CC1Option]>,
+ MarshallingInfoFlag<DiagnosticOpts<"GccCompatible">>,
HelpText<"Enable gcc compatibility for openEuler.">;
-def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Group<f_Group>;
+def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Flags<[CC1Option]>;
#endif
// Begin sanitizer flags. These should all be core options exposed in all driver
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index c49cb43ff19c..fac4f03d6193 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-Wno-error=varargs");
CmdArgs.push_back("-Wno-error=unused-value");
CmdArgs.push_back("-Wno-error=format-nonliteral");
+
+ CmdArgs.push_back("-fgcc-compatible");
}
#endif
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 1fba91bed041..d7b609ef276c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -818,8 +818,9 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::vector<std::string> &Diagnostics) {
for (auto *A : Args.filtered(Group)) {
if (A->getOption().getKind() == Option::FlagClass) {
- // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
- // its name (minus the "W" or "R" at the beginning) to the diagnostics.
+ // The argument is a pure flag (such as OPT_Wall or
+ // OPT_Wdeprecated). Add its name (minus the "W" or "R" at the
+ // beginning) to the diagnostics.
Diagnostics.push_back(
std::string(A->getOption().getName().drop_front(1)));
} else if (A->getOption().matches(GroupWithValue)) {
@@ -829,6 +830,7 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
+
Diagnostics.push_back(A->getValue());
}
}
@@ -3522,6 +3524,11 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
if (!Opts.RandstructSeed.empty())
GenerateArg(Args, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed, SA);
+
+#ifdef BUILD_FOR_OPENEULER
+ if (Opts.GccCompatible)
+ GenerateArg(Args, OPT_fgcc_compatible, SA);
+#endif
}
bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
@@ -4073,6 +4080,10 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
}
+#ifdef BUILD_FOR_OPENEULER
+ Opts.GccCompatible = Args.hasArg(options::OPT_fgcc_compatible);
+#endif
+
return Diags.getNumErrors() == NumErrorsBefore;
}
--
2.43.0
From c6f76aa5cdb02c376df17aafadf2dd7cf41fe5b1 Mon Sep 17 00:00:00 2001
From: wangqiang <wangqiang1@kylinos.cn>
Date: Fri, 19 Jul 2024 11:01:22 +0800
Subject: [PATCH 2/2] Handling of option `-Wall` and `-Werror=format=2`
override `-Wno`
Fix nfs-utils build issue
Signed-off-by: wangqiang <wangqiang1@kylinos.cn>
---
clang/lib/Frontend/CompilerInvocation.cpp | 32 ++++++++++++++++++++++-
clang/test/Driver/test-warnning.c | 15 +++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
create mode 100644 clang/test/Driver/test-warnning.c
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d7b609ef276c..cbb122cc6eeb 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -817,10 +817,40 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
OptSpecifier GroupWithValue,
std::vector<std::string> &Diagnostics) {
for (auto *A : Args.filtered(Group)) {
+#ifdef BUILD_FOR_OPENEULER
+ bool GccCompatible = Args.hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false);
if (A->getOption().getKind() == Option::FlagClass) {
// The argument is a pure flag (such as OPT_Wall or
// OPT_Wdeprecated). Add its name (minus the "W" or "R" at the
// beginning) to the diagnostics.
+ if (A->getOption().getName() == "Wall" && GccCompatible) {
+ // Avoid -Wall and -Werror=format=2 override -Wno-xxx
+ Diagnostics.insert(
+ Diagnostics.begin(),
+ std::string(A->getOption().getName().drop_front(1)));
+ } else {
+ Diagnostics.push_back(
+ std::string(A->getOption().getName().drop_front(1)));
+ }
+ } else if (A->getOption().matches(GroupWithValue)) {
+ // This is -Wfoo= or -Rfoo=, where foo is the name of the diagnostic
+ // group. Add only the group name to the diagnostics.
+ Diagnostics.push_back(std::string(
+ A->getOption().getName().drop_front(1).rtrim("=-")));
+ } else {
+ // Otherwise, add its value (for OPT_W_Joined and similar).
+ if (std::string(A->getValue()) == "error=format=2" && GccCompatible) {
+ // Avoid -Werror=format=2 override -Wno-xxx
+ Diagnostics.insert(Diagnostics.begin(), A->getValue());
+ } else {
+ Diagnostics.push_back(A->getValue());
+ }
+ }
+#else
+ if (A->getOption().getKind() == Option::FlagClass) {
+ // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
+ // its name (minus the "W" or "R" at the beginning) to the diagnostics.
Diagnostics.push_back(
std::string(A->getOption().getName().drop_front(1)));
} else if (A->getOption().matches(GroupWithValue)) {
@@ -830,9 +860,9 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
-
Diagnostics.push_back(A->getValue());
}
+#endif
}
}
diff --git a/clang/test/Driver/test-warnning.c b/clang/test/Driver/test-warnning.c
new file mode 100644
index 000000000000..641f9e3512d5
--- /dev/null
+++ b/clang/test/Driver/test-warnning.c
@@ -0,0 +1,15 @@
+// REQUIRES: build_for_openeuler
+
+// RUN: %clang -v -fgcc-compatible -Wno-format-security -Werror=format=2 -Wall %s
+// RUN: %clang -v -Wall %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: warning: format string is not a string literal (potentially insecure)
+// RUN: %clang -v -Wno-format-security -Werror=format=2 -Wall %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: error: format string is not a string literal (potentially insecure)
+
+#include <stdio.h>
+
+int main() {
+ char *str = "llvm-project";
+ printf(str);
+ return 0;
+}
\ No newline at end of file
--
2.43.0

View File

@ -0,0 +1,146 @@
From 25282cd2e1bbae9c68a4f0df21fef831331503f4 Mon Sep 17 00:00:00 2001
From: Carlos Eduardo Seo <carlos.seo@linaro.org>
Date: Sun, 24 Sep 2023 11:58:14 -0300
Subject: [PATCH] [Clang][CodeGen] Add __builtin_bcopy (#67130)
Add __builtin_bcopy to the list of GNU builtins. This was causing a
series of test failures in glibc.
Adjust the tests to reflect the changes in codegen.
Fixes #51409.
Fixes #63065.
---
clang/include/clang/Basic/Builtins.def | 3 ++-
clang/lib/AST/Decl.cpp | 6 ++++++
clang/lib/CodeGen/CGBuiltin.cpp | 14 ++++++++++++++
clang/test/Analysis/bstring.c | 3 +--
clang/test/Analysis/security-syntax-checks.m | 4 ++--
.../CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c | 6 +++---
6 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index 6dad8b512bd2..3f2cbcedc4b5 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -560,7 +560,7 @@ BUILTIN(__builtin_va_copy, "vAA", "n")
BUILTIN(__builtin_stdarg_start, "vA.", "nt")
BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nctE")
BUILTIN(__builtin_bcmp, "ivC*vC*z", "FnE")
-BUILTIN(__builtin_bcopy, "vv*v*z", "n")
+BUILTIN(__builtin_bcopy, "vvC*v*z", "nF")
BUILTIN(__builtin_bzero, "vv*z", "nF")
BUILTIN(__builtin_free, "vv*", "nF")
BUILTIN(__builtin_malloc, "v*z", "nF")
@@ -1154,6 +1154,7 @@ LIBBUILTIN(strndup, "c*cC*z", "f", STRING_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(index, "c*cC*i", "f", STRINGS_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(rindex, "c*cC*i", "f", STRINGS_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(bzero, "vv*z", "f", STRINGS_H, ALL_GNU_LANGUAGES)
+LIBBUILTIN(bcopy, "vvC*v*z", "f", STRINGS_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(bcmp, "ivC*vC*z", "fE", STRINGS_H, ALL_GNU_LANGUAGES)
// In some systems str[n]casejmp is a macro that expands to _str[n]icmp.
// We undefine then here to avoid wrong name.
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index fbc45fb6397f..3de1e4509bc0 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4320,6 +4320,10 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
case Builtin::BIbzero:
return Builtin::BIbzero;
+ case Builtin::BI__builtin_bcopy:
+ case Builtin::BIbcopy:
+ return Builtin::BIbcopy;
+
case Builtin::BIfree:
return Builtin::BIfree;
@@ -4351,6 +4355,8 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
return Builtin::BIstrlen;
if (FnInfo->isStr("bzero"))
return Builtin::BIbzero;
+ if (FnInfo->isStr("bcopy"))
+ return Builtin::BIbcopy;
} else if (isInStdNamespace()) {
if (FnInfo->isStr("free"))
return Builtin::BIfree;
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e512762fafaf..8f87c4d46109 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3555,6 +3555,20 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
return RValue::get(nullptr);
}
+
+ case Builtin::BIbcopy:
+ case Builtin::BI__builtin_bcopy: {
+ Address Src = EmitPointerWithAlignment(E->getArg(0));
+ Address Dest = EmitPointerWithAlignment(E->getArg(1));
+ Value *SizeVal = EmitScalarExpr(E->getArg(2));
+ EmitNonNullArgCheck(RValue::get(Src.getPointer()), E->getArg(0)->getType(),
+ E->getArg(0)->getExprLoc(), FD, 0);
+ EmitNonNullArgCheck(RValue::get(Dest.getPointer()), E->getArg(1)->getType(),
+ E->getArg(1)->getExprLoc(), FD, 0);
+ Builder.CreateMemMove(Dest, Src, SizeVal, false);
+ return RValue::get(Dest.getPointer());
+ }
+
case Builtin::BImemcpy:
case Builtin::BI__builtin_memcpy:
case Builtin::BImempcpy:
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index a7c7bdb23683..5d86241a4ac9 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -483,8 +483,7 @@ int memcmp8(char *a, size_t n) {
//===----------------------------------------------------------------------===
#define bcopy BUILTIN(bcopy)
-// __builtin_bcopy is not defined with const in Builtins.def.
-void bcopy(/*const*/ void *s1, void *s2, size_t n);
+void bcopy(const void *s1, void *s2, size_t n);
void bcopy0 (void) {
diff --git a/clang/test/Analysis/security-syntax-checks.m b/clang/test/Analysis/security-syntax-checks.m
index 5b4f35055f51..59e60f685236 100644
--- a/clang/test/Analysis/security-syntax-checks.m
+++ b/clang/test/Analysis/security-syntax-checks.m
@@ -77,9 +77,9 @@ int test_bcmp(void *a, void *b, size_t n) {
}
// Obsolete function bcopy
-void bcopy(void *, void *, size_t);
+void bcopy(const void *, void *, size_t);
-void test_bcopy(void *a, void *b, size_t n) {
+void test_bcopy(const void *a, void *b, size_t n) {
bcopy(a, b, n); // expected-warning{{The bcopy() function is obsoleted by memcpy() or memmove(}}
}
diff --git a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
index cced16431926..64bd6e3ed41e 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
@@ -167,15 +167,15 @@ void testalignx(const void *pointer) {
}
// 64BIT-LABEL: @testbcopy(
-// 64BIT: call void @bcopy(ptr noundef {{%.*}}, ptr noundef {{%.*}}, i64 noundef {{%.*}})
+// 64BIT: call void @llvm.memmove.p0.p0.i64(ptr align 1 {{%.*}}, ptr align 1 {{%.*}}, i64 {{%.*}}, i1 false)
// 64BIT-NEXT: ret void
//
// 32BIT-LABEL: @testbcopy(
-// 32BIT: call void @bcopy(ptr noundef {{%.*}}, ptr noundef {{%.*}}, i32 noundef {{%.*}})
+// 32BIT: call void @llvm.memmove.p0.p0.i32(ptr align 1 {{%.*}}, ptr align 1 {{%.*}}, i32 {{%.*}}, i1 false)
// 32BIT-NEXT: ret void
//
void testbcopy(const void *src, void *dest, size_t n) {
- __bcopy(src, dest, n);
+ bcopy(src, dest, n);
}
// 64BIT-LABEL: @testbzero(
--
Gitee

View File

@ -0,0 +1,27 @@
From 9efda5a71de8b117366152aa35a8837af0545d0f Mon Sep 17 00:00:00 2001
From: eastb233 <xiezhiheng@huawei.com>
Date: Mon, 28 Oct 2024 16:20:14 +0800
Subject: [PATCH] [clang] Increase the number of driver diagnostics
It hits the limited number of driver diagnostics,
increase `DIAG_SIZE_DRIVER`.
---
clang/include/clang/Basic/DiagnosticIDs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index bf4995175ef1..8bc45b91911c 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -31,7 +31,7 @@ namespace clang {
// Size of each of the diagnostic categories.
enum {
DIAG_SIZE_COMMON = 300,
- DIAG_SIZE_DRIVER = 300,
+ DIAG_SIZE_DRIVER = 350,
DIAG_SIZE_FRONTEND = 150,
DIAG_SIZE_SERIALIZATION = 120,
DIAG_SIZE_LEX = 400,
--
2.38.1.windows.1

View File

@ -0,0 +1,27 @@
From cd2d6fe2cdcb0fa047c77993c23da1fb612970be Mon Sep 17 00:00:00 2001
From: jianghaibo <jianghaibo9@huawei.com>
Date: Wed, 6 Nov 2024 16:04:39 +0800
Subject: [PATCH] [Driver] add option -fGNU-compatibility aliased with
-fgcc-compatible
---
clang/include/clang/Driver/Options.td | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 530bb53ea9b5..2faa65763234 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1814,6 +1814,9 @@ def fgcc_compatible : Flag<["-"], "fgcc-compatible">,
Flags<[CC1Option]>,
MarshallingInfoFlag<DiagnosticOpts<"GccCompatible">>,
HelpText<"Enable gcc compatibility for openEuler.">;
+def : Flag["-"], "fGNU-compatibility">,
+ Flags<[CC1Option]>, Alias<fgcc_compatible>,
+ HelpText<"Alias for -fgcc_compatible">;
def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Flags<[CC1Option]>;
#endif
--
2.38.1.windows.1

View File

@ -0,0 +1,38 @@
From 82d51aca563c40c84b70c0e295a9561d3dd4092b Mon Sep 17 00:00:00 2001
From: jianghaibo <jianghaibo9@huawei.com>
Date: Wed, 20 Nov 2024 16:13:04 +0800
Subject: [PATCH] [Driver] fix compile error for -fGNU-compatibility
---
clang/include/clang/Driver/Options.td | 2 +-
clang/test/Driver/test-generate-missing-build-notes.cpp | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index ccf395dad35a..c109d7a8fcab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1819,7 +1819,7 @@ def fgcc_compatible : Flag<["-"], "fgcc-compatible">,
Flags<[CC1Option]>,
MarshallingInfoFlag<DiagnosticOpts<"GccCompatible">>,
HelpText<"Enable gcc compatibility for openEuler.">;
-def : Flag["-"], "fGNU-compatibility">,
+def fGNU_compatibility : Flag<["-"], "fGNU-compatibility">,
Flags<[CC1Option]>, Alias<fgcc_compatible>,
HelpText<"Alias for -fgcc_compatible">;
def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Flags<[CC1Option]>;
diff --git a/clang/test/Driver/test-generate-missing-build-notes.cpp b/clang/test/Driver/test-generate-missing-build-notes.cpp
index efd5251e6a1c..54ac4c66a5b0 100644
--- a/clang/test/Driver/test-generate-missing-build-notes.cpp
+++ b/clang/test/Driver/test-generate-missing-build-notes.cpp
@@ -1,6 +1,7 @@
// REQUIRES: build_for_openeuler
// RUN: %clang -### -fgcc-compatible -Wa,--generate-missing-build-notes=yes %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
// RUN: %clang -### -fgcc-compatible -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
+// RUN: %clang -### -fGNU-compatibility -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
// CHECK-NO-ERROR-NOT: --generate-missing-build-notes=
// RUN: %clang -### -Wa,--generate-missing-build-notes=yes %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
// RUN: %clang -### -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
--
2.38.1.windows.1

View File

@ -1,3 +1,4 @@
%undefine __cmake_in_source_build
%bcond_without sys_llvm %bcond_without sys_llvm
%bcond_without check %bcond_without check
%bcond_with classic_flang %bcond_with classic_flang
@ -43,9 +44,8 @@
Name: %{pkg_name} Name: %{pkg_name}
Version: %{clang_version} Version: %{clang_version}
Release: 26 Release: 31
Summary: A C language family front-end for LLVM Summary: A C language family front-end for LLVM
License: NCSA License: NCSA
URL: http://llvm.org URL: http://llvm.org
Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_version}/%{clang_srcdir}.tar.xz Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_version}/%{clang_srcdir}.tar.xz
@ -74,6 +74,11 @@ Patch19: 0019-AArch64-Support-HiSilicon-s-HIP09-Processor.patch
Patch20: 0020-Backport-LoongArch-fix-and-add-some-new-support.patch Patch20: 0020-Backport-LoongArch-fix-and-add-some-new-support.patch
Patch21: 0021-AArch64-Delete-hip09-macro.patch Patch21: 0021-AArch64-Delete-hip09-macro.patch
Patch22: 0022-Driver-Pass-z-arg-and-Wl-z-arg-option-to-the-linker.patch Patch22: 0022-Driver-Pass-z-arg-and-Wl-z-arg-option-to-the-linker.patch
Patch23: 0023-Handling-of-option-Wall-and-Werror-format-2-override.patch
Patch24: 0024-Backport-PATCH-Clang-CodeGen-Add__builtin_bcopy.patch
Patch25: 0025-clang-Increase-the-number-of-driver-diagnostics.patch
Patch26: 0026-Driver-add-option-fGNU-compatibility-aliased-with-fg.patch
Patch27: 0027-Driver-fix-compile-error-for-fGNU-compatibility.patch
# Patches for clang-tools-extra # Patches for clang-tools-extra
# See https://reviews.llvm.org/D120301 # See https://reviews.llvm.org/D120301
@ -237,9 +242,7 @@ pathfix.py -i %{__python3} -pn \
tools/scan-build-py/libexec/* tools/scan-build-py/libexec/*
%build %build
mkdir -p _build %cmake -G Ninja \
cd _build
%cmake .. -G Ninja \
-DCLANG_DEFAULT_PIE_ON_LINUX=ON \ -DCLANG_DEFAULT_PIE_ON_LINUX=ON \
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \ -DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
@ -270,12 +273,8 @@ cd _build
-DCLANG_BUILD_EXAMPLES:BOOL=OFF \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \
-DBUILD_SHARED_LIBS=OFF \ -DBUILD_SHARED_LIBS=OFF \
-DCLANG_REPOSITORY_STRING="%{?distro} %{version}-%{release}" \ -DCLANG_REPOSITORY_STRING="%{?distro} %{version}-%{release}" \
-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../../%{clang_tools_srcdir} \ -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=%{_vpath_srcdir}/../%{clang_tools_srcdir} \
%if 0%{?__isa_bits} == 64 -DCLANG_RESOURCE_DIR=../%{_lib}/clang/%{maj_ver} \
-DCLANG_RESOURCE_DIR=../lib64/clang/%{maj_ver} \
%else
-DCLANG_RESOURCE_DIR=../lib/clang/%{maj_ver} \
%endif
%if 0%{?__isa_bits} == 64 %if 0%{?__isa_bits} == 64
-DLLVM_LIBDIR_SUFFIX=64 \ -DLLVM_LIBDIR_SUFFIX=64 \
%else %else
@ -294,11 +293,11 @@ cd _build
%endif %endif
-DCLANG_DEFAULT_UNWINDLIB=libgcc -DCLANG_DEFAULT_UNWINDLIB=libgcc
%ninja_build %cmake_build
%install %install
%ninja_install -C _build %cmake_install
mkdir -p %{buildroot}/%{_bindir} mkdir -p %{buildroot}/%{_bindir}
rm -vf %{buildroot}%{_datadir}/clang/clang-format-bbedit.applescript rm -vf %{buildroot}%{_datadir}/clang/clang-format-bbedit.applescript
@ -317,7 +316,7 @@ mkdir -p %{buildroot}%{install_libdir}/clang/%{maj_ver}/{bin,include,lib,share}/
%check %check
%if %{with check} %if %{with check}
LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build/ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake_builddir}
%endif %endif
%files %files
@ -418,6 +417,21 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build
%{install_bindir}/git-clang-format %{install_bindir}/git-clang-format
%changelog %changelog
* Thu Nov 21 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-31
- Add option -fGNU-compatibility
* Wed Nov 20 2024 Funda Wang <fundawang@yeah.net> - 17.0.6-30
- adopt to new cmake macro
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-29
- [clang] Increase the number of driver diagnostics
* Wed Nov 20 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-28
- [Backport][Clang][CodeGen] Add __builtin_bcopy
* Tue Nov 19 2024 wangqiang <wangqiang1@kylinos.cn> - 17.0.6-27
- Handling of option `-Wall` and `-Werror=format=2` override `-Wno`
* Tue Nov 19 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-26 * Tue Nov 19 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-26
- [Driver] Pass -z<arg> and -Wl,-z <arg> option to the linker - [Driver] Pass -z<arg> and -Wl,-z <arg> option to the linker

View File

@ -1,4 +1,4 @@
version_control: github version_control: github
src_repo: llvm/llvm-project src_repo: llvm/llvm-project
tag_prefix: ^llvmorg- tag_prefix: ^llvmorg-
seperator: . separator: .