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

define TIOCGWINSZ as c_ulong under arm-uclibc. #2615

Merged
merged 2 commits into from
Jan 18, 2022
Merged

define TIOCGWINSZ as c_ulong under arm-uclibc. #2615

merged 2 commits into from
Jan 18, 2022

Conversation

lancethepants
Copy link
Contributor

@lancethepants lancethepants commented Jan 4, 2022

I'm trying to bring up a new target for rust, armv7-unknown-linux-uclibceabi (softfloat). rust-lang/rust#92383 Looks like a lot of work has already been hashed out from the recent addition of armv7-unknown-linux-uclibceabihf. The only issue I'm currently seeing is when I encounter TIOCGWINSZ in a couple places. This is the error I see.

   Compiling termize v0.1.1 (/mmc/.cargo/registry/src/github.com-1285ae84e5963aae/termize-0.1.1)
error[E0277]: the trait bound `u32: From<i32>` is not satisfied
  --> src/platform/unix.rs:12:43
   |
12 |     let mut result = ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut window);
   |                      -----                ^^^^^^^^^^^^^^^^^ the trait `From<i32>` is not implemented for `u32`
   |                      |
   |                      required by a bound introduced by this call
   |
   = help: the following implementations were found:
             <u32 as From<Ipv4Addr>>
             <u32 as From<NonZeroU32>>
             <u32 as From<bool>>
             <u32 as From<char>>
           and 2 others
   = note: required because of the requirements on the impl of `Into<u32>` for `i32`

error[E0277]: the trait bound `u32: From<i32>` is not satisfied

I see the error in the termize crate, and also shell.rs in the cargo source.

My current fix is to define TIOCGWINSZ as c_ulong under arm-uclibc.

I don't want to break anything with the established armv7-unknown-linux-uclibceabihf target so perhaps @skrap could chime in and take a look. Maybe a better solutions exists.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon.

Please see the contribution instructions for more information.

@skrap
Copy link
Contributor

skrap commented Jan 4, 2022

I don't want to break anything with the established armv7-unknown-linux-uclibceabihf target so perhaps @skrap could chime in and take a look. Maybe a better solutions exists.

Since ioctl is defined in uclibc as extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;, it seems that this change is the right one. If you wanted to save some heartache for some future devs, you could change all of the constants from man ioctl_tty which appear here to the same type.

Thanks for contributing!

@lancethepants
Copy link
Contributor Author

I've updated my pull request. See if that looks alright. Looks like there's a broader discussion on ioctls going on now though.

@Amanieu
Copy link
Member

Amanieu commented Jan 4, 2022

ioctl is part of the kernel API, which means that the constants have the same value no matter which libc is used. It doesn't make sense to put these in modules that are specific to a particular libc.

The difference between gnu which uses c_ulong while musl and uclibc which use c_int only exists in Rust. The only thing we should care about is that the type matches the one used for the request parameter of the ioctl function.

We already have a typedef (Ioctl) which maps to the type used by the request parameter of the ioctl function for a particular libc. What needs to be done is:

  • Change Ioctl for uclibc to c_ulong so it matches the ioctl signature.
  • Define any ioctl constants in the common linux code, not libc-specific code, and using the Ioctl type instead of hard-coding c_int or c_ulong.

@skrap
Copy link
Contributor

skrap commented Jan 5, 2022

Yeah, that's great! @lancethepants do you feel like that's something you want to try out? Or is it more than you want to take on?

@lancethepants
Copy link
Contributor Author

I'll give it a try, consolidate all the ioctl code. It's true it's not libc-specific, but it is architecture specific, there are different values for different systems. I think it will probably all end up going under the arch directory.

@Amanieu
Copy link
Member

Amanieu commented Jan 8, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jan 8, 2022

📌 Commit d75d690 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Jan 8, 2022

⌛ Testing commit d75d690 with merge c248dd0...

bors added a commit that referenced this pull request Jan 8, 2022
define TIOCGWINSZ as c_ulong under arm-uclibc.

I'm trying to bring up a new target for rust, `armv7-unknown-linux-uclibceabi (softfloat)`. rust-lang/rust#92383 Looks like a lot of work has already been hashed out from the recent addition of `armv7-unknown-linux-uclibceabihf`. The only issue I'm currently seeing is when I encounter `TIOCGWINSZ` in a couple places. This is the error I see.
```
   Compiling termize v0.1.1 (/mmc/.cargo/registry/src/github.com-1285ae84e5963aae/termize-0.1.1)
error[E0277]: the trait bound `u32: From<i32>` is not satisfied
  --> src/platform/unix.rs:12:43
   |
12 |     let mut result = ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut window);
   |                      -----                ^^^^^^^^^^^^^^^^^ the trait `From<i32>` is not implemented for `u32`
   |                      |
   |                      required by a bound introduced by this call
   |
   = help: the following implementations were found:
             <u32 as From<Ipv4Addr>>
             <u32 as From<NonZeroU32>>
             <u32 as From<bool>>
             <u32 as From<char>>
           and 2 others
   = note: required because of the requirements on the impl of `Into<u32>` for `i32`

error[E0277]: the trait bound `u32: From<i32>` is not satisfied
```
I see the error in the `termize` crate, and also `shell.rs` in the cargo source.

My current fix is to define TIOCGWINSZ as c_ulong under arm-uclibc.

I don't want to break anything with the established `armv7-unknown-linux-uclibceabihf` target so perhaps `@skrap` could chime in and take a look. Maybe a better solutions exists.
@bors
Copy link
Contributor

bors commented Jan 8, 2022

💔 Test failed - checks-actions

@Amanieu
Copy link
Member

Amanieu commented Jan 9, 2022

The tests failed on MIPS: https://github.com/rust-lang/libc/runs/4749363042?check_suite_focus=true

It seems that some headers are missing in the testsuite. Have a look at libc-test/build.rs.

@lancethepants
Copy link
Contributor Author

I had run into a nearly identical issue for x86 when defining a different ioctl that had not before been previously defined stopped compilation in the same exact manner. The mips issue is an ioctl that had only been defined under musl, and not gnu, which is where the issue cropped up. I've undefined those ioctl for non-musl-mips, and maybe we'll see how it goes. I may need to undefine it for all non-musl builds, and maybe a few more issues like this one could pop up as well. We thought just defining everything and just being done with it would be nice, and I still think it's the way to go, just a few corner cases I think. I don't fully understand what the compilation issue is, it talks like the ioctl value is undefined, but then it worked when we had not defined the ioctl. Defining it somehow is messing it up I think.

@Amanieu
Copy link
Member

Amanieu commented Jan 10, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jan 10, 2022

📌 Commit 1826597 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Jan 10, 2022

⌛ Testing commit 1826597 with merge e9a8c4a...

bors added a commit that referenced this pull request Jan 10, 2022
define TIOCGWINSZ as c_ulong under arm-uclibc.

I'm trying to bring up a new target for rust, `armv7-unknown-linux-uclibceabi (softfloat)`. rust-lang/rust#92383 Looks like a lot of work has already been hashed out from the recent addition of `armv7-unknown-linux-uclibceabihf`. The only issue I'm currently seeing is when I encounter `TIOCGWINSZ` in a couple places. This is the error I see.
```
   Compiling termize v0.1.1 (/mmc/.cargo/registry/src/github.com-1285ae84e5963aae/termize-0.1.1)
error[E0277]: the trait bound `u32: From<i32>` is not satisfied
  --> src/platform/unix.rs:12:43
   |
12 |     let mut result = ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut window);
   |                      -----                ^^^^^^^^^^^^^^^^^ the trait `From<i32>` is not implemented for `u32`
   |                      |
   |                      required by a bound introduced by this call
   |
   = help: the following implementations were found:
             <u32 as From<Ipv4Addr>>
             <u32 as From<NonZeroU32>>
             <u32 as From<bool>>
             <u32 as From<char>>
           and 2 others
   = note: required because of the requirements on the impl of `Into<u32>` for `i32`

error[E0277]: the trait bound `u32: From<i32>` is not satisfied
```
I see the error in the `termize` crate, and also `shell.rs` in the cargo source.

My current fix is to define TIOCGWINSZ as c_ulong under arm-uclibc.

I don't want to break anything with the established `armv7-unknown-linux-uclibceabihf` target so perhaps `@skrap` could chime in and take a look. Maybe a better solutions exists.
@bors
Copy link
Contributor

bors commented Jan 10, 2022

💔 Test failed - checks-actions

@lancethepants
Copy link
Contributor Author

So the ppc error I did encounter the wrong value when doing this. Didn't know there was a test for it. Everything I can find shows that the value is currently incorrect in rust.
golang/go#19560
golang/go@197f9ba

What's the best way to proceed? Just fix these one at a time until we pass all the test? It'd be nice if I could test all the tiers on my own with my own system in an automated fashion, but that alone would be a project for me.

@bors
Copy link
Contributor

bors commented Jan 17, 2022

⌛ Testing commit 8fb8054 with merge d6b7075...

bors added a commit that referenced this pull request Jan 17, 2022
define TIOCGWINSZ as c_ulong under arm-uclibc.

I'm trying to bring up a new target for rust, `armv7-unknown-linux-uclibceabi (softfloat)`. rust-lang/rust#92383 Looks like a lot of work has already been hashed out from the recent addition of `armv7-unknown-linux-uclibceabihf`. The only issue I'm currently seeing is when I encounter `TIOCGWINSZ` in a couple places. This is the error I see.
```
   Compiling termize v0.1.1 (/mmc/.cargo/registry/src/github.com-1285ae84e5963aae/termize-0.1.1)
error[E0277]: the trait bound `u32: From<i32>` is not satisfied
  --> src/platform/unix.rs:12:43
   |
12 |     let mut result = ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut window);
   |                      -----                ^^^^^^^^^^^^^^^^^ the trait `From<i32>` is not implemented for `u32`
   |                      |
   |                      required by a bound introduced by this call
   |
   = help: the following implementations were found:
             <u32 as From<Ipv4Addr>>
             <u32 as From<NonZeroU32>>
             <u32 as From<bool>>
             <u32 as From<char>>
           and 2 others
   = note: required because of the requirements on the impl of `Into<u32>` for `i32`

error[E0277]: the trait bound `u32: From<i32>` is not satisfied
```
I see the error in the `termize` crate, and also `shell.rs` in the cargo source.

My current fix is to define TIOCGWINSZ as c_ulong under arm-uclibc.

I don't want to break anything with the established `armv7-unknown-linux-uclibceabihf` target so perhaps `@skrap` could chime in and take a look. Maybe a better solutions exists.
@bors
Copy link
Contributor

bors commented Jan 17, 2022

💔 Test failed - checks-actions

@kaniini
Copy link
Contributor

kaniini commented Jan 17, 2022

the musl changes look good

@lancethepants
Copy link
Contributor Author

Push a change that should fix the riscv issue.

@Amanieu
Copy link
Member

Amanieu commented Jan 17, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jan 17, 2022

📌 Commit 3384294 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Jan 17, 2022

⌛ Testing commit 3384294 with merge 8e72914...

bors added a commit that referenced this pull request Jan 17, 2022
define TIOCGWINSZ as c_ulong under arm-uclibc.

I'm trying to bring up a new target for rust, `armv7-unknown-linux-uclibceabi (softfloat)`. rust-lang/rust#92383 Looks like a lot of work has already been hashed out from the recent addition of `armv7-unknown-linux-uclibceabihf`. The only issue I'm currently seeing is when I encounter `TIOCGWINSZ` in a couple places. This is the error I see.
```
   Compiling termize v0.1.1 (/mmc/.cargo/registry/src/github.com-1285ae84e5963aae/termize-0.1.1)
error[E0277]: the trait bound `u32: From<i32>` is not satisfied
  --> src/platform/unix.rs:12:43
   |
12 |     let mut result = ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut window);
   |                      -----                ^^^^^^^^^^^^^^^^^ the trait `From<i32>` is not implemented for `u32`
   |                      |
   |                      required by a bound introduced by this call
   |
   = help: the following implementations were found:
             <u32 as From<Ipv4Addr>>
             <u32 as From<NonZeroU32>>
             <u32 as From<bool>>
             <u32 as From<char>>
           and 2 others
   = note: required because of the requirements on the impl of `Into<u32>` for `i32`

error[E0277]: the trait bound `u32: From<i32>` is not satisfied
```
I see the error in the `termize` crate, and also `shell.rs` in the cargo source.

My current fix is to define TIOCGWINSZ as c_ulong under arm-uclibc.

I don't want to break anything with the established `armv7-unknown-linux-uclibceabihf` target so perhaps `@skrap` could chime in and take a look. Maybe a better solutions exists.
@bors
Copy link
Contributor

bors commented Jan 17, 2022

💔 Test failed - checks-actions

@lancethepants
Copy link
Contributor Author

Pushed a commit to fix sparc64 issue. Interested to see how ci runs s390x. I'm getting errors on my machine from HEAD on Master.

@Amanieu
Copy link
Member

Amanieu commented Jan 18, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jan 18, 2022

📌 Commit dc36824 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Jan 18, 2022

⌛ Testing commit dc36824 with merge 3b15a77...

@bors
Copy link
Contributor

bors commented Jan 18, 2022

☀️ Test successful - checks-actions, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13
Approved by: Amanieu
Pushing 3b15a77 to master...

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

Successfully merging this pull request may close these issues.

None yet

6 participants