Add Windows native BLAS support (UCRT64 JNI DLL + CI)#39
Open
philwalk wants to merge 5 commits intoluhenry:masterfrom
Open
Add Windows native BLAS support (UCRT64 JNI DLL + CI)#39philwalk wants to merge 5 commits intoluhenry:masterfrom
philwalk wants to merge 5 commits intoluhenry:masterfrom
Conversation
On Windows (NTFS), Files.createTempFile with POSIX file attributes throws:
UnsupportedOperationException: 'posix:permissions' not supported as initial attribute
This crash prevents JNIBLAS, JNILAPACK, and JNIARPACK from loading on any
Windows JVM, silently falling back to the pure-Java implementation.
Fix: guard the POSIX attribute with a FileSystems.getDefault() check, which
returns an empty attribute array on non-POSIX filesystems (Windows/NTFS).
Also add Windows os.name normalisation ("windows") and .dll extension to
match the existing macOS pattern.
Affected files: JNIBLAS.java, JNILAPACK.java, JNIARPACK.java
Contributor
Author
|
If the next release will not include this PR, can we publish it as a SNAPSHOT or nightly? I have some MacOS tests I'd like to do. |
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
Enables
JNIBLASto load and function on Windows by making three changes:blas/src/main/native/jni.c— WindowsdlfcnshimReplaces the unconditional
#include <dlfcn.h>with a#ifdef _WIN32blockthat maps
dlopen/dlsym/dlclose/dlerrortoLoadLibraryA/GetProcAddress/FreeLibrary. This allowsjni.cto compile on Windows without a POSIXlibdldependency. The DLL is linked with
-Wl,-Bstatic,-ldl,-Bdynamicsolibdl.aisfolded in statically — the resulting
.dllimports onlyKERNEL32.dlland standardCRT forwarders.
pom.xml—windows-nativeMaven profileAdds a profile activated automatically on Windows (
<os><family>windows</family></os>)that invokes
makewith ucrt64gccto buildlibnetlibblasjni.dllintotarget/native/windows-amd64/, matching the layout expected by the resource-copy plugin.CI workflows — Windows build and test jobs
Both
build-and-test.ymlandrelease.ymlgain:build-windows-natives: runs onwindows-latest, sets up MSYS2 UCRT64(
msys2/setup-msys2@v2), generates the JNI header via Maven, then compilesand links the DLL with ucrt64
gcc.build-jar: updatedneedsto includebuild-windows-natives; downloadsthe
windows-nativesartifact alongsidemacos-nativesso the DLL is packagedinto the JAR.
test-windows: runs onwindows-latestacross JDK 11/17/21/25, installsOpenBLAS via MSYS2 (
mingw-w64-ucrt-x86_64-openblas), and runs the BLAS testsuite with
-Ddev.ludovic.netlib.blas.nativeLib=libopenblas.dll.Testing
Built and verified locally on Windows (MSYS2 UCRT64).
objdumpconfirms the DLLhas no
libdl.dlldependency. The fullunitest suite (which usesJNIBLASvianetlib) passes with native OpenBLAS acceleration confirmed.