For my programming language, the entry of a program is like C/C++ main
function:
int main(int argc, char **argv) {
return 0
}
Suppose:
main
is generated into llvm::Function
, using llvm::IRBuilder
llvm::LLVMContext
and llvm::Module
createdQuestion:
If I want to compile this code into binary prog
, how do use llvm to generate the part that passes the commandline arguments to argc
and argv
and then call main
, which are provided by users when running prog
?
Thanks to arnt's comment:
If that function actually is called main() and actually has those arguments, then it should just work. If it isn't, then you'll need to generate a bridge function that actually is called main() and calls the function you want to be called, in the way you want it to be called. – arnt
It works!