# openjdk and FreeBSD 13.1 on aarch64



## rrpalma (Jul 6, 2022)

Hello,
Unfortunately, I need to run java on a VM on M1 hardware. FreeBSD is running fine, but can't get java to run.
Have tried java11, 12, 14, 17. Have tried from ports or installing binaries. 
If using binaries, I get a segfault when running java.  If building from ports, the build process fails.
Any ideas?
Thanks!


----------



## acheron (Jul 6, 2022)

What's your FreeBSD version? What's the segfault?
PR 260187 PR 264065


----------



## SirDice (Jul 6, 2022)

If it helps:

```
root@pibsd:~ # java -version
openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment (build 11.0.14+9-1)
OpenJDK 64-Bit Server VM (build 11.0.14+9-1, mixed mode)
root@pibsd:~ # pkg info -x openjdk11
openjdk11-11.0.14+9.1_1
root@pibsd:~ # uname -a
FreeBSD pibsd.dicelan.home 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC arm64
```
FreeBSD 13.1-RELEASE running on my Pi 3. Installed the OpenJDK package from the FreeBSD quarterly repository. Didn't do any extensive testing though, but as far as I can tell it works just fine. Maybe it's something specific to the M1?


----------



## rrpalma (Jul 6, 2022)

Thanks acheron and SirDice for your replies.

This is the error I get when running java:


```
freebsdvm01% java -version
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x000000004ad9b250, pid=922, tid=100457
#
# JRE version:  (11.0.15+10) (build )
# Java VM: OpenJDK 64-Bit Server VM (11.0.15+10-1, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# Problematic frame:
# v  ~BufferBlob::native signature handlers
#
# Core dump will be written. Default location: /usr/home/rrpalma/java.core
#
# An error report file with more information is saved as:
# /usr/home/rrpalma/hs_err_pid922.log
Could not load hsdis-aarch64.so; library not loadable; PrintAssembly is disabled
#
#
zsh: abort (core dumped)  java -version
```

My FreeBSD version:


```
freebsdvm01% uname -a
FreeBSD freebsdvm01 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC arm64
```

It's worth noting that since I needed KDE, I'm working with the LATEST repo, and that's where I got the binaries from.
quarterly states 11.0.14+9.1_1
latest states 11.0.15+10.1

Thanks again!


----------



## acheron (Jul 6, 2022)

It's a sigill, can you get the problematic instruction?


----------



## rrpalma (Jul 6, 2022)

acheron said:


> It's a sigill, can you get the problematic instruction?


I'm a total newbie, but willing to learn  

How do I do that?  Thanks again.


----------



## acheron (Jul 6, 2022)

```
pkg install gdb
gdb --args java -version
run
dissassemble
```
and post the result


----------



## rrpalma (Jul 6, 2022)

I apologize for not been clear and specific on my initial post.
a) openjdk11 crashes when installed from binary repos
b) openjdk12 and above didn't even finish building when trying from ports -- so I can't debug them
c) I tried downgrading my binary install of openjdk11 from 11.0.15+10.1 to 11.0.14+9.1_1, which is working for SirDice
        Got the same SIGILL error as before
d)  I'm currently in the process of building from ports openjdk11


----------



## SirDice (Jul 6, 2022)

rrpalma said:


> I tried downgrading my binary install of openjdk11 from 11.0.15+10.1 to 11.0.14+9.1_1, which is working for SirDice


Switched to the latest repository, openjdk11-11.0.15+10.1 is working, on the Pi 3. 


rrpalma said:


> Got the same SIGILL error as before


Yes. That's the intention. Use the commands acheron posted, he might be able to figure out _why_ it's giving that SIGILL on your system.


----------



## rrpalma (Jul 6, 2022)

Ok, so the build of openjdk11 also failed, after an awful amount of time. It would seem to me, in my total ignorance of the subject, that although the system has llvm13 installed, the build process downloaded and also built llvm12 before attempting to build openjdk. Bear in mind I performed a default config of the build. The last messages that I got were:


```
configure: Found potential Boot JDK using configure arguments
configure: Potential Boot JDK found at /usr/local/bootstrap-openjdk11 is incorrect JDK version (#); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK
configure exiting with result code 1
===>  Script "configure" failed unexpectedly.
Please report the problem to java@FreeBSD.org [maintainer] and attach the
"/usr/ports/java/openjdk11/work/jdk11u-jdk-11.0.14-9-1/config.log" including
the output of the failure of your make command. Also, it might be a good idea
to provide an overview of all packages installed on your system (e.g. a
/usr/local/sbin/pkg-static info -g -Ea).
*** Error code 1

Stop.
make: stopped in /usr/ports/java/openjdk11
```

I'm attaching config.log for the build, as suggested, as well as the packages installed on my system.  Any suggestions are more than welcome !

Thanks again.


----------



## elgrande (Jul 10, 2022)

Just FYI:
When building something, you can install the dependencies first as binary packages using `pkg install `make missing`` if you like.
That may save a lot of time.


----------



## SirDice (Jul 11, 2022)

elgrande said:


> When building something, you can install the dependencies first as binary packages using `pkg install `make missing`` if you like.


`make install-missing-packages`


----------



## Alain De Vos (Jul 11, 2022)

In make.conf i have

```
DEFAULT_VERSIONS+=java=11
```


----------



## rrpalma (Jul 12, 2022)

Alain De Vos said:


> In make.conf i have
> 
> ```
> DEFAULT_VERSIONS+=java=11
> ```


Thanks.

This is for building which version of opendjk? 12?


----------



## rrpalma (Jul 12, 2022)

Thanks for all the comments.

I still can't get openjdk (any version >= 11) to work.

Binary pkg installs just crash when running java -version
(please see above)

Building from ports doesn't work either.  It would seem that the 'configure' phase doesn't like the installed (from pkg) bootstrap-openjdk:


```
configure: Found potential Boot JDK using configure arguments
configure: Potential Boot JDK found at /usr/local/bootstrap-openjdk11 is incorrect JDK version (#); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK
configure exiting with result code 1
===>  Script "configure" failed unexpectedly.
```




SirDice said:


> `make install-missing-packages`


This is a Godsend -- thanks!!  How can I remove all the products in the ports directories from the previous (unseccessful) builds? For example, although I have clang 13 installed, the previous build attempts for openjdk  built ckang 12
.


Alain De Vos said:


> In make.conf i have
> 
> ```
> DEFAULT_VERSIONS+=java=11
> ```


Will including this in /etc/make.conf have any effects, given the fact that I can't build any version of openjdk?

Odd fact: libreoffice apparently needs openjdk11. If I uninstall (crashing) openjdk11, libreoffice gets deleted too. If don't install openjdk on purpose, but install libreoffice, openjdk11 gets installed. And libreoffice runs without a problem.

Thanks!


----------

