Skip to content

Cannot run LLDB API Tests on MacOS #92603

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

Closed
vsoltan opened this issue May 17, 2024 · 1 comment · Fixed by #129135
Closed

Cannot run LLDB API Tests on MacOS #92603

vsoltan opened this issue May 17, 2024 · 1 comment · Fixed by #129135
Labels
cmake Build system in general and CMake in particular lldb platform:macos

Comments

@vsoltan
Copy link

vsoltan commented May 17, 2024

Environment:

MacOS Sonoma 14.4.1 (23E224)

% lldb --version
lldb version 19.0.0git (git@github.com:llvm/llvm-project.git revision 932bef23276da05c5eed2ffe7c62b7fc5f39caf1)
  clang revision 932bef23276da05c5eed2ffe7c62b7fc5f39caf1
  llvm revision 932bef23276da05c5eed2ffe7c62b7fc5f39caf1

% which python3
/usr/bin/python3

% python3 --version
Python 3.9.6

% echo $PYTHONPATH
/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python

Minimal repro:

$ python3
Python 3.9.6 (default, Feb  3 2024, 15:58:27)
[Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lldb
Traceback (most recent call last):
  File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/__init__.py", line 39, in <module>
    import _lldb
ModuleNotFoundError: No module named '_lldb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/__init__.py", line 42, in <module>
    from . import _lldb
ImportError: cannot import name '_lldb' from partially initialized module 'lldb' (most likely due to a circular import) (/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/__init__.py)
>>>

If I use the default installation of llvm (packaged with MacOS)

% echo PYTHONPATH
/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python

%which lldb
/usr/bin/lldb

% python3
Python 3.9.6 (default, Feb  3 2024, 15:58:27)
[Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lldb
>>>

it works as intended.

What led to all of this is trying to run the lldb api tests docs

% cmake -B build -G Ninja -C ./lldb/cmake/caches/Apple-lldb-macOS.cmake -DLLVM_ENABLE_PROJECTS="clang;lldb" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" ./llvm
% ninja check-lldb
********************
UNRESOLVED: lldb-api :: commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py (1006 of 2099)
******************** TEST 'lldb-api :: commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py' FAILED ********************
Script:
--
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 /Users/vsoltan/Documents/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env OBJCOPY=/Users/vsoltan/Documents/llvm-project/build/./bin/llvm-objcopy --env LLVM_LIBS_DIR=/Users/vsoltan/Documents/llvm-project/build/./lib --env LLVM_INCLUDE_DIR=/Users/vsoltan/Documents/llvm-project/build/include --env LLVM_TOOLS_DIR=/Users/vsoltan/Documents/llvm-project/build/./bin --libcxx-include-dir /Users/vsoltan/Documents/llvm-project/build/include/c++/v1 --libcxx-library-dir /Users/vsoltan/Documents/llvm-project/build/lib --arch arm64 --build-dir /Users/vsoltan/Documents/llvm-project/build/lldb-test-build.noindex --lldb-module-cache-dir /Users/vsoltan/Documents/llvm-project/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /Users/vsoltan/Documents/llvm-project/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /Users/vsoltan/Documents/llvm-project/build/./bin/lldb --compiler /Users/vsoltan/Documents/llvm-project/build/./bin/clang --dsymutil /Users/vsoltan/Documents/llvm-project/build/./bin/dsymutil --llvm-tools-dir /Users/vsoltan/Documents/llvm-project/build/./bin --lldb-obj-root /Users/vsoltan/Documents/llvm-project/build/tools/lldb --lldb-libs-dir /Users/vsoltan/Documents/llvm-project/build/./lib --framework /Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework /Users/vsoltan/Documents/llvm-project/lldb/test/API/commands/expression/import-std-module/vector-bool -p TestVectorBoolFromStdModule.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 19.0.0git (git@github.com:llvm/llvm-project.git revision 932bef23276da05c5eed2ffe7c62b7fc5f39caf1)
  clang revision 932bef23276da05c5eed2ffe7c62b7fc5f39caf1
  llvm revision 932bef23276da05c5eed2ffe7c62b7fc5f39caf1

--
Command Output (stderr):
--
No entry for terminal type "alacritty";
using dumb terminal settings.
No entry for terminal type "alacritty";
using dumb terminal settings.
Traceback (most recent call last):
  File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/__init__.py", line 39, 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/vsoltan/Documents/llvm-project/lldb/test/API/dotest.py", line 8, in <module>
    lldbsuite.test.run_suite()
  File "/Users/vsoltan/Documents/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", line 949, in run_suite
    import lldb
  File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/__init__.py", line 42, in <module>
    from . import _lldb
ImportError: cannot import name '_lldb' from partially initialized module 'lldb' (most likely due to a circular import) (/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/__init__.py)

Similar Issues:

  1. [lldb] tests errors ModuleNotFoundError: No module named '_lldb' with BuildType=Debug on Windows  #87381 On Windows and debug configuration. Seems like the fix has been checked in. Similar issue ([LLDB] Most tests fail on Windows when built for debug #51272) suggested using the Release configuration instead of Debug; I'm seeing the issue on Release and ReleaseWithDebInfo
  2. [lldb] Possible design issue when using Python >= 3.12 #70453 (comment) Issue for python >= 3.12, my version is 3.9.6
@llvmbot
Copy link
Member

llvmbot commented May 17, 2024

@llvm/issue-subscribers-lldb

Author: Valeriy Soltan (vsoltan)

Environment: ``` MacOS Sonoma 14.4.1 (23E224)

% lldb --version
lldb version 19.0.0git (git@github.com:llvm/llvm-project.git revision 932bef2)
clang revision 932bef2
llvm revision 932bef2

% which python3
/usr/bin/python3

% python3 --version
Python 3.9.6

% echo $PYTHONPATH
/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python


Minimal repro:

$ python3
Python 3.9.6 (default, Feb 3 2024, 15:58:27)
[Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lldb
Traceback (most recent call last):
File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/init.py", line 39, in <module>
import _lldb
ModuleNotFoundError: No module named '_lldb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/init.py", line 42, in <module>
from . import _lldb
ImportError: cannot import name '_lldb' from partially initialized module 'lldb' (most likely due to a circular import) (/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/init.py)
>>>


If I use the default installation of llvm (packaged with MacOS)

% echo PYTHONPATH
/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python

%which lldb
/usr/bin/lldb

% python3
Python 3.9.6 (default, Feb 3 2024, 15:58:27)
[Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lldb
>>>

it works as intended.

What led to all of this is trying to run the lldb api tests [docs](https://lldb.llvm.org/resources/test.html#api-tests)

% cmake -B build -G Ninja -C ./lldb/cmake/caches/Apple-lldb-macOS.cmake -DLLVM_ENABLE_PROJECTS="clang;lldb" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" ./llvm
% ninja check-lldb



UNRESOLVED: lldb-api :: commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py (1006 of 2099)
******************** TEST 'lldb-api :: commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py' FAILED ********************
Script:

/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 /Users/vsoltan/Documents/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env OBJCOPY=/Users/vsoltan/Documents/llvm-project/build/./bin/llvm-objcopy --env LLVM_LIBS_DIR=/Users/vsoltan/Documents/llvm-project/build/./lib --env LLVM_INCLUDE_DIR=/Users/vsoltan/Documents/llvm-project/build/include --env LLVM_TOOLS_DIR=/Users/vsoltan/Documents/llvm-project/build/./bin --libcxx-include-dir /Users/vsoltan/Documents/llvm-project/build/include/c++/v1 --libcxx-library-dir /Users/vsoltan/Documents/llvm-project/build/lib --arch arm64 --build-dir /Users/vsoltan/Documents/llvm-project/build/lldb-test-build.noindex --lldb-module-cache-dir /Users/vsoltan/Documents/llvm-project/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /Users/vsoltan/Documents/llvm-project/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /Users/vsoltan/Documents/llvm-project/build/./bin/lldb --compiler /Users/vsoltan/Documents/llvm-project/build/./bin/clang --dsymutil /Users/vsoltan/Documents/llvm-project/build/./bin/dsymutil --llvm-tools-dir /Users/vsoltan/Documents/llvm-project/build/./bin --lldb-obj-root /Users/vsoltan/Documents/llvm-project/build/tools/lldb --lldb-libs-dir /Users/vsoltan/Documents/llvm-project/build/./lib --framework /Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework /Users/vsoltan/Documents/llvm-project/lldb/test/API/commands/expression/import-std-module/vector-bool -p TestVectorBoolFromStdModule.py

Exit Code: 1

Command Output (stdout):

lldb version 19.0.0git (git@github.com:llvm/llvm-project.git revision 932bef2)
clang revision 932bef2
llvm revision 932bef2

--
Command Output (stderr):

No entry for terminal type "alacritty";
using dumb terminal settings.
No entry for terminal type "alacritty";
using dumb terminal settings.
Traceback (most recent call last):
File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/init.py", line 39, 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/vsoltan/Documents/llvm-project/lldb/test/API/dotest.py", line 8, in <module>
lldbsuite.test.run_suite()
File "/Users/vsoltan/Documents/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", line 949, in run_suite
import lldb
File "/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/init.py", line 42, in <module>
from . import _lldb
ImportError: cannot import name '_lldb' from partially initialized module 'lldb' (most likely due to a circular import) (/Users/vsoltan/Documents/llvm-project/build/bin/LLDB.framework/Resources/Python/lldb/init.py)


Similar Issues:
1. https://github.com/llvm/llvm-project/issues/87381 On Windows and debug configuration. Seems like the fix has been checked in. Similar issue (https://github.com/llvm/llvm-project/issues/51272) suggested using the Release configuration instead of Debug; I'm seeing the issue on `Release` and `ReleaseWithDebInfo`
2. https://github.com/llvm/llvm-project/issues/70453#issuecomment-2098783539 Issue for python &gt;= 3.12, my version is 3.9.6




</details>

JDevlieghere pushed a commit that referenced this issue Mar 3, 2025
Fix #92603

This replaces #113066. I finally came back to this issue and it seems
that this approach is still very promising.

As requested, I have added a short explanation as to why CPython module
should be moved into a submodule.

cc @JDevlieghere who reviewed on the previous PR earlier.
@EugeneZelenko EugeneZelenko added the cmake Build system in general and CMake in particular label Mar 3, 2025
jph-13 pushed a commit to jph-13/llvm-project that referenced this issue Mar 21, 2025
Fix llvm#92603

This replaces llvm#113066. I finally came back to this issue and it seems
that this approach is still very promising.

As requested, I have added a short explanation as to why CPython module
should be moved into a submodule.

cc @JDevlieghere who reviewed on the previous PR earlier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular lldb platform:macos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants