Starting from this source code:
fn main() { println!("Hello, world!"); }
You can create an intermediate representation of LLVM (IR) or bitcode (BC):
# IR in hello.ll rustc hello.rs --emit=llvm-ir # BC in hello.bc rustc hello.rs --emit=llvm-bc
These files can then be further processed by LLVM to create an assembly or object file:
# Assembly in hello.s llc hello.bc # Object in hello.o llc hello.bc --filetype=obj
Then you need to link the files to create the executable. This requires binding to the standard Rust libraries. The path depends on the platform and version:
cc -L/path/to/stage2/lib/rustlib/x86_64-apple-darwin/lib/ -lstd-2f39a9bd -o hello2 hello.o
Then you can run the program:
DYLD_LIBRARY_PATH=/path/to/stage2/lib/rustlib/x86_64-apple-darwin/lib/ ./hello2
This answer has specific OS X solutions, but general concepts should be extended to Linux and Windows. The implementation will be slightly different for Linux and probably significantly for Windows.
Shepmaster
source share