diff options
| author | Noah <33094578+coolreader18@users.noreply.github.com> | 2020-12-12 21:38:23 -0600 |
|---|---|---|
| committer | Noah <33094578+coolreader18@users.noreply.github.com> | 2021-01-08 13:09:40 -0600 |
| commit | 92d3537abb36a1c8c269fc96b9a962be40745a99 (patch) | |
| tree | cb6d2bb6ff16a6e6b77e48d4d7abc4b4d301c578 /compiler/rustc_session/src | |
| parent | 7efc097c4fe6e97f54a44cee91c56189e9ddb41c (diff) | |
| download | rust-92d3537abb36a1c8c269fc96b9a962be40745a99.tar.gz rust-92d3537abb36a1c8c269fc96b9a962be40745a99.zip | |
Add wasi-exec-model cg option for emitting wasi reactors
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 8 |
3 files changed, 29 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 54abb65dc38..31fc13d2372 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2086,6 +2086,7 @@ crate mod dep_tracking { SymbolManglingVersion, TrimmedDefPaths, }; use crate::lint; + use crate::options::WasiExecModel; use crate::utils::NativeLibKind; use rustc_feature::UnstableFeatures; use rustc_span::edition::Edition; @@ -2141,6 +2142,7 @@ crate mod dep_tracking { impl_dep_tracking_hash_via_hash!(Option<RelocModel>); impl_dep_tracking_hash_via_hash!(Option<CodeModel>); impl_dep_tracking_hash_via_hash!(Option<TlsModel>); + impl_dep_tracking_hash_via_hash!(Option<WasiExecModel>); impl_dep_tracking_hash_via_hash!(Option<PanicStrategy>); impl_dep_tracking_hash_via_hash!(Option<RelroLevel>); impl_dep_tracking_hash_via_hash!(Option<lint::Level>); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 74578f2dc17..bc1d862b160 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -278,6 +278,7 @@ macro_rules! options { pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)"; pub const parse_target_feature: &str = parse_string; + pub const parse_wasi_exec_model: &str = "either `command` or `reactor`"; } #[allow(dead_code)] @@ -708,6 +709,15 @@ macro_rules! options { None => false, } } + + fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool { + match v { + Some("command") => *slot = Some(WasiExecModel::Command), + Some("reactor") => *slot = Some(WasiExecModel::Reactor), + _ => return false, + } + true + } } ) } @@ -1147,9 +1157,17 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "in general, enable more debug printouts (default: no)"), verify_llvm_ir: bool = (false, parse_bool, [TRACKED], "verify LLVM IR (default: no)"), + wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED], + "whether to build a wasi command or reactor"), // This list is in alphabetical order. // // If you add a new option, please update: - // - src/librustc_interface/tests.rs + // - compiler/rustc_interface/src/tests.rs +} + +#[derive(Clone, Hash)] +pub enum WasiExecModel { + Command, + Reactor, } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 4e269f3172c..93c619c4054 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -796,6 +796,14 @@ impl Session { self.opts.debugging_opts.tls_model.unwrap_or(self.target.tls_model) } + pub fn is_wasi_reactor(&self) -> bool { + self.target.options.os == "wasi" + && matches!( + self.opts.debugging_opts.wasi_exec_model, + Some(config::WasiExecModel::Reactor) + ) + } + pub fn must_not_eliminate_frame_pointers(&self) -> bool { // "mcount" function relies on stack pointer. // See <https://sourceware.org/binutils/docs/gprof/Implementation.html>. |
