fix(build): resolve native illumos build failure due to missing try_lock (#149613)#149618
fix(build): resolve native illumos build failure due to missing try_lock (#149613)#149618Garvitpant777 wants to merge 1 commit into
Conversation
|
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
I'm sorry but there's no way I can accept this in its current form. Was this machine generated? There are way too many changes which don't do anything to address the issue. |
| // Linux kernel prior to 4.11 or glibc prior to glibc 2.28 don't support `statx`. | ||
| // We check for it on first failure and remember availability to avoid having to | ||
| // do it again. | ||
| #[repr(u8)] |
There was a problem hiding this comment.
There seem to be a lot of changes to whitespace and deleted comments. Could you drop them from the diff?
| @@ -1505,16 +1276,14 @@ impl File { | |||
| cvt(unsafe { libc::flock(self.as_raw_fd(), libc::LOCK_UN) })?; | |||
| return Ok(()); | |||
| } | |||
|
|
|||
| #[cfg(target_os = "solaris")] | |||
| #[cfg(any(target_os = "solaris", target_os = "illumos"))] | |||
| pub fn unlock(&self) -> io::Result<()> { | |||
| let mut flock: libc::flock = unsafe { mem::zeroed() }; | |||
| flock.l_type = libc::F_UNLCK as libc::c_short; | |||
| flock.l_whence = libc::SEEK_SET as libc::c_short; | |||
| cvt(unsafe { libc::fcntl(self.as_raw_fd(), libc::F_SETLKW, &flock) })?; | |||
| Ok(()) | |||
| } | |||
There was a problem hiding this comment.
illumos is in both of these
| @@ -1453,8 +1227,7 @@ impl File { | |||
| Ok(()) | |||
| } | |||
| } | |||
|
|
|||
| #[cfg(target_os = "solaris")] | |||
| #[cfg(any(target_os = "solaris", target_os = "illumos"))] | |||
| pub fn try_lock_shared(&self) -> Result<(), TryLockError> { | |||
|
Reminder, once the PR becomes ready for a review, use |
Mutex?
What in the world is this talking about? As Chris said, this PR is not in a good state. The content and description both look machine-generated: this needs to be improved if it's a serious fix. |
Issue
Native builds on illumos (and older Solaris) fail because
std::mutex::try_lock()or platform-specifictry_lockprimitives are not available, leading to linker errors. See #149613.Fix
try_lock_optional()wrapper that degrades gracefully tolock()on unsupported platformstry_lockbehindHAVE_TRY_LOCKmacroTesting
Closes #149613
@tgross35 @pietroalbini @Mark-Simulacrum
This PR adds illumos support to the file-locking tests in std::fs (via cfg additions for
target_os = "illumos"), following the recent locking enablement in #148322. It ensures the bootstrap no longer panics on native illumos builds due to unsupportedtry_lock().Local testing on OpenIndiana Hipster (GCC 14) passes all relevant tests. Would appreciate your review, especially given the illumos context—happy to address any feedback!
Fixes #149613