polyglot-compiler / JLang

JLang: Ahead-of-time compilation of Java programs to LLVM
http://polyglot-compiler.github.io/JLang/
Other
287 stars 30 forks source link

dynamic loader gives an error showing version 'SUNWprivate_1_1' not found in jdk1.7.0 #54

Open JianpingZeng opened 4 years ago

JianpingZeng commented 4 years ago

Hi, I am trying to build and run unit tests. But I encountered the following error when I tried to run the generated binary on the Ubuntu 16.04 + X86 platform with recommended clang+llvm 5.0.1.

./Add.binary: /home/xlous/Development/Compiler/JLang/runtime/out/libjvm.so: version `SUNWprivate_1.1' not found (required by /usr/lib/jdk/jdk1.7.0/jre/lib/amd64/libjava.so)

BTW, I solved three compilation problems on my Ubuntu 16.06 system.

  1. the --version-script=linux_version.map linker options defined in the defs.Linux should be removed for successfully building the project.
  2. It is required to add an -ldl option in the tests/isolated/Makefile to build the binary for unit tests.
  3. Any version of JDK higher than the 1.7.10 can not be used for compiling the project because there are some internal API functions, such as JPEG, etc, used by java library have been removed in any version of JDK newer than the JDK 1.7.10 (included). I successfully built the project with oracle JDK 1.7.0.

Thanks, Jianping.

dz333 commented 4 years ago

The reason you're having the linking problem is because you removed the --version-script=linux_version.map

What errors were you getting by building JLang with that included? I've also tested on an Ubuntu 16.06 system and had no problems so I'm curious as to what exact errors you're running into.

JianpingZeng commented 4 years ago

The linker gives me an error "/usr/bin/ld: error: linux_version.map:24:4: invalid character" BTW, a minor typo in my previous reply. My OS version is Ubuntu 16.04.

JianpingZeng commented 4 years ago

I solved that problem which is caused by an extra newline character at the end of the linux_version.map. Just delete it. It would be fine!

JianpingZeng commented 4 years ago

But, there is another problem happens when I try to run make tests even with the modified linux_version.map used.

./Subtype.binary: relocation error: /usr/lib/jdk/jdk1.7.0/jre/lib/amd64/libjava.so: symbol JVM_GetClassLoader, version SUNWprivate_1.1 not defined in file libjvm.so with link time reference

dz333 commented 4 years ago

Ah ok, thanks for the clarification. I don't have an Ubuntu16.04 system to reproduce this on myself at the moment so I won't be able to help debug this right away.

But, what it looks like is happening is the JLang runtime wasn't recompiled after you updated the linux_version.map file.If so, then running make clean and then rebuilding should solve this but I can't say for sure. If it isn't that then I'll have to do a bit more digging.

JianpingZeng commented 4 years ago

I have cleaned everything and recompiled it. The same problem is there.

dz333 commented 4 years ago

Ah I think the problem is with the minor version of the JDK that you're using. The best supported JDK is this one here: https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html

I believe that the version you have is probably not the same as this one.

In the future we are planning to make JLang more portable across these kinds of small changes but it's difficult based on how the internal JVM interfaces aren't actually intended to be stable or portable across versions.