这是我的第一个 Stackoverflow 问题:-)
我的背景:
事实: - Crystal-lang 编译和运行没有任何问题 - 在 x86_64 上运行
请客气点,因为我还没有太多的低级语言知识。
根据我的理解,当我们使用 LLVM 编译和运行一个基本的 hello.c 文件时,它是这样的:
你好ç :
#include
int main() {
printf("hello world\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
贝壳 :
$ clang -O3 -emit-llvm hello.c -c -o hello.bc
$ llc hello.bc -o hello.s
$ gcc hello.s -o hello.native
$ ./hello.native
Run Code Online (Sandbox Code Playgroud)
这来自 LLVM 示例)
我的观点是,我们可以生成一个非常短的 hello.bc 文件(128 行),可以使用以下方法以较慢的方式运行:
$ lli hello.bc
Run Code Online (Sandbox Code Playgroud)
但是当我尝试从 hello.cr 文件生成一个类似的 hello.bc 并像使用 hello.c 文件一样运行它时:
你好.cr : …