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

Change more x64 size checks to not apply to x32. #88668

Merged
merged 1 commit into from
Sep 11, 2021
Merged

Conversation

hvdijk
Copy link
Contributor

@hvdijk hvdijk commented Sep 5, 2021

Commit 95e096d changed a bunch of size checks already, but more have
been added, so this fixes the new ones the same way: the various size
checks that are conditional on target_arch = "x86_64" were not intended
to apply to x86_64-unknown-linux-gnux32, so add
target_pointer_width = "64" to the conditions.

Commit 95e096d changed a bunch of size checks already, but more have
been added, so this fixes the new ones the same way: the various size
checks that are conditional on target_arch = "x86_64" were not intended
to apply to x86_64-unknown-linux-gnux32, so add
target_pointer_width = "64" to the conditions.
@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 5, 2021
@CryZe
Copy link
Contributor

CryZe commented Sep 6, 2021

Do these even need the target_arch at all and not just the pointer width?

@hvdijk
Copy link
Contributor Author

hvdijk commented Sep 6, 2021

Do these even need the target_arch at all and not just the pointer width?

Good question. I think some of the checks could potentially fail if some target has 64-bit pointers that do not require 64-bit alignment, but I do not know whether Rust supports any such target. I wouldn't want to have that change as part of this one in case it needs to be reverted (the revert would break x32 again), but I can submit it as a followup PR if you like.

@michaelwoerister
Copy link
Member

r? @joshtriplett who seems to know more about this

@jrtc27
Copy link

jrtc27 commented Sep 7, 2021

Does target_pointer_width mean sizeof(void *) or log2(__UINTPTR_MAX__ + 1) (i.e. is it defined to be the size of a pointer or the range you can address)? If the latter, using a bare target_pointer_width == 64 would make things worse for CHERI, where pointers carry additional metadata beyond the address by using "capabilities", so 64-bit architectures have 128-bit pointers but still only a 64-bit address space (even the current patch would cause issues for a CHERI x86_64, but that is so far just a sketch in our ISA spec). The former is fine for CHERI but is often not what people use these kinds of things to mean.

(See also #65473 that tracks usize as defined conflating the ideas of size_t and uintptr_t)

@hvdijk
Copy link
Contributor Author

hvdijk commented Sep 7, 2021

Does target_pointer_width mean sizeof(void *) or log2(__UINTPTR_MAX__ + 1) (i.e. is it defined to be the size of a pointer or the range you can address)?

That's not clear to me from the specification. https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width just says "Key-value option set once with the target's pointer width in bits."

If the latter, using a bare target_pointer_width == 64 would make things worse for CHERI, where pointers carry additional metadata beyond the address by using "capabilities",

Let's play it safe and forget about that for now, then.

(even the current patch would cause issues for a CHERI x86_64, but that is so far just a sketch in our ISA spec)

The current patch wouldn't cause issues for that, as it doesn't enable any static asserts that were previously disabled: any assert that would fail with this patch already fails the same way without this patch.

@jrtc27
Copy link

jrtc27 commented Sep 7, 2021

Does target_pointer_width mean sizeof(void *) or log2(__UINTPTR_MAX__ + 1) (i.e. is it defined to be the size of a pointer or the range you can address)?

That's not clear to me from the specification. https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width just says "Key-value option set once with the target's pointer width in bits."

If the latter, using a bare target_pointer_width == 64 would make things worse for CHERI, where pointers carry additional metadata beyond the address by using "capabilities",

Let's play it safe and forget about that for now, then.

(even the current patch would cause issues for a CHERI x86_64, but that is so far just a sketch in our ISA spec)

The current patch wouldn't cause issues for that, as it doesn't enable any static asserts that were previously disabled: any assert that would fail with this patch already fails the same way without this patch.

Agreed :) and there are already asserts of that form elsewhere

@joshtriplett
Copy link
Member

This seems reasonable to me.

@bors r+

@bors
Copy link
Contributor

bors commented Sep 7, 2021

📌 Commit cd75af2 has been approved by joshtriplett

@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 Sep 7, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 11, 2021
Change more x64 size checks to not apply to x32.

Commit 95e096d changed a bunch of size checks already, but more have
been added, so this fixes the new ones the same way: the various size
checks that are conditional on target_arch = "x86_64" were not intended
to apply to x86_64-unknown-linux-gnux32, so add
target_pointer_width = "64" to the conditions.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 11, 2021
Change more x64 size checks to not apply to x32.

Commit 95e096d changed a bunch of size checks already, but more have
been added, so this fixes the new ones the same way: the various size
checks that are conditional on target_arch = "x86_64" were not intended
to apply to x86_64-unknown-linux-gnux32, so add
target_pointer_width = "64" to the conditions.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 11, 2021
…ingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#87904 (Reword description of automatic impls of `Unsize`.)
 - rust-lang#88147 (Fix non-capturing closure return type coercion)
 - rust-lang#88209 (Improve error message when _ is used for in/inout asm operands)
 - rust-lang#88668 (Change more x64 size checks to not apply to x32.)
 - rust-lang#88733 (Fix ICE for functions with more than 65535 arguments)
 - rust-lang#88757 (Suggest wapping expr in parentheses on invalid unary negation)
 - rust-lang#88779 (Use more accurate spans for "unused delimiter" lint)
 - rust-lang#88830 (Add help for E0463)
 - rust-lang#88849 (don't clone types that are Copy (clippy::clone_on_copy))
 - rust-lang#88850 (don't convert types into identical types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7b514cd into rust-lang:master Sep 11, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 11, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants