Closed gftea closed 1 year ago
You need to pass -Zquery-dep-graph
too. We should probably add a diagnostic.
OK, now it works with cargo clean; cargo +nightly rustc -- -Zquery-dep-graph -Zdump-dep-graph
but, now I have below codes, the generated dep-graph does not have any info about foo()
function. Why is that?
fn foo() {
let x = "foo";
println!("{}", x);
}
fn main() {
foo();
}
The generated graph only records dependencies between queries. It used to have both the query name and its argument. I removed that a few months back to have much terser dumps, easier to use.
I see, thanks! Why not let -Zdump-dep-graph implicitly enable query-dep-graph?
For the silliest reason: nobody implemented it :smile:. If you want to do it, please go ahead.
@cjgillot after reading the codes, it seems would be better to hint the missing flag if query-dep-graph is not given.
In build_dep_graph(), record_graph
only true when query-dep-graph is true.
pub fn build_dep_graph(...) {
....
Some(DepGraph::new(
&sess.prof,
prev_graph,
prev_work_products,
encoder,
sess.opts.unstable_opts.query_dep_graph,
sess.opts.unstable_opts.incremental_info,
))
In assert_dep_graph(), would be good to hint to user if missing query-dep-graph flag.
pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
tcx.dep_graph.with_ignore(|| {
if tcx.sess.opts.unstable_opts.dump_dep_graph {
tcx.dep_graph.with_query(dump_graph);
}
if !tcx.sess.opts.unstable_opts.query_dep_graph {
// --> Hint about the missing option ?
return;
}
and maybe better to have early error before runninig compiler?
fn run_compiler(
at_args: &[String],
callbacks: &mut (dyn Callbacks + Send),
file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
make_codegen_backend: Option<
Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>,
>,
) -> interface::Result<()> {
let args = args::arg_expand_all(at_args);
let Some(matches) = handle_options(&args) else { return Ok(()) };
let sopts = config::build_session_options(&matches);
// check dump-dep-graph and query-dep-graph here?
Inside build_session_options
may even be better. There are already a few diagnostics given in that function for option collisions.
A simple test setup, run on WSL2 on windows 11.
There is no file generated in current directory, nor in the /tmp folder