Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从rust运行LLC会导致未定义对“main';用于与gcc链接_Rust_Llvm - Fatal编程技术网

从rust运行LLC会导致未定义对“main';用于与gcc链接

从rust运行LLC会导致未定义对“main';用于与gcc链接,rust,llvm,Rust,Llvm,以LLVM-IR中的hello world为例 @.str = internal constant [14 x i8] c"hello, world\0A\00" declare i32 @printf(i8*, ...) define i32 @main(i32 %argc, i8** %argv) nounwind { entry: %tmp1 = getelementptr [14 x i8], [14 x i8]* @.str, i32 0, i32 0 %tmp2 = call

以LLVM-IR中的hello world为例

@.str = internal constant [14 x i8] c"hello, world\0A\00"
declare i32 @printf(i8*, ...)
define i32 @main(i32 %argc, i8** %argv) nounwind {
entry:
  %tmp1 = getelementptr [14 x i8], [14 x i8]* @.str, i32 0, i32 0
  %tmp2 = call i32 (i8*, ...) @printf( i8* %tmp1 ) nounwind
  ret i32 0
}

当我从rust启动
llc
流程时:

使用std::process::Command;
fn main(){
命令::new(“/usr/lib/llvm-8/bin/llc”)
.env_clear()
.arg(“test.bc”)
.arg(“-o”)
.arg(“test.s”)
.output()
.expect(“未能执行流程”);
}
我无法将生成的
test.s
与gcc
gcc test.s-no pie-o test
链接:

/usr/bin/ld:/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/crt1.o:在函数
\u start':
(.text+0x20):未定义对
main'
collect2:错误:ld返回了1个退出状态

但是当我在终端中运行
llc
direct时:

env-i/usr/lib/llvm-8/bin/llc test.bc-o test.s
一切正常


有人知道一些细节吗?

您是否尝试将“-filetype=asm”作为参数添加到命令?@FrankC.Yes,但这不会改变任何内容。您是否尝试将“-filetype=asm”作为参数添加到命令?@FrankC.Yes,但这不会改变任何内容。