Repository navigation
fix(library): compile .S/.s with the C driver, not C++ - #1886
Merged
Merged
Conversation
Library TUs picked their driver with `extension() == "c"`, so every other extension -- including preprocessed `.S` and raw `.s` assembly -- went to g++ with the C++ flag set. The core/sketch path already routes `c` and `s` through the C driver, so a library's asm recipe depended on how the library entered the build. `uses_c_driver()` now draws the line once, for both the dispatch and the rebuild signature: `c`, `S` and `s` -> gcc + target C flags; `cpp`, `cc`, `cxx` -> g++. Case is significant, as it is for GCC (`S` is assembled with the preprocessor, `s` without, `C` is C++); `library_info` only collects `c`/`S`/`s`, so that is the complete set. Because the signature is derived from the same predicate, an already-built object signed as a C++ invocation is re-signed and recompiled instead of being silently reused with the new driver. Tests: new `library_dispatch_tests.rs` (sibling module -- the main test file was at 848 lines) asserts the compiler path and flag set per extension via the fake backend, and that `compile_signature` equals the C-driver hash for `.S`/`.s`/`.c` and the C++-driver hash for `.cpp`/`.cc`/`.cxx`. Behavioral RED first: `.S` and `.s` dispatched `/fake/g++ -std=gnu++17 -fno-rtti`. Remaining from the same report (separate change): environment `lib_archive` and manifest `build.libArchive: false` are still ignored by the always-archive library paths. Refs #1885
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This was referenced Nov 4, 2026
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.
What
Library translation units picked their compiler with
source.extension() == "c", so every other extension — including preprocessed.Sand raw.sassembly — was dispatched tog++with the C++ flag set. The core/sketch path (CompilerBase::compile) already routescandsthrough the C driver, so a library's assembly recipe depended on how that library entered the build.uses_c_driver()now draws the line once, and both the dispatch (compile_one_source) and the rebuild signature (compile_signature) use it:.c.S.sgcc.cpp.cc.cxxg++Case is significant, as it is for GCC (
.Sis assembled with the preprocessor,.swithout;.Cis C++).library_info::is_collectable_sourceonly collectsc/S/s, so that is the complete set. Every library path — downloadedlib_deps,lib_extra_dirs, project-as-library, framework/local libs — funnels through this module, so there is a single fix site.Because the signature is derived from the same predicate, an object already built as a C++ invocation is re-signed and recompiled rather than silently reused under the new driver.
Tests
New
crates/fbuild-library/src/library/library_dispatch_tests.rs(sibling module —library_compiler_tests.rswas at 848 lines, close to the per-file cap):assembly_tus_compile_with_the_c_driver_and_c_flags— compilesa.c,b.S,c.s,d.cppthrough the fake backend and asserts the recorded compiler path and flag set per extension.compile_signature_of_assembly_describes_the_c_driver_invocation— the signature of.S/.s/.cequals the C-driver hash and.cpp/.cc/.cxxthe C++-driver hash, so signature and invocation cannot drift apart again.Behavioural RED before the fix (real test output):
GREEN after:
soldr cargo test -p fbuild-library --lib→ 321 passed; 0 failed; 1 ignored; the 2 new tests pass;soldr cargo fmt --all -- --checkrc0;soldr cargo clippy -p fbuild-library --all-targets -- -D warningsclean;ci/check_test_layout.pyrc0.Not in this PR
The same report also found environment
lib_archive = falseand manifestbuild.libArchive: falsesilently ignored by the always-archive library paths. That is a link-input policy change (loose objects vs.a) touching every caller's return shape, so it lands separately rather than riding along here.Refs #1885