add BUILD_FOR_OPENEULER to clang
add BUILD_FOR_OPENEULER make option to clang for gcc compatible. Signed-off-by: liyunfei <liyunfei33@huawei.com>
This commit is contained in:
parent
028db506c0
commit
9687d8d70b
40
0003-add-BUILD_FOR_OPENEULER-build-option-to-clang.patch
Normal file
40
0003-add-BUILD_FOR_OPENEULER-build-option-to-clang.patch
Normal file
@ -0,0 +1,40 @@
|
||||
From 752af60afc7fd9cc986adf280d4d03714228fb04 Mon Sep 17 00:00:00 2001
|
||||
From: liyunfei <liyunfei33@huawei.com>
|
||||
Date: Tue, 16 Jan 2024 14:47:02 +0800
|
||||
Subject: [PATCH] add BUILD_FOR_OPENEULER build option to clang
|
||||
|
||||
---
|
||||
clang/CMakeLists.txt | 5 +++++
|
||||
clang/include/clang/Driver/CMakeLists.txt | 4 ++++
|
||||
2 files changed, 9 insertions(+)
|
||||
|
||||
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
|
||||
index f7936d72e088..d558b0522e82 100644
|
||||
--- a/clang/CMakeLists.txt
|
||||
+++ b/clang/CMakeLists.txt
|
||||
@@ -317,6 +317,11 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
+option(BUILD_FOR_OPENEULER "Add gcc compatible options for openEuler toolchain" OFF)
|
||||
+if (BUILD_FOR_OPENEULER)
|
||||
+ add_definitions( -DBUILD_FOR_OPENEULER )
|
||||
+endif()
|
||||
+
|
||||
# Determine HOST_LINK_VERSION on Darwin.
|
||||
set(HOST_LINK_VERSION)
|
||||
if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*")
|
||||
diff --git a/clang/include/clang/Driver/CMakeLists.txt b/clang/include/clang/Driver/CMakeLists.txt
|
||||
index a9d988047920..ea55ba0f1f27 100644
|
||||
--- a/clang/include/clang/Driver/CMakeLists.txt
|
||||
+++ b/clang/include/clang/Driver/CMakeLists.txt
|
||||
@@ -1,3 +1,7 @@
|
||||
set(LLVM_TARGET_DEFINITIONS Options.td)
|
||||
+if (BUILD_FOR_OPENEULER)
|
||||
+tablegen(LLVM Options.inc -gen-opt-parser-defs -DBUILD_FOR_OPENEULER)
|
||||
+else()
|
||||
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
||||
+endif()
|
||||
add_public_tablegen_target(ClangDriverOptions)
|
||||
--
|
||||
Gitee
|
||||
86
0004-add-gcc-compatible-in-BUILD_FOR_OPENEULER.patch
Normal file
86
0004-add-gcc-compatible-in-BUILD_FOR_OPENEULER.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From 6503d6b87786e005c0557961aadba739d833f80c Mon Sep 17 00:00:00 2001
|
||||
From: liyunfei <liyunfei33@huawei.com>
|
||||
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
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
Name: %{pkg_name}
|
||||
Version: %{clang_version}
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: A C language family front-end for LLVM
|
||||
|
||||
License: NCSA
|
||||
@ -47,6 +47,8 @@ Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_
|
||||
Patch0: fedora-PATCH-clang-Don-t-install-static-libraries.patch
|
||||
Patch1: 0001-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch
|
||||
Patch2: 0002-Revert-Clang-Change-the-default-DWARF-version-to-5.patch
|
||||
Patch3: 0003-add-BUILD_FOR_OPENEULER-build-option-to-clang.patch
|
||||
Patch4: 0004-add-gcc-compatible-in-BUILD_FOR_OPENEULER.patch
|
||||
|
||||
# Patches for clang-tools-extra
|
||||
# See https://reviews.llvm.org/D120301
|
||||
@ -251,6 +253,7 @@ cd _build
|
||||
%else
|
||||
-DLLVM_LIBDIR_SUFFIX= \
|
||||
%endif
|
||||
-DBUILD_FOR_OPENEULER=ON \
|
||||
-DCLANG_DEFAULT_UNWINDLIB=libgcc
|
||||
|
||||
%ninja_build
|
||||
@ -374,6 +377,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build
|
||||
%{install_bindir}/git-clang-format
|
||||
|
||||
%changelog
|
||||
* Thu Feb 22 2024 liyunfei<liyunfei33@huawei.com> -17.0.6-6
|
||||
- Add BUILD_FOR_OPENEULER to clang
|
||||
|
||||
* Sun Feb 18 2024 liyunfei <liyunfei33@huawei.com> -17.0.6-5
|
||||
- Change the default DWARF version from 5 to 4.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user