Repository navigation
Define the stdio family for JIT'd code on Windows - #326
Merged
Merged
Conversation
A Mojo program that formats a float failed with "Symbols not found: [ snprintf ]". There is no snprintf on a Windows machine to find. The UCRT headers declare it inline over __stdio_common_vsprintf, so every program gets its own copy while it is being compiled and ucrtbase.dll exports nothing by that name. JIT'd code never had that moment, so it emits a plain call and there is nothing to bind it to. Nine names in the printf and scanf family are like this. Six more resolve, but through ntdll, which carries its own copies from the old NT C runtime. Those are not the UCRT functions, they differ in floating point conversion, and swprintf does not even take a buffer size there. That half was the worse one, because it went unnoticed. This defines all fifteen as absolute symbols in the platform stdlib, pointing at the copies already linked into mojo.exe, which links the UCRT statically. Defining them settles both halves at once, since a generator is only ever asked about a name the dylib does not already have.
tamnd
force-pushed
the
coff-jit-stdio
branch
from
September 9, 2026 07:15
0ae5961 to
3d57d3e
Compare
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #325.
A Mojo program that formats a float stopped with
JIT session error: Symbols not found: [ snprintf ]. There is nosnprintfon a Windows machine to find. The UCRT headers declare it inline over__stdio_common_vsprintf, so every program gets its own copy while it is being compiled anducrtbase.dllexports nothing by that name. JIT'd code never had that moment, so it emits a plain call and there is nothing to bind it to. Nine names in the printf and scanf family are in that state.Six more do resolve, but through ntdll, which carries its own copies from the old NT C runtime. Those are not the UCRT functions, they differ in floating point conversion, and ntdll's
swprintfdoes not even take a buffer size. That half was the worse one, because nothing about it looked broken.So this defines all fifteen as absolute symbols in the platform stdlib, pointing at the copies already linked into
mojo.exe, which links the UCRT statically. Defining them settles both halves at once, since a generator is only ever asked about a name the dylib does not already have.The two wide ones need a cast because the UCRT headers give them a C++ template overload that deduces an array size, so the bare name is an overload set rather than one address.
Cross built and run on a Windows host, on a program that exercises
List,Dict, string building,range,tryand float formatting:The last line of that is
snprintfdoing its job. Before this change the same program did not get past symbol resolution.Part of #31.