aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-session-manager.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-01-28 10:08:44 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-01-28 10:08:44 +0000
commitebfbdf962fb3e65e17ad8a0477558549e924dd22 (patch)
treeab049e20f1637ab091367922befeeafcc6d539d1 /gcc/rust/rust-session-manager.cc
parent1fc2b540800d25af1c70e90439e8a9077c7d07f8 (diff)
downloadgcc-ebfbdf962fb3e65e17ad8a0477558549e924dd22.zip
gcc-ebfbdf962fb3e65e17ad8a0477558549e924dd22.tar.gz
gcc-ebfbdf962fb3e65e17ad8a0477558549e924dd22.tar.bz2
Add -frust-cfg=value option for adding config options
This adds the initial support for config expansion on custom config values it need support for parsing options such as feature=test with apropriate error handling withing Session::handle_cfg_option(const std::string&). This also applies the mark_for_strip checks only on AST::Functions and will need applied to the rest of the crate in #872. Addresses #889
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r--gcc/rust/rust-session-manager.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 9650086..c930f55 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -353,9 +353,11 @@ Session::handle_option (
case OPT_I:
// TODO: add search path
break;
+
case OPT_L:
// TODO: add library link path or something
break;
+
case OPT_frust_crate_:
// set the crate name
if (arg != nullptr)
@@ -363,6 +365,7 @@ Session::handle_option (
else
ret = false;
break;
+
case OPT_frust_dump_:
// enable dump and return whether this was successful
if (arg != nullptr)
@@ -374,17 +377,31 @@ Session::handle_option (
ret = false;
}
break;
+
case OPT_frust_mangling_:
Compile::Mangler::set_mangling (flag_rust_mangling);
- // no option handling for -o
+ break;
+
+ case OPT_frust_cfg_:
+ ret = handle_cfg_option (std::string (arg));
+ break;
+
default:
- // return 1 to indicate option is valid
break;
}
return ret;
}
+bool
+Session::handle_cfg_option (const std::string &value)
+{
+ // rustc doesn't seem to error on any duplicate key
+ // TODO handle feature=bla and relevant error handling in parsing
+ options.target_data.insert_key (value);
+ return true;
+}
+
/* Enables a certain dump depending on the name passed in. Returns true if name
* is valid, false otherwise. */
bool