aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-session-manager.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-11-28 18:22:34 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2022-12-13 14:00:08 +0100
commitb07ef39ffbf4e77a586605019c64e2e070915ac3 (patch)
treeca0b82d92b43078d877edcd8e39a0146a1c6899d /gcc/rust/rust-session-manager.cc
parent88415d33bb34c087da29938ef270788f155bb584 (diff)
downloadgcc-b07ef39ffbf4e77a586605019c64e2e070915ac3.zip
gcc-b07ef39ffbf4e77a586605019c64e2e070915ac3.tar.gz
gcc-b07ef39ffbf4e77a586605019c64e2e070915ac3.tar.bz2
gccrs: Add fatal_error when experimental flag is not present
This commits ports over the flag/env variable checking from #1540 which only allows compilation using gccrs if a certain flag is specified gcc/rust/ * lang.opt (-frust-incomplete-and-experimental-compiler-do-not-use): New. * rust-session-manager.cc (Session::compile_crate): Check it. * Make-lang.in (RUST_SELFTEST_FLAGS): Add it. gcc/testsuite/ * lib/rust.exp (rust_init): Add '-frust-incomplete-and-experimental-compiler-do-not-use'.
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r--gcc/rust/rust-session-manager.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 6d7f1a8..264fb50 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -417,6 +417,28 @@ Session::handle_crate_name (const AST::Crate &parsed_crate)
void
Session::compile_crate (const char *filename)
{
+ if (!flag_rust_experimental
+ && !std::getenv ("GCCRS_INCOMPLETE_AND_EXPERIMENTAL_COMPILER_DO_NOT_USE"))
+ rust_fatal_error (
+ Location (), "%s",
+ "gccrs is not yet able to compile Rust code "
+ "properly. Most of the errors produced will be gccrs' fault and not the "
+ "crate you are trying to compile. Because of this, please reports issues "
+ "to us directly instead of opening issues on said crate's "
+ "repository.\n\nOur github repository: "
+ "https://github.com/rust-gcc/gccrs\nOur bugzilla tracker: "
+ "https://gcc.gnu.org/bugzilla/"
+ "buglist.cgi?bug_status=__open__&component=rust&product=gcc\n\n"
+ "If you understand this, and understand that the binaries produced might "
+ "not behave accordingly, you may attempt to use gccrs in an experimental "
+ "manner by passing the following flag:\n\n"
+ "`-frust-incomplete-and-experimental-compiler-do-not-use`\n\nor by "
+ "defining the following environment variable (any value will "
+ "do)\n\nGCCRS_INCOMPLETE_AND_EXPERIMENTAL_COMPILER_DO_NOT_USE\n\nFor"
+ "cargo-gccrs, this means passing\n\n"
+ "GCCRS_EXTRA_FLAGS=\"-frust-incomplete-and-experimental-compiler-do-not-"
+ "use\"\n\nas an environment variable.");
+
RAIIFile file_wrap (filename);
if (!file_wrap.ok ())
{