fix(sconstruct): correct Java libjvm discovery and Python linking#12
Open
quinnjr wants to merge 1 commit intoFIUBioRG:masterfrom
Open
fix(sconstruct): correct Java libjvm discovery and Python linking#12quinnjr wants to merge 1 commit intoFIUBioRG:masterfrom
quinnjr wants to merge 1 commit intoFIUBioRG:masterfrom
Conversation
- python3-config: use $PATH binary instead of hardcoded /usr/bin one, so the flags match the interpreter picked up by build_support. Add --embed on Python 3.8+ so ldflags emits -lpython3.x. - libjvm discovery: probe jre/lib/<arch>/server (JDK 8 layout) in addition to lib/server; honor $LIBJVM; drop the stale hardcoded 1.8.0.472 path. - Embed an rpath to the resolved JVM dir via SCons RPATH so pluma runs without LD_LIBRARY_PATH. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
SConstructbuild fails on two common real-world toolchains: a non-/usr/binPython (pyenv, conda, system updates) and OpenJDK 8 on RHEL-derived distros. This PR fixes both without changing the build's default behavior on systems where it already works.Problem
Python detection
python3-configwas invoked as/usr/bin/python3-config, so its flags did not match the Python interpreterbuild_supporthad actually selected via$PATH. Result: compile-time includes and link-time flags for two different interpreters.python3-config --ldflagsno longer emits-lpython3.xunless--embedis passed, so linking the embedded interpreter silently dropped the library.Java / libjvm discovery
$JAVA_HOME/lib/serverand$JAVA_HOME/lib. JDK 8 on Linux (java-1.8.0-openjdk-*) keepslibjvm.sounderjre/lib/<arch>/server, so detection failed on any RHEL/CentOS/Rocky host with the default OpenJDK 8 package.LIBPATHpointing at/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.472.b08-1.el8_10.x86_64/jre/lib/amd64/server/leaked into the environment of anyone who happened to have a matchinglibjvm.soat the computedlib_dir— a reviewer-hostile landmine that bound the build to one specific RPM version.$LIBJVMwas read but never used to actually resolve the library directory.libjvmdirectory was not added to the binary'sRPATH, so runningplumarequired the user to setLD_LIBRARY_PATHat runtime.Changes
SConstruct:python3-configvia$PATH(matches the interpreterbuild_supportselected). Append--embedwhen running on CPython >= 3.8 so-lpython3.xis emitted.lib/server) and JDK 8 (jre/lib/<arch>/server) layouts.<arch>is derived fromplatform.machine()with the standardx86_64 -> amd64,aarch64,i686 -> i386mapping.$LIBJVMas an explicit override: if it points at an existing file, its directory becomes the resolvedLIBPATH.RPATHvia SCons so the builtplumabinary findslibjvm.soat runtime withoutLD_LIBRARY_PATH.platformas_platformto avoid the shadowing frombuild_config.pythat already exists in this file.No default behavior changes on a system where the old code already worked: the first two candidates in the probe list are the same paths the old code checked, in the same order.
Test plan
sconson RHEL 8 / Rocky 9 withjava-1.8.0-openjdk-develinstalled and$JAVA_HOMEpointing at the JDK 8 root — verifylibjvm.sois found underjre/lib/amd64/serverand the resultingplumaruns withoutLD_LIBRARY_PATH.sconson a system with a modern JDK (17/21) — verifylib/serveris still picked first and the build is unchanged.sconswith$LIBJVM=/path/to/libjvm.so— verify the override wins over the candidate probe.sconsunder a pyenv or conda Python 3.10+ that is first on$PATH— verifypython3-configis resolved from$PATHand that-lpython3.xappears in the link command (i.e.--embedis in effect).sconsunder a Python 3.7 interpreter — verify--embedis omitted.readelf -d build/pluma | grep RPATH— confirm the resolved JVM directory is embedded.