Skip to content

Make -Zfixed-x18 into a target modifier #140661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2208,7 +2208,7 @@ options! {
fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
(default: no)"),
fixed_x18: bool = (false, parse_bool, [TRACKED],
fixed_x18: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
"make the x18 register reserved on AArch64 (default: no)"),
flatten_format_args: bool = (true, parse_bool, [TRACKED],
"flatten nested format_args!() and literals into a simplified format_args!() call \
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/target_modifiers/auxiliary/fixed_x18.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ no-prefer-dynamic
//@ compile-flags: --target aarch64-unknown-none -Zfixed-x18
//@ needs-llvm-components: aarch64

#![feature(no_core)]
#![crate_type = "rlib"]
#![no_core]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: mixing `-Zfixed-x18` will cause an ABI mismatch in crate `incompatible_fixedx18`
--> $DIR/incompatible_fixedx18.rs:12:1
|
LL | #![feature(no_core)]
| ^
|
= help: the `-Zfixed-x18` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
= note: unset `-Zfixed-x18` in this crate is incompatible with `-Zfixed-x18=` in dependency `fixed_x18`
= help: set `-Zfixed-x18=` in this crate or unset `-Zfixed-x18` in `fixed_x18`
= help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=fixed-x18` to silence this error

error: aborting due to 1 previous error

17 changes: 17 additions & 0 deletions tests/ui/target_modifiers/incompatible_fixedx18.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ aux-build:fixed_x18.rs
//@ compile-flags: --target aarch64-unknown-none
//@ needs-llvm-components: aarch64

//@ revisions:allow_match allow_mismatch error_generated
//@[allow_match] compile-flags: -Zfixed-x18
//@[allow_mismatch] compile-flags: -Cunsafe-allow-abi-mismatch=fixed-x18
//@[error_generated] compile-flags:
//@[allow_mismatch] check-pass
//@[allow_match] check-pass

#![feature(no_core)]
//[error_generated]~^ ERROR mixing `-Zfixed-x18` will cause an ABI mismatch in crate `incompatible_fixedx18`
#![crate_type = "rlib"]
#![no_core]

extern crate fixed_x18;
Loading