From cb205da7a5f7637ef82b187561ff5da81231c793 Mon Sep 17 00:00:00 2001 From: xiongzhou4 Date: Wed, 13 Sep 2023 11:41:07 +0800 Subject: [PATCH] Add fkernel-pgo option to support PGO kernel compilation. --- ...nel-pgo-option-to-support-PGO-kernel.patch | 57 +++++++++++++++++++ gcc.spec | 7 ++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 Add-fkernel-pgo-option-to-support-PGO-kernel.patch diff --git a/Add-fkernel-pgo-option-to-support-PGO-kernel.patch b/Add-fkernel-pgo-option-to-support-PGO-kernel.patch new file mode 100644 index 0000000..28291ca --- /dev/null +++ b/Add-fkernel-pgo-option-to-support-PGO-kernel.patch @@ -0,0 +1,57 @@ +From 284f9002e1a365fd1658b01763292811e3acb281 Mon Sep 17 00:00:00 2001 +From: c00416232 +Date: Wed, 13 Sep 2023 11:25:00 +0800 +Subject: [PATCH] [PGO kernel] Add fkernel-pgo option to support PGO kernel + compilation. + +If specified, disable TLS setting of instrumentation variables in +gcc/tree-profile.c, as kernel does not support TLS. +--- + gcc/common.opt | 4 ++++ + gcc/tree-profile.c | 8 ++++++-- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/gcc/common.opt b/gcc/common.opt +index 37835d5c0..2cfe5269f 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -2002,6 +2002,10 @@ fprofile-generate= + Common Joined RejectNegative + Enable common options for generating profile info for profile feedback directed optimizations, and set -fprofile-dir=. + ++fkernel-pgo ++Common Report Var(flag_kernel_pgo) Optimization Init(0) ++Disable TLS setting of instrumentation variables to support PGO kernel compilation in -fprofile-generate, as kernel does not support TLS. ++ + fprofile-use + Common Var(flag_profile_use) + Enable common options for performing profile feedback directed optimizations. +diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c +index a49ec37f8..c802ad08a 100644 +--- a/gcc/tree-profile.c ++++ b/gcc/tree-profile.c +@@ -91,7 +91,9 @@ init_ic_make_global_vars (void) + TREE_STATIC (ic_void_ptr_var) = 1; + DECL_ARTIFICIAL (ic_void_ptr_var) = 1; + DECL_INITIAL (ic_void_ptr_var) = NULL; +- if (targetm.have_tls) ++ /* Disable TLS setting when compiling kernel in -fprofile-generate, ++ as kernel does not support TLS. */ ++ if (targetm.have_tls && !flag_kernel_pgo) + set_decl_tls_model (ic_void_ptr_var, decl_default_tls_model (ic_void_ptr_var)); + + gcov_type_ptr = build_pointer_type (get_gcov_type ()); +@@ -108,7 +110,9 @@ init_ic_make_global_vars (void) + TREE_STATIC (ic_gcov_type_ptr_var) = 1; + DECL_ARTIFICIAL (ic_gcov_type_ptr_var) = 1; + DECL_INITIAL (ic_gcov_type_ptr_var) = NULL; +- if (targetm.have_tls) ++ /* Disable TLS setting when compiling kernel in -fprofile-generate, ++ as kernel does not support TLS. */ ++ if (targetm.have_tls && !flag_kernel_pgo) + set_decl_tls_model (ic_gcov_type_ptr_var, decl_default_tls_model (ic_gcov_type_ptr_var)); + } + +-- +2.27.0 + diff --git a/gcc.spec b/gcc.spec index 02e35a2..de7b2ea 100644 --- a/gcc.spec +++ b/gcc.spec @@ -41,7 +41,7 @@ Version: 7.3.0 # number 2020033101 meaning the openEuler 20.03 release date plus 01 to # replace DATE and will never change it in the future. %global openEulerDATE 2020033101 -Release: %{openEulerDATE}.51 +Release: %{openEulerDATE}.52 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD Group: Development/Languages #Source0: hcc-aarch64-linux-release.tar.bz2 @@ -98,6 +98,7 @@ Patch41: PR-c-83227-C-17-ICE-with-init-list-derived.patch Patch42: Remove-_GLIBCXX_USE_INT128-autoconf-macro.patch Patch43: Add-bolt-linker-plugin.patch Patch44: Enable-BOLT-linker-plugin-on-aarch64.patch +Patch45: Add-fkernel-pgo-option-to-support-PGO-kernel.patch #AutoReqProv: off AutoReq: true @@ -586,6 +587,7 @@ package or when debugging this package. %patch42 -p1 %patch43 -p1 %patch44 -p1 +%patch45 -p1 %if 0%{?_enable_debug_packages} cat > split-debuginfo.sh <<\EOF @@ -3346,6 +3348,9 @@ fi %changelog +* Wed Sep 13 2023 Xiong Zhou -7.3.0-2020033101.52 +- Add fkernel-pgo option to support PGO kernel compilation. + * Wed Dec 07 2022 konglidong -7.3.0-2020033101.51 - fix bad macro expansion in changelog -- Gitee