Skip to content

feat: build without libc++ on non-MSVC targets - #64

Open
cyyynthia wants to merge 2 commits into
Nugine:mainfrom
cyyynthia:no-libc++
Open

feat: build without libc++ on non-MSVC targets#64
cyyynthia wants to merge 2 commits into
Nugine:mainfrom
cyyynthia:no-libc++

Conversation

@cyyynthia

@cyyynthia cyyynthia commented Jul 12, 2026

Copy link
Copy Markdown

Leverages the new SIMDUTF_NO_LIBCXX macro 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).

Before After Diff
simdutfrs.o 631,824 407,624 -224,200
libsimdutfrs.a 675,332 441,428 -233,904
simdutfrs.o (-march=native1) 1,009,088 975,960 -33,128
libsimdutfrs.a (-march=native1) 1,074,544 1,040,760 -33,784

Footnotes

  1. AMD Ryzen 9 9950X3D 2

@Nugine
Nugine requested review from Nugine and a balanced review from Copilot August 21, 2026 01:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, defines SIMDUTF_NO_LIBCXX=1, and calls cpp_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants