Skip to content

posix_spawn_file_actions_addchdir_np lookup doesn't work on linux musl #99740

Closed
@sunshowers

Description

@sunshowers

I tried this code:

use std::process::Command;

let mut cmd = Command::new("ls");
cmd.current_dir(".");
cmd.output().unwrap();

(compiled under x86_64-unknown-linux-musl)

I expected to see this happen:

The posix_spawn fast path is used.

Instead, this happened:

Rust fell back to the fork/exec slow path. (Inspected this using gdb and strace).

This is presumably because

weak! {
fn posix_spawn_file_actions_addchdir_np(
*mut libc::posix_spawn_file_actions_t,
*const libc::c_char
) -> libc::c_int
}
does a dynamic symbol lookup but musl causes binaries to be statically linked.

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (93ffde6f0 2022-07-23)
binary: rustc
commit-hash: 93ffde6f04d3d24327a4e17a2a2bf4f63c246235
commit-date: 2022-07-23
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-muslTarget: The musl libc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions