From 0c7d24b68a71981cc20b509313d4585289cffe1f Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 13 Aug 2026 11:42:52 +0200 Subject: [PATCH] Add variant lib dir to lib runpaths on FreeBSD 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 --- make/common/JdkNativeCompilation.gmk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/make/common/JdkNativeCompilation.gmk b/make/common/JdkNativeCompilation.gmk index 8f9b8448a413a..db7872f41df8f 100644 --- a/make/common/JdkNativeCompilation.gmk +++ b/make/common/JdkNativeCompilation.gmk @@ -59,6 +59,10 @@ else ifeq ($(call isCompiler, clang), true) ifeq ($(call isTargetOs, arm), true) SetSharedLibraryOrigin = \ -Wl,-rpath,\$(DOLLAR)ORIGIN$1 + else ifeq ($(call isTargetOsEnv, bsd.freebsd), true) + SetSharedLibraryOrigin = \ + -Wl,-z,origin -Wl,-rpath,\$(DOLLAR)ORIGIN$1 \ + -Wl,-rpath,\$(DOLLAR)ORIGIN$1/$(JVM_VARIANT_MAIN) else SetSharedLibraryOrigin = \ -Wl,-z,origin -Wl,-rpath,\$(DOLLAR)ORIGIN$1