Skip to content
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

Fix thumbv4t-none-eabi frame pointer setting #99227

Merged
merged 7 commits into from
Jul 30, 2022
Merged

Fix thumbv4t-none-eabi frame pointer setting #99227

merged 7 commits into from
Jul 30, 2022

Conversation

Lokathor
Copy link
Contributor

@Lokathor Lokathor commented Jul 14, 2022

The thumb_base profile has changed since I last remember seeing it, and now it sets the frame pointer to "always keep", which is not desired for this target. Hooking a debugger to the running program is not really done, it's preferable to have the register available for actual program use, so the default "may omit" is now set.

I thought that the target was already using "may omit" when I checked on it last month, because I forgot that the target was previously based on thumb_base rather than Default::default(). I only noticed the issue just now when creating the armv4t-none-eabi target (#99226), though this PR is not in any way conditional on that one.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 14, 2022
@rust-highfive
Copy link
Collaborator

r? @cjgillot

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive
Copy link
Collaborator

⚠️ Warning ⚠️

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 14, 2022
@rust-log-analyzer

This comment has been minimized.

@Jinxit
Copy link

Jinxit commented Jul 17, 2022

Just chiming in to say that I also use thumbv4t-none-eabi and this seems like a good change to me.

main_needs_argc_argv: false,

// don't have atomic compare-and-swap
atomic_cas: false,
has_thumb_interworking: true,

..super::thumb_base::opts()
..Default::default()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little surprised from the PR description that this doesn't just manually set the frame pointer to "may omit" which thumb_base gets wrong for this specific target, but instead decides not to use thumb_base at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow that didn't even occur to me compared to "give me the real defaults".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to see it still use thumb_base and override the changed field, rather than this approach. Unless there's a reason why this specific target is likely to diverge from thumb_base more often than not. I'm not super familiar with what we normally do for target specifications though, so others may disagree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can set the field here, but either way I'd prefer to not use thumb_base. Then as the target maintainer i have to try and pay attention to changes to an additional thing. Also as a user a person would have to look in 3 places instead of just 2 to understand all the details.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's understandable, but at the same time, if there is a change to thumb_base that would be applicable here then it could easily be missed. Ultimately, this is a trade-off that's inherent to how we define these target specs, and I'm not sure it makes sense to be inconsistent about inheriting from base specs on the basis of the preference of the target maintainer, but I don't feel strongly about this. I'd like to see what others think.

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 29, 2022

📌 Commit 2eac6f3 has been approved by davidtwco

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 29, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 30, 2022
Rollup of 8 pull requests

Successful merges:

 - rust-lang#99227 (Fix thumbv4t-none-eabi frame pointer setting)
 - rust-lang#99518 (Let-else: break out scopes when a let-else pattern fails to match)
 - rust-lang#99671 (Suggest dereferencing index when trying to use a reference of usize as index)
 - rust-lang#99831 (Add Fuchsia platform support documentation)
 - rust-lang#99881 (fix ICE when computing codegen_fn_attrs on closure with non-fn parent)
 - rust-lang#99888 (Streamline lint checking)
 - rust-lang#99891 (Adjust an expr span to account for macros)
 - rust-lang#99904 (Cleanup html whitespace)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 36ab4ec into rust-lang:master Jul 30, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 30, 2022
@Lokathor Lokathor deleted the fix-thumbv4t-none-eabi-frame-pointer branch July 31, 2022 07:18
@Lokathor
Copy link
Contributor Author

As just one example, here's the previous output of a particular function where the only important line was bx r3, and all the push/add/pop stuff was just frame pointer manipulation

08000214 <gba2k::fc3_rust>:
 8000214:    b580          push    {r7, lr}
 8000216:    af00          add    r7, sp, #0
 8000218:    4718          bx    r3
 800021a:    bc80          pop    {r7}
 800021c:    bc01          pop    {r0}
 800021e:    4700          bx    r0

and then this is what it looks like with the updated target profile in today's nightly:

08000210 <gba2k::fc3_rust>:
 8000210:    4718          bx    r3
 8000212:    4770          bx    lr

I'd call that excellent results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants