c2z icon indicating copy to clipboard operation
c2z copied to clipboard

Build with `.want_lto = true;`

Open lassade opened this issue 2 years ago • 1 comments

By building with LTO enabled is possible to export c++ functions like so:

extern "C"
{
    const void *simple_getGreetings = (void *)&simple::getGreetings;
}

and interfacing them using:

const simple = struct {
    extern const simple_getGreetings: *fn () [*:0]const u8;
    pub inline fn getGreetings() [*:0]const u8 {
        return simple_getGreetings();
    }
};

This change will:

  • The asm generated turns out to be call simple::getGreetings witch is the best possible!
  • Allow for interfacing with varidact functions
  • Greatly reduce the code complexity for both the bridge (glue) code and the c2z library it self

lassade avatar Aug 26 '23 01:08 lassade

Ok... ok... apparently "lto triggers a ton of bugs" https://discord.com/channels/605571803288698900/1144805098074161202

lassade avatar Aug 26 '23 01:08 lassade