static inline C functions (mingw's printf and time), macOS libraries that call their host, lld's missing-library message

- a static inline function in a header is called through a pointer a small C file keeps
  (void *finch_inl_f = &f), built with the program's include folders and cached
- --shared on macOS links with -undefined dynamic_lookup, as a .so does on Linux
- "unable to find library -lx" (lld, MinGW) gives the library-not-found advice
- the language server test shows the index records when alias completion fails

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
This commit is contained in:
Nexoniarz 2026-10-29 11:53:24 +01:00
commit ff72f68804
8 changed files with 81 additions and 13 deletions

View file

@ -5086,17 +5086,26 @@ fn callC(ptr[Gen] g, ast.Node c, cimport.CFunc f) -> Val {
tail = "..."
}
}
if !g.cdone.contains("f:" + f.name) {
callee := "@" + f.name
sig := ""
if f.variadic {
sig = " (" + ptys.join(", ") + tail + ")"
}
if f.inline {
// a static inline function has no symbol: the linker builds a C file with void *finch_inl_name = &name;
if !g.cdone.contains("i:" + f.name) {
g.cdone.push("i:" + f.name)
g.head.push("@finch_inl_" + f.name + " = external global ptr")
}
callee = load(g, "ptr", "@finch_inl_" + f.name)
sig = " (" + ptys.join(", ") + tail + ")"
} else if !g.cdone.contains("f:" + f.name) {
g.cdone.push("f:" + f.name)
if !runtimeDeclares(f.name) {
g.head.push("declare" + retExt + " " + retLL + " @" + f.name + "(" + ptys.join(", ") + tail + ")")
}
}
sig := ""
if f.variadic {
sig = " (" + ptys.join(", ") + tail + ")"
}
text := "call" + retExt + " " + retLL + sig + " @" + f.name + "(" + args.join(", ") + ")"
text := "call" + retExt + " " + retLL + sig + " " + callee + "(" + args.join(", ") + ")"
if ret.kind == "void" {
emit(g, text)
releaseAll(g, temps, mark)