c2z
c2z copied to clipboard
Build with `.want_lto = true;`
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::getGreetingswitch 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
Ok... ok... apparently "lto triggers a ton of bugs" https://discord.com/channels/605571803288698900/1144805098074161202