Repository navigation
Replace cc_static_library with a deprecation stub - #274
Merged
Merged
Conversation
Every shipping consumer already loads cc_static_library from rules_cc: starling (c55b8e434d), libpal (#407) and starling-core (#1736) each migrated in June/July with a one line change to the load statement. Our copy has no users left on any default branch in the org. Upstream cannot hit the bug ours had, because it never merges archives. It collects the object files of the transitive deps and runs a single archive action over them, so there is no nesting of input archives as members -- the failure ours produced on macOS, where the toolchain archiver is llvm-ar and `llvm-ar rc out.a a.a b.a` yields an archive the linker rejects with "archive member 'libfoo.a' not a mach-o file". Delete the rule but keep the macro name failing loudly for one release rather than removing the symbol outright. Org code search only indexes default branches, and a branch walk of starling-core found ~39 stale branches still loading this from us. Those get a message naming the target and the exact load line to use instead, rather than an opaque missing symbol error, whenever they are rebased. Loading cc/defs.bzl for any other symbol is unaffected, which matters because 202 files in the org do exactly that. Verified upstream is a drop in for the two cgo consumers that were the reason to keep this rule. For both phoebe (//:gnss_cgo, 7 deps) and caster_session_logger (//:orion_cgo), the upstream archive has an identical member list (832 members, no nested archives) and an identical defined symbol set (73123 and 72395 respectively), passes symbol_check, and links and tests green through cgo on macOS. No version bump; `bazel run //tools:release` owns that.
Ports the regression example from #273 to upstream cc_static_library. The rule is gone, but the failure it hit was never really the rule's: the archiver comes from whichever toolchain is registered, and the llvm20 toolchains here wrap llvm-ar. Invoked wrongly llvm-ar nests input archives as members rather than merging their objects, and nothing notices until link time, where macOS reports "archive member 'libfoo.a' not a mach-o file". Keeps both halves of the guard. merged_members_test asserts the archive holds .o members and no nested .a; merged_link_test links a cc_test against the merged archive alone and calls into every folded library, including the transitive dep. The archive has to arrive through srcs now, since upstream provides no CcInfo at all. Confirmed the member assertion has teeth by building a nested archive by hand and checking the grep rejects it, rather than trusting that a passing test means the shape is checked. Renames the macOS job to archive-tools-macos, since it now covers strip and the archiver, both of which are Mach-O-only failure modes the Linux job cannot catch. No required status checks are configured on main, so the rename breaks nothing.
armallen
approved these changes
Sep 14, 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.
Supersedes #273, which fixed a bug in this rule. The better fix is not to ship the rule.
Why
Every shipping consumer already loads
cc_static_libraryfromrules_cc, each via a one line change to the load statement:c55b8e434d(AP-5401, 2026-07-09)Org-wide code search for the symbol returns 7 files: our two, and those three repos — all already on upstream. As a control, a search for
rules_swiftnav//cc:defs.bzlreturns 202 files, so the index is live and broad; 7 is a real number rather than an empty result.Upstream also cannot hit the bug #273 fixed, because it never merges archives. It collects the object files of the transitive deps and runs one archive action over them, so input archives are never nested as members — the failure ours produced on macOS, where the toolchain archiver is
llvm-arandllvm-ar rc out.a a.a b.ayields an archive the linker rejects witharchive member 'libfoo.a' not a mach-o file.Why a stub rather than deleting the symbol
Code search only indexes default branches. Walking every branch of the three consumer repos found 1,528 branches still loading this from us:
Most are abandoned personal branches going back to March 2023. But some are active release lines —
orion-v30.0-release(last commit 2026-09-03),orion-v31.0-release(2026-08-20),starling-v1.93.0-releaseand others.Their exposure today is nil, because they pin old versions (
starling@orion-v30.0-release→ rules_swiftnav 0.10.0,@orion-v31.0-release→ 0.18.1; starling-core 0.11.0 and 0.19.0; current is 0.29.0). They keep building against what they pin. But whenever one of them is bumped, this stub gives them a message naming the target and the exact load line to use, instead of an opaque missing-symbol error:Both migration gotchas are in the message because neither is guessable. Suggest keeping the stub for more than one release, given the release branches above.
cc/defs.bzlstill loads normally for every other symbol — only calling the macro fails. That matters, since 202 files in the org load that file.Upstream is a drop-in for the two cgo consumers
These were the reason to keep the rule. Built upstream
cc_static_libraryon the same deps and compared://:gnss_cgo//:orion_cgo.asymbol_checkNeither closure contains any
cc_importor prebuilt archive, so upstream's "deps without object files are dropped" behaviour doesn't apply. Follow-ups: swift-nav/phoebe#1929 and the CSL PR.Tests
The regression example from #273 is kept, retargeted at upstream
cc_static_library. The rule is gone, but the failure it caught was never really the rule's — the archiver comes from whichever toolchain is registered, and the llvm20 toolchains here wrapllvm-ar. A wrapper or toolchain change that regresses the archiver would reintroduce nested archives silently, because an archive full of nested archives still builds fine and only fails at link time.Both halves of the guard survive:
merged_members_test— the archive holds.omembers and no nested.amerged_link_test— acc_testlinks against the merged archive alone and calls into every folded library, including the transitive dep (fibonacci→add)The archive now arrives through
srcsout of necessity rather than care: upstream provides noCcInfo, so it cannot go indepsat all.I checked the member assertion isn't vacuous by building a nested archive by hand and confirming the grep rejects it:
Full run:
bazel test //...inexamples/small_worldis 9/9 green, and the two static library tests pass under--nocache_test_resultsagainst the upstream rule (output confirmed aslibmerged.awith memberssign.pic.o,fibonacci.pic.o,add.pic.o). Buildifier reports the same 3 pre-existing warnings asmain, none new. Confirmed by hand that calling the macro produces the error above, and that loadingcc/defs.bzlfor other symbols is unaffected.The macOS job is renamed
strip-macos→archive-tools-macos, since it now guards bothstripand the archiver — both Mach-O-only failure modes the Linux job cannot catch.mainhas no required status checks configured, so the rename breaks nothing.Verification was on macOS; Linux CI covers the other path.
Not included
No version bump:
bazel run //tools:releaseowns that.