clang-sys icon indicating copy to clipboard operation
clang-sys copied to clipboard

Directly include file from build directory instead of copying in build script

Open avsaase opened this issue 2 weeks ago • 0 comments

We transitively depend on on clang-sys with the runtime feature and I noticed that our dependencies frequently rebuild in CI, always starting at clang-sys. We use the -Zchecksum-freshness cargo feature and this seems to interact with the build script in this crate.

Specifically, cargo considers the build dirty because the sizes of the build/{common,dynamic,macros}.rs files are different after copying them to OUT_DIR because the copy implementation doesn't produce a byte for byte copy.

I took a look at how these files are used and I think it's more straightforward to include them directly where they are needed instead of copying them during the build and including them from OUT_DIR. This is what the second commit does. Alternatively, the fist commit uses std::fs::copy to copy the files. Both approaches fix our problem. Let me know if I overlooked something that requires doing this from build.rs, then I'll revert the other commit.

avsaase avatar Dec 23 '25 12:12 avsaase