-
Notifications
You must be signed in to change notification settings - Fork 673
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
Support the x86_64 x32 ABI #1384
Comments
Ah, I searched for issues, but not PRs. There is an open PR for this, #1366, which shows a test failure on CI but is likely to be a good starting point. |
Actually, aside from needing some more updates to the test code, that PR already looks good. The test failure that was displayed for CI previously was not related to x32. As I cannot update someone else's PR (nor should I be able to), I will put in a comment here the additional patch I needed to get tests to pass, with the exception of sys::test_socket::test_vsock which fails for unrelated reasons the same way as on x86_64-unknown-linux-gnu. @nabijaczleweli, does this look like something you could add to your PR, or would you want me to submit this independently somehow? diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs
index 38cf408b..5be99c1b 100644
--- a/test/sys/test_ptrace.rs
+++ b/test/sys/test_ptrace.rs
@@ -150,11 +150,11 @@ fn test_ptrace_syscall() {
// set this option to recognize syscall-stops
ptrace::setoptions(child, ptrace::Options::PTRACE_O_TRACESYSGOOD).unwrap();
- #[cfg(target_pointer_width = "64")]
- let get_syscall_id = || ptrace::getregs(child).unwrap().orig_rax as i64;
+ #[cfg(target_arch = "x86_64")]
+ let get_syscall_id = || ptrace::getregs(child).unwrap().orig_rax as libc::c_long;
- #[cfg(target_pointer_width = "32")]
- let get_syscall_id = || ptrace::getregs(child).unwrap().orig_eax as i32;
+ #[cfg(target_arch = "x86")]
+ let get_syscall_id = || ptrace::getregs(child).unwrap().orig_eax as libc::c_long;
// kill entry
ptrace::syscall(child, None).unwrap();
diff --git a/test/test_mq.rs b/test/test_mq.rs
index ecee2009..1667a35b 100644
--- a/test/test_mq.rs
+++ b/test/test_mq.rs
@@ -1,17 +1,15 @@
-use libc::c_long;
-
use std::ffi::CString;
use std::str;
use nix::errno::Errno::*;
use nix::Error::Sys;
-use nix::mqueue::{mq_open, mq_close, mq_send, mq_receive};
+use nix::mqueue::{mq_open, mq_close, mq_send, mq_receive, mq_attr_member_t};
use nix::mqueue::{MqAttr, MQ_OFlag};
use nix::sys::stat::Mode;
#[test]
fn test_mq_send_and_receive() {
- const MSG_SIZE: c_long = 32;
+ const MSG_SIZE: mq_attr_member_t = 32;
let attr = MqAttr::new(0, 10, MSG_SIZE, 0);
let mq_name= &CString::new(b"/a_nix_test_queue".as_ref()).unwrap();
@@ -43,7 +41,7 @@ fn test_mq_send_and_receive() {
#[cfg(not(any(target_os = "netbsd")))]
fn test_mq_getattr() {
use nix::mqueue::mq_getattr;
- const MSG_SIZE: c_long = 32;
+ const MSG_SIZE: mq_attr_member_t = 32;
let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0);
let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap();
let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY;
@@ -66,7 +64,7 @@ fn test_mq_getattr() {
#[cfg_attr(any(target_arch = "mips", target_arch = "mips64"), ignore)]
fn test_mq_setattr() {
use nix::mqueue::{mq_getattr, mq_setattr};
- const MSG_SIZE: c_long = 32;
+ const MSG_SIZE: mq_attr_member_t = 32;
let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0);
let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap();
let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY;
@@ -87,7 +85,7 @@ fn test_mq_setattr() {
// O_NONBLOCK can be set (see tests below)
assert_ne!(new_attr_get, new_attr);
- let new_attr_non_blocking = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as c_long, 10, MSG_SIZE, 0);
+ let new_attr_non_blocking = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as mq_attr_member_t, 10, MSG_SIZE, 0);
mq_setattr(mqd, &new_attr_non_blocking).unwrap();
let new_attr_get = mq_getattr(mqd).unwrap();
@@ -103,7 +101,7 @@ fn test_mq_setattr() {
#[cfg_attr(any(target_arch = "mips", target_arch = "mips64"), ignore)]
fn test_mq_set_nonblocking() {
use nix::mqueue::{mq_getattr, mq_set_nonblock, mq_remove_nonblock};
- const MSG_SIZE: c_long = 32;
+ const MSG_SIZE: mq_attr_member_t = 32;
let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0);
let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap();
let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY;
@@ -116,7 +114,7 @@ fn test_mq_set_nonblocking() {
let mqd = r.unwrap();
mq_set_nonblock(mqd).unwrap();
let new_attr = mq_getattr(mqd);
- assert_eq!(new_attr.unwrap().flags(), MQ_OFlag::O_NONBLOCK.bits() as c_long);
+ assert_eq!(new_attr.unwrap().flags(), MQ_OFlag::O_NONBLOCK.bits() as mq_attr_member_t);
mq_remove_nonblock(mqd).unwrap();
let new_attr = mq_getattr(mqd);
assert_eq!(new_attr.unwrap().flags(), 0);
@@ -127,7 +125,7 @@ fn test_mq_set_nonblocking() {
#[cfg(not(any(target_os = "netbsd")))]
fn test_mq_unlink() {
use nix::mqueue::mq_unlink;
- const MSG_SIZE: c_long = 32;
+ const MSG_SIZE: mq_attr_member_t = 32;
let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0);
let mq_name_opened = &CString::new(b"/mq_unlink_test".as_ref()).unwrap();
let mq_name_not_opened = &CString::new(b"/mq_unlink_test".as_ref()).unwrap(); There was also a problem in caps that prevented getting to the point where tests run; I have submitted a PR for that. |
I've added (a derivative of) your patch to #1366, thanks! |
Closing this issue, as it was fixed by #1366 |
When trying to build for x86_64-unknown-linux-gnux32, a lot of errors are shown (the first ones not related to x32). It would be nice to see support for this. The problem is that many places use
libc::c_long
, which for x86_64-unknown-linux-gnux32 isi32
, where the actual types to use arei64
for compatibility with x86_64-unknown-linux-gnu.I am just reporting this as an issue for the moment: I had taken a stab at fixing this myself, but quickly found I don't really know Rust well enough yet. If someone else doesn't get it working first, I will try again when I have some more time to learn the language properly.
The text was updated successfully, but these errors were encountered: