Skip to content

The names a host calls are not checked: JNI exports on Android, exported functions on the Web #982

Open

Description

@Sunrisepeak

Status: a note for discussion; not scheduled. Recorded in the design record .agents/docs/2026-11-20-program-start-model.md §7, item 1.

mcpp 2026.11.20.1 adds main = false (#981): an image whose host enters it only through the names it exports, such as an application on the Android rows or a Web module linked with --no-entry.

The gap. start is rendered with --require-defined, so an entry symbol that nothing defines fails the link. The names a host calls have no counterpart:

  • On Android: JNI_OnLoad, the Java_* functions, ANativeActivity_onCreate.
  • On the Web: the module's exported functions (EMSCRIPTEN_KEEPALIVE, -sEXPORTED_FUNCTIONS).

A name that is missing, or defined but not exported, fails at run time, when the Java process or the page looks it up.

A direction to discuss. A program could state the names its host calls, so that an omission becomes a link error. One candidate is the existing exports key, the published symbol set of an artifact:

  • On the Web row it would render as -sEXPORTED_FUNCTIONS, each name required to be defined.
  • On the Android row it would render as exports that must be defined.

Open questions:

  • Does exports mean the same on a Web module as on a shared library? Its entries are patterns there, while a host looks up exact names. C++ names are mangled, and Emscripten adds a _ prefix.
  • Who states Android's names: the program, the framework's entry target (main = { from }), or both? The names depend on the Java side (NativeActivity, JNI, GameActivity).
  • How does such a statement combine with an entry target that already defines the names, so that each name is stated once?

Activity

  1. added
    discussion
    on Nov 20, 2026
  2. speak-agent commented on Nov 27, 2026

    @speak-agent
    Member

    mcpp 2026.11.27.1 (#1023) implements the ELF half. An exact name in exports that the shared image does not define is reported after the link (unmatched-exact-export, floor 2027.3), which covers the JNI names on the Android rows; ld64 refuses such a name itself. The Web row (-sEXPORTED_FUNCTIONS) and PE are not implemented, because the open questions above are not settled: patterns against exact names, mangling, and Emscripten's _ prefix. The issue stays open for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions