Closed irfanmekic closed 1 year ago
Could you please provide your test.cpp so I can try to reproduce the issue?
Error message would be useful for debugging as well.
It seems included clang/native/libclang.dylib errors out with this message on recent mac M1 machines. Error goes away after replacing libclang.dylib under clang/native from:
Perhaps we need a github runner on macos-latest to build for current Darwin Kernel Version 22.4.0 ?
I have just rebuild version 16.0.4 wheels on cirrus-ci: https://cirrus-ci.com/task/4741189509840896
Not released yet. @d-e-e-p could you please help me to check if the latest cirrus-ci build works on your environment? The artifact can be downloaded from:
unfortunately I get the same error:
File "/opt/homebrew/lib/python3.11/site-packages/clang/cindex.py", line 2897, in parse
return TranslationUnit.from_source(path, args, unsaved_files, options,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/clang/cindex.py", line 3012, in from_source
raise TranslationUnitLoadError("Error parsing translation unit.")
clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
I noticed that:
> dyld_info -platform /opt/homebrew/lib/python3.11/site-packages/clang/native/libclang.dylib
/opt/homebrew/lib/python3.11/site-packages/clang/native/libclang.dylib [arm64]:
-platform:
platform minOS sdk
macOS 10.9 12.3
while the pre-built version from https://github.com/llvm/llvm-project/releases looks like:
> dyld_info -platform clang+llvm-16.0.4-arm64-apple-darwin22.0/lib/libclang.dylib
clang+llvm-16.0.4-arm64-apple-darwin22.0/lib/libclang.dylib [arm64]:
-platform:
platform minOS sdk
macOS 13.0 13.3
I'm also able to build from source and get a working version with:
#!/bin/bash -x
# from https://stackoverflow.com/questions/65293299/how-to-build-llvm-clang-clang-for-apple-m1
BUILD_SYSTEM=Ninja
INSTALLDIR=$HOME/.local
cmake ../llvm \
-G$BUILD_SYSTEM -B build \
-DCMAKE_OSX_ARCHITECTURES='arm64' \
-DCMAKE_C_COMPILER=`which clang` \
-DCMAKE_CXX_COMPILER=`which clang++` \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALLDIR \
-DLLVM_LOCAL_RPATH=$INSTALLDIR/lib \
-DLLVM_ENABLE_WERROR=FALSE \
-DLLVM_TARGETS_TO_BUILD='AArch64' \
-DLLVM_DEFAULT_TARGET_TRIPLE='16.0.4-arm64-apple-darwin22.4' \
-DDEFAULT_SYSROOT="$(xcrun --show-sdk-path)" \
-DLLVM_ENABLE_PROJECTS='clang'
@sighingnow the full error message, along with a test file, are attached Archive.zip
would you prefer a pull request with build procedure on cirrus-ci over github runner?
@d-e-e-p however, you binary on my machine does not work either.
nevermind...seems it is due to the file does not exist..
Closing as new wheels has been published to https://pypi.org/project/libclang/16.0.6/#files
I am fairly new to using this package and followed the install installation instructions (pip install and changing the call variable in cindex.py file). After running the below code
import clang.cindex
index = clang.cindex.Index.create()
index.parse("test.cpp")
I get the TranslationUnitLoadError. Any guidance would be greatly appreciated.
I am using an M1 Mac, btw