Skip to content

Scope CUDA link deps to their targets in meson.build#223

Merged
bodono merged 5 commits into
masterfrom
cleanup-gpu-meson-deps
Jul 22, 2026
Merged

Scope CUDA link deps to their targets in meson.build#223
bodono merged 5 commits into
masterfrom
cleanup-gpu-meson-deps

Conversation

@bodono

@bodono bodono commented Jul 22, 2026

Copy link
Copy Markdown
Owner

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_gpu block appended cuda/cublas/cusparse to the shared _deps list:

_deps += cuda_dep
_deps += cublas_dep
_deps += cusparse_dep

Because _deps is reused by every extension module defined later in the file, those CUDA libraries leaked into _scs_mkl, _scs_accelerate, and _scs_cudss whenever use_gpu=true was combined with those backends — linking them against libraries they don't use. The link_cudss block had the same anti-pattern with cuda/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:

gpu_deps = _deps + [cuda_dep, cublas_dep, cusparse_dep]   # use_gpu
cudss_deps = _deps + [cuda_dep, cudss_dep]                # link_cudss

Also adds a comment explaining the GPU sources are listed explicitly (Meson's fs module has no glob()) and must be kept in sync with the submodule's .c files.

2. Add a build-only GPU CI job (build.yml)

Neither the use_gpu build nor the cuBLAS/cuSPARSE linking fixed in #221 was covered by CI. The new build_gpu job 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 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.

Testing

  • meson setup + ninja on the default config build cleanly locally (all targets, including the previously-affected _scs_accelerate).
  • The new build_gpu CI job exercises the full use_gpu=true build + link path (this host has no CUDA toolkit, so it could not be built locally).

🤖 Generated with Claude Code

bodono and others added 5 commits July 22, 2026 14:21
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>
@bodono
bodono merged commit f1f0de9 into master Jul 22, 2026
36 checks passed
@bodono
bodono deleted the cleanup-gpu-meson-deps branch July 22, 2026 13:58
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.

1 participant