Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 69b725a

Browse files
authoredMar 5, 2025
Unrolled build for rust-lang#137463
Rollup merge of rust-lang#137463 - sunshowers:illumos-posix-spawn, r=Mark-Simulacrum [illumos] attempt to use posix_spawn to spawn processes illumos has `posix_spawn`, and the very newest versions also have `_addchdir`, so use that. POSIX standardized this function so I also added a weak symbol lookup for the non `_np` version. (illumos has both.) This probably also works on Solaris, but I don't have access to an installation to validate this so I decided to focus on illumos instead. This is a nice ~4x performance improvement for process creation. My go-to as usual is nextest against the clap repo, which acts as a stress test for process creation -- with [this commit]: ```console $ cargo nextest run -E 'not test(ui_tests) and not test(example_tests)' before: Summary [ 1.747s] 879 tests run: 879 passed, 2 skipped after: Summary [ 0.445s] 879 tests run: 879 passed, 2 skipped ``` [this commit]: clap-rs/clap@fde45f9
2 parents 4559163 + b340545 commit 69b725a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed
 

‎library/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ dependencies = [
151151

152152
[[package]]
153153
name = "libc"
154-
version = "0.2.169"
154+
version = "0.2.170"
155155
source = "registry+https://github.com/rust-lang/crates.io-index"
156-
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
156+
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
157157
dependencies = [
158158
"rustc-std-workspace-core",
159159
]

‎library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
3535
addr2line = { version = "0.24.0", optional = true, default-features = false }
3636

3737
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
38-
libc = { version = "0.2.169", default-features = false, features = [
38+
libc = { version = "0.2.170", default-features = false, features = [
3939
'rustc-dep-of-std',
4040
], public = true }
4141

‎library/std/src/sys/pal/unix/process/process_unix.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ impl Command {
410410

411411
#[cfg(not(any(
412412
target_os = "freebsd",
413+
target_os = "illumos",
413414
all(target_os = "linux", target_env = "gnu"),
414415
all(target_os = "linux", target_env = "musl"),
415416
target_os = "nto",
@@ -427,6 +428,7 @@ impl Command {
427428
// directly.
428429
#[cfg(any(
429430
target_os = "freebsd",
431+
target_os = "illumos",
430432
all(target_os = "linux", target_env = "gnu"),
431433
all(target_os = "linux", target_env = "musl"),
432434
target_os = "nto",
@@ -584,14 +586,27 @@ impl Command {
584586
fn get_posix_spawn_addchdir() -> Option<PosixSpawnAddChdirFn> {
585587
use crate::sys::weak::weak;
586588

589+
// POSIX.1-2024 standardizes this function:
590+
// https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addchdir.html.
591+
// The _np version is more widely available, though, so try that first.
592+
587593
weak! {
588594
fn posix_spawn_file_actions_addchdir_np(
589595
*mut libc::posix_spawn_file_actions_t,
590596
*const libc::c_char
591597
) -> libc::c_int
592598
}
593599

594-
posix_spawn_file_actions_addchdir_np.get()
600+
weak! {
601+
fn posix_spawn_file_actions_addchdir(
602+
*mut libc::posix_spawn_file_actions_t,
603+
*const libc::c_char
604+
) -> libc::c_int
605+
}
606+
607+
posix_spawn_file_actions_addchdir_np
608+
.get()
609+
.or_else(|| posix_spawn_file_actions_addchdir.get())
595610
}
596611

597612
/// Get the function pointer for adding a chdir action to a

0 commit comments

Comments
 (0)
Failed to load comments.