rust-lang / rust-lang/rust

Debuginfo tests sometimes run with the wrong Python version on MacOS

Open
#123,621 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-debuginfo A-testsuite C-bug O-macos T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

Running ./x t tests/debuginfo on my system configuration creates a lot of errors like this:

---- [debuginfo-lldb] tests/debuginfo/basic-types.rs stdout ----
NOTE: compiletest thinks it is using LLDB version 1700
NOTE: compiletest thinks it is using LLDB without native rust support
error: Error while running LLDB
status: exit status: 1
command: PYTHONPATH="/opt/homebrew/Cellar/llvm/17.0.6_1/libexec/python3.12/site-packages" PYTHONUNBUFFERED="1" "/usr/bin/python3" "/Users/user/Documents/projects/rust/src/etc/lldb_batchmode.py" "/Users/user/Documents/projects/rust/build/aarch64-apple-darwin/test/debuginfo/basic-types.lldb/a" "/Users/user/Documents/projects/rust/build/aarch64-apple-darwin/test/debuginfo/basic-types.lldb/basic-types.debugger.script"
--- stdout -------------------------------
3.9.6 (default, Feb  3 2024, 15:58:27)
[Clang 15.0.0 (clang-1500.3.9.4)]
------------------------------------------
--- stderr -------------------------------
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/llvm/17.0.6_1/libexec/python3.12/site-packages/lldb/__init__.py", line 44, in <module>
    import _lldb
ModuleNotFoundError: No module named '_lldb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/Documents/projects/rust/src/etc/lldb_batchmode.py", line 17, in <module>
    import lldb
  File "/opt/homebrew/Cellar/llvm/17.0.6_1/libexec/python3.12/site-packages/lldb/__init__.py", line 47, in <module>
    from . import _lldb
ImportError: cannot import name '_lldb' from partially initialized module 'lldb' (most likely due to a circular import) (/opt/homebrew/Cellar/llvm/17.0.6_1/libexec/python3.12/site-packages/lldb/__init__.py)
------------------------------------------

I have the following system configuration:

$ which lldb
/opt/homebrew/opt/llvm/bin/lldb
$ /opt/homebrew/opt/llvm/bin/lldb --version
3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)]
lldb version 17.0.6
$ xcrun -f lldb
/Library/Developer/CommandLineTools/usr/bin/lldb
$ /Library/Developer/CommandLineTools/usr/bin/lldb --version
lldb-1500.0.404.7
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
$ which python3
/opt/homebrew/bin/python3
$ /opt/homebrew/bin/python3 --version
Python 3.12.2
$ xcrun -f python3
/Library/Developer/CommandLineTools/usr/bin/python3
$ /Library/Developer/CommandLineTools/usr/bin/python3 --version
Python 3.9.6
$ printenv | grep PYTHON
# nothing

Homebrew provides the default python3 and lldb in PATH, with python 3.12.2. There is also the CLI tools versions, which are available via xcrun or at /usr/bin, with python version 3.9.6. This should be a pretty common configuration.

_lldb.cpython-312-darwin.so exists in /opt/homebrew/Cellar/llvm/17.0.6_1/libexec/python3.12/site-packages/lldb/, but based on some poking around it seems like this is trying to get run with python 3.9. This makes me think that lldb_python_dir in compiletest is not choosing a version that aligns with the LLDB version/path imported by src/etc/lldb_batchmode.py.

Some discussion at https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20MacOS.20_lldb.20python.20error.20for.20debugifo.20tests

@rustbot label +A-testsuite +O-macos +T-bootstrap

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running ./x t tests/debuginfo on macOS and inspect compiletest's lldb_python_dir selection alongside src/etc/lldb_batchmode.py. Trace how the selected Python interpreter and LLDB installation are paired; done means the debuginfo tests use matching versions and no longer produce the reported _lldb import errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, python, rust
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.