aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-07-17 13:09:36 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:55:56 +0100
commitdcba437a8223ca1a88a59e8286fb3565bd07b445 (patch)
treeb18b083787e11d3a4dd5762b9ee4b82228ffd80d /gcc
parent2327631e4ba359fb43a6a46bf2771ac5ea441d8c (diff)
downloadgcc-dcba437a8223ca1a88a59e8286fb3565bd07b445.zip
gcc-dcba437a8223ca1a88a59e8286fb3565bd07b445.tar.gz
gcc-dcba437a8223ca1a88a59e8286fb3565bd07b445.tar.bz2
gccrs: cli: Add frust-type option
Add a new option to crab1 cli to accept crate type. This version of the argument only accept a single crate type. Rustc accepts a comma separated list of crate types but this might require a litle more work for gcc. gcc/rust/ChangeLog: * lang.opt: Add option * rust-session-manager.cc: Add option registration in session target options. * rust-session-manager.h (struct CompileOptions): Add new getter for proc macros instead of a boolean. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/lang.opt28
-rw-r--r--gcc/rust/rust-session-manager.cc4
-rw-r--r--gcc/rust/rust-session-manager.h28
3 files changed, 58 insertions, 2 deletions
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt
index 2af0f1a..5b744f7 100644
--- a/gcc/rust/lang.opt
+++ b/gcc/rust/lang.opt
@@ -82,6 +82,34 @@ frust-max-recursion-depth=
Rust RejectNegative Type(int) Var(rust_max_recursion_depth) Init(64)
-frust-max-recursion-depth=<integer>
+frust-crate-type=
+Rust Joined RejectNegative Enum(frust_crate_type) Var(flag_rust_crate_type)
+-frust-crate-type=[bin|lib|rlib|dylib|cdylib|staticlib|proc-macro] Crate type to emit
+
+Enum
+Name(frust_crate_type) Type(int) UnknownError(unknown crate type: '%qs')
+
+EnumValue
+Enum(frust_crate_type) String(bin) Value(0)
+
+EnumValue
+Enum(frust_crate_type) String(lib) Value(1)
+
+EnumValue
+Enum(frust_crate_type) String(rlib) Value(2)
+
+EnumValue
+Enum(frust_crate_type) String(dylib) Value(3)
+
+EnumValue
+Enum(frust_crate_type) String(cdylib) Value(4)
+
+EnumValue
+Enum(frust_crate_type) String(staticlib) Value(5)
+
+EnumValue
+Enum(frust_crate_type) String(proc-macro) Value(6)
+
frust-mangling=
Rust Joined RejectNegative Enum(frust_mangling) Var(flag_rust_mangling)
-frust-mangling=[legacy|v0] Version to use for name mangling
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index b1a735c..af57d57 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -234,7 +234,9 @@ Session::handle_option (
ret = handle_cfg_option (string_arg);
break;
}
-
+ case OPT_frust_crate_type_:
+ options.set_crate_type (flag_rust_crate_type);
+ break;
case OPT_frust_edition_:
options.set_edition (flag_rust_edition);
break;
diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h
index f4f95af..8706f72 100644
--- a/gcc/rust/rust-session-manager.h
+++ b/gcc/rust/rust-session-manager.h
@@ -54,7 +54,26 @@ struct TargetOptions
std::unordered_map<std::string, std::unordered_set<tl::optional<std::string>>>
features;
+ enum class CrateType
+ {
+ BIN = 0,
+ LIB,
+ RLIB,
+ DYLIB,
+ CDYLIB,
+ STATICLIB,
+ PROC_MACRO
+ } crate_type
+ = CrateType::BIN;
+
public:
+ void set_crate_type (int raw_type)
+ {
+ crate_type = static_cast<CrateType> (raw_type);
+ }
+
+ const CrateType &get_crate_type () const { return crate_type; }
+
// Returns whether a key is defined in the feature set.
bool has_key (std::string key) const
{
@@ -214,7 +233,6 @@ struct CompileOptions
bool crate_name_set_manually = false;
bool enable_test = false;
bool debug_assertions = false;
- bool proc_macro = false;
std::string metadata_output_path;
enum class Edition
@@ -281,6 +299,14 @@ struct CompileOptions
const Edition &get_edition () const { return edition; }
+ void set_crate_type (int raw_type) { target_data.set_crate_type (raw_type); }
+
+ bool is_proc_macro () const
+ {
+ return target_data.get_crate_type ()
+ == TargetOptions::CrateType::PROC_MACRO;
+ }
+
void set_compile_step (int raw_step)
{
compile_until = static_cast<CompileStep> (raw_step);