Skip to content

Compiler does not recognize the reserve-x18 target feature #121970

Closed
@Darksonn

Description

@Darksonn

On the aarch64-unknown-none target, specifying the reserve-x18 target feature using the flag -Ctarget-feature=+reserve-x18 results in the following warning:

warning: unknown feature specified for `-Ctarget-feature`: `reserve-x18`
  |
  = note: it is still passed through to the codegen backend
  = help: consider filing a feature request

The desired effect of this flag is to reserve the x18 register so that LLVM does not use it during codegen. Note that despite the warning, the flag still works fine today since it is passed on to LLVM.

This feature is necessary for Rust to work when using the Linux Kernel's dynamic shadow call stack feature on aarch64 (more info). The shadow call stack feature requires that the x18 register is reserved, since it is used to store the shadow stack. In C code, the dynamic version of shadow call stack requires you to pass -ffixed-x18 but not -fsanitize=shadow-call-stack (which is only used for non-dynamic SCS).

Clang has a collection of flags for reserving other registers than x18 as well. I think it would make sense to add those as well, even if they are less useful than x18.

Related to #96472.
Related to this thread on LKML.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ABIArea: Concerning the application binary interface (ABI)A-diagnosticsArea: Messages for errors, warnings, and lintsA-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.C-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.O-AArch64Armv8-A or later processors in AArch64 modeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions