From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id 57847387387D; Tue, 13 Dec 2022 13:20:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57847387387D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670937636; bh=bt4Ys4SpTS8UkaxVwevmCY3fGAPDYTInh+Vwx2Axi8w=; h=From:To:Subject:Date:From; b=Qc/j/8jfB59kGS7wu3G3VmUekAer8ywDq0g6cM8VBqFHdNYmyufETj0ULnArXr0g8 Xy0xuwKgmfHp5m4i6fZJkqW9uRDZ9WFqI0mcLOIZhwyA4+REbp9JMOn+VZXDQBK6tv pvx00u+7nMkSzmwm3xTWbt9nw+CcTHyKiypbcCF0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4675] gccrs: Add fatal_error when experimental flag is not present X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/master X-Git-Oldrev: 88415d33bb34c087da29938ef270788f155bb584 X-Git-Newrev: b07ef39ffbf4e77a586605019c64e2e070915ac3 Message-Id: <20221213132036.57847387387D@sourceware.org> Date: Tue, 13 Dec 2022 13:20:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b07ef39ffbf4e77a586605019c64e2e070915ac3 commit r13-4675-gb07ef39ffbf4e77a586605019c64e2e070915ac3 Author: Arthur Cohen Date: Mon Nov 28 18:22:34 2022 +0100 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'. Diff: --- gcc/rust/Make-lang.in | 2 +- gcc/rust/lang.opt | 4 ++++ gcc/rust/rust-session-manager.cc | 22 ++++++++++++++++++++++ gcc/testsuite/lib/rust.exp | 2 ++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index f3a03a3199d..681ac7b3fee 100644 --- a/gcc/rust/Make-lang.in +++ b/gcc/rust/Make-lang.in @@ -267,7 +267,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 6187fbf2935..63732a636a3 100644 --- a/gcc/rust/lang.opt +++ b/gcc/rust/lang.opt @@ -66,6 +66,10 @@ frust-dump- Rust Joined RejectNegative -frust-dump- 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 6d7f1a85f19..264fb5051b7 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 ()) { diff --git a/gcc/testsuite/lib/rust.exp b/gcc/testsuite/lib/rust.exp index 6993c976304..287905bd544 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:"