Skip to content

Fix compilation error on 32-bit Apple #1407

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

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Mar 9, 2025

Fixes an error we're seeing in cc-rs (link), because time_t is c_long, which is i32 on 32-bit Apple platforms:

error[E0308]: mismatched types
    --> src/backend/libc/fs/syscalls.rs:2658:45
     |
2658 |         crate::timespec::fix_negative_nsecs(&mut stat.st_atime, stat.st_atime_nsec as _) as _;
     |         ----------------------------------- ^^^^^^^^^^^^^^^^^^ expected `&mut i64`, found `&mut i32`
     |         |
     |         arguments to this function are incorrect
     |
     = note: expected mutable reference `&mut i64`
                found mutable reference `&mut i32`
note: function defined here
    --> src/timespec.rs:341:15
     |
341  | pub(crate) fn fix_negative_nsecs(secs: &mut i64, mut nsecs: i32) -> i32 {
     |               ^^^^^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
    --> src/backend/libc/fs/syscalls.rs:2660:45
     |
2660 |         crate::timespec::fix_negative_nsecs(&mut stat.st_mtime, stat.st_mtime_nsec as _) as _;
     |         ----------------------------------- ^^^^^^^^^^^^^^^^^^ expected `&mut i64`, found `&mut i32`
     |         |
     |         arguments to this function are incorrect
     |
     = note: expected mutable reference `&mut i64`
                found mutable reference `&mut i32`
note: function defined here
    --> src/timespec.rs:341:15
     |
341  | pub(crate) fn fix_negative_nsecs(secs: &mut i64, mut nsecs: i32) -> i32 {
     |               ^^^^^^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
    --> src/backend/libc/fs/syscalls.rs:2662:45
     |
2662 |         crate::timespec::fix_negative_nsecs(&mut stat.st_ctime, stat.st_ctime_nsec as _) as _;
     |         ----------------------------------- ^^^^^^^^^^^^^^^^^^ expected `&mut i64`, found `&mut i32`
     |         |
     |         arguments to this function are incorrect
     |
     = note: expected mutable reference `&mut i64`
                found mutable reference `&mut i32`
note: function defined here
    --> src/timespec.rs:341:15
     |
341  | pub(crate) fn fix_negative_nsecs(secs: &mut i64, mut nsecs: i32) -> i32 {
     |               ^^^^^^^^^^^^^^^^^^ --------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `rustix` (lib) due to 3 previous errors

@sunfishcode
Copy link
Member

Thanks for the fix!

@sunfishcode sunfishcode merged commit f162919 into bytecodealliance:main Mar 9, 2025
51 checks passed
@madsmtm madsmtm deleted the fix-arm-compilation branch March 9, 2025 21:19
@sunfishcode
Copy link
Member

This is now released in rustix 1.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants