You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
with migrate refuses fma, frexp, ldexp, isnan and other C99 <math.h> functions #2680
migrate: untranslatable function 'f': bailed at ReturnStmt ...
migrate: unsupported filtered system variable 'fma' from .../bits/mathcalls.h:394:1; add an explicit binding or extend std.libc
Refused the same way: fma, fmin, fmax, fdim, frexp, ldexp, modf, scalbn, nextafter, remainder, ilogb, logb, lround, llrint. The classification macros fail differently: isnan, isinf, isfinite, signbit expand to __builtin_isnan etc., and each is "unsupported compiler
builtin '__builtin_isnan': no structural lowering". sqrt, cos and fmod in the same template migrate.
Cause. A libm call passes the system-symbol filter only if it is a row of src/MathBuiltins.w
(ci_is_libm_fn is math_fn_lookup(name) >= 0, src/CImport.w:20946, read by ci_libc_symbol_kind_mask at :20980; the filter is ci_note_filtered_system_symbol_ref, :21131-21143). The table has the 34 functions of
§17.6a. D42 rules "the full libm surface (specification §17.6a lists it)", and §17.6a's list leaves these out;
std.libc doesn't bind them either. The __builtin_* classification calls fall through to reject_builtin_call(..., "no structural lowering") (:12504).
Nearly every numeric C library uses these. pocketfft's my_sincosm1pi calls fma 13 times, so the file
doesn't migrate; Cephes uses frexp/ldexp/isnan throughout.
Fix direction (your call). Add the missing C99 functions to the builtin table (fma → llvm.fma,
which mul_add already lowers to; fmin/fmax → llvm.minnum/maxnum; the rest to libm symbols), and
lower the four classification builtins structurally (x != x, x.abs() == inf, …). Or bind them in
std.libc.
Checked on Linux x86_64 (WSL2) with release builds of main 14a720bd and 25ac6ac0; main is now e3b0ad0e, which doesn't touch the libm filter.
Fixed in #3257. Root cause: a libm call passed the migrator's system-symbol filter only if it was a row of the builtin table. std.libc now binds the C99 functions outside it (fma, fmin, fmax, fdim, frexp, ldexp, modf, scalbn, nextafter, remainder, logb, ilogb, the rounding family, each with its f form), and isnan/isinf/isfinite/signbit lower to four std.libc functions from Darwin's __inline_*, clang/glibc's __builtin_* and older glibc's __* spellings. Test: c-migrator-basic-tests c99_math migrates and runs a C program using every function. Not covered: the UCRT's _dclass/_dsign spellings on Windows still fail loudly.
Activity
ehartford commentedon Oct 26, 2026
Very nice feedback thank you!
Issues batch G: #2680 #1153 #2369 #2761 #1014 (#3257)
ehartford commentedon Nov 11, 2026
Fixed in #3257. Root cause: a libm call passed the migrator's system-symbol filter only if it was a row of the builtin table. std.libc now binds the C99 functions outside it (fma, fmin, fmax, fdim, frexp, ldexp, modf, scalbn, nextafter, remainder, logb, ilogb, the rounding family, each with its f form), and isnan/isinf/isfinite/signbit lower to four std.libc functions from Darwin's
__inline_*, clang/glibc's__builtin_*and older glibc's__*spellings. Test: c-migrator-basic-testsc99_mathmigrates and runs a C program using every function. Not covered: the UCRT's_dclass/_dsignspellings on Windows still fail loudly.