]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: scan for case sensitive file extensions in lto.exp
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Thu, 2 Apr 2026 17:22:38 +0000 (19:22 +0200)
committerTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Fri, 8 May 2026 14:58:12 +0000 (16:58 +0200)
On a case insensitive filesystem, like on Windows, the "glob" function
in tcl returns an entry for each possible case that matches the
expression.

For example, `glob -nocomplain -types f -- "foo.{c,C}"` would return
both "foo.c" and "foo.C" even if there were only a "foo.c" file in the
directory.

gcc/testsuite/ChangeLog:

* lib/lto.exp: Make file listing case sensitive by doing case
sensitive filter after directory listing.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
gcc/testsuite/lib/lto.exp

index 4d04f8f8495de6670093ad13a410a074630d6f6e..64b7d992272690785071dcc534c260d0e953d18a 100644 (file)
@@ -711,9 +711,19 @@ proc lto-execute-1 { src1 sid } {
     set i 1
     set done 0
     while { !$done } {
-       set names [glob -nocomplain -types f -- "${dir}/${base}_${i}.{c,C,ii,\[fF\]{,90,95,03,08},d,m,mm}"]
+       set prefix "${dir}/${base}_${i}"
+
+       # glob returns a case insensitive list if filesystem is case
+       # insensitive.  To have a case sensitive list, fetch the extended list
+       # and then filter it to avoid duplicates.
+       regsub -all {([.^$*+?()$${}|])} $prefix {\\\1} pattern
+       set pattern [format {^%s.(c|C|ii|[fF](|90|95|03|08)|d|m|mm)$} $pattern]
+       set names [lsearch -inline -all -regexp \
+         [glob -nocomplain -types f -- "${prefix}.*"] $pattern]
+
        if { [llength ${names}] > 1 } {
-           warning "lto-execute: more than one file matched ${dir}/${base}_${i}.{c,C,ii,\[fF\]{,90,95,03,08},d,m,mm}"
+           warning "lto-execute: more than one file matched $pattern"
+           verbose "matching files: $names"
        }
        if { [llength ${names}] == 1 } {
            lappend src_list [lindex ${names} 0]