Linking against musl libc causes linker error undefined symbol: posix_spawn_file_actions_addchdir_np
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at library/std/src/sys/process/unix/unix.rs:706 and compare the Rust 1.83.0 and newer builds that reference posix_spawn_file_actions_addchdir_np. Reproduce by linking a musl-built Rust archive into a C++ application, consult issue #99740 and the referenced libc pull request, and consider the issue resolved when the resulting link succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- build-system, compilers, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100