[PATCH] D98278: [test] Only use hardcoded errno messages when compiling with an MSVC implementation

Markus Böck via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 9 11:41:49 PST 2021


zero9178 created this revision.
zero9178 added reviewers: jhenderson, ASDenysPetrov, abhina.sreeskantharajan, jdenny.
Herald added subscribers: mstorsjo, delcypher.
zero9178 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Visual Studios implementation of the C++ Standard Library does not use strerror to produce a message for std::error_code unlike other standard libraries such as libstdc++ or libc++ that might be used on Windows.

This patch changes the check to the following: Only use the hardcoded messages if windows-msvc is contained in the host triple and libc++ was not used when compiling LLVM.

This patch also allows various tests using these errc substitutions to pass when using a MinGW Toolchain on Windows outside of MSYS.

Cases this patch sadly does not solve: Host compiler is Clang-cl using libc++ or when a testsuite does not configure with host_triple


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98278

Files:
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===================================================================
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -347,10 +347,10 @@
         return True
 
     def add_err_msg_substitutions(self):
-        host_cxx = getattr(self.config, 'host_cxx', '')
-        # On Windows, python's os.strerror() does not emit the same spelling as the C++ std::error_code.
-        # As a workaround, hardcode the Windows error message.
-        if (sys.platform == 'win32' and 'MSYS' not in host_cxx):
+        # When using Visual Studio, python's os.strerror() does not emit the same spelling as the C++ std::error_code.
+        # As a workaround, hardcode the Visual Studio error messages.
+        host_triple = getattr(self.config, 'host_triple', '')
+        if re.search(r'windows-msvc', host_triple):
             self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
             self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
             self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98278.329420.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210309/ab217671/attachment.bin>


More information about the llvm-commits mailing list