rust/compiler/rustc_session/src
Guillaume Gomez 0d7067d7b2
Rollup merge of #140661 - Darksonn:fixedx18-tm, r=wesleywiser
Make `-Zfixed-x18` into a target modifier

As part of #136966, the `-Zfixed-x18` flag should be turned into a target modifier. This is a blocker to stabilization of the flag. The flag was originally added in #124655 and the MCP for its addition is [MCP#748](https://github.com/rust-lang/compiler-team/issues/748).

On some aarch64 targets, the x18 register is used as a temporary caller-saved register by default. When the `-Zfixed-x18` flag is passed, this is turned off so that the compiler doesn't use the x18 register. This allows end-users to use the x18 register for other purposes. For example, by accessing it with inline asm you can use the register as a very efficient thread-local variable. Another common use-case is to store the stack pointer needed by the shadow-call-stack sanitizer. There are also some aarch64 targets where not using x18 is the default – in those cases the flag is a no-op.

Note that this flag does not *on its own* cause an ABI mismatch. What actually causes an ABI mismatch is when you have different compilation units that *disagree* on what it should be used for. But having a CU that uses it and another CU that doesn't normally isn't enough to trigger an ABI problem. However, we still consider the flag to be a target modifier in all cases, since it is assumed that you are passing the flag because you intend to assign some other meaning to the register. Rejecting all flag mismatches even if not all are unsound is consistent with [RFC#3716](https://rust-lang.github.io/rfcs/3716-target-modifiers.html). See the headings "not all mismatches are unsound" and "cases that are not caught" for additional discussion of this.

On aarch64 targets where `-Zfixed-x18` is not a no-op, it is an error to pass `-Zsanitizer=shadow-call-stack` without also passing `-Zfixed-x18`.
2025-05-05 21:32:34 +02:00
..
config Implement the internal feature cfg_target_has_reliable_f16_f128 2025-04-27 19:58:44 +00:00
code_stats.rs Document why CodeStats::type_sizes is public 2025-04-21 17:36:36 +02:00
config.rs Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
cstore.rs Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
errors.rs Auto merge of #138947 - madsmtm:refactor-apple-versions, r=Noratrieb 2025-04-06 10:16:28 +00:00
filesearch.rs Cache current_dll_path output 2025-03-21 12:46:24 +00:00
lib.rs Make #![feature(let_chains)] bootstrap conditional in compiler/ 2025-04-23 16:40:30 +02:00
options.rs Rollup merge of #140661 - Darksonn:fixedx18-tm, r=wesleywiser 2025-05-05 21:32:34 +02:00
output.rs Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
parse.rs Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
search_paths.rs Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
session.rs Stabilize -Zdwarf-version as -Cdwarf-version 2025-04-14 21:26:41 -05:00
utils.rs session: Cleanup CanonicalizedPath::new 2025-04-26 18:42:15 +03:00