-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implementation of RFC2867 #76260
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
Implementation of RFC2867 #76260
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
I think at minimum the following targets will also need
Someone who knows about platforms supporting ARMv6 and ARMv7 will have to sort through the rest. (@jonas-schievink?) |
Responded to feedback, also aimed to improve some of the error messages in collect.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good now! Some tests should be added though (and some manual testing is probably useful too)
@jonas-schievink where should I look to for examples of tests in the code base covering similar areas? |
I think for the initial version of this, it's enough to check that the attribute is accepted and rejected correctly. For that, you can write UI tests in |
Oh, I also suggest rebasing this PR to fix the merge conflicts, then CI can run tests for you. |
This comment has been minimized.
This comment has been minimized.
@jonas-schievink So I started working on the tests and after seeing CI fail started running the tests locally. I'm just wondering if there's a way to run them for a different architecture? Otherwise I'll just get the architecture doesn't support |
This comment has been minimized.
This comment has been minimized.
@jonas-schievink I'd like to try and get this sorted by this week if possible but I might need some help with the UI tests to figure out how to get them to just run with the intended architectures.. Also should I add a UI test to just run with intel so I can get the error message for arch doesn't support instruction_set 🤔 (I think yes so I'll probably just start that soon-ish) |
This comment has been minimized.
This comment has been minimized.
src/test/ui/error-codes/E0775.rs
Outdated
@@ -0,0 +1,11 @@ | |||
// only-armv4t-unknown-linux-gnueabi | |||
// only-armv5te-unknown-linux-gnueabi | |||
// only-armv5te-unknown-linux-musleabi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you can stack only
like that?
I recall it did not work and tests like that have been changed to use different conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, I couldn't really find any documentation on how the comments worked and figured it was worth trying before writing the mass of ignore-*
I'd need to do to run using just those 3 architectures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Judging by the comment it won't run this test on any target:
rust/src/tools/compiletest/src/header.rs
Line 53 in 6cae281
// we should check if any only-<platform> exists and if it exists |
So I guess I need to add |
I don't know how to solve it and have very limited search ability on the mobile. |
@mati865 okay thanks for the pointer though, I'll try the ignores at some point later, just trying to get the CI to the point of running those tests first 😬 |
@@ -0,0 +1,35 @@ | |||
// ignore-aarch64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonas-schievink @mati865 I don't know if either of you have time to have a look at this. But I can't figure out all the ignores I need to stop this running on architectures other than the arm v4 and v5 targets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine to just run it on one of the Arm architectures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that would make things easier, I was trying to test on all relevant arm targets
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -331,6 +331,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ | |||
optimize, AssumedUsed, template!(List: "size|speed"), optimize_attribute, | |||
experimental!(optimize), | |||
), | |||
// RFC 2867 | |||
gated!(instruction_set, AssumedUsed, template!(List: "arm::a32|arm::t32"), isa_attribute, experimental!(instruction_set)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonas-schievink so I have a feeling this is causing one of my issues with the E0775 error code test?
error[E0658]: the `#[instruction_set]` attribute is an experimental feature
--> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:15478:1
|
2 | #[instruction_set()] // error: expected one argument
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #74727 <https://github.com/rust-lang/rust/issues/74727> for more information
= help: add `#![feature(isa_attribute)]` to the crate attributes to enable
error[E0776]: target does not support `#[instruction_set]`
--> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:15478:1
|
2 | #[instruction_set()] // error: expected one argument
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do it with Word
as the element instead of List
previously but it didn't seem to work, might have been multiple issues working together though 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use #![feature(instruction_set)]
in the test to get rid of the first error.
The second error just looks like architecture support is checked before attribute syntax, which matches what your code is doing. I'm not sure how much validation is actually derived from the template!
(the string is used in the error message, but might not actually be used to check attribute syntax).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh then I made a mistake (I guess). The RFC says the feature gate is isa_attribute and the attribute is instruction_set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, #![feature(isa_attribute)]
should also fix this then. I think the RFC initially proposed #[isa]
instead of #[instruction_set]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the check so it does it the other way around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This codes outdated I changed it to gated!(isa_attribute, AssumedUsed, template!(Word), isa_attribute, experimental!(instruction_set)),
but I still get the not supported on this architecture in the E0775 ui test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code in typeck first checks whether the architecture supports #[instruction_set]
, and only then check whether it is syntactically correct. There is no architecture check done in builtin_attrs.rs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So with the E0775.rs ui test I have // only-armv4t-unknown-linux-gnueabi
at the top of the file. And I thought that meant I'd only get the compiler errors for that architecture. Because I wouldn't expect the error messages to be the same for an unsupported arch as a supported arch, and checking thumb_interworking first seems to be the quickest and most-general check to do first (arm v4/v5 isn't a lot of users). I could change it to do it the other way round and fix the errors that way if that's the better/easiest/preferred approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would make sense. I'd usually expect syntax to be validated first, and independently of the target, and then have semantic checks performed.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ah oops I was looking at the test failure from yesterday. That should be fine then. |
You can make this take less time with |
yeah I tried doing filtering on them like with cargo test but that didn't seem to work. It wasn't so bad when it failed early on 😅. So the current error_code doctest issue is to do with the architecture it's ran on not supporting arm:a32 or arm::t32. I'll add a cfg_attr to it so it works. But do you want it to encompass all the targets it works on, or just pick one of them? And also should I mention which targets do support it or just leave that off because it's discoverable elsewhere i.e. the tracking issue? |
I'm not the person to ask, but #76260 (comment) sounds like only one target is fine.
This seems like the list could grow a lot over time - maybe point to the tracking issue instead? |
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
@jonas-schievink all the feedback should be addressed now 👍 |
Awesome! Will approve once CI passes |
@xd009642 do you mind squashing the commit history a little? 52 commits is a lot 😅 |
There are instructions at https://rustc-dev-guide.rust-lang.org/git.html#rebasing |
Yeah I can do that tomorrow morning 👍 |
gazes longingly at rust-lang/triagebot#821 |
@jonas-schievink @jyn514 squashed and I fixed the mistake in the stderr post case fix. Just couldn't wait until tomorrow 😄 |
@bors r=jonas-schievink |
📌 Commit bdb3f77 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
#74727
So I've started work on this, I think my next steps are to make use of the
instruction_set
value in the llvm codegen but this is the point where I begin to get a bit lost. I'm looking at the code but it would be nice to have some guidance on what I've currently done and what I'm doing next 😄