[PATCH] D158221: [llvm-lit] copy CRT/STL DLLs into the output directory
Nicole Mazzuca via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 17 14:58:17 PDT 2023
strega-nil created this revision.
strega-nil added reviewers: barcharcraz, jdenny, RKSimon.
Herald added a subscriber: delcypher.
Herald added a project: All.
strega-nil requested review of this revision.
Herald added a project: LLVM.
It turns out that the STL requires you to place the DLLs into the
directory of the executable; else, msvcp140.dll will be taken from
C:\Windows\System32 (which is unsupported).
This was discovered because of the recent constexpr mutex change;
see [microsoft/STL#3824][]. Especially the fuzzer unit tests fail
completely with the mutex changes.
[microsoft/STL#3824]: https://github.com/microsoft/STL/issues/3824
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158221
Files:
llvm/utils/lit/lit/TestRunner.py
llvm/utils/lit/lit/util.py
Index: llvm/utils/lit/lit/util.py
===================================================================
--- llvm/utils/lit/lit/util.py
+++ llvm/utils/lit/lit/util.py
@@ -241,10 +241,10 @@
# Get suffixes to search.
# On Cygwin, 'PATHEXT' may exist but it should not be used.
- if os.pathsep == ";":
- pathext = os.environ.get("PATHEXT", "").split(";")
+ if os.path.splitext(command)[-1] != '' or os.pathsep != ';':
+ pathext = ['']
else:
- pathext = [""]
+ pathext = os.environ.get('PATHEXT', '').split(';')
# Search the paths...
for path in paths.split(os.pathsep):
Index: llvm/utils/lit/lit/TestRunner.py
===================================================================
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -11,6 +11,7 @@
import shutil
import tempfile
import threading
+from pathlib import Path
import io
@@ -2066,7 +2067,18 @@
return out, err, exitCode, timeoutInfo, status
# Create the output directory if it does not already exist.
- lit.util.mkdir_p(os.path.dirname(tmpBase))
+ outputDir = os.path.dirname(tmpBase)
+ lit.util.mkdir_p(outputDir)
+
+ # On Windows, copy the required DLLs from PATH into the test directory
+ # This avoids the loader finding DLLs in C:\Windows\System32
+ if litConfig.isWindows:
+ toolsetDirectory = Path(lit.util.which("cl.exe")).parent
+ for dllToCopy in itertools.chain(\
+ toolsetDirectory.glob('msvcp*.dll'),\
+ toolsetDirectory.glob('vcruntime*.dll'),\
+ toolsetDirectory.glob('ucrtbase*.dll')):
+ shutil.copyfile(dllToCopy, os.path.join(outputDir, dllToCopy.name))
# Re-run failed tests up to test.allowed_retries times.
execdir = os.path.dirname(test.getExecPath())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158221.551284.patch
Type: text/x-patch
Size: 1837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230817/9df4c6a7/attachment.bin>
More information about the llvm-commits
mailing list