https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108183
--- Comment #9 from Iain Sandoe <iains at gcc dot gnu.org> --- So we do set _M2_termios_ctor Symbol to extern. But then here: PreAddModGcc (Sym, BuildEndFunctionDeclaration (begin, end, KeyToCharStar (GetFullSymName (Sym)), returnType, IsExternal (Sym), (* Extern relative to the main module. *) IsProcedureGccNested (Sym), (* Exported from the module where it was declared. *) IsExported (GetModuleWhereDeclared (Sym), Sym) OR IsExtern (Sym))) ; PopBinding(scope) ; "IsExternal (Sys)" returns false, because it thinks that the scope of _M2_termios_ctor is HelloMod. (lldb) p SymbolTable_GetScope(Sym) (unsigned int) $5 = 155 (lldb) p M2GCCDeclare_PrintSym(155) information about symbol: 155 ============================== sym 155 IsModule (HelloWorld) (lldb) p Sym (unsigned int) $6 = 6114 (lldb) p M2GCCDeclare_PrintSym(6114) information about symbol: 6114 ============================== sym 6114 IsProcedure (_M2_termios_ctor) scope HelloWorld:1 155 extern ctor declared in /source/test/hello.mod:1 So we create the decl assuming it exists in the TU .. which is the source of the wrong code.