feat: build without libc++ on non-MSVC targets - #64
Conversation
There was a problem hiding this comment.
Pull request overview
This PR leverages the SIMDUTF_NO_LIBCXX macro (available in the bundled simdutf 9.0.0) to eliminate the dependency on the C++ standard library (lib(std)c++) on non-MSVC targets. This keeps the crate closer to its no-std positioning, reduces dynamic linking dependencies, and produces significantly smaller binaries on Linux. MSVC targets are unchanged and still link the C++ standard library.
Changes:
- In
build.rs, the non-MSVC branch now passes-nostdlib++,-fno-rtti,-fno-exceptions, definesSIMDUTF_NO_LIBCXX=1, and callscpp_link_stdlib(None)to stop cc from emitting a C++ stdlib link directive. - Updated the MSVC comment to note it does not support
-nostdlib++. - Refreshed crate-level docs: toolchain requirement corrected from C++11 to C++17 (the build already used
-std=c++17), and clarified that only Windows (MSVC) links the C++ standard library.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
build.rs |
Adds no-libc++ compile/link flags and SIMDUTF_NO_LIBCXX define for GCC/Clang targets; disables cc's C++ stdlib linking. |
src/lib.rs |
Documentation updates: C++17 toolchain requirement and clarification that only MSVC depends on the C++ standard library. |
I verified that cc 1.2.58 supports Build::flags, the bundled simdutf is 9.0.0 (so SIMDUTF_NO_LIBCXX and its weak __cxa_pure_virtual stub are present), and the compiled binding code (cpp/simdutfrs.cpp and its includes) contains no throw/dynamic_cast/typeid, so -fno-exceptions/-fno-rtti are safe. The C++11→C++17 doc change is consistent with the pre-existing -std=c++17 flag. I found no concrete defects. Note that this alters cross-platform linking behavior (e.g., -nostdlib++ requires GCC ≥ 9, and non-MSVC Windows/musl paths take the new branch), while CI only runs on ubuntu-latest, so the change is not fully validated across the platforms it affects.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Leverages the new
SIMDUTF_NO_LIBCXXmacro introduced in simdutf 9 to remove the dependency on lib(std)c++. Sadly doesn't get rid of it in Windows MSVC, but other platforms at least don't have this dependency anymore.The binaries are also quite significantly smaller. Values in bytes, Linux x86 (glibc).
Footnotes
AMD Ryzen 9 9950X3D ↩ ↩2