Sync patches from openeuler/gcc.
This commit is contained in:
parent
29bc173cdb
commit
5a6f8255b0
195
0332-Bugfix-Can-not-find-fdata-file.patch
Normal file
195
0332-Bugfix-Can-not-find-fdata-file.patch
Normal file
@ -0,0 +1,195 @@
|
||||
From e0b6e2e9d8226881886c28826a2fe2e55fd29511 Mon Sep 17 00:00:00 2001
|
||||
From: zhenyu--zhao_admin <zhaozhenyu17@huawei.com>
|
||||
Date: Sun, 29 Dec 2024 14:11:14 +0800
|
||||
Subject: [PATCH] [Bugfix] Can not find fdata file.
|
||||
|
||||
---
|
||||
gcc/ai-optimizer.cc | 49 ++++++++++++++++++++++++++++++++++++---------
|
||||
gcc/ai4c-infer.cc | 28 ++++----------------------
|
||||
gcc/gcc.cc | 31 +++++++++++++++++++++++++---
|
||||
gcc/gcc.h | 1 +
|
||||
4 files changed, 73 insertions(+), 36 deletions(-)
|
||||
|
||||
diff --git a/gcc/ai-optimizer.cc b/gcc/ai-optimizer.cc
|
||||
index c3d99dd85..70ff24077 100644
|
||||
--- a/gcc/ai-optimizer.cc
|
||||
+++ b/gcc/ai-optimizer.cc
|
||||
@@ -284,19 +284,50 @@ static int
|
||||
graph_infer (int argc1, const char **argv1, const char *mops,
|
||||
int argc2, int64_t *argv2)
|
||||
{
|
||||
- char *gcc_exec_prefix = getenv ("ONNX_FDATA_PATH");
|
||||
- if (gcc_exec_prefix == NULL)
|
||||
+ char gcc_exec_prefix[512];
|
||||
+ ssize_t len = readlink ("/proc/self/exe", gcc_exec_prefix,
|
||||
+ sizeof (gcc_exec_prefix) - 1);
|
||||
+ if (len == -1)
|
||||
return 0;
|
||||
- char native_file[512];
|
||||
|
||||
- if (gcc_exec_prefix)
|
||||
+ char native_file[512];
|
||||
+ strncpy (native_file, gcc_exec_prefix, sizeof (native_file) - 1);
|
||||
+ const char *target = "bin/gcc";
|
||||
+ const char *target_cc1 = "cc1";
|
||||
+ const char *target_gpp = "bin/g++";
|
||||
+ const char *target_cc1plus = "cc1plus";
|
||||
+ const char *target_gfortran = "bin/gfortran";
|
||||
+ const char *target_f951 = "f951";
|
||||
+ const char *replacement = "../libexec/gcc/optimizer.fdata";
|
||||
+ const char *replacement_front_end = "../../optimizer.fdata";
|
||||
+
|
||||
+ /* Replace the part of the current executable file path after the last slash
|
||||
+ to locate the model file. */
|
||||
+ if (strstr (native_file, target) != NULL ||
|
||||
+ strstr (native_file, target_gpp) != NULL ||
|
||||
+ strstr (native_file, target_gfortran) != NULL)
|
||||
{
|
||||
- const char *onnx_fdata = "optimizer.fdata";
|
||||
- strncpy (native_file, gcc_exec_prefix, sizeof (native_file) - 1);
|
||||
- native_file[sizeof (native_file) - 1] = '\0';
|
||||
char *last_slash = strrchr (native_file, '/');
|
||||
- if (last_slash)
|
||||
- strcpy (last_slash + 1, onnx_fdata);
|
||||
+ if (last_slash != NULL)
|
||||
+ {
|
||||
+ size_t prefix_len = last_slash - native_file + 1;
|
||||
+ native_file[prefix_len] = '\0';
|
||||
+ strncat (native_file, replacement, sizeof (native_file) -
|
||||
+ strlen (native_file) - 1);
|
||||
+ }
|
||||
+ }
|
||||
+ else if (strstr (native_file, target_cc1) != NULL ||
|
||||
+ strstr (native_file, target_cc1plus) != NULL ||
|
||||
+ strstr (native_file, target_f951) != NULL)
|
||||
+ {
|
||||
+ char *last_slash = strrchr (native_file, '/');
|
||||
+ if (last_slash != NULL)
|
||||
+ {
|
||||
+ size_t prefix_len = last_slash - native_file + 1;
|
||||
+ native_file[prefix_len] = '\0';
|
||||
+ strncat (native_file, replacement_front_end, sizeof (native_file) -
|
||||
+ strlen (native_file) - 1);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (access (native_file, F_OK) == 0)
|
||||
diff --git a/gcc/ai4c-infer.cc b/gcc/ai4c-infer.cc
|
||||
index 42922e1ca..4cd4bfb00 100644
|
||||
--- a/gcc/ai4c-infer.cc
|
||||
+++ b/gcc/ai4c-infer.cc
|
||||
@@ -333,29 +333,11 @@ preprocess (int argc, int64_t *argv, int64_t *in_modes)
|
||||
static int
|
||||
graph_infer (int argc, const char *argv, int argc2, int64_t *argv2)
|
||||
{
|
||||
- char *gcc_exec_prefix = getenv ("ONNX_FDATA_PATH");
|
||||
- if (gcc_exec_prefix == NULL)
|
||||
- return 0;
|
||||
- char file_name[512];
|
||||
-
|
||||
- if (gcc_exec_prefix)
|
||||
- {
|
||||
- const char *onnx_fdata = "onnx.fdata";
|
||||
- strncpy (file_name, gcc_exec_prefix, sizeof (file_name) - 1);
|
||||
- file_name[sizeof (file_name) - 1] = '\0';
|
||||
- char *last_slash = strrchr (file_name, '/');
|
||||
- if (last_slash)
|
||||
- strcpy (last_slash + 1, onnx_fdata);
|
||||
- }
|
||||
-
|
||||
+ const char *file_name = getenv ("GCC_AI4C_ONNX_FDATA");
|
||||
if (access (file_name, F_OK) == 0)
|
||||
- {
|
||||
- fill_node (file_name);
|
||||
- }
|
||||
+ fill_node (file_name);
|
||||
else
|
||||
- {
|
||||
- return 0;
|
||||
- }
|
||||
+ return 0;
|
||||
|
||||
int64_t in_modes[M_MODE_SIZE];
|
||||
|
||||
@@ -441,9 +423,7 @@ int
|
||||
get_optimize_decision_from_ai4c ()
|
||||
{
|
||||
if (initialized== 1)
|
||||
- {
|
||||
- return optimize_result;
|
||||
- }
|
||||
+ return optimize_result;
|
||||
if (native_tune && (strchr (native_tune, '+') != NULL))
|
||||
{
|
||||
char hash[65];
|
||||
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
|
||||
index 179d507f2..b4beb1957 100644
|
||||
--- a/gcc/gcc.cc
|
||||
+++ b/gcc/gcc.cc
|
||||
@@ -8133,6 +8133,7 @@ driver::main (int argc, char **argv)
|
||||
putenv_COLLECT_GCC (argv[0]);
|
||||
maybe_putenv_COLLECT_LTO_WRAPPER ();
|
||||
maybe_putenv_OFFLOAD_TARGETS ();
|
||||
+ putenv_ONNX_FDATA ();
|
||||
handle_unrecognized_options ();
|
||||
|
||||
if (completion)
|
||||
@@ -8189,9 +8190,6 @@ driver::expand_at_files (int *argc, char ***argv) const
|
||||
void
|
||||
driver::decode_argv (int argc, const char **argv)
|
||||
{
|
||||
- const char* libexec_path = standard_libexec_prefix;
|
||||
- if (libexec_path)
|
||||
- setenv ("ONNX_FDATA_PATH", libexec_path, 1);
|
||||
init_opts_obstack ();
|
||||
init_options_struct (&global_options, &global_options_set);
|
||||
|
||||
@@ -8590,6 +8588,33 @@ driver::maybe_putenv_COLLECT_LTO_WRAPPER () const
|
||||
|
||||
}
|
||||
|
||||
+/* Set up to remember the pathname of the onnx.fdata. */
|
||||
+
|
||||
+void
|
||||
+driver::putenv_ONNX_FDATA () const
|
||||
+{
|
||||
+ char *lto_wrapper_file;
|
||||
+ lto_wrapper_file = find_a_program ("lto-wrapper");
|
||||
+
|
||||
+ if (lto_wrapper_file)
|
||||
+ {
|
||||
+ lto_wrapper_file = convert_white_space (lto_wrapper_file);
|
||||
+ char native_file[512];
|
||||
+ const char *onnx_fdata = "../../onnx.fdata";
|
||||
+ strncpy (native_file, lto_wrapper_file, sizeof (native_file) - 1);
|
||||
+ native_file[sizeof (native_file) - 1] = '\0';
|
||||
+ char *last_slash = strrchr (native_file, '/');
|
||||
+ if (last_slash)
|
||||
+ strcpy (last_slash + 1, onnx_fdata);
|
||||
+ obstack_init (&collect_obstack);
|
||||
+ obstack_grow (&collect_obstack, "GCC_AI4C_ONNX_FDATA=",
|
||||
+ sizeof ("GCC_AI4C_ONNX_FDATA=") - 1);
|
||||
+ obstack_grow (&collect_obstack, native_file,
|
||||
+ strlen ( native_file) + 1);
|
||||
+ xputenv (XOBFINISH (&collect_obstack, char *));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* Set up to remember the names of offload targets. */
|
||||
|
||||
void
|
||||
diff --git a/gcc/gcc.h b/gcc/gcc.h
|
||||
index 63231ddb3..ff3ae8bed 100644
|
||||
--- a/gcc/gcc.h
|
||||
+++ b/gcc/gcc.h
|
||||
@@ -44,6 +44,7 @@ class driver
|
||||
void set_up_specs () const;
|
||||
void putenv_COLLECT_GCC (const char *argv0) const;
|
||||
void maybe_putenv_COLLECT_LTO_WRAPPER () const;
|
||||
+ void putenv_ONNX_FDATA () const;
|
||||
void maybe_putenv_OFFLOAD_TARGETS () const;
|
||||
void handle_unrecognized_options ();
|
||||
int maybe_print_and_exit () const;
|
||||
--
|
||||
2.43.0
|
||||
|
||||
10
gcc.spec
10
gcc.spec
@ -2,7 +2,7 @@
|
||||
%global gcc_major 12
|
||||
# Note, gcc_release must be integer, if you want to add suffixes to
|
||||
# %%{release}, append them after %%{gcc_release} on Release: line.
|
||||
%global gcc_release 63
|
||||
%global gcc_release 64
|
||||
|
||||
%global _unpackaged_files_terminate_build 0
|
||||
%global _performance_build 1
|
||||
@ -437,6 +437,7 @@ Patch328: 0328-Bugfix-if-split-Added-checking-for-ssa_name.patch
|
||||
Patch329: 0329-Fixed-work-with-loops-in-process_complex_cond.patch
|
||||
Patch330: 0330-bugfix-fix-typo-error.patch
|
||||
Patch331: 0331-fix-function-missing-return-value.patch
|
||||
Patch332: 0332-Bugfix-Can-not-find-fdata-file.patch
|
||||
|
||||
# Part 1001-1999
|
||||
%ifarch sw_64
|
||||
@ -1554,6 +1555,7 @@ not stable, so plugins must be rebuilt any time GCC is updated.
|
||||
%patch -P329 -p1
|
||||
%patch -P330 -p1
|
||||
%patch -P331 -p1
|
||||
%patch -P332 -p1
|
||||
|
||||
%ifarch sw_64
|
||||
%patch -P1001 -p1
|
||||
@ -4177,6 +4179,12 @@ end
|
||||
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
||||
|
||||
%changelog
|
||||
* Mon Dec 30 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-64
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Sync patches from openeuler/gcc.
|
||||
|
||||
* Thu Dec 26 2024 rfwang07 <wangrufeng5@huawei.com> - 12.3.1-63
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user