dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Add new switch to rename a module in its mangling

Open rikkimax opened this issue 4 months ago • 0 comments

Proposal: add a new switch similar to -mv in syntax, that renames a module in its mangling.

Benefit: it allows for multiple instances of a module be in a process, with minimal effort. This is needed on Posix platforms, as each binary is not separated out at load time, all symbols intermix.

module perprocessregistration;

struct Thing;

void register(Thing);
module perbinaryregistration;
import perprocessregistration;

shared static this() {
    Thing[] things = ...; // get a list of things somehow that need registering
    foreach(thing; things) {
        register(thing);
    }
}

-mvm=perbinaryregistration=__somename1234

module someusage;
import perbinaryregistration;

void somethingToRegister(); // how this get to the module constructor in perbinaryregistration is unrelated to this ticket.

It must not alter module lookup, only how that module gets mangled.

rikkimax avatar Jun 16 '25 12:06 rikkimax