虚拟机 |带有命令行选项的程序入口函数的代码生成器

LLVM | codegen for program entry function with command line options

对于我的编程语言,程序的入口就像C/C++ main函数:

int main(int argc, char **argv) {
    return 0
}

假设:

问题:

如果我想将此代码编译成二进制 prog,如何使用 llvm 生成将命令行参数传递给 argcargv 然后调用 main, 运行 prog?

时由用户提供

感谢 arnt 的评论:

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

有效!