diff options
| author | Miguel Ojeda <ojeda@kernel.org> | 2025-05-07 15:38:14 +0200 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2025-08-17 16:51:42 +0200 |
| commit | 1a29d9c23ff8df46197f5ebd3df15fe99904d312 (patch) | |
| tree | 5902dc3d038702a438812bb9598f63277f383953 /compiler/rustc_session/src | |
| parent | 1cd7080c3a7f29297675a72a157575ae12717304 (diff) | |
| download | rust-1a29d9c23ff8df46197f5ebd3df15fe99904d312.tar.gz rust-1a29d9c23ff8df46197f5ebd3df15fe99904d312.zip | |
Add `-Zindirect-branch-cs-prefix` option
This is intended to be used for Linux kernel RETPOLINE builds. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/errors.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 6 |
3 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index bf95014843d..9471807df01 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -472,6 +472,10 @@ pub(crate) struct FunctionReturnRequiresX86OrX8664; pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel; #[derive(Diagnostic)] +#[diag(session_indirect_branch_cs_prefix_requires_x86_or_x86_64)] +pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664; + +#[derive(Diagnostic)] #[diag(session_unsupported_regparm)] pub(crate) struct UnsupportedRegparm { pub(crate) regparm: u32, diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index fce4d18a1d8..6d5be2d92cd 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -2296,7 +2296,7 @@ options! { - hash collisions of query keys - hash collisions when creating dep-nodes"), indirect_branch_cs_prefix: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER], - "add cs prefix to call and jmp to indirect thunk (default: no)"), + "add `cs` prefix to `call` and `jmp` to indirect thunks (default: no)"), inline_llvm: bool = (true, parse_bool, [TRACKED], "enable LLVM inlining (default: yes)"), inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index c6956cf5f23..c8f4b511a7e 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1368,6 +1368,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } } + if sess.opts.unstable_opts.indirect_branch_cs_prefix { + if sess.target.arch != "x86" && sess.target.arch != "x86_64" { + sess.dcx().emit_err(errors::IndirectBranchCsPrefixRequiresX86OrX8664); + } + } + if let Some(regparm) = sess.opts.unstable_opts.regparm { if regparm > 3 { sess.dcx().emit_err(errors::UnsupportedRegparm { regparm }); |
