Skip to content

Add variant lib dir to lib runpaths on FreeBSD - #72

Closed
snake66 wants to merge 1 commit into
battleblow:bsd-portfrom
snake66:battleblow-bsd-port--fix-libjava-runpath
Closed

Add variant lib dir to lib runpaths on FreeBSD#72
snake66 wants to merge 1 commit into
battleblow:bsd-portfrom
snake66:battleblow-bsd-port--fix-libjava-runpath

Conversation

@snake66

@snake66 snake66 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

The Elf DT_RUNPATH tag added to libraries only contained $ORIGIN, but since libjvm was located in the $ORIGIN/$JVM_VARIANT_MAIN directory, it was not found by the elf loader on FreeBSD.

It would instead pick up the libjvm from OpenJDK 11, if present, and fail to load if not.

The actual libjvm is loaded on demand, though, and would pick up the right JVM for the java version running.

This work is sponsored by The FreeBSD Foundation


The Elf DT_RUNPATH tag added to libraries only contained $ORIGIN, but
since libjvm was located in the $ORIGIN/$JVM_VARIANT_MAIN directory, it
was not found by the elf loader on FreeBSD.

It would instead pick up the libjvm from OpenJDK 11, if present, and
fail to load if not.

The actual libjvm is loaded on demand, though, and would pick up the
right JVM for the java version running.

This work is sponsored by The FreeBSD Foundation
@snake66
snake66 requested review from battleblow and bsdkurt August 13, 2026 09:52
@bsdkurt

bsdkurt commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

This seems like a departure from the other operating systems supported. I'm not quite following the reason for the change so I will defer to @battleblow to review this.

@bsdkurt

bsdkurt commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

I found the bug report for this here.

ldd /usr/local/openjdk25/lib/libjava.so not finding libjvm.so is the expected behavior.

Example from Linux:

$ ldd jdk-25/lib/libjava.so 
	linux-vdso.so.1 =>  (0x00007ffffa3fb000)
	libjvm.so => not found
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3bcf0a4000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3bcecda000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3bcf2a8000)

In order for the user to be finding libjvm.so from another jvm like jdk11 the path (/usr/local/openjdk11/lib/server/) must be exported in LD_LIBRARY_PATH or added to /var/run/ld-elf.so.hints using ldconfig(8).

On my FreeBSD 14.4/aarch64 test system I see this and is the expected behavior:

$ ldd /usr/local/openjdk25/lib/libjava.so
/usr/local/openjdk25/lib/libjava.so:
        libjvm.so => not found (0)
        libdl.so.1 => /usr/lib/libdl.so.1 (0x3721ac186000)
        libc.so.7 => /lib/libc.so.7 (0x3721ad00c000) 

What problem is the user trying to solve other then lld?

@bsdkurt

bsdkurt commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Not sure why this is here but it explains how /usr/local/openjdk11/lib/server/ got into ldconfig(8)
https://github.com/freebsd/freebsd-ports/blob/main/java/openjdk11/Makefile#L34

It came in with this commit that does not explain why this change is needed:
freebsd/freebsd-ports@57ff2ad

With multiple versions of the jdk on FreeBSD, having one in /var/run/ld-elf.so.hints seems wrong to me.

I'm not familiar with FreeBSD ports/packaging enough to advise further. @battleblow?

@snake66

snake66 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks! Nice find. I was looking for something like this, but somehow overlooked it...

I'm wondering if this was added to fix an issue with the LibreOffice port installing OpenJDK 8 because it depends on libjawt.so or something... I need to investigate a bit further, but I agree, this seems like it needs a fix in the ports not in the upstream code.

Dropping this PR.

@snake66 snake66 closed this Aug 14, 2026
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

Successfully merging this pull request may close these issues.

2 participants