Description
Checklist
- I've looked through the issues and pull requests for similar reports
Describe your issue
I've already opened an issue on the Rust compiler repository for this. But, it seems more of a cross-rs issue than Rust.
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)
We install cross like this:
$ cargo install cross --git https://github.com/cross-rs/cross
$ cross --version
cross 0.2.5 (51f46f2 2025-05-24)
[cross] warning: unable to get metadata for package
[cross] note: Falling back to `cargo` on the host.
cargo 1.87.0 (99624be96 2025-05-06)
So, it's from the latest GitHub commit. But, is cross-rs musl libc is really v1.2.3
?
What target(s) are you cross-compiling for?
$ cross build --package SomeLib \
--manifest-path=/Some/Path/Cargo.toml \
--target aarch64-unknown-linux-musl
$ cross build --package SomeLib \
--manifest-path=/Some/Path/Cargo.toml \
--target aarch64-unknown-linux-musl --release
$ cross build --package SomeLib \
--manifest-path=/Some/Path/Cargo.toml \
--target x86_64-unknown-linux-musl
$ cross build --package SomeLib \
--manifest-path=/Some/Path/Cargo.toml \
--target x86_64-unknown-linux-musl --release
Which operating system is the host (e.g computer cross is on) running?
- macOS
- Windows
- Linux / BSD
- other OS (specify in description)
What architecture is the host?
- x86_64 / AMD64
- arm32
- arm64 (including Mac M1)
What container engine is cross using?
- docker
- podman
- other container engine (specify in description)
cross version
cross 0.2.5 (51f46f2 2025-05-24)
Example
No response
Additional information / notes
Just to clarify further, we use the Epic Native Toolchain versions v22, v23, and v25 since we use this library in Unreal Engine. Unreal Engine links against libc++
and not libstdc++
.
v22
is built against CentOS 7 and v23
and v25
against Rocky Linux 8.
_LIBCPP_VERSION
version for v22
is reported as 15001
while for the other two as 180100
.
Furthermore, since Unreal Engine's build system UBT (Unreal Build Tool) is written in C#, you can see here it invokes the toolchain like this:
private static string GetBundledLinuxLibCxxFlags(string ToolchainPath)
{
string ToolchainFlags = string.Format("--sysroot={0} -B{0}/usr/lib/ -B{0}/usr/lib64", ToolchainPath);
string CFlags = "\"" + ToolchainFlags + "\"";
string CxxFlags = "\"-I " + ThirdPartySourceDirectory + "/Linux/LibCxx/include -I " + ThirdPartySourceDirectory + "/Linux/LibCxx/include/c++/v1 " + ToolchainFlags + "\"";
string CxxLinkerFlags = "\"-stdlib=libc++ -nodefaultlibs -L " + ThirdPartySourceDirectory + "/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu/ " + ThirdPartySourceDirectory + "/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu/libc++.a " + ThirdPartySourceDirectory + "/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu/libc++abi.a -lm -lc -lgcc_s -target x86_64-unknown-linux-gnu " + ToolchainFlags + "\"";
return "-DCMAKE_C_FLAGS=" + CFlags + " -DCMAKE_CXX_FLAGS=" + CxxFlags + " -DCMAKE_EXE_LINKER_FLAGS=" + CxxLinkerFlags + " -DCAMKE_MODULE_LINKER_FLAGS=" + CxxLinkerFlags + " -DCMAKE_SHARED_LINKER_FLAGS=" + CxxLinkerFlags + " ";
}