about summary refs log tree commit diff
path: root/compiler/rustc_session/src/options.rs
diff options
context:
space:
mode:
authorAndrew Zhogin <andrew.zhogin@gmail.com>2025-01-15 20:43:02 +0700
committerAndrew Zhogin <andrew.zhogin@gmail.com>2025-06-09 21:29:59 +0700
commit5601490c9d889ff8d964d4aafd44dcdeea40bfef (patch)
tree1555b009d14a71a2187d8506ef00ec8cb9866fe9 /compiler/rustc_session/src/options.rs
parent7c10378e1fee5ddc6573b916aeb884ab10e0de17 (diff)
downloadrust-5601490c9d889ff8d964d4aafd44dcdeea40bfef.tar.gz
rust-5601490c9d889ff8d964d4aafd44dcdeea40bfef.zip
-Zretpoline and -Zretpoline-external-thunk flags (target modifiers) to enable retpoline-related target features
Diffstat (limited to 'compiler/rustc_session/src/options.rs')
-rw-r--r--compiler/rustc_session/src/options.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index 12fa05118ca..7da48830b6a 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -290,6 +290,14 @@ macro_rules! top_level_options {
                 mods.sort_by(|a, b| a.opt.cmp(&b.opt));
                 mods
             }
+
+            pub fn target_feature_flag_enabled(&self, flag: &str) -> bool {
+                match flag {
+                    "retpoline" => self.unstable_opts.retpoline,
+                    "retpoline-external-thunk" => self.unstable_opts.retpoline_external_thunk,
+                    _ => false,
+                }
+            }
         }
     );
 }
@@ -2446,6 +2454,11 @@ options! {
     remark_dir: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
         "directory into which to write optimization remarks (if not specified, they will be \
 written to standard error output)"),
+    retpoline: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
+        "enables retpoline-indirect-branches and retpoline-indirect-calls target features (default: no)"),
+    retpoline_external_thunk: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
+        "enables retpoline-external-thunk, retpoline-indirect-branches and retpoline-indirect-calls \
+        target features (default: no)"),
     sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
         "use a sanitizer"),
     sanitizer_cfi_canonical_jump_tables: Option<bool> = (Some(true), parse_opt_bool, [TRACKED],