On 2025-04-03 11:37, Lulu Cheng wrote:


在 2025/4/3 上午11:12, Xi Ruoyao 写道:
On Thu, 2025-04-03 at 10:13 +0800, Lulu Cheng wrote:
在 2025/4/2 上午11:19, Xi Ruoyao 写道:
Avoid using gensub that FreeBSD awk lacks, use gsub and split those
each
of gawk, mawk, and FreeBSD awk provides.

Reported-by: mp...@vip.163.com
Link: https://man.freebsd.org/cgi/man.cgi?query=awk

gcc/ChangeLog:

    * config/loongarch/genopts/gen-evolution.awk: Avoid using
gensub
    that FreeBSD awk lacks.
---

Manually tested the script with gawk and FreeBSD awk.  Ok for trunk?
OK.

Thanks!
Pushed now.

Could you backpoint it  to gcc 14?

Thanks.

gcc/config/loongarch/genopts/gen-evolution.awk | 8 +++++---
   1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/config/loongarch/genopts/gen-evolution.awk
b/gcc/config/loongarch/genopts/gen-evolution.awk
index bf16b26760e..142b658fe7a 100644
--- a/gcc/config/loongarch/genopts/gen-evolution.awk
+++ b/gcc/config/loongarch/genopts/gen-evolution.awk
@@ -33,10 +33,12 @@ BEGIN {
   {
       cpucfg_word[NR] = $1
       cpucfg_bit_in_word[NR] = $2
-    name[NR] = gensub(/-/, "_", "g", $3)
+    name[NR] = $3
+    gsub("-", "_", name[NR])
       name_capitalized[NR] = toupper(name[NR])
-    isa_version_major[NR] = gensub(/^([1-9][0-9]*)\.([0-9]+)$/,
"\\1", 1, $4)
-    isa_version_minor[NR] = gensub(/^([1-9][0-9]*)\.([0-9]+)$/,
"\\2", 1, $4)
+    split($4, isa_ver, "\\.")
+    isa_version_major[NR] = isa_ver[1]
+    isa_version_minor[NR] = isa_ver[2]
          $1 = $2 = $3 = $4 = ""
       sub (/^\s*/, "")
Hi, Ruoyao and Lulu,

When I cross-build gcc on ubuntu I triggered `illegal reference to array idx_list` at asort by mawk.

$ cd gcc/config/loongarch/genopts
$ mawk -v header_p=1 -f gen-evolution.awk isa-evolution.in
mawk: gen-evolution.awk: line 104: illegal reference to array idx_list

$ mawk --version
mawk 1.3.4 20240123
Copyright 2008-2023,2024, Thomas E. Dickey
Copyright 1991-1996,2014, Michael D. Brennan

random-funcs:       arc4random_stir/arc4random
regex-funcs:        internal

compiled limits:
sprintf buffer      8192
maximum-integer     9223372036854775808


Reply via email to