diff options
author | YunQiang Su <syq@gcc.gnu.org> | 2023-12-19 07:36:52 +0800 |
---|---|---|
committer | YunQiang Su <syq@gcc.gnu.org> | 2023-12-23 16:46:23 +0800 |
commit | 384dbb0b4e751e6eb7ba3f9993a6cce466743926 (patch) | |
tree | 83dc3438d1142d95a3114d70b683d1f193d3fcd6 | |
parent | 290230034092898981488d0716ddae43bd36c09f (diff) | |
download | gcc-384dbb0b4e751e6eb7ba3f9993a6cce466743926.zip gcc-384dbb0b4e751e6eb7ba3f9993a6cce466743926.tar.gz gcc-384dbb0b4e751e6eb7ba3f9993a6cce466743926.tar.bz2 |
MIPS: Put the ret to the end of args of reconcat [PR112759]
The function `reconcat` cannot append string(s) to NULL,
as the concat process will stop at the first NULL.
Let's always put the `ret` to the end, as it may be NULL.
We keep use reconcat here, due to that reconcat can make it
easier if we add more hardware features detecting, for example
by hwcap.
gcc/
PR target/112759
* config/mips/driver-native.cc (host_detect_local_cpu):
Put the ret to the end of args of reconcat.
-rw-r--r-- | gcc/config/mips/driver-native.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/config/mips/driver-native.cc b/gcc/config/mips/driver-native.cc index afc276f..4ef48e1 100644 --- a/gcc/config/mips/driver-native.cc +++ b/gcc/config/mips/driver-native.cc @@ -44,6 +44,8 @@ const char * host_detect_local_cpu (int argc, const char **argv) { const char *cpu = NULL; + /* Don't assigne any static string to ret. If you need to do so, + use concat. */ char *ret = NULL; char buf[128]; FILE *f; @@ -90,7 +92,8 @@ host_detect_local_cpu (int argc, const char **argv) fallback_cpu: #if defined (__mips_nan2008) - ret = reconcat (ret, " -mnan=2008 ", NULL); + /* Put the ret to the end of list, since it may be NULL. */ + ret = reconcat (ret, " -mnan=2008 ", ret, NULL); #endif #ifdef HAVE_GETAUXVAL @@ -104,7 +107,7 @@ fallback_cpu: #endif if (cpu) - ret = reconcat (ret, ret, "-m", argv[0], "=", cpu, NULL); + ret = reconcat (ret, " -m", argv[0], "=", cpu, ret, NULL); return ret; } |