keystone-engine / keystone

Keystone assembler framework: Core (Arm, Arm64, Hexagon, Mips, PowerPC, Sparc, SystemZ & X86) + bindings
http://www.keystone-engine.org
GNU General Public License v2.0
2.31k stars 459 forks source link

Is there a way to disable certain architectures (or enable just a few ones) like in Capstone? #545

Closed rdbo closed 1 year ago

rdbo commented 1 year ago

In Capstone's CMakeLists.txt, there are some options there such as CAPSTONE_ARCHITECTURE_DEFAULT, which sets the default value (on/off) for all architectures, and it can be overridden with other options, such as CAPSTONE_X86_SUPPORT. Is there such thing for this project? Turns out that the final binary for it gets huge:

$ du -h llvm/lib/libkeystone.a 
125M    llvm/lib/libkeystone.a

If there isn't a way to toggle some architectures off, will there be a way in the future?

rdbo commented 1 year ago

Found a fix, the library is still big though. You have to pass the argument -DLLVM_TARGETS_TO_BUILD to CMake and tell it the architectures you want to build. For example: -DLLVM_TARGETS_TO_BUILD=X86;ARM;Aarch64 Result:

$ du -h libkeystone.a 
60M     libkeystone.a

The available architectures are listed in the CMakeLists.txt in the path llvm/lib/CMakeLists.txt: https://github.com/keystone-engine/keystone/blob/master/llvm/CMakeLists.txt#L172-L180