Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hsdis fails to build under binutils-2.39 #3

Open
DingliZhang opened this issue Dec 1, 2022 · 2 comments
Open

hsdis fails to build under binutils-2.39 #3

DingliZhang opened this issue Dec 1, 2022 · 2 comments

Comments

@DingliZhang
Copy link
Owner

DingliZhang commented Dec 1, 2022

When I cross-compile jdk, hsdis will fail to build when using binutils2.39. The configure script like this:

$ CC=/home/dingli/toolchain-rvv/riscv64/bin/riscv64-unknown-linux-gnu-gcc \
CXX=/home/dingli/toolchain-rvv/riscv64/bin/riscv64-unknown-linux-gnu-g++ \
bash configure \
--with-boot-jdk=/home/dingli/jdk-bin/jdk-19.0.1 \
--openjdk-target=riscv64-unknown-linux-gnu \
--with-sysroot=/home/dingli/toolchain-rvv/riscv64/sysroot \
--disable-warnings-as-errors \
--with-native-debug-symbols=internal \
--with-debug-level=fastdebug \
--with-hsdis=binutils \
--with-binutils-src=/home/dingli/jdk-tools/binutils-2.39
$ make build-hsdis -j && make install-hsdis -j

And fails like this:

ERROR: Build failed for target 'build-hsdis' in configuration 'linux-riscv64-server-fastdebug' (exit code 2) 

=== Output from failing command(s) repeated here ===
* For target support_hsdis_hsdis-binutils.o:
/home/dingli/jdk-rvv/src/utils/hsdis/binutils/hsdis-binutils.c: In function 'init_disassemble_info_from_bfd':
/home/dingli/jdk-rvv/src/utils/hsdis/binutils/hsdis-binutils.c:564:3: error: too few arguments to function 'init_disassemble_info'
  564 |   init_disassemble_info(dinfo, stream, fprintf_func);
      |   ^~~~~~~~~~~~~~~~~~~~~
In file included from /home/dingli/jdk-rvv/src/utils/hsdis/binutils/hsdis-binutils.c:62:
/home/dingli/jdk-tools/binutils-2.39/include/dis-asm.h:472:13: note: declared here
  472 | extern void init_disassemble_info (struct disassemble_info *dinfo, void *stream,
      |             ^~~~~~~~~~~~~~~~~~~~~

* All command lines available in /home/dingli/jdk-rvv/build/linux-riscv64-server-fastdebug/make-support/failure-logs.
=== End of repeated output ===

No indication of failed target found.
HELP: Try searching the build log for '] Error'.
HELP: Run 'make doctor' to diagnose build problems.

The reasson is that binutils add additional parameter of init_disassemble_info()[1], which now causes compilation failures.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=60a3da00bd5407f07d64dff82a4dae98230dfaac

@DingliZhang
Copy link
Owner Author

In the case of not considering the compatibility of the old version, the simple method of JDK-8244819 can be used to repair:

diff --git a/src/utils/hsdis/binutils/hsdis-binutils.c b/src/utils/hsdis/binutils/hsdis-binutils.c
index 279ed53ba5d..70230f8de32 100644
--- a/src/utils/hsdis/binutils/hsdis-binutils.c
+++ b/src/utils/hsdis/binutils/hsdis-binutils.c
@@ -561,7 +561,7 @@ static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo,
                                            fprintf_ftype fprintf_func,
                                            bfd* abfd,
                                            char* disassembler_options) {
-  init_disassemble_info(dinfo, stream, fprintf_func);
+  init_disassemble_info(dinfo, stream, fprintf_func, NULL);
 
   dinfo->flavour = bfd_get_flavour(abfd);
   dinfo->arch = bfd_get_arch(abfd);

But when we run java -XX:+PrintAssembly -version, it will report an error:

BFD: unrecognized disassembler option: 
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000000000, pid=2035312, tid=2035395
#
# JRE version: OpenJDK Runtime Environment (20.0) (fastdebug build 20-internal-adhoc.dingli.jdk-rvv)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 20-internal-adhoc.dingli.jdk-rvv, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# C  [hsdis-riscv64.so+0xa3fe0]  riscv_disassemble_insn+0x20c
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/dingli/jdk-rvv/hs_err_pid2035312.log

@DingliZhang
Copy link
Owner Author

openjdk#10817 wow, shipilev has already found this problem before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant