Fix config mismatch for targets under multiple top-level parents#193
Open
arrizer wants to merge 3 commits into
Open
Fix config mismatch for targets under multiple top-level parents#193arrizer wants to merge 3 commits into
arrizer wants to merge 3 commits into
Conversation
When a dependency exists under multiple top-level targets (e.g., an app and its extensions), each top-level target gets a unique settings transition hash (-ST-<hex>) in its config mnemonic. The parent config stored during cquery may reference a different ST hash than the one present in the aquery actions, causing "No relevant target actions found" errors for otherwise valid targets. Fall back to matching without the ST hash when exact mnemonic matching fails. This preserves the platform/arch/minOS constraint while tolerating ST hash differences across top-level targets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests that extractCompilerArgs succeeds when the platform info has a different ST hash than the aquery actions, for both Swift and ObjC targets.
Member
|
I think #195 might fix this issue (some of the label parsing was wonky) |
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.
Fix config mismatch for targets under multiple top-level parents
Problem
Each top-level target (app, extension, test) gets its own Bazel settings transition hash — the
-ST-<hex>suffix in the configuration mnemonic (e.g.,ios_sim_arm64-dbg-ios-sim_arm64-min16.1-ST-90f37f7dbff2).A dependency shared between multiple top-level targets (e.g., a library used by both the main app and an extension) appears in the aquery result with the ST hash of whichever top-level target compiled it. However,
platformBuildLabelInfomay return a different top-level target's config mnemonic (viabspUriToParentConfigMap), causing the exact mnemonic match ingetTargetActionto fail.This produces a continuous stream of
"No relevant target actions found for <target>. This is unexpected."errors.The issue affects both Swift and C/ObjC targets. Any dependency that exists under multiple top-level targets with different ST hashes can be affected — this includes common libraries, not just obscure external dependencies.
Root cause
In
getTargetAction, the config mnemonic filter requires an exact string match:Two top-level targets with the same platform/arch/minOS but different build settings produce different ST hashes. The cquery and aquery may associate the same dependency with different top-level parents, creating a mismatch between the stored parent config and the available aquery actions.
Fix
When the exact mnemonic match finds no candidates, fall back to matching with the
-ST-<hex>suffix stripped. This preserves the platform/arch/minOS constraint while tolerating ST hash differences across top-level targets.The fallback only runs when the exact match already returned zero results, so the happy path is unchanged. For C/ObjC files, the per-file
-cargument filter runs after the fallback to ensure the correct source file is matched across all ST variants.After all filtering, multiple remaining candidates are different ST variants of the same platform/file combination their compiler args are effectively identical, so we pick the first.
Changes
getTargetActionwhen exact config mnemonic matching failsmultipleTargetActionserror withcandidateActions.first— after the fallback + file filtering, remaining duplicates are benign ST variants-ST-<hex>stripping intoString.strippingSettingsTransitionHashwith documentation linking to the Bazel config transitions docs