How to compile rust with tpidr1 as thread local register

Viewed 53

In bare-metal AArch64, rust generates tpidr0 as the default register for thread_local calculations. For scenarios like kernel, tpidr1 should be used instead of tpidr0. How to make rust compiler generate code to use tpidr1 instead of the default?

1 Answers

LLVM support a custom attribute -mattr=tipdr-el[1|2|3] to override the thread local register.

By default, tipdr0 is used for this purpose. This can be overriden in rust by doing something like the following

rustc -C target-feature=tpidr-el1 --target=aarch64-unknown-none
Related