llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.61k stars 11.35k forks source link

Cannot run LLDB API Tests on MacOS #92603

Open vsoltan opened 3 months ago

vsoltan commented 3 months ago

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. 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 >= 3.12, my version is 3.9.6
llvmbot commented 3 months ago

@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 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](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 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. 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 >= 3.12, my version is 3.9.6