Skip to content

Use posix_spawn on cygwin #139617

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
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions library/std/src/sys/process/unix/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ impl Command {
all(target_os = "linux", target_env = "musl"),
target_os = "nto",
target_vendor = "apple",
target_os = "cygwin",
)))]
fn posix_spawn(
&mut self,
Expand All @@ -433,6 +434,7 @@ impl Command {
all(target_os = "linux", target_env = "musl"),
target_os = "nto",
target_vendor = "apple",
target_os = "cygwin",
))]
// FIXME(#115199): Rust currently omits weak function definitions
// and its metadata from LLVM IR.
Expand Down Expand Up @@ -587,7 +589,7 @@ impl Command {
/// Some platforms can set a new working directory for a spawned process in the
/// `posix_spawn` path. This function looks up the function pointer for adding
/// such an action to a `posix_spawn_file_actions_t` struct.
#[cfg(not(all(target_os = "linux", target_env = "musl")))]
#[cfg(not(any(all(target_os = "linux", target_env = "musl"), target_os = "cygwin")))]
fn get_posix_spawn_addchdir() -> Option<PosixSpawnAddChdirFn> {
use crate::sys::weak::weak;

Expand Down Expand Up @@ -621,7 +623,9 @@ impl Command {
/// Weak symbol lookup doesn't work with statically linked libcs, so in cases
/// where static linking is possible we need to either check for the presence
/// of the symbol at compile time or know about it upfront.
#[cfg(all(target_os = "linux", target_env = "musl"))]
///
/// Cygwin doesn't support weak symbol, so just link it.
#[cfg(any(all(target_os = "linux", target_env = "musl"), target_os = "cygwin"))]
fn get_posix_spawn_addchdir() -> Option<PosixSpawnAddChdirFn> {
// Our minimum required musl supports this function, so we can just use it.
Some(libc::posix_spawn_file_actions_addchdir_np)
Expand Down
Loading