rust_for_linux: -Zregparm=<N> commandline flag for X86 (#116972)
This commit is contained in:
parent
a0c2aba29a
commit
b3ae64d24f
20 changed files with 436 additions and 53 deletions
|
@ -136,3 +136,6 @@ session_unsupported_crate_type_for_target =
|
|||
dropping unsupported crate type `{$crate_type}` for target `{$target_triple}`
|
||||
|
||||
session_unsupported_dwarf_version = requested DWARF version {$dwarf_version} is greater than 5
|
||||
|
||||
session_unsupported_regparm = `-Zregparm={$regparm}` is unsupported (valid values 0-3)
|
||||
session_unsupported_regparm_arch = `-Zregparm=N` is only supported on x86
|
||||
|
|
|
@ -485,6 +485,16 @@ pub(crate) struct FunctionReturnRequiresX86OrX8664;
|
|||
#[diag(session_function_return_thunk_extern_requires_non_large_code_model)]
|
||||
pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_unsupported_regparm)]
|
||||
pub(crate) struct UnsupportedRegparm {
|
||||
pub(crate) regparm: u32,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_unsupported_regparm_arch)]
|
||||
pub(crate) struct UnsupportedRegparmArch;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_failed_to_create_profiler)]
|
||||
pub(crate) struct FailedToCreateProfiler {
|
||||
|
|
|
@ -2000,6 +2000,10 @@ options! {
|
|||
"enable queries of the dependency graph for regression testing (default: no)"),
|
||||
randomize_layout: bool = (false, parse_bool, [TRACKED],
|
||||
"randomize the layout of types (default: no)"),
|
||||
regparm: Option<u32> = (None, parse_opt_number, [TRACKED],
|
||||
"On x86-32 targets, setting this to N causes the compiler to pass N arguments \
|
||||
in registers EAX, EDX, and ECX instead of on the stack.\
|
||||
It is UNSOUND to link together crates that use different values for this flag!"),
|
||||
relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"whether ELF relocations can be relaxed"),
|
||||
remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
|
||||
|
|
|
@ -1337,6 +1337,15 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(regparm) = sess.opts.unstable_opts.regparm {
|
||||
if regparm > 3 {
|
||||
sess.dcx().emit_err(errors::UnsupportedRegparm { regparm });
|
||||
}
|
||||
if sess.target.arch != "x86" {
|
||||
sess.dcx().emit_err(errors::UnsupportedRegparmArch);
|
||||
}
|
||||
}
|
||||
|
||||
// The code model check applies to `thunk` and `thunk-extern`, but not `thunk-inline`, so it is
|
||||
// kept as a `match` to force a change if new ones are added, even if we currently only support
|
||||
// `thunk-extern` like Clang.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue