Feature
As far as I can tell, there's no build-in way to generate an entrypoint (_start) when generating an object file using cranelift-object. Please correct me if I'm mistaken, but I think this makes it impossible to actually produce a properly executable file using only cranelift and a linker.
Two solutions came to my mind:
- A function like
define_entrypoint, which let's us define an entrypoint directly (_start). One could define a custom entrypoint similar to how one defines a function now.
cranelift-object defines a default entrypoint, calling a main-function (similar to what C does)
Note: I tried defining _start as a function which obviously didn't work out.
Benefit
Being able to actually generate runnable executables with cranelift-object.
Implementation
I'm definitely not qualified to fill this section in :P
Alternatives
Some alternative approaches come to mind:
- Compile the object file to a dynamic library and link it with a "boot"-program written in C/Rust, which calls a custom entrypoint in our "library". Requires an extra toolchain to be installed.
- Do what saltwater does and link it using
cc, which apperantely insert a valid entrypoint calling main. This is also the only project I came across which uses cranelift-object. Requires an extra toolchain to be installed.
- Using
cranelift-faerie, which is deprecated. Not sure if it has the same problem, through.
- I'm yet to reverse-engineer how
rustc-codegen-cranelift does it
Feature
As far as I can tell, there's no build-in way to generate an entrypoint (
_start) when generating an object file usingcranelift-object. Please correct me if I'm mistaken, but I think this makes it impossible to actually produce a properly executable file using only cranelift and a linker.Two solutions came to my mind:
define_entrypoint, which let's us define an entrypoint directly (_start). One could define a custom entrypoint similar to how one defines a function now.cranelift-objectdefines a default entrypoint, calling amain-function (similar to what C does)Note: I tried defining
_startas a function which obviously didn't work out.Benefit
Being able to actually generate runnable executables with
cranelift-object.Implementation
I'm definitely not qualified to fill this section in :P
Alternatives
Some alternative approaches come to mind:
cc, which apperantely insert a valid entrypoint callingmain. This is also the only project I came across which usescranelift-object. Requires an extra toolchain to be installed.cranelift-faerie, which is deprecated. Not sure if it has the same problem, through.rustc-codegen-craneliftdoes it