Hardening no-STL Builds in C++ - #335
Open
ashvardanian wants to merge 2 commits into
Open
Conversation
`<memory>`, `<thread>`, and `<numeric>` leave `include/` entirely. `min_of_two`, `max_of_two`, `rebound_allocator`, and `iterator_value` join `trivial_swap` in `types.hpp`, and the ~93 call sites that reached for `std::min`, `std::allocator_traits`, and `std::iterator_traits` without including a header for them now name what they use - they resolved only because `<memory>` routes through `bits/stl_algobase.h` on libstdc++. `safe_vector` reads its allocator's members directly; the `propagate_on_container_copy_assignment` branch was dead in every instantiation and is gone. `std::gcd` becomes a Euclid loop, dropping a needless C++17 floor from the fingerprints. The OpenMP executor sizes its slices from the team that actually shows up rather than `hardware_concurrency()`, which ignored `OMP_NUM_THREADS` and left `start` unclamped - with 7 threads on a 16-core box, `n=1` handed callers 14 inverted ranges. `sz_status_t` gains `sz_out_of_range_k` and `sz_length_error_k`, appended below the existing codes so nothing shifts. All 38 `throw` statements collapse into one `raise(status, site)` taking `__func__`, leaving the exception dependency in a single body and retiring 35 hand-written literals that could drift from the functions they named. The same exception types still fire, `what()` still carries the site, and the hot path still compiles to `cmp`/`jb` with the throw relocated out of line. `SZ_AVOID_STL=1`, which no build system set and which had rotted to 137 errors, compiles again. The freestanding headers move out of its gate while `<iterator>` and `<memory>` stay behind it, and owning containers default to `dummy_alloc` so a caller who brings no allocator gets a clean refusal. Only the failure path is conditional - gating the throwing methods would have cascaded into `compare`, `rfind`, and every future caller. `test/avoid_stl.cpp` pins the contract with header-guard probes and runs from the four Ubuntu jobs; the existing suite cannot cover the mode, being 84 errors deep in the interop it removes. Engine translation units drop ~25% of their preprocessed lines and about 6% of their compile time; under `SZ_AVOID_STL=1` `stringzilla/types.hpp` falls from 58K preprocessed lines to 13K.
The recorded DOI was v4.6.3's version record while the metadata declared 5.1.2. The concept DOI always resolves to the newest release, so it survives the version bumps that no automation applies to the DOI field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.