[llvm] [llvm-ar] fix inconsistent case sensitivity for path matching on Windows (PR #196541)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 00:58:05 PDT 2026


================
@@ -27,3 +27,35 @@
 # RUN: FileCheck %s -input-file=%t/thin-archive.a --check-prefix=EMPTY --implicit-check-not {{.}}
 
 EMPTY: !<thin>
+
+# File instance counting should respect Windows case-insensitive name matching.
+# Otherwise, if you have foo.txt and FOO.TXT, "-N 2 foo.txt" fails because
+# file is not found.
+
+# RUN: rm -f %t/count-case.a 
+# RUN: mkdir -p %t/a %t/b
+# RUN: echo first > %t/a/foo.txt
+# RUN: echo second > %t/b/FOO.TXT
+# RUN: llvm-ar rc %t/count-case.a %t/a/foo.txt %t/b/FOO.TXT
+
+# RUN: mkdir -p %t/out1 %t/out2
+# RUN: llvm-ar xN 1 --output %t/out1 %t/count-case.a foo.txt
+# RUN: cat %t/out1/foo.txt | FileCheck %s --check-prefix=EXTRACT-FIRST
+# RUN: llvm-ar xN 2 --output %t/out2 %t/count-case.a foo.txt
+# RUN: cat %t/out2/FOO.TXT | FileCheck %s --check-prefix=EXTRACT-SECOND
+# RUN: not llvm-ar xN 3 --output %t/out2 %t/count-case.a foo.txt 2>&1 | FileCheck %s --check-prefix=EXTRACT-NOT-FOUND
+
+# EXTRACT-FIRST: first
+# EXTRACT-SECOND: second
+# EXTRACT-NOT-FOUND: error: 'foo.txt' was not found
+
+# RUN: rm -f %t/delete-count.a
+# RUN: llvm-ar rc %t/delete-count.a %t/a/foo.txt %t/b/FOO.TXT
+# RUN: llvm-ar dN 2 %t/delete-count.a foo.txt
+# RUN: llvm-ar t %t/delete-count.a | FileCheck %s --check-prefix=DELETE-SECOND
----------------
jh7370 wrote:

It's probably worth an `--implicit-check-not={{.*}}` addition to the FileCheck command here and to drop the `-NOT` check line. The reason for this is that if the archive members got reordered or renamed, the NOT would no longer be valid (in the case of reordering, the -NOT only checks that the pattern doesn't exist since the previous positive check line was matched), whereas `--implicit-check-not={{.*}}` is equivalent to saying "fail if any output is detected outside the output I explicitly am looking for".

https://github.com/llvm/llvm-project/pull/196541


More information about the llvm-commits mailing list