Skip to content

Conversation

@devnexen
Copy link
Contributor

No description provided.

@rust-highfive
Copy link

r? @Amanieu

(rust-highfive has picked a reviewer for you, use r? to override)

Copy link
Contributor

@semarie semarie left a comment

Choose a reason for hiding this comment

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

struct definitions are corrects, but it doesn't pass the test on OpenBSD:

+ cargo test --features extra_traits --manifest-path libc-test/Cargo.toml --target x86_64-unknown-openbsd                                                                                                                               
+ RUST_BACKTRACE=1                                         
   Compiling libc v0.2.94 (/data/semarie/repos/rust/libc-rs)
   Compiling libc-test v0.2.94 (/data/semarie/repos/rust/libc-rs/libc-test)
error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
  --> src/macros.rs:76:57                                  
   |                                                
76 |               #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
   |                                                           ^^^^^
   |                                                                                                                   
  ::: src/unix/bsd/netbsdlike/openbsd/x86_64.rs:8:1
   |
8  | / s! {
9  | |     #[repr(packed)]
10 | |     pub struct fxsave64 {
11 | |         pub fx_fcw: u16,
...  |
56 | |     }
57 | | }
   | |_- in this macro invocation
   |
note: the lint level is defined here
  --> src/lib.rs:24:39
   |
24 | #![deny(missing_copy_implementations, safe_packed_borrows)]
   |                                       ^^^^^^^^^^^^^^^^^^^
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
  --> src/macros.rs:76:68
   |
76 |               #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
   |                                                                      ^^^^
   | 
  ::: src/unix/bsd/netbsdlike/openbsd/x86_64.rs:8:1
   |
8  | / s! {
9  | |     #[repr(packed)]
10 | |     pub struct fxsave64 {
11 | |         pub fx_fcw: u16,
...  |
56 | |     }
57 | | }
   | |_- in this macro invocation
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
  --> src/macros.rs:76:74
   |
76 |               #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
   |                                                                            ^^^^^^^^^
   | 
  ::: src/unix/bsd/netbsdlike/openbsd/x86_64.rs:8:1
   |
8  | / s! {
9  | |     #[repr(packed)]
10 | |     pub struct fxsave64 {
11 | |         pub fx_fcw: u16,
...  |
56 | |     }
57 | | }
   | |_- in this macro invocation
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors

error: could not compile `libc`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

@semarie
Copy link
Contributor

semarie commented May 22, 2021

+ cargo test --no-default-features --manifest-path libc-test/Cargo.toml --target x86_64-unknown-openbsd
   Compiling libc v0.2.94 (/data/semarie/repos/rust/libc-rs)
   Compiling libc-test v0.2.94 (/data/semarie/repos/rust/libc-rs/libc-test)
error: type could implement `Copy`; consider adding `impl Copy`
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:10:1
   |
10 | / pub struct fxsave64 {
11 | |     pub fx_fcw: u16,
12 | |     pub fx_fsw: u16,
13 | |     pub fx_ftw: u8,
...  |
22 | |     __reserved: [u8; 96],
23 | | }
   | |_^
   |
note: the lint level is defined here
  --> src/lib.rs:24:9
   |
24 | #![deny(missing_copy_implementations, safe_packed_borrows)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: could not compile `libc`

@semarie
Copy link
Contributor

semarie commented May 22, 2021

it is fine now, LGTM. thanks !

@Amanieu
Copy link
Member

Amanieu commented May 23, 2021

@bors r+

@bors
Copy link
Contributor

bors commented May 23, 2021

📌 Commit 9ebc4f6 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented May 23, 2021

⌛ Testing commit 9ebc4f6 with merge 4ebd0f1...

bors added a commit that referenced this pull request May 23, 2021
openbsd update map sigcontext for amd64
@bors
Copy link
Contributor

bors commented May 23, 2021

💔 Test failed - checks-actions

@JohnTitor
Copy link
Member

@bors retry

@bors
Copy link
Contributor

bors commented May 23, 2021

⌛ Testing commit 9ebc4f6 with merge 0ba94e5...

bors added a commit that referenced this pull request May 23, 2021
openbsd update map sigcontext for amd64
@bors
Copy link
Contributor

bors commented May 23, 2021

💔 Test failed - checks-actions

@Amanieu
Copy link
Member

Amanieu commented May 23, 2021

@bors r+

@bors
Copy link
Contributor

bors commented May 23, 2021

📌 Commit 8b59b86 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented May 23, 2021

⌛ Testing commit 8b59b86 with merge 149da7b...

bors added a commit that referenced this pull request May 23, 2021
openbsd update map sigcontext for amd64
@bors
Copy link
Contributor

bors commented May 23, 2021

💔 Test failed - checks-actions

@JohnTitor
Copy link
Member

JohnTitor commented Jun 7, 2021

Friendly-ping @devnexen this one still fails. Feel free to reach out if you need help.

@devnexen
Copy link
Contributor Author

devnexen commented Jun 7, 2021

I still do not know how to solve nightly vs older release cases. facts that are fields are unaligned make things complicated. If there is plan for release this PR is still not a blocker.

