capstone icon indicating copy to clipboard operation
capstone copied to clipboard

Universal wheel for macOS contains only x86_64 build

Open doronz88 opened this issue 1 year ago • 9 comments

When installing the package on an Apple Silicon, the universal wheel being installed is only for intel.

This can be examined:

file /opt/homebrew/lib/python3.11/site-packages/capstone/lib/libcapstone.dylib
# outputs: /opt/homebrew/lib/python3.11/site-packages/capstone/lib/libcapstone.dylib: Mach-O 64-bit dynamically linked shared library x86_64

As a result, capstone will fail to import on Apple Silicon.

doronz88 avatar Sep 05 '23 15:09 doronz88

Do you want to use Capstone for AArch64 binaries? If yes, I highly recommend to use the auto-sync branch and cherry-pick the commits from this PR to make it build on ARM Macs. Regarding the wheel: cc @kabeor Any progress with this?

Rot127 avatar Sep 05 '23 17:09 Rot127

I want it to not crash. Not even disassembling.

doronz88 avatar Sep 05 '23 17:09 doronz88

Added in https://github.com/capstone-engine/capstone/issues/2081

XVilka avatar Sep 06 '23 02:09 XVilka

Compile from Apple Silicon:

$ make -j8   
[  1%] Building C object CMakeFiles/capstone.dir/Mapping.c.o
[  1%] Building C object CMakeFiles/capstone.dir/MCInst.c.o
[  1%] Building C object CMakeFiles/capstone.dir/cs.c.o
[  3%] Building C object CMakeFiles/capstone.dir/MCInstPrinter.c.o
[  3%] Building C object CMakeFiles/capstone.dir/SStream.c.o
[  5%] Building C object CMakeFiles/capstone.dir/utils.c.o
[  5%] Building C object CMakeFiles/capstone.dir/MCInstrDesc.c.o
[  5%] Building C object CMakeFiles/capstone.dir/MCRegisterInfo.c.o
/Users/kabeor/capstone/MCInstPrinter.c:91:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
}
^
/Users/kabeor/capstone/MCInst.c:284:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
}
^
1 error generated.
1 error generated.
[  5%] Building C object CMakeFiles/capstone.dir/arch/ARM/ARMBaseInfo.c.o
make[2]: *** [CMakeFiles/capstone.dir/MCInst.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/capstone.dir/MCInstPrinter.c.o] Error 1
[  6%] Building C object CMakeFiles/capstone.dir/arch/ARM/ARMDisassembler.c.o
make[1]: *** [CMakeFiles/capstone.dir/all] Error 2
make: *** [all] Error 2

About MCInstPrinter.c, I guess default is missing from switch-case at line 88.

Since the code comes from #1949, Would you mind to have a look? @Rot127

kabeor avatar Sep 06 '23 08:09 kabeor

Should be fixed in #2160.

However, the homebrew way is not maintaining by us, compiling source code is ok.

kabeor avatar Sep 11 '23 14:09 kabeor

@kabeor I'll wait for the published .whl package to report when this issue is resolved

doronz88 avatar Sep 11 '23 14:09 doronz88

I'm also encountering the same problem. Is there a release schedule coming soon so I can install the package directly from pypi instead of building it myself?

orid95 avatar Oct 15 '23 07:10 orid95

A possible workaround could be to force it to build the x86_64 dylib, then link them together using lipo. But I can't seem to get the x86_64 dylib built. Even if I run

arch -x86_64 python setup.py bdist_wheel

The resulting dylib is arm64. Same result for the cython build. This might also be a hint to what is going wrong, something is detecting the arch in a different way.

guyshe-jfrog avatar Nov 19 '23 14:11 guyshe-jfrog

Should be fixed via https://github.com/capstone-engine/capstone/commit/a554a1dfb8a468d6df786acc0bb1ad045eb044e9

XVilka avatar Jan 13 '24 10:01 XVilka

It seems like this is still not fixed

acama avatar Aug 07 '24 20:08 acama

@acama it should be a part of the upcoming 5.0.2 release

XVilka avatar Aug 08 '24 00:08 XVilka

@kabeor

Rot127 avatar Aug 08 '24 01:08 Rot127