Skip to content

Fix GCC/libstdc++ compilation (unblock Linux builds) + tests & CI - #10

Open
sqr00t wants to merge 11 commits into
mainfrom
fix/gcc-cpp-compat
Open

Fix GCC/libstdc++ compilation (unblock Linux builds) + tests & CI#10
sqr00t wants to merge 11 commits into
mainfrom
fix/gcc-cpp-compat

Conversation

@sqr00t

@sqr00t sqr00t commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Closes #7

What this PR does

Fixes the C++ extension so it compiles under GCC/libstdc++ (Linux), and adds test + lint CI.

The fix (src/shim.hpp)

NumericVector both inherited std::vector<double>'s constructors (using) and redeclared NumericVector(size_t) / NumericVector(size_t, double). A call like NumericVector(cols, 0.0) (with an int) was then ambiguous between the inherited fill ctor and the redeclared one — GCC rejects it, Clang tolerates it, so the package built on macOS but not on Linux.

Removed the two redeclared constructors and kept the inherited ones (using std::vector<double>::vector;). Behaviour is identical — vector(n) value-initialises to 0.0 and vector(n, v) fills with v — verified compiling on both clang++ (libc++) and g++-16 (libstdc++), with initializer-list and all existing call sites intact.

Tests (tests/)

  • Unit (test_unit.py) — API contracts: output keys/shapes, scalar↔list equivalence, all six energy_build interpolations, input-validation errors, and results_to_polars long-format output.
  • Regression (test_regression.py) — pinned model behaviour that must survive the C++ change: weight maintenance with no intake change, a golden weight-loss value for a −250 kcal/day deficit, adult_weight determinism, analytic energy_build Linear values, and Brownian seed reproducibility. Physical quantities use a loose relative tolerance to absorb cross-platform FP differences while still catching real regressions.

20 tests, passing locally on macOS.

CI (.github/workflows/ci.yml)

  • lintruff check + ruff format --check, pinned to 0.14.10 (matches .pre-commit-config.yaml).
  • test — builds the extension (scikit-build-core) and runs pytest on ubuntu-latest (GCC) and macos-latest (Clang). The Linux leg is the standing guard against this regression recurring.

Follow-up

Once merged, the publish matrix (#9 / PR #8) can drop continue-on-error from its Linux legs and move them to cibuildwheel/manylinux.

@sqr00t sqr00t added the bug Something isn't working label Jul 9, 2026
@sqr00t
sqr00t force-pushed the fix/gcc-cpp-compat branch from 7a75b6c to a931e2f Compare July 9, 2026 11:53
@sqr00t

sqr00t commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

✅ CI green on the fix (run):

sqr00t added 3 commits August 18, 2026 17:07
cppcheck reported uninitMemberVarNoCtor for ColProxy::col in both
NumericMatrix and StringMatrix. Both are only ever built via aggregate
initialisation, so col was in fact always set, but the diagnostic blocked
the cpp job before cppcheck's remaining checks could run.
Google style with Allman braces and a 120-column limit, chosen to match the
code as written rather than rewrite it: raw Google style reported 299
violations in shim.hpp against 38 for this config.

Only src/shim.hpp and src/bindings.cpp are formatted. adult_weight.{h,cpp}
and energy_build.cpp stay byte-identical to upstream INSP-RH/bw.
… blocking

The cpp job failed on every run: it ran clang-format over all of src/ with
--style=Google, which the byte-identical upstream sources will never satisfy.
continue-on-error kept it from blocking the merge but left a permanent red X,
and the failure meant cppcheck never ran at all.

Now: clang-format runs pinned at 22.1.8 via uvx over src/shim.hpp and
src/bindings.cpp only, and is blocking. cppcheck still covers all of src/ but
is advisory at step level until its version is pinned too. Adds a matching
pre-commit hook so this is caught before push.
sqr00t added 2 commits August 18, 2026 18:37
ci(format): make the cpp job work — pin clang-format, scope it to owned sources, unblock cppcheck
The apt install wedged for over an hour on three separate runs. It had no
timeout and no continue-on-error, so a stuck mirror hung the whole cpp job
and took the blocking clang-format result with it — despite cppcheck itself
being advisory by design.

Both cppcheck steps now carry continue-on-error and timeout-minutes: 5, and
the install drops recommends. clang-format already runs first, so the check
that gates the merge no longer depends on apt at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++ extension fails to compile under GCC/libstdc++ (blocks Linux wheels)

1 participant