rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.87k stars 451 forks source link

Object file hash prefix creates determinism issues #1271

Closed nmattia closed 1 week ago

nmattia commented 1 week ago

Hi,

I've noticed that when generating object files, the full path of the source files is hashed and included in the object file name. This causes some issues in build systems like Bazel and Nix because the intermediary files will change depending on the directory where the build is performed. This also seems to influence the final output.

I've created a strawman PR with a fix that I've only tested on 1.0.83, though it makes some assumptions about where the source files are located.

What would be a good way of fixing this?

Thanks!

NobodyXu commented 1 week ago

You can use compile_intermediates, which output paths to the objects compiled and you can assmble it manually from there.

nmattia commented 1 week ago

Fixed in #1270