diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-08-31 13:53:28 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-09-26 09:32:34 +0200 |
commit | 138a6260124740208b8f3aff2e38617f43b05fe8 (patch) | |
tree | fadb7a043b546b3b7319377099840839973fea07 /gcc/rust/rust-session-manager.cc | |
parent | 4f0a2729d78d77f14140531ca809d1c45311f0c9 (diff) | |
download | gcc-138a6260124740208b8f3aff2e38617f43b05fe8.zip gcc-138a6260124740208b8f3aff2e38617f43b05fe8.tar.gz gcc-138a6260124740208b8f3aff2e38617f43b05fe8.tar.bz2 |
rust: Add -frust-compile-until option
This option helps ensure that we do not introduce regressions on various
parts of the compilation pipeline. For example, a testcase (or testsuite
from the `testing` project) might pass attribute checking, expansion and
lowering, but fail during typechecking. Should a change suddenly make
that testcase fail expansion, we would not be able to notice it. By
generating tests that run up until expansion, typechecking, compilation
and so forth we ensure that no regressions are added accidentally to
already failing tests/testsuites.
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index fc66b69..a6291a3 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -223,7 +223,9 @@ Session::handle_option ( case OPT_frust_edition_: options.set_edition (flag_rust_edition); break; - + case OPT_frust_compile_until_: + options.set_compile_step (flag_rust_compile_until); + break; case OPT_frust_metadata_output_: options.set_metadata_output (arg); break; @@ -425,6 +427,8 @@ Session::compile_crate (const char *filename) return; } + auto last_step = options.get_compile_until (); + // parse file here /* create lexer and parser - these are file-specific and so aren't instance * variables */ @@ -481,7 +485,7 @@ Session::compile_crate (const char *filename) // If -fsyntax-only was passed, we can just skip the remaining passes. // Parsing errors are already emitted in `parse_crate()` - if (flag_syntax_only) + if (flag_syntax_only || last_step == CompileOptions::CompileStep::Ast) return; // register plugins pipeline stage @@ -500,8 +504,14 @@ Session::compile_crate (const char *filename) // TODO: what do I dump here? injected crate names? } + if (last_step == CompileOptions::CompileStep::AttributeCheck) + return; + Analysis::AttributeChecker ().go (parsed_crate); + if (last_step == CompileOptions::CompileStep::Expansion) + return; + // expansion pipeline stage expansion (parsed_crate); rust_debug ("\033[0;31mSUCCESSFULLY FINISHED EXPANSION \033[0m"); @@ -514,6 +524,9 @@ Session::compile_crate (const char *filename) rust_debug ("END POST-EXPANSION AST DUMP"); } + if (last_step == CompileOptions::CompileStep::NameResolution) + return; + // resolution pipeline stage Resolver::NameResolution::Resolve (parsed_crate); if (options.dump_option_enabled (CompileOptions::RESOLUTION_DUMP)) @@ -524,6 +537,9 @@ Session::compile_crate (const char *filename) if (saw_errors ()) return; + if (last_step == CompileOptions::CompileStep::Lowering) + return; + // lower AST to HIR std::unique_ptr<HIR::Crate> lowered = HIR::ASTLowering::Resolve (parsed_crate); @@ -541,6 +557,9 @@ Session::compile_crate (const char *filename) dump_hir_pretty (hir); } + if (last_step == CompileOptions::CompileStep::TypeCheck) + return; + // type resolve Resolver::TypeResolution::Resolve (hir); if (options.dump_option_enabled (CompileOptions::TYPE_RESOLUTION_DUMP)) @@ -551,17 +570,30 @@ Session::compile_crate (const char *filename) if (saw_errors ()) return; + if (last_step == CompileOptions::CompileStep::Privacy) + return; + // Various HIR error passes. The privacy pass happens before the unsafe checks Privacy::Resolver::resolve (hir); if (saw_errors ()) return; + if (last_step == CompileOptions::CompileStep::Unsafety) + return; + HIR::UnsafeChecker ().go (hir); + + if (last_step == CompileOptions::CompileStep::Const) + return; + HIR::ConstChecker ().go (hir); if (saw_errors ()) return; + if (last_step == CompileOptions::CompileStep::Compilation) + return; + // do compile to gcc generic Compile::Context ctx (backend); Compile::CompileCrate::Compile (hir, &ctx); |