https://github.com/kendalharland created 
https://github.com/llvm/llvm-project/pull/104514

In python 3.8 PATH is no longer used to search for DLLs on Windows. When 
building Swift's patched version of LLDB this prevents LLDB from starting up, 
because it cannot find DLLs like swiftCore.dll, cmark-gfm.dll, etc. This PR 
adds a flag that can be passed to manually add specific directories as DLL 
search paths. This is preferred over simply expanding all directories in PATH 
which would recreate the code-injection security issues that the Python 3.8 
change was designed to address.

For context in this change to Python 3.8, see: 
https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew

Fixes https://github.com/llvm/llvm-project/issues/46235

>From f7b8c8dc3a670c70e5e21f63dc1e8e7cfb682c43 Mon Sep 17 00:00:00 2001
From: kendal <kendal@thebrowser.company>
Date: Wed, 14 Aug 2024 16:23:37 -0700
Subject: [PATCH] [lldb][dotest] Add an arg to add DLL search paths.

In python 3.8 PATH is no longer used to search for DLLs
on Windows. When building Swift's patched version of LLDB
this prevents LLDB from starting up, because it cannot find
DLLs like swiftCore.dll, cmark-gfm.dll, etc..

For context in this change to Python 3.8, see:
https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew
---
 lldb/packages/Python/lldbsuite/test/dotest.py      | 4 ++++
 lldb/packages/Python/lldbsuite/test/dotest_args.py | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index f14a00a2394b0b..aa9581a0aedc23 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -219,6 +219,10 @@ def parseOptionsAndInitTestdirs():
     except:
         raise
 
+    if args.dll_directory:
+        for dir in args.dll_directory:
+            os.add_dll_directory(dir)
+
     if args.unset_env_varnames:
         for env_var in args.unset_env_varnames:
             if env_var in os.environ:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index a80428ebec5891..cdcc659df61b1f 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -321,6 +321,12 @@ def create_parser():
         action="append",
         help="Specify an environment variable to set to the given value for 
the inferior.",
     )
+    # See https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew.
+    group.add_argument(
+        "--dll-directory",
+        action="append",
+        help="Specify a directory to include when searching for .dll files. 
This can be passed multiple times.",
+    )
     X(
         "-v",
         "Do verbose mode of unittest framework (print out each test case 
invocation)",

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to