Skip to content

Bind the C library math functions of the JIT to the ones roadrunner links - #1477

Closed
matthiaskoenig wants to merge 1 commit into
sys-bio:developfrom
matthiaskoenig:fix/jit-crt-math-symbols
Closed

matthiaskoenig wants to merge 1 commit into
sys-bio:developfrom
matthiaskoenig:fix/jit-crt-math-symbols

Conversation

@matthiaskoenig

Copy link
Copy Markdown
Collaborator

Fixes #1476

The JIT resolved the C library functions which Jit::createCLibraryFunctions declares (pow, exp, log, fabs, floor, fmod, the trigonometric and hyperbolic functions) through the search of the symbols of the process. On Windows ntdll.dll, ucrtbase.dll and msvcrt.dll all export them, LLVM returns the export of the module loaded last, and the functions of msvcrt.dll and ucrtbase.dll differ in the last bits for some arguments, so the results of a model depended on the load order of the process.

Jit::cLibraryFunctionAddresses gives the addresses of these functions in the C runtime roadrunner is linked against, and both jits bind the declarations to them, the way they bind the SBML support functions of externalFunctionSignatures: LLJit with absoluteSymbols, MCJit with sys::DynamicLibrary::AddSymbol, which is searched before the loaded libraries. The process search is still there for everything else.

On Linux and macOS the functions are the ones of the single C library of the process, so nothing changes there. On Windows a model now integrates with the functions of ucrtbase.dll in every process, where before it was msvcrt.dll in most processes and another module in a few. Checked with a build of this branch on windows-latest: a process with a copy of ucrtbase.dll loaded before the model is compiled (which before the change bound the copy) now gives bitwise the simulation of a normal process, for a plain simulation and for a fit of a whole body model. All C++ tests (3614) pass on Linux, and the Windows release job of BuildRoadRunner passes on the branch.

…inks

The JIT resolved pow, exp, log and the other C library functions which
createCLibraryFunctions declares through the search of the symbols of the
process. On Windows ntdll.dll, ucrtbase.dll and msvcrt.dll all export them,
LLVM returns the export of the module loaded last, and the functions of
msvcrt and ucrtbase differ in the last bits for some arguments, so the
results of a model depended on the load order of the process. LLJit and
MCJit now bind them explicitly, as they do for the SBML support functions.
@luciansmith

Copy link
Copy Markdown

Subsumed this into #1489

@luciansmith luciansmith closed this Dec 3, 2026
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.

On Windows the JIT binds pow, exp, log to whichever loaded DLL exports them last, so results depend on the load order of the process

2 participants