-
Notifications
You must be signed in to change notification settings - Fork 2.6k
cargo build should have --force option #1101
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
Comments
We do have |
@kballard what do you think about @alexcrichton 's suggestion? |
I suppose that's an acceptable workaround. Since nobody else has requested this, I'll go ahead and close it. |
This isn't particularly discoverable - I didn't try Has having an alias, such as My use case isn't regenerating warnings, but developing a compiler plugin, and just wanting to 'run' it again. |
I second this. It's hard, especially for a new user when filing bug reports to figure out how to re-compile everything to show the warnings again. |
I also think it would be worth reopening this, as others have pointed out, this should be more accessible to beginners ("Where have my compiler warnings / clippy lints gone?"). I think the key thing here is to inform the user that some targets are not being compiled at all, explicitly (i.e. as opposed to just not outputting
Whether the message points to the already available solution, or whether a new flag should be added ("run with --force (--force-all)"), is an issue of lesser importance, though personally I would also welcome a less verbose way of achieving this :) |
for the record, now it's |
That was a hypothetical example, it didn't exist. |
I'm going to reopen this issue, as a colleague has recently informed me that decreasing the optimization level for a package does not rebuild it (whereas increasing it does; I do realize that this makes sense in most cases). As the reason for decreasing was to test compilation time of the package in question, this feature actually got in the way and a I have a vague recollection that at some point in the past, |
Thanks for raising the awareness. I had a hard time reproducing it. There are several ways that can contribute to optimization levels. Do you have a reproducer at hand? I've used the follow command and it did recompile. Like
You could use
This sounds like a bug. And the other two as well. I'd suggest let's focus on the problem first before diving into the solution space. Would you be willing to open new issues if you can reproduce them? Thank you in advance! |
@weihanglo I did not test it myself, but AIUI my colleague was overriding the |
I also ended up using cargo clean && cargo build a lot in my current project that provides a wrapper for C/C++. Whereas in my case it is related to foreign function interface (ffi) to C/C++ world and keeping the rust library part on sync as somehow changes are not detected by cargo. Is there a way to just clean/rebuild the own crate without all dependencies? In good old Visual Studio there was a "Rebuild Project" - "Rebuild Solution" command and I would love if there is something similar for cargo. In the project, I'm working at the moment cargo is called by CMake to build dlls/static libs that than are imported by a C/C++ code base. I'm already using some workarounds, e.g. using [[example]] to get a "staticlib" and "cdylib" output for the same ffi code. And I often use cargo clean && cargo build --all-targets to ensure that changes are synced to the C/C++ side. (see a related issue regarding cdylib and cargo) |
Have you tried |
Since this wasn't explicitly said, the main motivation for this has been resolved (warnings). The warnings are now tracked and re-reported even when a rebuild doesn't happen. |
The cargo team discussed this and we are in favor of closing this. The original motivation as been resolved now that cargo captures and replays warnings. We have the solution of |
Sometimes I need to force a rebuild of a target, because it compiled successfully but I want to see the generated warnings. It would be convenient if
cargo build
accepted a--force
flag that makes it consider the current target to be dirty even if it's not. This should not force the recompilation of any dependencies.The text was updated successfully, but these errors were encountered: