aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-12-07 14:19:12 +0000
committerGitHub <noreply@github.com>2022-12-07 14:19:12 +0000
commit038e11c3eeb4eb36f8894829af6299abb70f3e04 (patch)
tree51d06c10aa3f7773575c3968467f8ee0535628f1
parent8c0f4e48ffe9095acd65a109a1e53540140dece5 (diff)
parentd9d9ca0b9e50b669d5445e028739bcdd0aa024bd (diff)
downloadgcc-038e11c3eeb4eb36f8894829af6299abb70f3e04.zip
gcc-038e11c3eeb4eb36f8894829af6299abb70f3e04.tar.gz
gcc-038e11c3eeb4eb36f8894829af6299abb70f3e04.tar.bz2
Merge #1540
1540: Implement `-frust-incomplete-and-experimental-compiler-do-not-use` flag r=dkm a=CohenArthur Remember to change your `./configure` line :) This is obviously up for discussion and I would be happy to get some more input. Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com> Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
-rw-r--r--gcc/rust/Make-lang.in2
-rw-r--r--gcc/rust/lang.opt4
-rw-r--r--gcc/rust/rust-session-manager.cc22
-rw-r--r--gcc/testsuite/lib/rust.exp2
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 8f10396..21d7d4e 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -269,7 +269,7 @@ rust.uninstall:
# Enable selftests for the rust frontend
selftest-rust: s-selftest-rust
-RUST_SELFTEST_FLAGS = -xrust $(SELFTEST_FLAGS)
+RUST_SELFTEST_FLAGS = -xrust -frust-incomplete-and-experimental-compiler-do-not-use $(SELFTEST_FLAGS)
RUST_SELFTEST_DEPS = rust1$(exeext) $(SELFTEST_DEPS)
# Run the rust selftests
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt
index 40297ad..ff4f537 100644
--- a/gcc/rust/lang.opt
+++ b/gcc/rust/lang.opt
@@ -66,6 +66,10 @@ frust-dump-
Rust Joined RejectNegative
-frust-dump-<type> Dump Rust frontend internal information.
+frust-incomplete-and-experimental-compiler-do-not-use
+Rust Var(flag_rust_experimental)
+Enable experimental compilation of Rust files at your own risk
+
frust-max-recursion-depth=
Rust RejectNegative Type(int) Var(rust_max_recursion_depth) Init(64)
-frust-max-recursion-depth=integer
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 513bf50..54660a8 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -427,6 +427,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 ())
{
diff --git a/gcc/testsuite/lib/rust.exp b/gcc/testsuite/lib/rust.exp
index 6993c97..287905b 100644
--- a/gcc/testsuite/lib/rust.exp
+++ b/gcc/testsuite/lib/rust.exp
@@ -149,6 +149,8 @@ proc rust_init { args } {
lappend ALWAYS_RUSTFLAGS "additional_flags=$TOOL_OPTIONS"
}
+ lappend ALWAYS_RUSTFLAGS "additional_flags=-frust-incomplete-and-experimental-compiler-do-not-use"
+
verbose -log "ALWAYS_RUSTFLAGS set to $ALWAYS_RUSTFLAGS"
set gcc_warning_prefix "warning:"