Hi rustaceans. I’m having a trouble with cross compiling (nostd code) Rust.
Basically I have my own LLVM that’s not in the upstream, and what I’d like to do is
- Use
rustc
to compile rust code into LLVM IR - Use my own LLVM
llc
,opt
to compile LLVM IR into objects, and finally linking the objects withld
orlld
Now I’m starting, so target platform is the same as host. That’s, I just want to split the build process into the above two phases.
I compiled my rust project into LLVM IR with cargo rustc -- --emit=llvm-ir
and did the same with libcore
.
The rustc
and libcore
are on the same commit. Then I used ls *.ll | xargs -IX llc -filetype=obj X
to generate object files. No problem till here.
But when I tried to link all the code together, the linker complained about undefined references.
My project wanted _ZN4core9panicking5panic17he3feabc16d430735E
but libcore
provided _ZN4core9panicking5panic17ha8afdce0157d83a3E
. Only the last hash part was different.
I’m using the 2224a42c3536 commit for both rustc
and libcore
. So I feel it might be an LLVM versioning problem but I can’t be sure.
So could you provide help on how to build rust projects in two phases? Thank you very much!