-
Notifications
You must be signed in to change notification settings - Fork 252
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
notify cargo to regenerate inclusion files when WASM changes #1262
Conversation
This was not the case earlier since the inclusion file that contains WASM was not updated even when WASM was updated beacuse the cargo was not watching the change to re-run the build script that actually updates the inclusion file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you share a bit more the story behind this? I'm curious what kind of issue leads you to this patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is necessary? The only reason for that file to change is for code to change and dependencies to update. When dependencies change it will already trigger recompilation. What rerun-if-changed
is typically used for is to reduce amount of recompilation, let's say, when code changes, but you know you don't need to recompile.
So I'm not yet convinced it is doing anything good. I'm also curious what issue you had exactly and why you think this fixes it.
This is only helpful if you modify WASM file manually after the fact, but we don't do that.
We hardcode the length of WASM in the bundle inclusion. Right now build.rs is not run since there is not notifier to watch for WASM changes once it has run first time or if the crate itself changes. I found that, if I change something in the pallets, do a here is a sample error
With this patch, build will re-run the inclusion file when the WASM blobs changes. |
I'm actually curious how @nazar-pc or @liuchengxu did not see this earlier 🤔 |
It might depend on file system you're using. Cargo uses mtime to see if files changed. As https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed says it is not additive, What were the exact steps you were doing to reproduce this? I'd like to experiment myself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually typically combine this with Substrate's wasm building tooling, which issues some of these instructions to Cargo, which might be the reason why it requires more annotation like added here.
So I'm generally not opposed to having this overall, but I don't feel like I fully understood what happens in your specific case, I have not seen this before even though I recompile things with minor and major changes (something like subspace-core-primitives
triggers a lot of recompilation) every day.
I would love to recreate this in your machine. This is what I pretty much did. I'm using clippy here but I think it happens with all the cargo commands.
This is what I think is happening. taken from rust lang
I think build script is not run after it was run first time if there no changes to the package. This is confusing, does package mean crate here or workspace. From the observations so far, it looks like its crate. So since the change was not in the crate, maybe build is not re-run and hence, bundle inclusion file is not regenrated with updated WASM. Would love to hear your results |
Repeated a few times (I was running I'm on Linux of course, might behave differently on other OSs. |
alright, only difference I see is the OS. I'm gonna get this in. If you see any issues, we can revert |
This was not the case earlier since the inclusion file that contains WASM was not updated even when WASM was updated because the cargo was not watching the change to re-run the build script that actually updates the inclusion file.
Code contributor checklist: