Skip to content

Instantly share code, notes, and snippets.

@NullYing
Last active April 29, 2022 09:44
Show Gist options
  • Save NullYing/89cead69c0b31a6b1458a98ac2a7aeb6 to your computer and use it in GitHub Desktop.
Save NullYing/89cead69c0b31a6b1458a98ac2a7aeb6 to your computer and use it in GitHub Desktop.
修正pycharm在macos m1的arm python无法调试
g++ -fPIC -D_REENTRANT -std=c++11 -arch x86_64 -c -o attach_x86_64.o attach.cpp
g++ -dynamiclib -nostartfiles -arch x86_64 -o attach_x86_64.dylib attach_x86_64.o -lc
rm attach_x86_64.o
mv attach_x86_64.dylib ../attach_x86_64.dylib
g++ -fPIC -D_REENTRANT -std=c++11 -arch i386 -c -o attach_x86.o attach.cpp
g++ -dynamiclib -nostartfiles -arch i386 -o attach_x86.dylib attach_x86.o -lc
rm attach_x86.o
mv attach_x86.dylib ../attach_x86.dylib
# arm64补丁
g++ -fPIC -D_REENTRANT -std=c++11 -arch arm64 -c -o attach_arm64.o attach.cpp
g++ -dynamiclib -nostartfiles -arch arm64 -o attach_arm64.dylib attach_arm64.o -lc
rm attach_arm64.o
mv attach_arm64.dylib ../attach_arm64.dylib
# 合并成胖包兼容两种架构
lipo -create ../attach_arm64.dylib ../attach_x86_64.dylib -output pang.dylib
mv pang.dylib ../attach_x86_64.dylib
@NullYing
Copy link
Author

修改/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/linux_and_mac/compile_mac.sh为以上内容,并执行一遍./compile_mac.sh

可以同时兼容两种架构的python调试,而不会出错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment