1 Star 0 Fork 128

cenhuilin/gcc

forked from src-openEuler/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0033-AutoBOLT-Enable-BOLT-linker-plugin-on-aarch64-3-3.patch 11.94 KB
一键复制 编辑 原始数据 按行查看 历史
赵震宇 提交于 2024-04-01 17:15 . [Sync] Sync patch from openeuler/gcc
From 94242286383a80e6ab83d824a4d7ea23ea311f75 Mon Sep 17 00:00:00 2001
From: zhenyu--zhao_admin <[email protected]>
Date: Mon, 22 Jan 2024 15:38:24 +0800
Subject: [PATCH] [AutoBOLT] Enable BOLT linker plugin on aarch64 3/3
---
Makefile.def | 10 ++++++++++
configure | 27 ++++++++++++++++++++++++++-
configure.ac | 22 +++++++++++++++++++++-
gcc/config.host | 1 +
gcc/config.in | 13 +++++++++++++
gcc/configure | 10 ++++++++--
gcc/configure.ac | 4 ++++
gcc/gcc.cc | 23 +++++++++++++++++++++++
8 files changed, 106 insertions(+), 4 deletions(-)
diff --git a/Makefile.def b/Makefile.def
index 72d585496..0ba868890 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -145,6 +145,9 @@ host_modules= { module= gnattools; };
host_modules= { module= lto-plugin; bootstrap=true;
extra_configure_flags='--enable-shared @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
extra_make_flags='@extra_linker_plugin_flags@'; };
+host_modules= { module= bolt-plugin; bootstrap=true;
+ extra_configure_flags='--enable-shared @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
+ extra_make_flags='@extra_linker_plugin_flags@'; };
host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
host_modules= { module= gotools; };
host_modules= { module= libctf; bootstrap=true; };
@@ -349,6 +352,7 @@ dependencies = { module=configure-gcc; on=all-mpfr; };
dependencies = { module=configure-gcc; on=all-mpc; };
dependencies = { module=configure-gcc; on=all-isl; };
dependencies = { module=configure-gcc; on=all-lto-plugin; };
+dependencies = { module=configure-gcc; on=all-bolt-plugin; };
dependencies = { module=configure-gcc; on=all-binutils; };
dependencies = { module=configure-gcc; on=all-gas; };
dependencies = { module=configure-gcc; on=all-ld; };
@@ -374,6 +378,7 @@ dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
dependencies = { module=all-gcc; on=all-libiberty; };
dependencies = { module=all-gcc; on=all-fixincludes; };
dependencies = { module=all-gcc; on=all-lto-plugin; };
+dependencies = { module=all-gcc; on=all-bolt-plugin; };
dependencies = { module=all-gcc; on=all-libiconv; };
dependencies = { module=info-gcc; on=all-build-libiberty; };
dependencies = { module=dvi-gcc; on=all-build-libiberty; };
@@ -381,8 +386,10 @@ dependencies = { module=pdf-gcc; on=all-build-libiberty; };
dependencies = { module=html-gcc; on=all-build-libiberty; };
dependencies = { module=install-gcc ; on=install-fixincludes; };
dependencies = { module=install-gcc ; on=install-lto-plugin; };
+dependencies = { module=install-gcc ; on=install-bolt-plugin; };
dependencies = { module=install-strip-gcc ; on=install-strip-fixincludes; };
dependencies = { module=install-strip-gcc ; on=install-strip-lto-plugin; };
+dependencies = { module=install-strip-gcc ; on=install-strip-bolt-plugin; };
dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
dependencies = { module=configure-libcpp; on=configure-intl; };
@@ -401,6 +408,9 @@ dependencies = { module=all-gnattools; on=all-target-libstdc++-v3; };
dependencies = { module=all-lto-plugin; on=all-libiberty; };
dependencies = { module=all-lto-plugin; on=all-libiberty-linker-plugin; };
+dependencies = { module=all-bolt-plugin; on=all-libiberty; };
+dependencies = { module=all-bolt-plugin; on=all-libiberty-linker-plugin; };
+
dependencies = { module=configure-libcc1; on=configure-gcc; };
dependencies = { module=all-libcc1; on=all-gcc; };
diff --git a/configure b/configure
index 5dcaab14a..aff62c464 100755
--- a/configure
+++ b/configure
@@ -826,6 +826,7 @@ with_isl
with_isl_include
with_isl_lib
enable_isl_version_check
+enable_bolt
enable_lto
enable_linker_plugin_configure_flags
enable_linker_plugin_flags
@@ -1550,6 +1551,7 @@ Optional Features:
enable the PGO build
--disable-isl-version-check
disable check for isl version
+ --enable-bolt enable bolt optimization support
--enable-lto enable link time optimization support
--enable-linker-plugin-configure-flags=FLAGS
additional flags for configuring linker plugins
@@ -8564,6 +8566,15 @@ fi
+# Check for BOLT support.
+# Check whether --enable-bolt was given.
+if test "${enable_bolt+set}" = set; then :
+ enableval=$enable_bolt; enable_bolt=$enableval
+else
+ enable_bolt=no; default_enable_bolt=no
+fi
+
+
# Check for LTO support.
# Check whether --enable-lto was given.
if test "${enable_lto+set}" = set; then :
@@ -8593,6 +8604,16 @@ if test $target_elf = yes; then :
# ELF platforms build the lto-plugin always.
build_lto_plugin=yes
+ # ELF platforms can build the bolt-plugin.
+ # NOT BUILD BOLT BY DEFAULT.
+ case $target in
+ aarch64*-*-linux*)
+ if test $enable_bolt = yes; then :
+ build_bolt_plugin=yes
+ fi
+ ;;
+ esac
+
else
if test x"$default_enable_lto" = x"yes" ; then
case $target in
@@ -8780,6 +8801,10 @@ if test -d ${srcdir}/gcc; then
fi
fi
+ if test "${build_bolt_plugin}" = "yes" ; then
+ configdirs="$configdirs bolt-plugin"
+ fi
+
# If we're building an offloading compiler, add the LTO front end.
if test x"$enable_as_accelerator_for" != x ; then
case ,${enable_languages}, in
@@ -9202,7 +9227,7 @@ fi
extra_host_libiberty_configure_flags=
extra_host_zlib_configure_flags=
case " $configdirs " in
- *" lto-plugin "* | *" libcc1 "*)
+ *" lto-plugin "* | *" libcc1 "* | *" bolt-plugin "*)
# When these are to be built as shared libraries, the same applies to
# libiberty.
extra_host_libiberty_configure_flags=--enable-shared
diff --git a/configure.ac b/configure.ac
index 85977482a..f310d75ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1863,6 +1863,12 @@ fi
AC_SUBST(isllibs)
AC_SUBST(islinc)
+# Check for BOLT support.
+AC_ARG_ENABLE(bolt,
+[AS_HELP_STRING([--enable-bolt], [enable bolt optimization support])],
+enable_bolt=$enableval,
+enable_bolt=no; default_enable_bolt=no)
+
# Check for LTO support.
AC_ARG_ENABLE(lto,
[AS_HELP_STRING([--enable-lto], [enable link time optimization support])],
@@ -1871,6 +1877,16 @@ enable_lto=yes; default_enable_lto=yes)
ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
build_lto_plugin=yes
+
+ # ELF platforms can build the bolt-plugin.
+ # NOT BUILD BOLT BY DEFAULT.
+ case $target in
+ aarch64*-*-linux*)
+ if test $enable_bolt = yes; then :
+ build_bolt_plugin=yes
+ fi
+ ;;
+ esac
],[if test x"$default_enable_lto" = x"yes" ; then
case $target in
*-apple-darwin[[912]]* | *-cygwin* | *-mingw* | *djgpp*) ;;
@@ -2049,6 +2065,10 @@ if test -d ${srcdir}/gcc; then
fi
fi
+ if test "${build_bolt_plugin}" = "yes" ; then
+ configdirs="$configdirs bolt-plugin"
+ fi
+
# If we're building an offloading compiler, add the LTO front end.
if test x"$enable_as_accelerator_for" != x ; then
case ,${enable_languages}, in
@@ -2457,7 +2477,7 @@ fi
extra_host_libiberty_configure_flags=
extra_host_zlib_configure_flags=
case " $configdirs " in
- *" lto-plugin "* | *" libcc1 "*)
+ *" lto-plugin "* | *" libcc1 "* | *" bolt-plugin "*)
# When these are to be built as shared libraries, the same applies to
# libiberty.
extra_host_libiberty_configure_flags=--enable-shared
diff --git a/gcc/config.host b/gcc/config.host
index 4ca300f11..bf7dcb4cc 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -75,6 +75,7 @@ out_host_hook_obj=host-default.o
host_can_use_collect2=yes
use_long_long_for_widest_fast_int=no
host_lto_plugin_soname=liblto_plugin.so
+host_bolt_plugin_soname=libbolt_plugin.so
# Unsupported hosts list. Generally, only include hosts known to fail here,
# since we allow hosts not listed to be supported generically.
diff --git a/gcc/config.in b/gcc/config.in
index 64c27c9cf..6bb25b25b 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -24,6 +24,13 @@
#endif
+/* Define to the name of the BOLT plugin DSO that must be passed to the
+ linker's -plugin=LIB option. */
+#ifndef USED_FOR_TARGET
+#undef BOLTPLUGINSONAME
+#endif
+
+
/* Define to the root for URLs about GCC changes. */
#ifndef USED_FOR_TARGET
#undef CHANGES_ROOT_URL
@@ -2208,6 +2215,12 @@
#endif
+/* Define which stat syscall is able to handle 64bit indodes. */
+#ifndef USED_FOR_TARGET
+#undef HOST_STAT_FOR_64BIT_INODES
+#endif
+
+
/* Define as const if the declaration of iconv() needs const. */
#ifndef USED_FOR_TARGET
#undef ICONV_CONST
diff --git a/gcc/configure b/gcc/configure
index 98bbf0f85..30f386789 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -13578,6 +13578,12 @@ case $use_collect2 in
esac
+cat >>confdefs.h <<_ACEOF
+#define BOLTPLUGINSONAME "${host_bolt_plugin_soname}"
+_ACEOF
+
+
+
cat >>confdefs.h <<_ACEOF
#define LTOPLUGINSONAME "${host_lto_plugin_soname}"
_ACEOF
@@ -19668,7 +19674,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19671 "configure"
+#line 19677 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19774,7 +19780,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19777 "configure"
+#line 19783 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index c74f4b555..dd6cd60f8 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2531,6 +2531,10 @@ case $use_collect2 in
;;
esac
+AC_DEFINE_UNQUOTED(BOLTPLUGINSONAME,"${host_bolt_plugin_soname}",
+[Define to the name of the BOLT plugin DSO that must be
+ passed to the linker's -plugin=LIB option.])
+
AC_DEFINE_UNQUOTED(LTOPLUGINSONAME,"${host_lto_plugin_soname}",
[Define to the name of the LTO plugin DSO that must be
passed to the linker's -plugin=LIB option.])
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index fbcc9d033..b0d03430e 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1156,6 +1156,8 @@ proper position among the other output files. */
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
%(linker) " \
LINK_PLUGIN_SPEC \
+ "%{fauto-bolt|fauto-bolt=*|fbolt-use|fbolt-use=*: \
+ -plugin %(linker_auto_bolt_plugin_file) }"\
"%{flto|flto=*:%<fcompare-debug*} \
%{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \
"%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
@@ -1210,6 +1212,7 @@ static const char *endfile_spec = ENDFILE_SPEC;
static const char *startfile_spec = STARTFILE_SPEC;
static const char *linker_name_spec = LINKER_NAME;
static const char *linker_plugin_file_spec = "";
+static const char *linker_auto_bolt_plugin_file_spec = "";
static const char *lto_wrapper_spec = "";
static const char *lto_gcc_spec = "";
static const char *post_link_spec = POST_LINK_SPEC;
@@ -1723,6 +1726,8 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("multilib_reuse", &multilib_reuse),
INIT_STATIC_SPEC ("linker", &linker_name_spec),
INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec),
+ INIT_STATIC_SPEC ("linker_auto_bolt_plugin_file",
+ &linker_auto_bolt_plugin_file_spec),
INIT_STATIC_SPEC ("lto_wrapper", &lto_wrapper_spec),
INIT_STATIC_SPEC ("lto_gcc", &lto_gcc_spec),
INIT_STATIC_SPEC ("post_link", &post_link_spec),
@@ -9118,6 +9123,24 @@ driver::maybe_run_linker (const char *argv0) const
}
#endif
set_static_spec_shared (&lto_gcc_spec, argv0);
+
+ /* Set bolt-plugin. */
+ const char *fauto_bolt = "fauto-bolt";
+ const char *fbolt_use = "fbolt-use";
+ if (switch_matches (fauto_bolt, fauto_bolt + strlen (fauto_bolt), 1)
+ || switch_matches (fbolt_use, fbolt_use + strlen (fbolt_use), 1))
+ {
+ linker_auto_bolt_plugin_file_spec = find_a_file (&exec_prefixes,
+ BOLTPLUGINSONAME, X_OK, false);
+ if (!linker_auto_bolt_plugin_file_spec)
+ {
+ fatal_error (input_location,
+ "-fauto-bolt or -fbolt-use is used, but %s is not found",
+ BOLTPLUGINSONAME);
+
+ }
+ }
+
}
/* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cenhuilin/gcc.git
[email protected]:cenhuilin/gcc.git
cenhuilin
gcc
gcc
master

搜索帮助