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
@[c_export] definition of a c_imported prototype with a different type links against an undefined __stale_decl #1850
Found while fixing #1831. When a c_imported prototype and the With function that @[c_export]s its symbol have different LLVM function types, the link fails with an undefined <with name>__stale_decl:
use c_import("int zz_sum(int n, ...);\n")
@[c_export("zz_sum")]
fn sum_impl(n: c_int, a: c_int, b: c_int) -> c_int: a + b
fn main:
print(unsafe { zz_sum(2, 30, 12) })
Undefined symbols for architecture arm64:
"_sum_impl__stale_decl", referenced from: _main in ce2.o
(v0.15.3.0, darwin arm64.)
Codegen.w (declare-then-define, ~line 5062): a bodiless declaration of the c_export symbol whose type differs from the definition is renamed effective_name ++ "__stale_decl" and a new function is added under the With name, so the call sites keep the renamed, never-defined declaration.
Expected: a loud Sema diagnostic naming both signatures when they are not the same C function type (here a variadic prototype defined with fixed parameters is a C conflict); and for a prototype C accepts as compatible (an unprototyped int zz_f(); — #1831 — defined as fn(c_int, c_int) -> c_int), the definition takes the prototype's symbol and every call site's reference (replace the declaration's uses) rather than leaving them on a renamed declaration.
Activity
@[c_export] of a declared symbol: a conflicting definition is refused…