diff options
Diffstat (limited to '0325-gcc-opts-common.cc-Fix-build-with-clang.patch')
-rw-r--r-- | 0325-gcc-opts-common.cc-Fix-build-with-clang.patch | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/0325-gcc-opts-common.cc-Fix-build-with-clang.patch b/0325-gcc-opts-common.cc-Fix-build-with-clang.patch new file mode 100644 index 0000000..b862bf6 --- /dev/null +++ b/0325-gcc-opts-common.cc-Fix-build-with-clang.patch @@ -0,0 +1,54 @@ +From 14457b169e1e4cb372d165de3bbdde391e8b817f Mon Sep 17 00:00:00 2001 +From: YunQiang Su <yunqiang@isrc.iscas.ac.cn> +Date: Tue, 8 Oct 2024 18:04:01 +0800 +Subject: [PATCH] gcc/opts-common.cc: Fix build with clang + +1. For putenv ("AI_INFER_LEVEL=1"), clang complains that C++11 deprecates +convert string literal to char *, while putenv expcets "char *". +Let's use setenv, which expects "const char *". + +2. Ditto for char *lan in handle_lto_option. + +3. In `handle_machine_option`, there is a variable length array, + int64_t argv_hw[argc_hw] + clang complains about it, and in fact, argc_hw can be an const var. +--- + gcc/opts-common.cc | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc +index 12c3f7299..33c696f3d 100644 +--- a/gcc/opts-common.cc ++++ b/gcc/opts-common.cc +@@ -1053,7 +1053,7 @@ ai_infer_optimization (int argc, const char **argv, + dlclose (onnxruntime_lib_handle); + + if (model_pred == 1) +- putenv ("AI_INFER_LEVEL=1"); ++ setenv ("AI_INFER_LEVEL", "1", 1); + return model_pred; + } + +@@ -1065,9 +1065,8 @@ handle_lto_option (unsigned int lang_mask, + struct cl_decoded_option *&opt_array) + { + int ret = 0; +- char *lan = ""; + char *compiler = xstrdup (argv[0]); +- lan = strrchr (compiler, '/'); ++ char *lan = strrchr (compiler, '/'); + if (lan != NULL) + lan ++; + else +@@ -1125,7 +1124,7 @@ handle_machine_option (unsigned int lang_mask, + { + return ret; + } +- int argc_hw = 6; ++ const int argc_hw = 6; + int64_t argv_hw[argc_hw] = { + global_options.x_param_simultaneous_prefetches, + global_options.x_param_l1_cache_size, +-- +2.33.0 + |