-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][dotest] Add an arg to add DLL search paths. #104514
Conversation
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
@llvm/pr-subscribers-lldb Author: Kendal Harland (kendalharland) ChangesIn 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 #46235 Full diff: https://github.com/llvm/llvm-project/pull/104514.diff 2 Files Affected:
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)",
|
Can those swift libraries be found automatically? For example if they're at some known path relative to lldb or the swift compiler? |
Yes. They can be copied into the python module where _lldb resides. Help me understand: why is this preferrable over an explicit input to add dll search paths? |
I think that having fewer knobs that one needs to remember to set to correct values is better. Sometimes that's unavoidable, but I wanted to make sure this is one of those cases. Embedding this information into the swig bindings sounds like a good idea. |
@labath @kendalharland Here is an attempt to fix this in the bindings themselves: swiftlang#9370 What do you think? |
Superceded by swiftlang#9370 |
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 #46235
Related to swiftlang#9141