Skip to content

Add .cpu <arch> directive to .S files #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xiongyu0523 opened this issue Aug 3, 2021 · 7 comments
Closed

Add .cpu <arch> directive to .S files #133

xiongyu0523 opened this issue Aug 3, 2021 · 7 comments
Assignees

Comments

@xiongyu0523
Copy link

When I'm porting threadX to Arduino environment, some of the core platform's toolchain does not specify -mcpu option for assembly code so it cause gcc throw an error related to 'MSR' and 'MSR' instructions. I already submit a PR to a known core platform to add -mcpu but there are too many core platform Arudino support and old version in use, so better if we can add this directive to all ports (I assume this is not harmful) so it will be fixed even -mpcu is not added

Related PR:
arduino/ArduinoCore-samd#642

@goldscott goldscott self-assigned this Aug 3, 2021
@goldscott
Copy link
Contributor

Internally, we have one copy of the file (e.g. for ARMv7-M) that is used for M0, M3, M4, M7. So we cannot put the cpu in the file. Is there a different way to do this? We could put the arch in the files.... would that help?

@xiongyu0523
Copy link
Author

Are you saying you are generating Cortex-Mx CPU ports from a single ARMv7-M arch base file? I was thinking there're different source and implementation as cortex-m0 only implements a small number of Thumb-2.

What is the directive for specify arch? I can have a quick try if it can suppress GNU AS error

@goldscott
Copy link
Contributor

Sorry, that should be M3/4/7. Not M0.

Check out the -march option here: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

@xiongyu0523
Copy link
Author

xiongyu0523 commented Aug 5, 2021

this option is for compiler, what I was mentioning is Arduino has many core platform (with toolchain and its configurations), it is not easy to revise all of them support -mcpu or -march. If we can add .cpu cortex-m0/3/4/7 to our port source, it can fix this without need specifying them. Or is there another way to claim instruction set in assembly code

@xiongyu0523
Copy link
Author

Ok. I found there are equivalent method, and source code directive take priority over compiler options.
I have tried on one of the platform generating errors, by adding .arch armv6-m on top of .S source, it fixes the error.

@goldscott
Copy link
Contributor

I don't know what the arduino build environment looks like. Couldn't you pass a compiler flag to that to specify the cpu/architecture?
Or you can edit the ThreadX source and create a pull request, we will review and possibly implement it.

@xiongyu0523
Copy link
Author

I add this directive out side of official port and then include official port to solve this problem. we can close, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants