-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
--emit=dep-info or some flag should include rlibs & externally linked files that will be used #57717
Comments
It's right yeah that sccache implicitly relies on this, where if A depends on B which depends on C, sccache's hash for A only includes B, but B's own hash transitively includes C so it ends up working out in practice. I don't think this is overly hard to do in rustc in principle, but I suspect some refactoring would be necessary to achieve this without engaging the whole compiler on |
First off, just to be clear, sccache doesn't attempt to cache rustc invocations that output anything but an rlib, so it does not currently attempt to deal with linker inputs. sccache gets the list of static libs / rlibs that are involved in compilation by parsing the rustc commandline: It uses the search paths (also from the commandline) to locate all static libs: I don't think adding rlibs etc to the dep-info output would break sccache in any way--it currently just parses the first line of the file (sort of cheating, but rustc lists all source files as dependencies of the dep file itself there) and hashes all files listed there to use as inputs to the overall hash key. This would change the hash for existing compilations, and sccache would be doing redundant work but it should otherwise be harmless. |
Yeah, this is just insufficient since everything added to a link search path ( |
This is fair. What we're doing in sccache is more of a heuristic and not 100% precise, but it covers the "rustc as invoked by cargo" use case which is what I aimed to support initially. |
I've been looking into this. One question is how hard it will be to successfully do this across multiple crates that depend on each other. e.g. I want to run rustc with I know that in the case of |
This is supported on nightly with |
Currently,
--emit=dep-info
only shows source files that are included in the current crate. There should be another mode (or the behavior should be extended) to include all files that will be used by the equivalent non-dep-info
invocation ofrustc
. This includesrlibs
of all crates used by the build, both explicitly in--extern
and brought in through lib search paths, as well as external object files etc. that may be linked in. This is necessary in order to add Rust support to remote compilers and compiler caches, which depend on the exact hashes of all files used in the build.Note that AFAICT sccache currently works around this by relying on some behaviors of
cargo
and depending on all the libraries contained in link paths. (@luser / @alexcrichton please correct me if I'm wrong here). I'd like to instead ensure that we can ship the exact set of files needed for compilation, both of libraries, and for the final link step.i'm sure what I've written above is probably partially incorrect and misrepresentative somehow, but hopefully others will correct my errors and we can work towards a solution together :)
cc @juliehockett @petrhosek
The text was updated successfully, but these errors were encountered: