-
Notifications
You must be signed in to change notification settings - Fork 10
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
Respect -C opt-level=s
to build smaller artifacts
#115
Comments
I believe the C++ build of wasm-opt already respects I have not verified this though. The C++ build is handled by the To affect only the C++ it should also be possible to override |
Okay, what about potentially deleting build artifacts then? I don't think it makes a lot of sense to keep anything except final binaries/libraries here for the purposes of the crate (I can create a separate issue for that). |
@nazar-pc I am reluctant to try to delete intermediate build artifacts as part of the build process itself, mostly because it strikes me as an atypical thing for a build script (or any build system) to do. There are no pre-existing facilities to help with this either - I would just have to use my judgment about what to delete out of the target directory. I don't think this crate is generating an abnormal quantity of build artifacts. On my local machine the entire source and debug build size is 3.5 GB, which doesn't seem unusual for a Rust project. |
I don't think this is necessarily the case for nested dependencies. When I install this crate from crates.io, it'll be compiled once and then just used whenever necessary. So it makes sense to produce necessary artifacts and remove everything else as the likelihood of it being necessary later is low.
I'm primarily talking about In my case of debug build This is why I think removing at least part of those temporary files would be really beneficial. |
I am interested to hear more from the substrate authors about this, as it does seem to be primarily an issue with how the substrate build is orchestrated. The issue I know to follow is this one, paritytech/substrate#12672, which hasn't been updated recently. I would also be interested in evidence that this is affecting other substrate chains. My first inclination, knowing that every substrate runtime is built in its own workspace, is to clean those builds after they are done; or to otherwise be more efficient in building substrate runtimes. Even if making the wasm-opt build more efficient will help for this specific case in the near term, it seems like this probably will probably happen again with substrate runtimes. If I were to add an ability to delete intermediate files I would probably make it opt-in with an environment variable. The intermediate files are evenly split between object files and the archive files that collects them. The object files are easy to delete. The archive less so, as that is the output that is passed back to cargo to link into the rlib. They could possibly be deleted in the wasm-op-cxx-sys build script, which runs after wasm-opt-sys, but that's getting very hacky, and I don't know what mechanisms might be available to help one build script discover the output dir of another crate. |
Here's another issue as linked in the substrate PR: paritytech/substrate#12671 |
I think the fewer bytes crate needs on disk the better all other things being equal. At least object files should be safe to remove as an intermediate build product. Archive files will likely need to stay. |
We're running out of space in CI and
wasm-opt-sys
is a big contributor to that. I'm wondering if it would be possible to respect-C opt-level=s
to build smaller binaries without users being aware ofOPT_LEVEL
environment variable.If that is already the case then consider cleaning up things that are no longer needed at the end of the build step to reduce the total space used by build artifacts.
The text was updated successfully, but these errors were encountered: