Skip to content

Compile CTarget C source in ccompile test (Symbolics no longer accepts expression=Val{false}) - #5261

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-ccompile-ctarget-val-true
Oct 14, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-ccompile-ctarget-val-true

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Ignore until reviewed by @ChrisRackauckas.

What and why

Symbolics v7.43.0 (JuliaSymbolics/Symbolics.jl#2040, closing JuliaSymbolics/Symbolics.jl#1672) makes build_function(...; target = CTarget(), expression = Val{false}) throw ArgumentError on purpose, following the maintainer's guidance in the issue. lib/ModelingToolkitBase/test/ccompile.jl used that combination, so the MTKBase Extended group (and the SciMLBase downstream job "ModelingToolkit.jl/Extended", e.g. https://github.com/SciML/SciMLBase.jl/actions/runs/37642465025/job/112864709358) errors in "C Compilation Test". The test now takes the C source (expression = Val{true}), compiles it with gcc, and calls diffeqf through Libdl.dlopen/dlsym/ccall, comparing against the Julia-built function as before. Test-only change; no package source touched.

Verification (local, Symbolics v7.44.1, ModelingToolkitBase from this branch, only the ccompile testset)

Before (master ccompile.jl):

LoadError: ArgumentError: CTarget with expression=Val{false} is not supported. ...
C Compilation Test |     1      1  23m00.3s     (1 error)

After:

Test Summary:      | Pass  Total     Time
C Compilation Test |    2      2  8m48.7s

Runic --check and typos clean on the changed file.

Not verified

Full Extended group (other testsets) and other groups were not run locally (machine compute cap); CI runs them. Needs gcc on the runner, same as before.

Risk assessment

  • Risk: low
  • Blast radius: one test file in lib/ModelingToolkitBase; no package code or public API.
  • Evidence: fail-before / pass-after above.
  • Independent review: pending
  • Merge: auto-merge candidate once reviewed and CI green.

🤖 Generated with Claude Code (model: claude-opus-5-5[1m]) https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd

Independent review: Devin Fusion (fusion-claude-opus-5-5-high-sidekick-swe-2-medium) rated it low, verdict MERGE: #5261 (comment)

…sion=Val{false}

Symbolics v7.43.0 (JuliaSymbolics/Symbolics.jl#2040) makes CTarget with
expression=Val{false} throw an ArgumentError. Build the C source with
expression=Val{true}, compile it with gcc, and call it through Libdl.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of ci-green head)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): MERGE, risk low.

Full review

VERDICT: MERGE
RISK: low

Blocking findings

None.

Non-blocking findings

  1. lib/ModelingToolkitBase/test/ccompile.jl:13: the compiled .so/.dylib at tempname() * "." * Libdl.dlext is never deleted. dlclose runs, but the file stays in TMPDIR. This is harmless on CI runners. Calling rm(libpath; force = true) after Libdl.dlclose(lib) would tidy it up. (Found by reading the code.)
  2. Context outside this PR: in Symbolics, CTarget + expression=Val{false} started throwing in a minor release (7.43.0), and MTKBase's compat floor is Symbolics = "7.41.1". This PR's test works on both sides of that change. CI shows downgrade-mtkbase (Extended) passing at the lower bound and sublibrary-ci [Extended] passing on current releases. Nothing needs to change here.

What I ran

All results in this section were confirmed by running them. I used Julia 1.12.7 with a scratch env containing the dev'd lib/ModelingToolkitBase plus Symbolics v7.45.0, Test, and Libdl, on macOS with Apple clang as gcc.

  • PR ccompile.jl (included in a fresh module): PR ccompile | Pass 2 Total 2.
  • Master ccompile.jl, same env (fail before): ArgumentError: CTarget with expression=Val{false} is not supported... thrown from Symbolics/src/build_function.jl:836. This reproduces the PR body's "before".
  • Probes against the same compiled-C path (scratch/run.jl, log in scratch/run.log):
    • Generated C source: void diffeqf(double* du, const double* RHS1, const double* RHS2, const double RHS3). This matches the ccall signature (Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Float64) and the symbol :diffeqf.
    • Independent check against a hand-written reference: with du pre-filled with NaN, u=[0.3,0.7], p=[1.7], the C output was [0.3, -1.89]. The hand-computed [a*x - x*y, -3y + x*y] is [0.3, -1.89]. So the C function really writes du, and the test's du ≈ du2 cannot pass vacuously (both buffers start as different rand(2) values).
    • Negative control: I changed -3 to -4 in the C source and recompiled. The output was [0.3, -2.59] and ≈ ref was false, so the comparison catches a wrong kernel.
    • gcc failure: feeding invalid C makes open(cmd, "w") do ... end raise ProcessFailedException. Compile errors surface rather than being swallowed.
  • Formatting and spelling: julia +1.12 --project=@runic -m Runic --check --diff lib/ModelingToolkitBase/test/ccompile.jl exited 0, and typos on the file exited 0.
  • Libdl availability: Libdl is a direct [deps] entry of lib/ModelingToolkitBase/Project.toml:36, so using Libdl in the test needs no new test dependency.
  • PR CI logs (gh pr checks and gh run view --log): sublibrary-ci [Extended] Julia 1 shows C Compilation Test | 2 2. The failing jobs are other groups: InterfaceI, Optimization, RegressionI (Latexify), and Benchmarks. None of them touch this file.
  • Repo-wide search: a grep for CTarget finds no other expression = Val{false} + CTarget use (docs, top-level test/). The only other hits are in test/qa/qa.jl name lists. The git log and the PR list show no sibling PR touching ccompile.jl.
  • Rules: the diff touches one test file and has a single concern. It adds no comments, no dependencies, and no non-public API. The commit carries the Co-Authored-By and Agent-* trailers, and the PR body has the do-not-review banner and an attribution footer.

What I did not verify

  • I did not run the full Extended group (Big System, Multithreading, Distributed, Serialization) locally. I relied on CI showing that group green.
  • I did not run on Linux with real GNU gcc; I ran Apple clang only. CI on ubuntu covers Linux.
  • I did not investigate the failing InterfaceI, Optimization, RegressionI, and Benchmarks CI jobs beyond confirming they are outside this file. I did not check whether they also fail on master. I judged them unrelated because this PR changes only ccompile.jl.

🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (review), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master)

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 14, 2026 00:14
@ChrisRackauckas
ChrisRackauckas merged commit aea9c2e into SciML:master Oct 14, 2026
98 of 109 checks passed
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.

2 participants