Building hsdis on Windows & porting to Capstone

Jorn Vernee jbvernee at xs4all.nl
Wed Apr 24 17:07:45 UTC 2019


Hi,

I have been keeping an eye on the following hsdis related issues:

port "hsdis" plugin to Capstone library 
(https://bugs.openjdk.java.net/browse/JDK-8188073)
Include hsdis in the JDK 
(https://bugs.openjdk.java.net/browse/JDK-8209784)
hsdis should build OOTB on Windows 
(https://bugs.openjdk.java.net/browse/JDK-8208495)

Being on Windows, I've previously always used a binary distribution of 
hsdis, but lately have been trying to figure out how to build it myself.

The current problem with the makefile included with the hsdis sources, 
is that it uses gcc as a compiler on Windows, and this is required to 
build binutils which is part of the build process, but then tries to 
pass MSVC flags to gcc, which doesn't work obviously. After translating 
the flags to gcc compatible ones, and adding zlib as a dependency as 
well, I can build hsdis on Windows using cygwin's gcc, but then we have 
a dependency on the cygwin runtime, which can't be linked statically 
(bleh). Compiling with mingw gcc doesn't work either, since some part of 
binutils depends on fcntl.h, which is not available with mingw gcc.

Another interesting idea is to have the OpenJDK build system build 
hsdis, as per JDK-8209784, but the problem is that binutils requires gcc 
as a compiler, which is not supported by the OpenJDK build system on all 
platforms (e.g. Windows). So building hsdis based on binutils using the 
OpenJDK build system doesn't seem like a good option.

That seems to be where JDK-8188073 comes in. By dropping the binutils 
dependency, and switching to Capstone, which is a much smaller/simpler 
library, we can support building on Windows as well. Capstone can very 
easily be built using cmake and supports MSVC as well. I don't know how 
much discussion there has been on this topic already, but porting to 
Capstone seems to provide a nice answer to the other 2 problems.

I have a prototype of that working on Windows: 
http://cr.openjdk.java.net/~jvernee/capstone2/webrev.02/

I'd like to contribute this if possible. But, there's probably still a 
few things that need to happen before that. I have some questions;

- What should the licensing of the new sources be? hsdis is under UPL 
currently, so that's what I've copied for the prototype as well, but not 
sure it's correct.
- Should the building of capstone itself be included in the OpenJDK 
build system as well (i.e. clone the repo + run cmake), or is it better 
to have users do that separately?

Thanks,
Jorn


More information about the jdk-dev mailing list