rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.35k stars 50 forks source link

Improve cargo-zigbuild zig performance #244

Open breezewish opened 2 months ago

breezewish commented 2 months ago

I recently discovered my C++ projects builds notably slower when using cargo-zigbuild, compared with a cmake toolchain I craft manually similar to https://github.com/mrexodia/zig-cross

After some debugging, I found that the initial process of fn execute_compiler (everything before actual zig Command::run) takes heavy amout of time, almost equal to the Command::run itself:

image

It would be great if the initial time could be reduced. Thanks!

messense commented 2 months ago

Maybe we can cache some of the repeated works.

breezewish commented 2 months ago

I guess most cost comes from spawning the Rust and Zig to checkout their versions. The versions could be checked when zigbuild is invoked and stored in zigcc-xx.sh.