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

Added ucontext_t for powerpc64-linux #3986

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mgiessing
Copy link

@mgiessing mgiessing commented Oct 17, 2024

Description

This PR will add ucontext_t to powerpc64le-unknown-linux-gnu.
The relevant header files this is linked to can be found here: https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h and for ucontext_t specifically here: https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h#L155-L196

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

Testing throws an error, but that is not related to this PR as far as I can see. Even without the patch I see an error in the main branch

[...]
  cargo:warning=57833 |             }
  cargo:warning=      |             ^
  cargo:warning=/root/git/libc/target/powerpc64le-unknown-linux-gnu/debug/build/libc-test-0e970a92698d6386/out/main.c: In function ‘__test_fn_epoll_pwait2’:
  cargo:warning=/root/git/libc/target/powerpc64le-unknown-linux-gnu/debug/build/libc-test-0e970a92698d6386/out/main.c:57858:13: error: control reaches end of non-void function [-Werror=return-type]
  cargo:warning=57858 |             }
  cargo:warning=      |             ^
  cargo:warning=At top level:
  cargo:warning=cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
  cargo:warning=cc1: all warnings being treated as errors

  --- stderr
  rust version: 1.84.0-nightly


  error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-Wall" "-Wextra" "-Werror" "-Wno-unused-parameter" "-Wno-type-limits" "-Wno-address-of-packed-member" "-Wno-unknown-warning-option" "-Wno-deprecated-declarations" "-D_GNU_SOURCE" "-D__GLIBC_USE_DEPRECATED_SCANF" "-o" "/root/git/libc/target/powerpc64le-unknown-linux-gnu/debug/build/libc-test-0e970a92698d6386/out/4d9447838b1b2e62-main.o" "-c" "/root/git/libc/target/powerpc64le-unknown-linux-gnu/debug/build/libc-test-0e970a92698d6386/out/main.c" with args cc did not execute successfully (status code exit status: 1).

@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@mgiessing
Copy link
Author

Related to #3964

@mgiessing
Copy link
Author

I see there is an issue with the PR in regards to the usage of of c_double/float64.

error[E0277]: the trait bound `f64: core::cmp::Eq` is not satisfied
  --> src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs:43:9
   |
43 |         pub fp_regs: [::c_double; 33], // # define __NFPREG    33
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `core::cmp::Eq` is not implemented for `f64`, which is required by `[f64; 33]: core::cmp::Eq`
   |
   = help: the following other types implement trait `core::cmp::Eq`:
             i128
             i16
             i32
             i64
             i8
             isize
             u128
             u16
           and 4 others
   = note: required for `[f64; 33]` to implement `core::cmp::Eq`
note: required by a bound in `AssertParamIsEq`
  --> /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/cmp.rs:359:1
   = note: this error originates in the derive macro `Eq` which comes from the expansion of the macro `s` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `f64: Hash` is not satisfied
  --> src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs:43:9
   |
43 |         pub fp_regs: [::c_double; 33], // # define __NFPREG    33
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Hash` is not implemented for `f64`, which is required by `[f64; 33]: Hash`
   |
   = help: the following other types implement trait `Hash`:
             i128
             i16
             i32
             i64
             i8
             isize
             u128
             u16
           and 4 others
   = note: required for `[f64; 33]` to implement `Hash`
   = note: this error originates in the derive macro `Hash` which comes from the expansion of the macro `s` (in Nightly builds, run with -Z macro-backtrace for more info)

@JohnTitor Would you know what I need to change to make this pass? I tried to adapt based on the aarch64, loongarch64 & riscv64 version with the help of the powerpc64 glibc ucontext header file but apparently something's going wrong!

Any help is appreciated!

@mgiessing
Copy link
Author

@rustbot label stable-nominated

@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Oct 22, 2024
@tgross35
Copy link
Contributor

tgross35 commented Nov 6, 2024

I think this looks fine, but could you please add links to the relevant headers in the PR description?

@tgross35
Copy link
Contributor

tgross35 commented Nov 6, 2024

@rustbot author

(just comment @rustbot review once the above is done)

@mgiessing
Copy link
Author

@tgross35 Thanks for looking into this! I updated the PR description with the relevant header files.

Comment on lines +43 to +46
pub gp_regs: [::c_ulong; 48], // # define __NGREG 48
pub fp_regs: [::c_double; 33], // # define __NFPREG 33
pub v_regs: *mut vrregset_t,
pub vmx_reserve: [::c_long; 69], // # define __NVRREG 34 (34*2+1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Jut to be consistent, could you duplicate the C types?

const _NGREG: usize = 48;
const __NFPREG: usize = 33;
const __NVRREG: usize = 34;

type gregset_t = [::c_ulong; __NGREG];
type fpregset_t = [::c_double; __NFPREG];

// in the struct
pub vmx_reserve: [::c_long; __NVRREG + __NVRREG + 1],

}

#[allow(missing_debug_implementations)]
pub struct pt_regs {
Copy link
Contributor

Choose a reason for hiding this comment

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

@bors
Copy link
Contributor

bors commented Nov 17, 2024

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

@tgross35
Copy link
Contributor

@mgiessing this will need a rebase since the align module is gone now (which is a great thing 🎉)

@mgiessing
Copy link
Author

I'm currently not having access to my laptop so the earliest I can work again on this will be mid of December, more probably beginning of next year :-)

@tgross35
Copy link
Contributor

No worries! I'll mark this as a draft.

Any chance you know the answer to https://github.com/rust-lang/libc/pull/3986/files#r1831808892? If so, maybe somebody could pick this up to finish it.

@tgross35 tgross35 marked this pull request as draft November 20, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author stable-nominated This PR should be considered for cherry-pick to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants