#FFI

15 messages · Page 1 of 1 (latest)

thick chasm
#

Hi,

I'm working on FFI and I've got two small questions :
1 - what is the equivalent of size_t in Mojo ?
2 - Dynamic linking is easy but I haven't found a way to proceed with a static library (.a file). Is there a clean and official way to do that ?

Thanks.

rapid glade
#

I think size_t equivalent is Int (or maybe UInt?) which is the size of the pointer in your machine.

thick chasm
#

thanks. It should be UInt since size_t is supposed to be unsigned

rapid glade
thick chasm
#

yeah, I've start to feel the pain with this. I've found nothing to convert to/from Int and even a basic & doesn't seems to exist 😋
Guess, it will be Int for now

polar cape
#

I'm working on improving UInt but feel free to send PRs! It's pretty easy to get started with the stdlib 🙂

limpid tiger
#

For size_t for our interop we've used Int for that in the stdlib, but UInt is more correct I haven't personally tried it yet with interop though

thick chasm
charred wadiBOT
#

Congrats @thick chasm, you just advanced to level 1!

thick chasm
thick chasm
limpid tiger
# thick chasm another question but I guess I know the answer. Any plan for LTO/PGO/BOLT ? BOLT...

LTO is already done at the MLIR level, for the other two this was a comment from an engineer:

Profile guided optimization and BOLT are amazing technologies in my opinion, supporting them would be really cool. For PGO (sometimes also referred to as FDO -- feedback-directed optimization) would need to add options to the mojo driver to take profiles as inputs when compiling or running Mojo code.
BOLT refers to the optimization of fully compiled binaries -- in theory it might be possible to use already, with executables produced by mojo build.
thick chasm
#

thanks.
BOLT doesn't work, at least on my setup, that's why I've asked.
I've got this error :

BOLT-ERROR: function reordering only works when relocations are enabled

It's usually solved with something like "-Wl,--emit-relocs" in the LDFLAGS.
but it's no big deal, really.