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

Vxworks build error for current master branch. Need to update some source. #127084

Closed
biabbas opened this issue Jun 28, 2024 · 8 comments
Closed
Labels
C-bug Category: This is a bug. O-vxworks Target: when they made us, they called us Curiosity, and Spirit, and told us to tell you hello T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@biabbas
Copy link
Contributor

biabbas commented Jun 28, 2024

Hi all,
For target x86_64-wrs-vxworks, I'm not able to build rustc due to the following errors.

error[E0432]: unresolved imports `libc::fdopendir`, `libc::openat`, `libc::unlinkat`
    --> library/std/src/sys/pal/unix/fs.rs:2015:16
     |
2015 |     use libc::{fdopendir, openat, unlinkat};
     |                ^^^^^^^^^  ^^^^^^  ^^^^^^^^ no `unlinkat` in the root
     |                |          |
     |                |          no `openat` in the root
     |                no `fdopendir` in the root
     |
help: a similar name exists in the module
     |
2015 |     use libc::{opendir, openat, unlinkat};
     |                ~~~~~~~
help: a similar name exists in the module
     |
2015 |     use libc::{fdopendir, open, unlinkat};
     |                           ~~~~
help: a similar name exists in the module
     |
2015 |     use libc::{fdopendir, openat, nlink_t};
     |                                   ~~~~~~~

error[E0432]: unresolved import `crate::sys_common::thread`
 --> library/std/src/sys/pal/unix/process/process_vxworks.rs:7:5
  |
7 | use crate::sys_common::thread;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^ no `thread` in `sys_common`
  |
help: consider importing one of these modules instead
  |
7 | use crate::os::unix::thread;
  |     ~~~~~~~~~~~~~~~~~~~~~~~
7 | use crate::sys::thread;
  |     ~~~~~~~~~~~~~~~~~~
7 | use crate::thread;
  |     ~~~~~~~~~~~~~

error[E0425]: cannot find value `SOMAXCONN` in crate `libc`
   --> library/std/src/os/unix/net/listener.rs:104:48
    |
104 |             const backlog: libc::c_int = libc::SOMAXCONN;
    |                                                ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `dirfd` in crate `libc`
   --> library/std/src/sys/pal/unix/fs.rs:862:37
    |
862 |             let fd = unsafe { libc::dirfd(self.0) };
    |                                     ^^^^^ not found in `libc`

error[E0425]: cannot find value `UTIME_OMIT` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:1327:67
     |
1327 |             None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }),
     |                                                                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `futimens` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:1398:36
     |
1398 |                 cvt(unsafe { libc::futimens(self.as_raw_fd(), times.as_ptr()) })?;
     |                                    ^^^^^^^^ help: a function with a similar name exists: `utimes`
     |
    ::: /folk/smoodala/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.155/src/vxworks/mod.rs:1249:5
     |
1249 |     pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int;
     |     ---------------------------------------------------------------------------- similarly named function `utimes` defined here

error[E0425]: cannot find value `S_ISVTX` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:1661:44
     |
1661 |         let sticky = mode as c_int & libc::S_ISVTX as c_int != 0;
     |                                            ^^^^^^^ help: a constant with a similar name exists: `S_ISTXT`
     |
    ::: /folk/smoodala/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.155/src/vxworks/mod.rs:755:1
     |
755  | pub const S_ISTXT: ::c_int = 0x0200;
     | -------------------------- similarly named constant `S_ISTXT` defined here

error[E0425]: cannot find function `lchown` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:1967:28
     |
1967 |         cvt(unsafe { libc::lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })
     |                            ^^^^^^
     |
    ::: /folk/smoodala/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.155/src/vxworks/mod.rs:1207:5
     |
1207 |     pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
     |     -------------------------------------------------------------------- similarly named function `chown` defined here     |
help: a function with a similar name exists
     |
1967 |         cvt(unsafe { libc::chown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })
     |                            ~~~~~
help: consider importing this function
     |
