Skip to content

[GIAC] Bump to v2.0.2 — GIAC_TYPE_ON_8BITS default, align GCC to v10, enable GSL/LAPACK/GLPK#13717

Draft
s-celles wants to merge 7 commits into
JuliaPackaging:masterfrom
s-celles:giac-2.0.2-type-on-8bits
Draft

[GIAC] Bump to v2.0.2 — GIAC_TYPE_ON_8BITS default, align GCC to v10, enable GSL/LAPACK/GLPK#13717
s-celles wants to merge 7 commits into
JuliaPackaging:masterfrom
s-celles:giac-2.0.2-type-on-8bits

Conversation

@s-celles
Copy link
Copy Markdown
Contributor

@s-celles s-celles commented May 13, 2026

Summary

  • Bumps GIAC_jll to v2.0.2.
  • Pins the source SHA to s-celles/giac@64fdcefb, the new tip of the fork's dev branch, which defaults GIAC_TYPE_ON_8BITS=1 in src/dispatch.h. That replaces the historical unsigned char type:5; unsigned char type_unused:3; bitfield in class gen with a plain unsigned char type;.
  • Bumps preferred_gcc_version from v"8" to v"10" to match libgiac_julia_jll's recipe.

Why

The bitfield layout was access-fused differently across GCC versions. GCC's optimizer combines adjacent bitfield writes (g.type = ...; g.subtype = ...;) into a wider store using version-dependent bit placements. GCC 8 (current GIAC_jll) and GCC 10 (libgiac_julia_jll) disagree on which bits hold type, which produces a real user-visible ABI bug downstream:

  • libgiac.so writes a gen tagged _REAL (3)
  • libgiac_julia_jll (the CxxWrap wrapper) reads it back and sees _DOUBLE_ (1)
  • Result on Windows: evalf(pi, 50) returned by Giac.jl is mis-tagged, breaking float() and other conversions. Tracking in s-celles/Giac.jl#22.

A multi-platform C++ probe (investigation in s-celles/libgiac-julia-wrapper#5) ran with both modes (bitfield default vs -DGIAC_TYPE_ON_8BITS) on Linux GCC 12, macOS clang, and Windows MSYS2 GCC 15.2. Same-compiler builds produced correct _REAL tagging in both modes; the bug only manifests when libgiac and consumer were compiled with different GCC versions — exactly the production scenario.

With GIAC_TYPE_ON_8BITS=1, the type field is a plain byte at offset 0; both GCC 8 and GCC 10 emit a trivial byte store/load. No fusion, no version-dependent packing. The ABI becomes compiler-invariant.

The macro is set in dispatch.h (which is installed alongside gen.h), so every consumer of GIAC_jll automatically sees the same layout libgiac.so was compiled with — no implicit "remember to -D it on your side too" contract.

Cost

3 bits of mantissa lost on inline doubles stored within a gen (48 → 45). sizeof(gen) unchanged at 64 bits.

Coordinated downstream change

L/libgiac_julia/build_tarballs.jl should be bumped after this PR lands to pick up the new GIAC_jll ABI. The pinned commit there (s-celles/libgiac-julia-wrapper@490207923b75678ace5409e16ed5bc134bd9c7d9) doesn't need to change — only the version and the GIAC_jll compat range. I'll open that follow-up PR after this one merges.

Verification

  • Built locally with julia build_tarballs.jl --verbose --deploy=local x86_64-linux-gnu-cxx11 → success in 4m13s, all 3 products (libgiac.so, icas, share/giac/aide_cas) produced; audit clean; libstdc++ auto-detected to system (GCC 10 ABI).
  • giac's own CI on the fork green on Linux + macOS + Windows MSYS2 (unit + integration tests) for the merged patch — run 25812396543.

Test plan (for CI here)

  • All Yggdrasil platforms build successfully

s-celles added 6 commits May 13, 2026 18:36
Pins to s-celles/giac@64fdcefb (PR #1 on that fork, merged into
dev) which sets GIAC_TYPE_ON_8BITS=1 by default in dispatch.h,
replacing the historical `type:5 + type_unused:3` bitfield in
`class gen` with a plain 8-bit `unsigned char`. The default ships
through the installed header so every consumer of GIAC_jll sees
the same gen layout libgiac.so was compiled with — no implicit
"remember to -D the macro too" contract.

The bitfield form was access-fused differently by GCC 8 vs GCC 10,
producing a real ABI bug in the downstream JLL pair: a gen tagged
_REAL by libgiac (built here with GCC 8) was read back as _DOUBLE_
by libgiac_julia_jll (GCC 10), breaking MPFR float conversions on
Windows (Giac.jl#22, libgiac-julia-wrapper#5 investigation).

Two coordinated changes prevent regressions of the same class:
  1. New giac default replaces the bitfield with a full byte —
     compiler-invariant layout regardless of fusion choices.
  2. preferred_gcc_version bumped 8 → 10 to match
     libgiac_julia_jll's recipe.

Cost noted by giac's author: 3 mantissa bits on inline doubles
encoded in a gen (48 → 45). sizeof(gen) unchanged.

Verified:
  - Built locally on x86_64-linux-gnu-cxx11 in 4m13s, all 3
    products (libgiac, icas, aide_cas) produced.
  - giac's own CI green on Linux, macOS, Windows MSYS2 post-merge
    (unit + integration tests).
Switch -Dgsl from disabled to enabled and add GSL_jll 2.8.1 as a
dependency. Validated by a clean cross-build for x86_64-linux-gnu;
icas and libgiac.so auto-map to libgsl.so.28 and libgslcblas.so.0
from GSL_jll.
Switch -Dlapack from disabled to enabled and add OpenBLAS32_jll
(LP64 ABI) plus CompilerSupportLibraries_jll as dependencies.
OpenBLAS_jll itself is ILP64 with _64_ symbol suffixes that Giac
does not expect.

Meson's dependency('blas')/dependency('lapack') only look for
blas.pc/lapack.pc; the script now drops self-contained wrappers
in ${prefix}/lib/pkgconfig before meson setup (skipped on macOS,
where Giac picks up the Accelerate framework).

Validated by a clean cross-build for x86_64-linux-gnu; eigenvals
on a 300x300 float matrix completes in ~70 ms (vs seconds without
LAPACK).
Switch -Dglpk from disabled to enabled and add GLPK_jll 5.0.1 as a
dependency. GLPK_jll ships no pkg-config file, so the script drops
a self-contained glpk.pc in ${prefix}/lib/pkgconfig before meson
setup.

Validated by a clean cross-build for x86_64-linux-gnu; libgiac.so
auto-maps to libglpk.so.40 and lpsolve returns the expected
optima on small LP test problems.
GLPK_jll doesn't ship a riscv64 binary, so building Giac with
-Dglpk=enabled fails on those targets. Gate the GLPK option (and the
glpk.pc shim) behind a target check so riscv64 falls back to
-Dglpk=disabled while every other platform keeps GLPK enabled.
Restrict GLPK_jll to platforms that ship artifacts, mirroring the
GLPK_OPT=disabled branch in the script.
@s-celles
Copy link
Copy Markdown
Contributor Author

#13754 should probably be considered before this. So marking this one as draft

@s-celles s-celles marked this pull request as draft May 18, 2026 06:49
GLPK_jll now ships riscv64-linux-gnu artifacts (JuliaPackaging#13754),
so drop the platform filter and conditional and bump compat to 5.0.2.
@s-celles s-celles changed the title [GIAC] Bump to v2.0.2 — GIAC_TYPE_ON_8BITS default, align GCC to v10 [GIAC] Bump to v2.0.2 — GIAC_TYPE_ON_8BITS default, align GCC to v10, enable GSL/LAPACK/GLPK May 19, 2026
@s-celles s-celles marked this pull request as ready for review May 19, 2026 06:34
@s-celles
Copy link
Copy Markdown
Contributor Author

s-celles commented May 21, 2026

#13771 should also be considered before this.
So re-converting as draft also - sorry for noise

@s-celles s-celles marked this pull request as draft May 21, 2026 14:40
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