Skip to content
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

-Z dump-dep-graph does not generate output #106736

Closed
gftea opened this issue Jan 11, 2023 · 7 comments
Closed

-Z dump-dep-graph does not generate output #106736

gftea opened this issue Jan 11, 2023 · 7 comments
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gftea
Copy link
Contributor

gftea commented Jan 11, 2023

A simple test setup, run on WSL2 on windows 11.

cargo new hello
cd hello
cargo clean; cargo +nightly rustc -- -Zdump-dep-graph

There is no file generated in current directory, nor in the /tmp folder

@cjgillot
Copy link
Contributor

You need to pass -Zquery-dep-graph too. We should probably add a diagnostic.

@gftea
Copy link
Contributor Author

gftea commented Jan 11, 2023

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();
}

@cjgillot
Copy link
Contributor

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.

@gftea
Copy link
Contributor Author

gftea commented Jan 11, 2023

I see, thanks! Why not let -Zdump-dep-graph implicitly enable query-dep-graph?

@Noratrieb Noratrieb added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) labels Jan 12, 2023
@cjgillot
Copy link
Contributor

For the silliest reason: nobody implemented it 😄.
If you want to do it, please go ahead.

@gftea
Copy link
Contributor Author

gftea commented Jan 13, 2023

@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?

@cjgillot
Copy link
Contributor

Inside build_session_options may even be better. There are already a few diagnostics given in that function for option collisions.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 16, 2023
check -Z query-dep-graph is enabled if -Z dump-dep-graph (rust-lang#106736)

PR to solve rust-lang#106736, r? `@cjgillot`
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 16, 2023
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#105954 (Update instrument-coverage.md)
 - rust-lang#106835 (new trait solver: rebase impl substs for gats correctly)
 - rust-lang#106912 (check -Z query-dep-graph is enabled if -Z dump-dep-graph (rust-lang#106736))
 - rust-lang#106940 (Improve a TAIT error and add an error code plus documentation)
 - rust-lang#106942 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@gftea gftea closed this as completed May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants