Description
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.