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

Move sys::vxworks code to sys::unix #84119

Merged
merged 3 commits into from
Apr 22, 2021
Merged

Move sys::vxworks code to sys::unix #84119

merged 3 commits into from
Apr 22, 2021

Conversation

CDirkx
Copy link
Contributor

@CDirkx CDirkx commented Apr 12, 2021

Follow-up to #77666, sys::vxworks is almost identical to sys::unix, the only differences are the rand, thread_local_dtor, and process implementation. Since vxworks is target_family = unix anyway, there is no reason for the code not to live inside of sys::unix like all the other unix-OSes.

os_family: Some("unix".to_string()),

@rustbot label: +T-libs-impl

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Apr 12, 2021
@rust-highfive
Copy link
Collaborator

r? @m-ou-se

(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 Apr 12, 2021
@m-ou-se
Copy link
Member

m-ou-se commented Apr 14, 2021

I don't have required toolchain to build vxworks on my machine, so I can't confirm this code compiles

Does this work for you? ./x.py check --target=x86_64-wrs-vxworks library/std

It gives some compiler errors:
error[E0428]: the name `imp` is defined multiple times
   --> library/std/src/sys/unix/rand.rs:242:1
    |
23  | mod imp {
    | ------- previous definition of the module `imp` here
...
242 | mod imp {
    | ^^^^^^^ `imp` redefined here
    |
    = note: `imp` must be defined only once in the type namespace of this module

error[E0433]: failed to resolve: could not find `platform` in `super`
 --> library/std/src/sys/unix/ext/fs.rs:5:12
  |
5 | use super::platform::fs::MetadataExt as _;
  |            ^^^^^^^^ could not find `platform` in `super`

error[E0433]: failed to resolve: could not find `platform` in `super`
  --> library/std/src/sys/unix/ext/raw.rs:27:16
   |
27 | pub use super::platform::raw::pthread_t;
   |                ^^^^^^^^ could not find `platform` in `super`

error[E0433]: failed to resolve: could not find `platform` in `super`
  --> library/std/src/sys/unix/ext/raw.rs:30:16
   |
30 | pub use super::platform::raw::{blkcnt_t, time_t};
   |                ^^^^^^^^ could not find `platform` in `super`

error[E0433]: failed to resolve: could not find `platform` in `super`
  --> library/std/src/sys/unix/ext/raw.rs:33:16
   |
33 | pub use super::platform::raw::{blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t};
   |                ^^^^^^^^ could not find `platform` in `super`

error[E0432]: unresolved import `crate::os::unix::raw::pthread_t`
 --> library/std/src/sys/unix/ext/thread.rs:6:5
  |
6 | use crate::os::unix::raw::pthread_t;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `pthread_t` in `sys::unix::ext::raw`

error[E0425]: cannot find function `env_lock` in module `sys::os`
  --> library/std/src/sys/unix/process/process_vxworks.rs:71:34
   |
71 |             let _lock = sys::os::env_lock();
   |                                  ^^^^^^^^ not found in `sys::os`

error[E0599]: no method named `st_dev` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:661:14
    |
661 |         self.st_dev()
    |              ^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_ino` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:664:14
    |
664 |         self.st_ino()
    |              ^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_mode` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:667:14
    |
667 |         self.st_mode()
    |              ^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_nlink` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:670:14
    |
670 |         self.st_nlink()
    |              ^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_uid` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:673:14
    |
673 |         self.st_uid()
    |              ^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_gid` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:676:14
    |
676 |         self.st_gid()
    |              ^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_rdev` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:679:14
    |
679 |         self.st_rdev()
    |              ^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_size` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:682:14
    |
682 |         self.st_size()
    |              ^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_atime` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:685:14
    |
685 |         self.st_atime()
    |              ^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_atime_nsec` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:688:14
    |
688 |         self.st_atime_nsec()
    |              ^^^^^^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_mtime` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:691:14
    |
691 |         self.st_mtime()
    |              ^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_mtime_nsec` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:694:14
    |
694 |         self.st_mtime_nsec()
    |              ^^^^^^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_ctime` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:697:14
    |
697 |         self.st_ctime()
    |              ^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_ctime_nsec` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:700:14
    |
700 |         self.st_ctime_nsec()
    |              ^^^^^^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_blksize` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:703:14
    |
703 |         self.st_blksize()
    |              ^^^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_blocks` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:706:14
    |
706 |         self.st_blocks()
    |              ^^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `st_attrib` found for reference `&fs::Metadata` in the current scope
   --> library/std/src/sys/unix/ext/fs.rs:710:14
    |
710 |         self.st_attrib()
    |              ^^^^^^^^^ method not found in `&fs::Metadata`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::os::vxworks::fs::MetadataExt;`

error[E0599]: no method named `core_dumped` found for reference `&process_inner::ExitStatus` in the current scope
   --> library/std/src/sys/unix/ext/process.rs:259:25
    |
259 |         self.as_inner().core_dumped()
    |                         ^^^^^^^^^^^ method not found in `&process_inner::ExitStatus`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `ExitStatusExt` defines an item `core_dumped`, perhaps you need to implement it
   --> library/std/src/sys/unix/ext/process.rs:210:1
    |
210 | pub trait ExitStatusExt: Sealed {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no method named `stopped_signal` found for reference `&process_inner::ExitStatus` in the current scope
   --> library/std/src/sys/unix/ext/process.rs:263:25
    |
263 |         self.as_inner().stopped_signal()
    |                         ^^^^^^^^^^^^^^ method not found in `&process_inner::ExitStatus`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `ExitStatusExt` defines an item `stopped_signal`, perhaps you need to implement it
   --> library/std/src/sys/unix/ext/process.rs:210:1
    |
210 | pub trait ExitStatusExt: Sealed {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no method named `continued` found for reference `&process_inner::ExitStatus` in the current scope
   --> library/std/src/sys/unix/ext/process.rs:267:25
    |
267 |         self.as_inner().continued()
    |                         ^^^^^^^^^ method not found in `&process_inner::ExitStatus`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `ExitStatusExt` defines an item `continued`, perhaps you need to implement it
   --> library/std/src/sys/unix/ext/process.rs:210:1
    |
210 | pub trait ExitStatusExt: Sealed {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no method named `into_raw` found for reference `&process_inner::ExitStatus` in the current scope
   --> library/std/src/sys/unix/ext/process.rs:271:25
    |
271 |         self.as_inner().into_raw().into()
    |                         ^^^^^^^^ method not found in `&process_inner::ExitStatus`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `ExitStatusExt` defines an item `into_raw`, perhaps you need to implement it
   --> library/std/src/sys/unix/ext/process.rs:210:1
    |
210 | pub trait ExitStatusExt: Sealed {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 28 previous errors

@m-ou-se m-ou-se added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 14, 2021
@m-ou-se
Copy link
Member

m-ou-se commented Apr 14, 2021

Oh, it looks like quite a few of those errors also exist on the main branch. Apparently std for vxworks is already broken on nightly. :(

@CDirkx
Copy link
Contributor Author

CDirkx commented Apr 14, 2021

./x.py check --target=x86_64-wrs-vxworks library/std

I tried, but that results in couldn't find required command: "wr-cc", which I assumed was a proprietary compiler vendored by Wind River.

@m-ou-se
Copy link
Member

m-ou-se commented Apr 14, 2021

Ah, making wr-cc a symlink to gcc or clang 'works' (at least for ./x.py check). Apparently I already set that up on my machine last time I was moving some stuff around for this target.

@CDirkx
Copy link
Contributor Author

CDirkx commented Apr 14, 2021

making wr-cc a symlink to gcc or clang 'works'

It did :) passing CC=cc and AR=ar is enough to run check.
I fixed the issues, so now everything compiles. However, because libc::WCOREDUMP and libc::WIFCONTINUED are not available on vxworks, and I don't know what the correct implementation would be, some methods are implemented using unimplemented!

@bors
Copy link
Contributor

bors commented Apr 18, 2021

☔ The latest upstream changes (presumably #78880) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@m-ou-se m-ou-se left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

library/std/src/sys/unix/process/process_vxworks.rs Outdated Show resolved Hide resolved
@@ -223,7 +223,7 @@ impl Command {
pub fn get_groups(&self) -> Option<&[gid_t]> {
self.groups.as_deref()
}

#[allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

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

It's probably better to not put this attribute here and instead put something like let _ = self.get_closures(); with a comment in the vxworks code. Then it's more explicit that the pre_exec closures are ignored on vxworks.

(Ideally we shouldn't even expose pre_exec on platforms that don't have that ability, but it's part of the unix extension trait for Command.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added your suggestion with a comment.

@m-ou-se
Copy link
Member

m-ou-se commented Apr 21, 2021

Thanks!

@bors r+

(We should maybe try to at least run ./x.py check for vxworks in our CI, because now none of this really gets checked even for compiler errors.)

@bors
Copy link
Contributor

bors commented Apr 21, 2021

📌 Commit aa46f08 has been approved by m-ou-se

@bors
Copy link
Contributor

bors commented Apr 21, 2021

🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 21, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Apr 21, 2021
Move `sys::vxworks` code to `sys::unix`

Follow-up to rust-lang#77666, `sys::vxworks` is almost identical to `sys::unix`, the only differences are the `rand`, `thread_local_dtor`, and `process` implementation. Since `vxworks` is `target_family = unix` anyway, there is no reason for the code not to live inside of `sys::unix` like all the other unix-OSes.

https://github.com/rust-lang/rust/blob/e41f378f825488a537b024fc3ed599d9c12fda96/compiler/rustc_target/src/spec/vxworks_base.rs#L12

`@rustbot` label: +T-libs-impl
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2021
Rollup of 12 pull requests

Successful merges:

 - rust-lang#84013 (Replace all `fmt.pad` with `debug_struct`)
 - rust-lang#84119 (Move `sys::vxworks` code to `sys::unix`)
 - rust-lang#84212 (Replace `Void` in `sys` with never type)
 - rust-lang#84251 (fix 'const-stable since' for NonZeroU*::new_unchecked)
 - rust-lang#84301 (Document that `index` and `index_mut` can panic)
 - rust-lang#84365 (Improve the docstrings of the `Lto` struct.)
 - rust-lang#84378 (Fix broken doc link)
 - rust-lang#84379 (Add GAT related tests)
 - rust-lang#84380 (Write Rustdoc titles like "x in crate::mod - Rust")
 - rust-lang#84390 (Format `Struct { .. }` on one line even with `{:#?}`.)
 - rust-lang#84393 (Support `x.py doc std --open`)
 - rust-lang#84406 (Remove `delete` alias from `mem::drop`.)

Failed merges:

 - rust-lang#84387 (Move `sys_common::poison` to `sync::poison`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3897ad1 into rust-lang:master Apr 22, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 22, 2021
@CDirkx CDirkx deleted the vxworks branch April 22, 2021 07:57
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-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants