Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Last active November 18, 2024 22:57
Show Gist options
  • Select an option

  • Save thewh1teagle/c580063db10d0124ca2f02632ca624fb to your computer and use it in GitHub Desktop.

Select an option

Save thewh1teagle/c580063db10d0124ca2f02632ca624fb to your computer and use it in GitHub Desktop.

Manual compile rustc program

# Rust -> AST -> HIR -> MIR -> IR -> Assembly -> Object -> Link -> Executable
rustc main.rs --emit=llvm-ir # clang IR
llc main.ll # Assembly
clang -c -o main.o main.s # Object file
clang main.o -o main.exe -l"C:\Users\yaako\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\std-2df1f22abef96888.dll.lib" # Executable
$env:PATH += "C:\Users\yaako\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib"
.\main.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment