Skip to content

Linking against musl libc causes linker error undefined symbol: posix_spawn_file_actions_addchdir_np #141795

Open
@NuLL3rr0r

Description

@NuLL3rr0r

We have a proprietry Rust library we have been using for the past few years. We compile it to a .a file on GNU/Linux linked against musl libc, and then link it to our C++ libraries or applications.

This used to work fine until Rust version 1.83.0. But, with any newer versions we get the following linker error:

 ld.lld: error: undefined symbol: posix_spawn_file_actions_addchdir_np
>>> referenced by unix.rs:706 (library/std/src/sys/process/unix/unix.rs:706)
>>>               std-35c5a11e4fef3042.std.b3e601a09ed2eba9-cgu.0.rcgu.o:(std::sys::process::unix::unix::_$LT$impl$u20$std..sys..process..unix..common..Command$GT$::spawn::h08060e6e1d5b59e5) in archive /home/mamadou/dev/SomeProject/stage/lib/linux/rustc/x86-64/debug/libSomeRustLib.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I've noticed issue #99740 and pull request 3949 has introduced something related to this.

Code

I expected to see this happen:

The code should

Instead, this happened: explanation

Version it worked on

It most recently worked on: Rust 1.83.0

Version with regression

Any version newer than v1.83.0 fails to link.

rustc --version --verbose:

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-external-bugCategory: issue that is caused by bugs in software beyond our controlO-muslTarget: The musl libcT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions