Open mhanberg opened 1 week ago
Hi @mhanberg!
This compiler can only produce object/assembly files, not executables. You will need to link with your runtime and define entrypoints in order to turn this into a runnable executable, which was not part of the original LLVM tutorial IIRC. Executing code will require the interpreted session.
Also, be sure to use --
followed by the arguments to pass to your built binary, ex. cargo r -- --help
or cargo r -- test.ks
.
Actually, instead of linking with runtime and defining entrypoints, it might be easier to feed the resulting object into a C compiler of your choice, or rustc and run functions like so:
// test.c
#include <stdio.h>
extern double fib(double);
extern double fibi(double);
int main(void) {
printf("The 20th fibonacci number is: %.0lf\n", fibi(20));
return 0;
}
clang test.c a.out -o test
kaleidrs$ ./test
The 20th fibonacci number is: 6765
What are the steps to actually run the compiled file?
Running
cargo run test.ks
and then./a.out
results inzsh: exec format error: ./a.out
for me.Thanks!