Scope CUDA link deps to their targets in meson.build#223
Merged
Conversation
The use_gpu block appended cuda/cublas/cusparse to the shared `_deps` list, so those libraries leaked into every extension module defined afterwards (_scs_mkl, _scs_accelerate, _scs_cudss) when use_gpu was combined with those backends. link_cudss had the same issue with cuda/cudss. Build a per-target dependency list (mirroring the existing `_mkl_deps = _deps + [...]` pattern) instead of mutating `_deps`. Also note in a comment that the GPU sources are listed explicitly because Meson's fs module has no glob(), and must be kept in sync with the .c files in the submodule. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Neither the use_gpu build nor the cuBLAS/cuSPARSE linking (fixed in #221) was covered by CI. Add a build_gpu job that installs the CUDA toolkit libraries from conda-forge and builds with -Duse_gpu=true. Linking against cuBLAS/cuSPARSE needs the toolkit but not a physical GPU, so the job builds and link-checks without running the solver. A shared library links successfully even with undefined symbols, so the job asserts via readelf that _scs_gpu records libcublas and libcusparse as NEEDED entries -- the #221 bug was a missing link that only surfaced at import time as `undefined symbol: cusparseDestroySpMat`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The GPU backend requires 32-bit integers; meson errors out otherwise (meson.build:173). Match the documented use_gpu build invocation from #221. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Importing scs from the repo root resolved the local ./scs source directory (a namespace package, __file__ is None) instead of the installed package, leaving the .so path empty. Find the extension under sysconfig platlib instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
pixi run stripped the inner single quotes from the python -c snippet,
so sysconfig.get_path('platlib') became a bare name (NameError). Locate
the .so with find over the pixi env lib dir instead of invoking python.
Co-Authored-By: Claude Opus 4.8 <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.
Follow-up cleanup to #221, addressing review feedback on that PR, plus CI coverage for the GPU build.
1. Scope CUDA link deps to their targets (
meson.build)The
use_gpublock appendedcuda/cublas/cusparseto the shared_depslist:Because
_depsis reused by every extension module defined later in the file, those CUDA libraries leaked into_scs_mkl,_scs_accelerate, and_scs_cudsswheneveruse_gpu=truewas combined with those backends — linking them against libraries they don't use. Thelink_cudssblock had the same anti-pattern withcuda/cudss.This builds a per-target dependency list instead of mutating the shared
_deps, mirroring the existing_mkl_deps = _deps + [mkl_rt_dep]pattern already used for the MKL target:Also adds a comment explaining the GPU sources are listed explicitly (Meson's
fsmodule has noglob()) and must be kept in sync with the submodule's.cfiles.2. Add a build-only GPU CI job (
build.yml)Neither the
use_gpubuild nor the cuBLAS/cuSPARSE linking fixed in #221 was covered by CI. The newbuild_gpujob installs the CUDA toolkit libraries from conda-forge and builds with-Duse_gpu=true. Linking against cuBLAS/cuSPARSE requires the toolkit but not a physical GPU, so the job builds and link-checks without running the solver.Because a shared library links successfully even with undefined symbols, the job asserts via
readelfthat_scs_gpurecordslibcublasandlibcusparseasNEEDEDentries — the #221 bug was a missing link that only surfaced at import time asundefined symbol: cusparseDestroySpMat.Testing
meson setup+ninjaon the default config build cleanly locally (all targets, including the previously-affected_scs_accelerate).build_gpuCI job exercises the fulluse_gpu=truebuild + link path (this host has no CUDA toolkit, so it could not be built locally).🤖 Generated with Claude Code