RFR: 8253757: Add LLVM-based backend for hsdis

Jorn Vernee jvernee at openjdk.java.net
Wed Oct 13 13:10:51 UTC 2021


On Wed, 13 Oct 2021 00:00:22 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

> This patch expands the newly added system for hsdis backends to include LLVM.
> 
> The actual code in hsdis-llvm.cpp is based heavily on the work by @luhenry, as published in the never integrated PR https://github.com/openjdk/jdk/pull/392. (I have basically just ripped out the binutils-based part of it.)
> 
> Unfortunately I have not been able to make this work properly on Windows. With some additional flags I made it compile without complaints, but it caused hotspot to segfault in `LoadLibrary` (!) in `os::dll_load` when I tried to load the library. This is somewhat ironic, since the initial implementation was created by Ludovic for the very purpose of using it on Windows.
> 
> The lack of Windows support in this patch does not mean it is impossible to get it to work, just that I need to co-operate with someone who has more experience of compiling LLVM on Windows, and/or are more eager to get this combination to work.

In my experience the output of llvm-config is also not usable. I think the output also depends on the toolchain you use to build llvm FWIW. The output of my locally built llvm-config does contain the MSVC flags, but the paths it points to are incorrect (all pointing to the build directory, instead of the package install location).

I have a patch here that gets me a working hsdis based on the llvm package I built manually using MSVC (the [official package](https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/LLVM-13.0.0-win64.exe) doesn't seem to contain the needed header files): https://github.com/openjdk/jdk/compare/pr/5920...JornVernee:hsdis_llvm_windows

(The only issue currently is that the code I used to filter out the incorrect `-I` flags from what llvm-config gives me doesn't seem to work, though the build still passes).

I built llvm using something like this (according to my notes):


git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build_llvm
cd build_llvm
cmake ../llvm -D"LLVM_TARGETS_TO_BUILD:STRING=X86" -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_INSTALL_PREFIX=install_local" -A x64 -T host=x64
cmake --build . --config Release --target install


This then uses MSVC to build me an llvm 'package' in `build_llvm/install_local`, which I then point to using `--with-llvm`.

The only other issue I had is that `install-hsdis` only copies the library to the exploded JDK, so I manually copy it to `images/jdk/bin/server` afterwards.

HTH

-------------

PR: https://git.openjdk.java.net/jdk/pull/5920


More information about the hotspot-compiler-dev mailing list