rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.08k stars 1.04k forks source link

ucontext_t is missing on aarch64-unknown-freebsd #3217

Closed jbeich closed 2 weeks ago

jbeich commented 1 year ago

2e3999ddf0fa added mcontext_t but not ucontext_t. FreeBSD ucontext_t is machine-independent but libc crate limits it by target_arch.

See ucontext_t definition vs. mcontext_t definition

error[E0412]: cannot find type `ucontext_t` in crate `libc`
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:219:57
    |
219 |               let ucontext = &mut *(context as *mut libc::ucontext_t);
    |                                                           ^^^^^^^^^^ help: a struct with a similar name exists: `mcontext_t`
    |
   ::: veloren-4b6c5f57e3a9/cargo-crates/libc-0.2.133/src/unix/bsd/freebsdlike/freebsd/aarch64.rs:20:1
    |
20  | / s_no_extra_traits! {
21  | |     pub struct gpregs {
22  | |         pub gp_x: [::register_t; 30],
23  | |         pub gp_lr: ::register_t,
..   |
44  | |     }
45  | | }
    | |_- similarly named struct `mcontext_t` defined here

error[E0412]: cannot find type `ucontext_t` in crate `libc`
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:259:45
    |
259 |           unsafe fn get_pc_sp(context: &libc::ucontext_t) -> (usize, usize) {
    |                                               ^^^^^^^^^^ help: a struct with a similar name exists: `mcontext_t`
    |
   ::: veloren-4b6c5f57e3a9/cargo-crates/libc-0.2.133/src/unix/bsd/freebsdlike/freebsd/aarch64.rs:20:1
    |
20  | / s_no_extra_traits! {
21  | |     pub struct gpregs {
22  | |         pub gp_x: [::register_t; 30],
23  | |         pub gp_lr: ::register_t,
..   |
44  | |     }
45  | | }
    | |_- similarly named struct `mcontext_t` defined here

error[E0412]: cannot find type `ucontext_t` in crate `libc`
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:314:54
    |
314 |           unsafe fn update_context(context: &mut libc::ucontext_t, regs: TrapHandlerRegs) {
    |                                                        ^^^^^^^^^^ help: a struct with a similar name exists: `mcontext_t`
    |
   ::: veloren-4b6c5f57e3a9/cargo-crates/libc-0.2.133/src/unix/bsd/freebsdlike/freebsd/aarch64.rs:20:1
    |
20  | / s_no_extra_traits! {
21  | |     pub struct gpregs {
22  | |         pub gp_x: [::register_t; 30],
23  | |         pub gp_lr: ::register_t,
..   |
44  | |     }
45  | | }
    | |_- similarly named struct `mcontext_t` defined here

error[E0425]: cannot find value `pc` in this scope
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:420:59
    |
420 |                     context.uc_mcontext.mc_gpregs.gp_pc = pc as libc::register_t;
    |                                                           ^^ not found in this scope

error[E0425]: cannot find value `sp` in this scope
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:421:59
    |
421 |                     context.uc_mcontext.mc_gpregs.gp_sp = sp as libc::register_t;
    |                                                           ^^ not found in this scope

error[E0425]: cannot find value `x0` in this scope
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:422:61
    |
422 |                     context.uc_mcontext.mc_gpregs.gp_x[0] = x0 as libc::register_t;
    |                                                             ^^ not found in this scope

error[E0425]: cannot find value `x1` in this scope
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:423:61
    |
423 |                     context.uc_mcontext.mc_gpregs.gp_x[1] = x1 as libc::register_t;
    |                                                             ^^ not found in this scope

error[E0425]: cannot find value `x29` in this scope
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:424:62
    |
424 |                     context.uc_mcontext.mc_gpregs.gp_x[29] = x29 as libc::register_t;
    |                                                              ^^^ not found in this scope

error[E0425]: cannot find value `lr` in this scope
   --> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:425:62
    |
425 |                     context.uc_mcontext.mc_gpregs.gp_x[30] = lr as libc::register_t;
    |                                                              ^^ not found in this scope

Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `wasmer-vm` due to 9 previous errors
tgross35 commented 2 months ago

Thanks for the report, feel free to put up a PR for this!