diff --git a/delete-auto-bolt-feature.patch b/delete-auto-bolt-feature.patch new file mode 100644 index 0000000000000000000000000000000000000000..fcdd00c9301e3d1e7145cac6a383cbbb4661ae8e --- /dev/null +++ b/delete-auto-bolt-feature.patch @@ -0,0 +1,480 @@ +From 7a43777d1dec212a8e6fb4d30d3ad90298dc54f5 Mon Sep 17 00:00:00 2001 +From: liyancheng <412998149@qq.com> +Date: Tue, 5 Dec 2023 20:28:15 +0800 +Subject: [PATCH] delete auto-bolt + +--- + bolt-plugin/bolt-plugin.cc | 372 +------------------------------------ + 1 file changed, 4 insertions(+), 368 deletions(-) + +diff --git a/bolt-plugin/bolt-plugin.cc b/bolt-plugin/bolt-plugin.cc +index f357b00dd..25cd637ea 100644 +--- a/bolt-plugin/bolt-plugin.cc ++++ b/bolt-plugin/bolt-plugin.cc +@@ -215,28 +215,10 @@ struct plugin_objfile + const struct ld_plugin_input_file *file; + }; + +-struct jump_info +-{ +- string des_func_name; +- string src_addr_offset; +- string dst_addr_offset; +- string count; +-}; +- +-struct func_info +-{ +- string function_name; +- string bind_type; /* "GLOBAL","WEAK","LOCAL","UNKNOWN". */ +- string size; +- vector edges; +-}; +- + /* Define feedback data type. */ + enum feedback_type + { + NULL_TYPE, /* No feedback data. */ +- PGO_TYPE, /* Feedback data from PGO. */ +- AFDO_TYPE, /* Feedback data from AutoFDO. */ + BOLT_TYPE, /* Feedback data from BOLT. */ + }; + +@@ -246,10 +228,6 @@ enum feedback_type + + /* The FDO section's special prefix names. */ + #define ASM_FDO_SECTION_PREFIX ".text.fdo." +-#define ASM_FDO_CALLER_FLAG ".fdo.caller " +-#define ASM_FDO_CALLER_BIND_FLAG ".fdo.caller.bind " +-#define ASM_FDO_CALLER_SIZE_FLAG ".fdo.caller.size " +-#define ASM_FDO_CALLEE_FLAG ".fdo.callee " + + static int linker_output_set; + +@@ -277,9 +255,6 @@ static enum feedback_type fdo_type = feedback_type::NULL_TYPE; + + static vector gcc_options; + +-/* Map of > */ +-static map> weak_functions; +- + /* Returns 1 if two strings have the same prefix. */ + + inline static int +@@ -369,14 +344,7 @@ generate_bolt_cmd () + } + else + { +- if (fdo_type == feedback_type::AFDO_TYPE) +- { +- cmd = string ("llvm-bolt -reorder-functions=hfsort+ ") +- + tmp_out_file_name + " -o " + new_binary +- + " -data=" + bolt_profile_name; +- } +- else if (fdo_type == feedback_type::PGO_TYPE +- || fdo_type == feedback_type::BOLT_TYPE) ++ if (fdo_type == feedback_type::BOLT_TYPE) + { + cmd = string ("llvm-bolt -reorder-blocks=cache+ ") + + string (" -reorder-functions=hfsort+ ") +@@ -386,12 +354,7 @@ generate_bolt_cmd () + + " -data=" + bolt_profile_name; + } + else +- { +- MSG_ERROR ("Invalid profile type!"); +- return string (); +- } +- MSG_INFO ("Using the default llvm-bolt optimization option," +- " manually specify this option by -fbolt-option. "); ++ MSG_ERROR ("Invalid profile type!"); + } + return cmd; + } +@@ -460,201 +423,14 @@ cleanup_handler () + return LDPS_OK; + } + +-/* Open BOLT profile file generated by -fauto-bolt. */ +- +-static void +-open_bolt_profile_file (const char *file_name) +-{ +- if (file_name == NULL) +- { +- MSG_ERROR ("Empty BOLT profile name, exit!"); +- } +- +- if (bolt_file_fd == NULL) +- { +- MSG_INFO ("Generate profile file for BOLT: %s", file_name); +- bolt_file_fd = fopen (file_name, "wt"); +- if (!bolt_file_fd) +- { +- MSG_ERROR ("Failed to open the file: %s." +- " Please check whether the target path exists.", +- file_name); +- } +- return; +- } +- else +- { +- MSG_WARN ("BOLT profile file: %s is open, skip.", file_name); +- } +-} +- +-/* In BOLT profile, function with same name represent as func_name/file_name/1, +- also, `/` has been added in gcc/final.c, so add /1 if this function is same +- name function. */ +- +-static string +-add_suffix (string str) +-{ +- if (str.empty () || (strstr (str.c_str (), "/") == NULL)) +- { +- return str; +- } +- +- return str + "/1"; +-} +- +-/* Dump function info to BOLT profile, bolt_file_fd does not need +- to be closed here. */ +- +-static void +-dump_func_to_bolt_profile_file (const struct func_info &func) +-{ +- if (func.edges.empty ()) +- { +- return; +- } +- +- if (!bolt_file_fd) +- { +- open_bolt_profile_file (bolt_profile_name.c_str ()); +- +- /* Check whether the feedback data is from AutoFDO. */ +- if (fdo_type == feedback_type::AFDO_TYPE) +- { +- fprintf (bolt_file_fd, "no_lbr cycles:u:\n"); +- } +- } +- +- for (const auto &edge: func.edges) +- { +- if (fdo_type == feedback_type::PGO_TYPE) +- { +- fprintf (bolt_file_fd, "1 %s %s 1 %s %s 0 %s\n", +- add_suffix (func.function_name).c_str (), +- edge.src_addr_offset.c_str (), +- add_suffix (edge.des_func_name).c_str (), +- edge.dst_addr_offset.c_str (), edge.count.c_str ()); +- } +- else if (fdo_type == feedback_type::AFDO_TYPE) +- { +- fprintf (bolt_file_fd, "1 %s %s %s\n", +- add_suffix (func.function_name).c_str (), +- edge.src_addr_offset.c_str (), +- edge.count.c_str ()); +- } +- } +- +- fflush (bolt_file_fd); +-} +- + /* Called by the linker when all symbols have been read. */ + + static enum ld_plugin_status + all_symbols_read_handler () + { +- for (const auto &functions: weak_functions) +- { +- /* More than one weak function. */ +- if (functions.second.size () > 1) +- { +- MSG_WARN ("The weak function: %s is confusing, take the first one.", +- functions.first.c_str ()); +- } +- +- dump_func_to_bolt_profile_file (functions.second[0]); +- } + return LDPS_OK; + } + +-/* Move pointer p to end and return end. */ +- +-static char * +-get_next_content (char *p, char *end) +-{ +- while (*p && p < end) +- { +- p++; +- } +- p++; +- +- return p; +-} +- +-/* Process function head info. */ +- +-static char * +-process_function_head (char *data , char *end, struct func_info *func) +-{ +- CHECK (is_prefix_of (ASM_FDO_CALLER_FLAG, data), LDPL_FATAL, +- "The function name is missing."); +- func->function_name = xstrdup (data + strlen (ASM_FDO_CALLER_FLAG)); +- data = get_next_content (data, end); +- +- CHECK (is_prefix_of (ASM_FDO_CALLER_SIZE_FLAG, data), LDPL_FATAL, +- "The function size is missing."); +- func->size = xstrdup (data + strlen (ASM_FDO_CALLER_SIZE_FLAG)); +- data = get_next_content (data, end); +- +- CHECK (is_prefix_of (ASM_FDO_CALLER_BIND_FLAG, data), LDPL_FATAL, +- "The function bind type is missing."); +- func->bind_type = xstrdup (data + strlen (ASM_FDO_CALLER_BIND_FLAG)); +- data = get_next_content (data, end); +- return data; +-} +- +-/* Read profile info from the symbol table located between data and end. */ +- +-static void +-process_section (char *data, char *end) +-{ +- struct func_info func; +- +- data = process_function_head (data, end, &func); +- +- while (*data && data < end) +- { +- struct jump_info jump; +- +- CHECK (data, LDPL_FATAL, "data is NULL"); +- jump.src_addr_offset = xstrdup (data); +- +- data = get_next_content (data, end); +- CHECK (data, LDPL_FATAL, "data is NULL"); +- if (is_prefix_of (ASM_FDO_CALLEE_FLAG, data)) +- { +- jump.des_func_name = xstrdup (data + strlen (ASM_FDO_CALLEE_FLAG)); +- jump.dst_addr_offset = "0"; +- data = get_next_content (data, end); +- CHECK (data, LDPL_FATAL, "data is NULL"); +- } +- else if (fdo_type == feedback_type::PGO_TYPE) +- { +- jump.des_func_name = func.function_name; +- jump.dst_addr_offset = xstrdup (data); +- data = get_next_content (data, end); +- CHECK (data, LDPL_FATAL, "data is NULL"); +- } +- else +- { +- jump.des_func_name = func.function_name; +- } +- +- jump.count = xstrdup (data); +- data = get_next_content (data, end); +- +- func.edges.push_back (jump); +- } +- +- if (is_prefix_of ("WEAK", func.bind_type.c_str ())) +- { +- weak_functions[func.function_name].push_back (func); +- } +- else +- { +- dump_func_to_bolt_profile_file (func); +- } +-} +- + /* Process error when calling function process_symtab. */ + + static int +@@ -694,42 +470,8 @@ process_symtab (void *data, const char *name, off_t offset, off_t length) + { + return 1; + } +- +- secdata = secdatastart = (char *)xmalloc (length * sizeof (char)); +- offset += obj->file->offset; +- if (offset != lseek (obj->file->fd, offset, SEEK_SET)) +- { +- return process_symtab_error (obj, secdatastart); +- } +- +- do +- { +- ssize_t got = read (obj->file->fd, secdata, length); +- +- if (got == 0) +- { +- break; +- } +- else if (got > 0) +- { +- secdata += got; +- length -= got; +- } +- else if (errno != EINTR) +- { +- return process_symtab_error (obj, secdatastart); +- } +- } +- while (length > 0); +- +- if (length > 0) +- { +- return process_symtab_error (obj, secdatastart); +- } +- +- process_section (secdatastart, secdata); +- free (secdatastart); +- return 1; ++ MSG_ERROR ("-fauto-bolt is not support."); ++ return 0; + } + + /* Callback used by gold to check if the plugin will claim FILE. Writes +@@ -769,74 +511,6 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) + return LDPS_OK; + } + +-/* Mangle filename path of BASE and output new allocated pointer with +- mangled path. */ +- +-static string +-mangle_path (const string &base) +-{ +- if (base.empty ()) +- { +- return base; +- } +- +- /* Convert '/' to '#', convert '..' to '^', +- convert ':' to '~' on DOS based file system. */ +- +- string new_path; +- int base_len = base.size (); +- int l = 0; +- int r = 0; +- while (l < base_len) +- { +- while (r < base_len && base[r] != '/') +- { +- r++; +- } +- +- int len = r - l; +- if (len == 2 && base[r - 2] == '.' && base[r - 1] == '.') +- { +- new_path += '^'; +- } +- else +- { +- new_path += base.substr (l, r - l); +- } +- if (r < base_len) +- { +- new_path += '#'; +- } +- +- r++; +- l = r; +- } +- return new_path; +-} +- +-/* Generate BOLT profile name from file_name. */ +- +-static string +-generate_bolt_profile_name (string file_name) +-{ +- if (!IS_ABSOLUTE_PATH (file_name.c_str ())) +- { +- if (!bolt_dir_path.empty ()) +- { +- file_name = concat (get_current_dir_name (), +- separator, file_name.c_str (), NULL); +- file_name = mangle_path (file_name); +- } +- else +- { +- bolt_dir_path = DEFAULT_BOLT_OUT_DIR; +- } +- } +- file_name = concat (bolt_dir_path.c_str (), separator, file_name.c_str (), +- NULL); +- return file_name; +-} +- + /* Match option_prefix from gcc_options, return the index of gcc_options. */ + + static int +@@ -927,31 +601,6 @@ parser_bolt_optimize_option (string raw_string) + return raw_string; + } + +-/* Process option -fauto-bolt. */ +- +-static void +-process_auto_bolt_option (const string &flag_auto_bolt) +-{ +- const int auto_bolt_index = match_gcc_option (flag_auto_bolt.c_str ()); +- +- if (auto_bolt_index != -1) +- { +- if (gcc_options[auto_bolt_index] == "-fauto-bolt") +- { +- MSG_INFO ("Use default output directory %s, ", DEFAULT_BOLT_OUT_DIR); +- MSG_INFO ("Specify it using -fauto-bolt= if needed."); +- } +- else +- { +- string flag_auto_bolt_equal = "-fauto-bolt="; +- bolt_dir_path = lrealpath (gcc_options[auto_bolt_index].substr ( +- flag_auto_bolt_equal.size ()).c_str ()); +- MSG_INFO ("Get bolt profile path: %s", bolt_dir_path.c_str ()); +- } +- bolt_profile_name = generate_bolt_profile_name(bolt_profile_name); +- } +-} +- + /* Process option -fbolt-use=. */ + + static void +@@ -1035,9 +684,6 @@ process_output_option (const string &flag_o) + static void + process_gcc_option () + { +- string flag_profile_use = "-fprofile-use"; +- string flag_auto_profile = "-fauto-profile"; +- string flag_auto_bolt = "-fauto-bolt"; + string flag_bolt_use = "-fbolt-use="; + string flag_bolt_target = "-fbolt-target="; + string flag_bolt_optimize_options = "-fbolt-option="; +@@ -1051,19 +697,9 @@ process_gcc_option () + /* Function process_output_option should be processed before + process_auto_bolt_option to obtain correct bolt_profile_name. */ + process_output_option (flag_o); +- process_auto_bolt_option (flag_auto_bolt); + process_bolt_use_option (flag_bolt_use); + process_bolt_target_option (flag_bolt_target); + process_bolt_option (flag_bolt_optimize_options); +- +- if (match_gcc_option (flag_profile_use.c_str ()) != -1) +- { +- fdo_type = feedback_type::PGO_TYPE; +- } +- else if (match_gcc_option (flag_auto_profile.c_str ()) != -1) +- { +- fdo_type = feedback_type::AFDO_TYPE; +- } + + if (match_gcc_option (flag_bolt_use.c_str ()) != -1) + { +-- +2.25.1 + diff --git a/gcc.spec b/gcc.spec index e0547c7102b32bb93660799efafc01889d413158..61b334b7d08589464c460024da8f2628e84a36a9 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}.57 +Release: %{openEulerDATE}.58 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD Group: Development/Languages #Source0: hcc-aarch64-linux-release.tar.bz2 @@ -105,6 +105,7 @@ Patch55: Backport-Rework-cold-and-hot-label-attributes-in-pre.patch Patch56: Backport-Learn-GIMPLE-pretty-printer-to-produce-nice.patch Patch57: Backport-AArch64-Fix-longbranch-test.patch Patch58: Backport-re-PR-tree-optimization-84552-Compile-time-.patch +Patch59: delete-auto-bolt-feature.patch #AutoReqProv: off AutoReq: true @@ -3337,6 +3338,9 @@ fi %changelog +* Tue Dec 05 2023 liyancheng <412998149@qq.com> - 7.3.0-2020033101.58 +- Delete useless auto-bolt feature. + * Tue Dec 05 2023 eastb233 - 7.3.0-2020033101.57 - Fix efl compilation issue.