@JohnTitor
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 14, 2021

📌 Commit e146747 has been approved by JohnTitor

@bors
Copy link
Contributor

bors commented Jun 14, 2021

⌛ Testing commit e146747 with merge 255090d...

bors added a commit that referenced this pull request Jun 14, 2021
openbsd update map sigcontext for amd64
@bors
Copy link
Contributor

bors commented Jun 14, 2021

💔 Test failed - checks-actions


s_no_extra_traits! {
#[repr(C, packed)]
pub struct __c_anonymous_fxsave64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

the struct isn't anonymous, it is called struct fxsave64 in OpenBSD code source.

if you need to not not test it because it is failing, please just explicitly not test it (and comment why in test_openbsd())

@semarie
Copy link
Contributor

semarie commented Aug 20, 2021

I have this kind of error with 1.54.0 on OpenBSD (for :

   Compiling libc-test v0.2.99 (/data/semarie/repos/rust/libc-rs/libc-test)                                            
error: reference to packed field is unaligned                                                                          
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:83:25                                                                                                                                                                                          
   |                                                                                                                                                                                                                                           
83 |                         self.fx_xmm == other.fx_xmm                                                                                                                                                                                       
   |                         ^^^^^^^^^^^
   |
note: the lint level is defined here
  --> src/lib.rs:24:39
   |
24 | #![deny(missing_copy_implementations, safe_packed_borrows)]
   |                                       ^^^^^^^^^^^^^^^^^^^
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:83:40
   |
83 |                         self.fx_xmm == other.fx_xmm
   |                                        ^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

@semarie
Copy link
Contributor

semarie commented Aug 21, 2021

I still have the same errors, and some additionnals warnings: unnecessary 'unsafe' block.

full error messages (on OpenBSD with 1.54.0):

   Compiling libc-test v0.2.99 (/data/semarie/repos/rust/libc-rs/libc-test)
error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:75:34
   |
75 |                     let fx_xmm = self.fx_xmm.as_ptr();
   |                                  ^^^^^^^^^^^
   |
note: the lint level is defined here
  --> src/lib.rs:24:39
   |
24 | #![deny(missing_copy_implementations, safe_packed_borrows)]
   |                                       ^^^^^^^^^^^^^^^^^^^
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:76:35
   |
76 |                     let ofx_xmm = other.fx_xmm.as_ptr();
   |                                   ^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:85:25
   |
85 |                         self.fx_st == other.fx_st &&
   |                         ^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:85:39
   |
85 |                         self.fx_st == other.fx_st &&
   |                                       ^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:95:42
   |
95 |                         .field("fx_fcw", &self.fx_fcw)
   |                                          ^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:96:42
   |
96 |                         .field("fx_fsw", &self.fx_fsw)
   |                                          ^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:98:42
   |
98 |                         .field("fx_fop", &self.fx_fop)
   |                                          ^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:99:42
   |
99 |                         .field("fx_rip", &self.fx_rip)
   |                                          ^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
   --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:100:42
    |
100 |                         .field("fx_rdp", &self.fx_rdp)
    |                                          ^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
   --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:101:44
    |
101 |                         .field("fx_mxcsr", &self.fx_mxcsr)
    |                                            ^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
   --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:102:49
    |
102 |                         .field("fx_mxcsr_mask", &self.fx_mxcsr_mask)
    |                                                 ^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
   --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:103:41
    |
103 |                         .field("fx_st", &self.fx_st)
    |                                         ^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
   --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:104:42
    |
104 |                         .field("fx_xmm", &self.fx_xmm)
    |                                          ^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

warning: unnecessary `unsafe` block
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:74:21
   |
74 |                     unsafe {
   |                     ^^^^^^ unnecessary `unsafe` block
   |
   = note: `#[warn(unused_unsafe)]` on by default

warning: unnecessary `unsafe` block
  --> src/unix/bsd/netbsdlike/openbsd/x86_64.rs:93:21
   |
93 |                     unsafe {
   |                     ^^^^^^ unnecessary `unsafe` block

error: aborting due to 13 previous errors; 2 warnings emitted

error: could not compile `libc`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

@devnexen
Copy link
Contributor Author

are you working with a snapshot ? with 6.9 it s only rust 1.51

@semarie
Copy link
Contributor

semarie commented Aug 21, 2021

@devnexen yes, I am working on OpenBSD -current version (so 7.0-beta currently).

if you agree, I could take the work and look to provide sigcontext struct (and fxsave64). it should be more straightfull to work and test it by the same person

@devnexen
Copy link
Contributor Author

sure why not

@devnexen devnexen closed this Aug 21, 2021
bors added a commit that referenced this pull request Aug 21, 2021
openbsd: export `struct sigcontext` for x86_64

based on initial work from `@devnexen` (see #2189)

tested on OpenBSD (7.0-beta) with rustc 1.54.0
bors added a commit that referenced this pull request Aug 21, 2021
openbsd: export `struct sigcontext` for x86_64

based on initial work from `@devnexen` (see #2189)

tested on OpenBSD (7.0-beta) with rustc 1.54.0
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.

6 participants