7    + use crate::os::unix::fs::lchown;
     |
help: if you import `lchown`, refer to it directly
     |
1967 -         cvt(unsafe { libc::lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })
1967 +         cvt(unsafe { lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })
     |

error[E0425]: cannot find value `AT_FDCWD` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:2065:43
     |
2065 |                 parent_fd.unwrap_or(libc::AT_FDCWD),
     |                                           ^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `O_NOFOLLOW` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:2067:58
     |
2067 |                 libc::O_CLOEXEC | libc::O_RDONLY | libc::O_NOFOLLOW | libc::O_DIRECTORY,
     |                                                          ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `O_DIRECTORY` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:2067:77
     |
2067 |                 libc::O_CLOEXEC | libc::O_RDONLY | libc::O_NOFOLLOW | libc::O_DIRECTORY,
     |                                                                             ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `AT_FDCWD` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:2156:48
     |
2156 |             unlinkat(parent_fd.unwrap_or(libc::AT_FDCWD), path.as_ptr(), libc::AT_REMOVEDIR)
     |                                                ^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `AT_REMOVEDIR` in crate `libc`
    --> library/std/src/sys/pal/unix/fs.rs:2156:80
     |
2156 |             unlinkat(parent_fd.unwrap_or(libc::AT_FDCWD), path.as_ptr(), libc::AT_REMOVEDIR)
     |                                                                                ^^^^^^^^^^^^ not found in `libc`

error: unused import: `Error`
 --> library/std/src/sys/pal/unix/process/process_vxworks.rs:2:23
  |
2 | use crate::io::{self, Error, ErrorKind};
  |                       ^^^^^
  |
  = note: `-D unused-imports` implied by `-D warnings`
  = help: to override `-D warnings` add `#[allow(unused_imports)]`

error: unnecessary `unsafe` block
   --> library/std/src/sys/pal/unix/fd.rs:137:9
    |
137 |         unsafe {
    |         ^^^^^^ unnecessary `unsafe` block
    |
    = note: `-D unused-unsafe` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unused_unsafe)]`

error: unnecessary `unsafe` block
   --> library/std/src/sys/pal/unix/fd.rs:330:9
    |
330 |         unsafe {
    |         ^^^^^^ unnecessary `unsafe` block

Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `std` (lib) due to 16 previous errors
Building bootstrap
Build completed unsuccessfully in 0:44:04 

I'll be authoring some pr's to address some, but I have few doubts that I need help with. Thank you.

  1. Why is Error and unused import in process_vxworks.rs as it is referenced twice in the same file.
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 28, 2024
@workingjubilee
Copy link
Member

@biabbas

Why is Error and unused import in process_vxworks.rs as it is referenced twice in the same file.

Because it is both times referenced by the qualified io::Error form:

} else {
Err(io::Error::last_os_error())
}
}
}
pub fn output(&mut self) -> io::Result<(ExitStatus, Vec<u8>, Vec<u8>)> {
let (proc, pipes) = self.spawn(Stdio::MakePipe, false)?;
crate::sys_common::process::wait_with_output(proc, pipes)
}
pub fn exec(&mut self, default: Stdio) -> io::Error {
let ret = Command::spawn(self, default, false);

@workingjubilee
Copy link
Member

For the unused_imports linting, the qualified form isn't considered to be equal to the unqualified form, and the import makes the unqualified form available.

@workingjubilee workingjubilee added O-vxworks Target: when they made us, they called us Curiosity, and Spirit, and told us to tell you hello C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 29, 2024
@workingjubilee
Copy link
Member

it seems originally @BaoshanPang was the maintainer of these targets.

jhpratt added a commit to jhpratt/rust that referenced this issue Jul 4, 2024
Remove unqualified form import of io::Error in process_vxworks.rs and fallback on remove_dir_impl for vxworks

Hi all,
This is to address issue rust-lang#127084. On inspections it was found that io::Error refrences were all of qualified form and there was no need to add a unqualified form import. Also to successfully build rust for vxworks, we need to fallback on the remove_impl_dir implementations.

Thank you.
@biabbas
Copy link
Contributor Author

biabbas commented Jul 4, 2024

Why are there unsafe errors for unsafe blocks? If I add the whole fn as unsafe and remove unsafe blocks, I'm able to compile for vxworks.

rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 4, 2024
Rollup merge of rust-lang#127195 - biabbas:vxworks_cleanup, r=jhpratt

Remove unqualified form import of io::Error in process_vxworks.rs and fallback on remove_dir_impl for vxworks

Hi all,
This is to address issue rust-lang#127084. On inspections it was found that io::Error refrences were all of qualified form and there was no need to add a unqualified form import. Also to successfully build rust for vxworks, we need to fallback on the remove_impl_dir implementations.

Thank you.
@workingjubilee
Copy link
Member

The standard library denies all warnings in its build. One of the warnings the Rust compiler issues is "you added an unsafe {} block but you didn't need it".

@biabbas
Copy link
Contributor Author

biabbas commented Jul 8, 2024

The standard library denies all warnings in its build. One of the warnings the Rust compiler issues is "you added an unsafe {} block but you didn't need it"

But for vxworks somehow these are not disabled. Is this because we only build the libraries for vxworks.

@workingjubilee
Copy link
Member

Somehow it thinks libc::pwrite is not an unsafe extern "C" function...?

@biabbas
Copy link
Contributor Author

biabbas commented Jul 16, 2024

Pushed commits to build nightly for vxworks. Current stable source 1.79.0 can be built after applying this patch.
1.79_stable.patch

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 24, 2024
Fix build failure on vxworks rust-lang#127084

PR to address issue rust-lang#127084 .
1. Skip `reset_segpipe` for vxworks
2. Return unimplemented error for vxworks from settimes and lchown
3. Temporarily skip dirfd for vxworks
4. Add allow unused unsafe on read_at and write_at functions in unix/fs.rs
5. Using cfg disable ON_BROKEN_PIPE_FLAG_USED and on_broken_pipe_flag_used() for vxworks
6. Remove old crate::syscommon::thread::min_stack() reference from process_vxworks.rs and update to set stack size of rtpthread

Thank you.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 24, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#126152 (size_of_val_raw: for length 0 this is safe to call)
 - rust-lang#127252 (Add edge-case examples to `{count,leading,trailing}_{ones,zeros}` methods)
 - rust-lang#127374 (Tweak "wrong # of generics" suggestions)
 - rust-lang#127457 (Make tidy fast without compromising case alternation)
 - rust-lang#127480 (Fix build failure on vxworks rust-lang#127084 )
 - rust-lang#127733 (Replace some `mem::forget`'s with `ManuallyDrop`)
 - rust-lang#128120 (Gate `AsyncFn*` under `async_closure` feature)
 - rust-lang#128131 (Import `c_void` rather than using the full path)
 - rust-lang#128133 (Improve spans on evaluated `cfg_attr`s.)

r? `@ghost`
`@rustbot` modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 24, 2024
Rollup merge of rust-lang#127480 - biabbas:vxworks, r=workingjubilee

Fix build failure on vxworks rust-lang#127084

PR to address issue rust-lang#127084 .
1. Skip `reset_segpipe` for vxworks
2. Return unimplemented error for vxworks from settimes and lchown
3. Temporarily skip dirfd for vxworks
4. Add allow unused unsafe on read_at and write_at functions in unix/fs.rs
5. Using cfg disable ON_BROKEN_PIPE_FLAG_USED and on_broken_pipe_flag_used() for vxworks
6. Remove old crate::syscommon::thread::min_stack() reference from process_vxworks.rs and update to set stack size of rtpthread

Thank you.
@biabbas biabbas closed this as completed Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-vxworks Target: when they made us, they called us Curiosity, and Spirit, and told us to tell you hello T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants