Skip to content

Why would `musl` environment imply `libc++` as C standard library implementation?

See https://gitlab.com/taricorp/llvm-sys.rs/-/blob/7287aed95fe0115f3cd41486957da694f8d680dd/build.rs#L365

Alpine Linux is, I believe, the most popular operating system that links to the musl C standard library implementation by default. Its default compiler is GCC, for which libstdc++ is tailored instead of libc++. I believe that on Linux in general, libstdc++ is the default C++ standard library implementation, since it's historically more feature complete there.

  1. Why does the build script specify libc++ in this case?
  2. Why does the build script specify a C++ standard library implementation in the first place, rather than depending on the toolchain's default? Clang has a default, as does GCC.

Should the default -nodefaultlibs setting that the Rust compiler uses be an impediment, then it can be turned off. https://doc.rust-lang.org/rustc/codegen-options/index.html#default-linker-libraries