Fixed r9 in arm

Hello, I'm developing for an embedded arm platform. Currently our code is in C and is compiled with clang. The code uses r9 as a "per thread" data and must remain untouched. To achieve that we use -ffixed-r9. We want to move to using rust on that platform and that requires as to do the same, keep r9 fixed. However, I could not get that to be the case. I have tried passing it in the llvm-flags and RUSTFLAGS but I could not get it to work.

I would like some help getting it to work. A side-by-side godbolt where one instance has r9 used, and the other instance has r9 unused, with the difference being a flag somewhere would be best.

Thanks in advance.

Do you have a Godbolt sample I can start from with r9 in use?

I believe you want -C target-feature="+reserve-r9", but I've not got a trivial code sample to hand that causes rustc to use r9.

3 Likes

You are right.

Adding this target feature worked!! Thank you very much! :grinning: