How to build HotSpot Disassembler (hsdis) on macOS
hsdis: HotSpot Disassembler
Start by cloning the JDK repository. Checkout the version for which you want to build.
# Clone jdk
git clone https://github.com/openjdk/jdk.git
# Go to the root directory
cd jdk
# Checkout the latest version
git checkout jdk-21+25You can take a look src/utils/hsdis/README.md to have detailed instructions. In my case, I used capstone to build hsdis (tried binutils but ended up facing a lot of issues).
Install capstone with Hombrew
brew install capstoneIn the jdk root directory, execute the following command. It might not found capstone so that you need to tell it where it is.
bash configure --with-hsdis=capstone --with-capstone=/opt/homebrew/Cellar/capstone/5.0.6/If everything went fine, you’ll see
====================================================
A new configuration has been successfully created in
/Users/username/dev/gh/jdk/build/macosx-aarch64-server-release
using configure arguments '--with-hsdis=capstone --with-capstone=/opt/homebrew/Cellar/capstone/5.0.6/'.And finally
make build-hsdisIf everything went fine, you’ll see
Building target 'build-hsdis' in configuration 'macosx-aarch64-server-release'
Creating support/hsdis/libhsdis.dylib from 1 file(s)
ld: warning: search path '/Users/username/dev/gh/jdk/build/macosx-aarch64-server-release/support/modules_libs/java.base' not found
ld: warning: search path '/Users/username/dev/gh/jdk/build/macosx-aarch64-server-release/support/modules_libs/java.base/server' not found
Finished building target 'build-hsdis' in configuration 'macosx-aarch64-server-release'Jitwatch
Jitwatch will looking for disassembler hsdis-aarch64.dylib. You might need to put it in your java library under lib/server/ directory.
cp build/macosx-aarch64-server-release/support/hsdis/hsdis-aarch64.dylib ~/Library/Java/JavaVirtualMachines/corretto-21.0.7/Contents/Home/lib/server/