Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigdecimal 0.4.0 always forces a rebuild (on mac) #105

Closed
alamb opened this issue Jul 9, 2023 · 6 comments · Fixed by #106
Closed

bigdecimal 0.4.0 always forces a rebuild (on mac) #105

alamb opened this issue Jul 9, 2023 · 6 comments · Fixed by #106

Comments

@alamb
Copy link
Contributor

alamb commented Jul 9, 2023

After we updated to bigdecimal 0.4.0 in apache/datafusion#6848 our project now always rebuilds even when we make no code change

Reproducer

run this in this repository:

cargo test
cargo test

I expect the second invocation of cargo test not to recompile, it should just rerun the test

In DataFusion, when I run cargo test -v

the following is output in the following line

       Dirty bigdecimal v0.4.0: the file `/Users/alamb/Software/target-df2/debug/build/bigdecimal-b4aed73795116eae/out/default_precision.rs` has changed (1688920018.458734757s, 202831743ns after last build at 1688920018.255903014s)
   Compiling bigdecimal v0.4.0

It appears to me that the issue is that build.rs always rewrites default_precision.rs even when there are no changes:

write_default_precision(&outdir_path, "default_precision.rs")?;

I think this could be fixed by checking if the contents of default_precision.rs would be changed prior to rewriting them

@alamb alamb changed the title bigdecimal always forces a rebuild bigdecimal 0.4.0 always forces a rebuild Jul 9, 2023
@akubera
Copy link
Owner

akubera commented Jul 9, 2023

I can reproduce this on my macbook, but running multiple builds on my Linux machine does not trigger a recompile. I'm not sure why there will be a difference.

It's been merged and will be in v0.4.1, soon.

@alamb
Copy link
Contributor Author

alamb commented Jul 10, 2023

It's been merged and will be in v0.4.1, soon.

Thank you @akubera -- I was also seeing this on Mac

Do you have any idea when yo plan to release 0.4.1? There is no rust from my perspective, but if it will be more than a day or so I plan to downgrade back to 0.3.0 until it is ready

@alamb alamb changed the title bigdecimal 0.4.0 always forces a rebuild bigdecimal 0.4.0 always forces a rebuild (on mac) Jul 10, 2023
@rukai
Copy link
Contributor

rukai commented Jul 21, 2023

I think some cases have been fixed, but I still see bigdecimal get rebuilt sometimes and im not sure what the pattern is yet.

@rukai
Copy link
Contributor

rukai commented Jul 21, 2023

Oh I've figured it out.
It always triggers a rebuild on the second compile, after that it settles down and stops recompiling.

I ran with cargo build --verbose and saw the reason for rebuild listed as:
image

@rukai
Copy link
Contributor

rukai commented Jul 21, 2023

I think you could use this macro https://docs.rs/const-str/latest/const_str/macro.parse.html and println!("cargo:rustc-env=DEFAULT_PRECISION={default_precision}"); to avoid having to generate a .rs file

I've used rustc-env without rebuilding issues like this https://github.com/shotover/shotover-proxy/blob/468cea8afab29a2c5eb9798b73971337b04d89ce/shotover-proxy/build.rs#L5

@akubera
Copy link
Owner

akubera commented Jul 21, 2023

Unfortunately its minimum Rust version is 1.64.0, and this project supports older versions.

But that is a good crate to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants