From 5cba42c99e63808e3ba4cbaa37c6789d40cf7995 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Fri, 15 Mar 2024 09:30:54 +0800 Subject: [PATCH] Add more warning options to BUILD_FOR_OPENEULER gcc compatible Signed-off-by: liyunfei --- ...e-warning-options-to-fgcc-compatible.patch | 48 +++++++++++++++++++ clang.spec | 6 ++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 0007-add-more-warning-options-to-fgcc-compatible.patch diff --git a/0007-add-more-warning-options-to-fgcc-compatible.patch b/0007-add-more-warning-options-to-fgcc-compatible.patch new file mode 100644 index 0000000..8356c52 --- /dev/null +++ b/0007-add-more-warning-options-to-fgcc-compatible.patch @@ -0,0 +1,48 @@ +From 929e5c1d4f2c36e233a26b480f1dd172b6d63362 Mon Sep 17 00:00:00 2001 +From: liyunfei +Date: Thu, 14 Mar 2024 16:04:40 +0800 +Subject: [PATCH] add more warning options to -fgcc-compatible + +--- + clang/lib/Driver/ToolChains/Clang.cpp | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp +index 793af55a1e5f..f0da323d8adb 100644 +--- a/clang/lib/Driver/ToolChains/Clang.cpp ++++ b/clang/lib/Driver/ToolChains/Clang.cpp +@@ -4683,11 +4683,31 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, + #ifdef BUILD_FOR_OPENEULER + if (Args.hasFlag(options::OPT_fgcc_compatible, + options::OPT_fno_gcc_compatible, false)) { ++ // compatibility relevent warnings + CmdArgs.push_back("-Wno-error=unknown-warning-option"); ++ CmdArgs.push_back("-Wno-error=ignored-attributes"); ++ // By default, clang reports warnings, but gcc does not. + 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"); ++ CmdArgs.push_back("-Wno-error=deprecated-non-prototype"); ++ CmdArgs.push_back("-Wno-error=unsafe-buffer-usage"); ++ CmdArgs.push_back("-Wno-error=string-plus-int"); ++ // By default, clang reports errors, but gcc reports warnings. ++ // when -Werror is passed don't add -Wno-error=*. ++ if(!D.getDiags().getWarningsAsErrors()) { ++ CmdArgs.push_back("-Wno-error=implicit-function-declaration"); ++ CmdArgs.push_back("-Wno-error=incompatible-function-pointer-types"); ++ CmdArgs.push_back("-Wno-error=register"); ++ CmdArgs.push_back("-Wno-error=int-conversion"); ++ CmdArgs.push_back("-Wno-error=implicit-int"); ++ CmdArgs.push_back("-Wno-error=enum-constexpr-conversion"); ++ CmdArgs.push_back("-Wno-error=return-type"); ++ } ++ //other warnings ++ CmdArgs.push_back("-Wno-error=cast-align"); ++ CmdArgs.push_back("-Wno-error=enum-conversion"); + } + #endif + +-- +2.42.0.windows.2 + diff --git a/clang.spec b/clang.spec index 449a3e3..a98c3cc 100644 --- a/clang.spec +++ b/clang.spec @@ -36,7 +36,7 @@ Name: %{pkg_name} Version: %{clang_version} -Release: 8 +Release: 9 Summary: A C language family front-end for LLVM License: NCSA @@ -51,6 +51,7 @@ Patch3: 0003-add-BUILD_FOR_OPENEULER-build-option-to-clang.patch Patch4: 0004-add-gcc-compatible-in-BUILD_FOR_OPENEULER.patch Patch5: 0005-backport-Disable-InterpreterExceptionTest-on-RISC-V.patch Patch6: 0006-clang-LoongArch-Add-loongarch64-to-os-triple.patch +Patch7: 0007-add-more-warning-options-to-fgcc-compatible.patch # Patches for clang-tools-extra # See https://reviews.llvm.org/D120301 @@ -379,6 +380,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build %{install_bindir}/git-clang-format %changelog +* Fri Mar 15 2024 liyunfei -17.0.6-9 +- Add more warning options to BUILD_FOR_OPENEULER gcc compatible. + * Thu Mar 14 2024 zhanglimin -17.0.6-8 - Add loongarch64 to os-triple patch -- Gitee