Lto with GCC compiled code

LTO requires all code being compiled with the same compiler framework. You can't mix GCC and LLVM compiled object files with LTO. As such you either have to use clang for compiling the C code or use the experimental GCC backend for rustc. I don't know if it supports linker plugin LTO yet. It requires nightly rustc. Instructions on how to build it can be found at GitHub - rust-lang/rustc_codegen_gcc: libgccjit AOT codegen for rustc If you are on x86_64 linux you can use the provided libgccjit.so to compile against, if not you will have to build libgccjit too, which can take an hour or so if I understand correctly.

1 Like