Repository navigation
build: link the c++ runtime and the rust archive for every target - #133
Conversation
clang does not search gcc's libstdc++ directory, so chemfiles configure fails with "cannot find -lstdc++" and the scan cannot see <string>. name the runtime, search the directory g++ reports before project(), and compile the scan with g++.
the prebuilt gcc 4.8 archive uses the old std::string, so an atom is 80 bytes. the scan was built with the compiler default, 128 bytes, and indexing the frame aborted. nm of the linked library selects the macro. both markers, or a cxxflags override, fail the build.
cargo used its own linker while meson linked consumers with the compiler it found. pass that compiler, not a ccache prefix, as cc and as the linker for the cargo target.
a global cmake toolchain file makes cmake-rs skip the c and c++ compiler it found. set the file for the host build only, and leave the msvc linker as link.exe.
c_link_args never reached the rust archive. pass each one as a link-arg, including the ones that are not -l.
the ndk uses libc++, so a linux stdc++ link does not apply to android.
armv7-linux-androideabi has no android component, so meson still asked for libstdc++ and the host g++ directory. match androideabi, and keep that directory off an android library path. quote the cross-check heredoc so it does not expand the scratch path.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 4 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8e1f0d1. Configure here.
| ] | ||
| if _needs_cxx | ||
| _stdcxx_dirs = _cxx_libdir != '' ? [_cxx_libdir] : [] | ||
| _rust_sys_deps += cc.find_library('stdc++', dirs: _stdcxx_dirs, required: true) |
There was a problem hiding this comment.
Host libstdc++ used for Linux cross
Medium Severity
The meson wrap still probes the build-machine g++ for libstdc++ whenever host_machine is Linux, and the cargo helper prepends that directory to LIBRARY_PATH for every non-Android target. build.rs already skips that path on cross compiles, so a Linux-to-Linux cross can still pick the wrong-architecture runtime.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 8e1f0d1. Configure here.
| chemfiles_link::CppStdlib::Libcxx | ||
| } else { | ||
| chemfiles_link::CppStdlib::Libstdcxx | ||
| } |
There was a problem hiding this comment.
Android ABI fallback assumes libstdc++
Medium Severity
When the C++ stdlib preprocessor probe fails, cpp_stdlib() treats Android like libstdc++ even though this change links Android with libc++. That sends the chemfiles shim down the nm ABI path, which then fatals because NDK archives have neither __cxx11 nor ERKSs symbols.
Reviewed by Cursor Bugbot for commit 8e1f0d1. Configure here.
| } | ||
| chemfiles_link::AbiChoice::Cxx11 => { | ||
| println!("cargo:rustc-env=READCON_CHEMFILES_STRING_ABI=cxx11"); | ||
| } |
There was a problem hiding this comment.
Cxx11 string ABI is not forced
Medium Severity
The chemfiles shim defines _GLIBCXX_USE_CXX11_ABI=0 for the old COW archive but does not define =1 when nm selects cxx11. A toolchain whose default libstdc++ ABI is still the gcc4-compatible string then compiles an 80-byte Atom against a 128-byte archive, which this change exists to prevent.
Reviewed by Cursor Bugbot for commit 8e1f0d1. Configure here.
| elif host_machine.system() == 'android' | ||
| if _needs_cxx | ||
| _rust_sys_deps += cc.find_library('c++', required: true) | ||
| endif |
There was a problem hiding this comment.
MinGW meson wrap omits libstdc++
Low Severity
build.rs links stdc++ for windows-gnu when zstd or chemfiles is on, but the meson wrap's Windows branch never adds that library. MinGW consumers of the static archive then drop the C++ runtime that the new link logic is supposed to name on every target.
Reviewed by Cursor Bugbot for commit 8e1f0d1. Configure here.
ruff 0.15.2 puts the cargo helper calls on one line and wraps the link-arg extend. no behavior change.


Links the C++ runtime and the Rust archive correctly for every target the meson build supports, in seven commits.
armv7-linux-androideabihas no android component, so it now matches as an NDK target too, and a Linux host no longer puts its libstdc++ directory onLIBRARY_PATHfor an Android cargo target.scripts/check_cross_cmake.shwrites its cc and cxx wrappers from quoted heredocs, so the scratch path is not expanded into them.READCON_CROSS_INVOKEDpasses that path at run time, andtest_cross_check_heredoc_does_not_interpolate_the_scratch_pathcovers it.Note
Medium Risk
Touches native linking, CMake toolchains, and libstdc++ ABI selection for chemfiles—high impact on build portability but guarded by new CI checks and fail-fast probes.
Overview
Builds with
zstdorchemfilesnow emit explicit C++ runtime link metadata (libstdc++on Linux,libc++on Apple/Android), including a host-onlyscripts/libstdcxx.cmakewired throughHOST_CMAKE_TOOLCHAIN_FILEso clang-as-c++ can link chemfiles-sys without host libstdc++ leaking into cross CMake configures.Chemfiles C++ shim ABI is chosen at build time: new
support/chemfiles_link.rsinspects the linked libchemfiles (vianm/DEP_CHEMFILES_*), sets_GLIBCXX_USE_CXX11_ABIwhen needed, and rejects conflicting CXXFLAGS overrides; the chosen ABI is exposed asREADCON_CHEMFILES_STRING_ABI.Meson → cargo integration is tightened: Meson writes compiler and
c_link_argsfiles;meson_cargo_build.pystrips ccache wrappers, forwards the real CC/target linker, adds C++ runtime flags (with Android androideabi handling), and applies non-soname link args to the staticlib. CI adds jobs/scripts for clang chemfiles link, meson+ccache, and cross CMake compiler selection.Reviewed by Cursor Bugbot for commit af109df. Bugbot is set up for automated code reviews on this repo. Configure here.