Repository navigation
Validate native symbol packages after pack - #4856
mattleibow wants to merge 13 commits into
Conversation
Generate stable Apple symbols packages from the normal Cake NuGet flow, validate archive UUIDs, and add post-promotion retrieval checks for MSDL and SymWeb. Co-authored-by: Copilot App <[email protected]>
Use shared MSBuild packaging targets to emit complete Apple dSYM symbol packages directly from dotnet pack, preserving normal runtime packages and Catalyst framework handling. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
Declare each dSYM bundle once and let the shared MSBuild target expand its contents and completeness checks. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
Derive runtime packing, symbol-only content, and completeness validation from one declaration per physical Apple artifact. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
Derive symbol packaging from native artifact items, emit stable and preview symbols uniformly, and use the repository's existing relative native paths. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
Keep existing runtime PackageFile declarations and use one generic PackageSymbolFile item for second-pass symbol package content. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
Move native symbol validation out of the production change and clean package output directories before each complete repack. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
📦 Try the packages from this PRWarning Do not run these scripts without first reviewing the code in this PR. Step 1 — Download the packages bash / macOS / Linux: curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 4856PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 4856"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-4856/packages --name skiasharp-pr-4856More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-4856 |
Integrate the cross-platform native symbol package validator as the middle layer beneath the dnceng migration PR. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4b716c9b-78fe-4fd9-a242-31e192b5aa77
📊 SkiaSharp benchmarks — PR #4856⭐ this PR (full source build) vs 🌙 nightly · Linux · Windows · macOS
Highlights⏱️ Time — 🔴 26 slower · 🟢 55 faster
Full per-OS benchmark deltasLinux⏱️ Time (vs 🌙 nightly
Windows⏱️ Time (vs 🌙 nightly
macOS⏱️ Time (vs 🌙 nightly
|
Integrate native symbol package validation into the dnceng migration layer and adapt it to the unified NuGet artifact topology. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4b716c9b-78fe-4fd9-a242-31e192b5aa77 # Conflicts: # scripts/azure-templates-stages-package.yml
Require each Xcode archive dSYM to match its runtime UUID and verify the final universal runtime has exactly the staged per-architecture UUID set. Fail official Windows packaging unless all stable and preview Apple symbol packages contain the expected runtime modules and dSYM payloads, while leaving partial package builds unchanged. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
c50c794 to
ed2d14e
Compare
|
📖 Documentation Preview The documentation for this PR has been deployed and is available at: 🔗 View Staging Site This preview will be updated automatically when you push new commits to this PR. This comment is automatically updated by the documentation staging workflow. |
Move native UUID checks, package completeness checks, and their regressions to the stacked validator change so this pull request only produces Apple symbol packages. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
Require each Xcode archive dSYM to match its runtime UUID and verify the final universal runtime has exactly the staged per-architecture UUID set. Fail official Windows packaging unless all stable and preview Apple symbol packages contain the expected runtime modules and dSYM payloads, while leaving partial package builds unchanged. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 28a5c16a-00b3-4742-ba7f-abc43845afbc
Adds a standalone console tool that validates the real packed `.nupkg` / `.symbols.nupkg` artifacts produced by the normal Cake pack, rather than making assumptions about the source tree. Apple (SkiaSharp + HarfBuzzSharp, macOS/iOS/tvOS/MacCatalyst): - customer packages carry no dSYM/DWARF payload; - the symbol package preserves the normal package id, version, curated metadata, dependency graph and byte-for-byte runtime payload; - dSYM bundles are complete, with `Contents/Info.plist` and the official extensionless `Contents/Resources/DWARF/<module>` payload name; - arm64 and x86_64 device/simulator coverage is present; - MacCatalyst additionally ships the unpacked real `Versions/A/<library>` Mach-O alongside `framework.zip`; - runtime and dSYM UUID sets match two-way, per architecture. Android (both products, all four packaged ABIs): - the customer package ships the stripped `.so` and no `.dbg`; - the symbols package ships both the module and its `.so.dbg`; - GNU build IDs match between the two. For both platforms the tool asserts that Microsoft.SymbolStore produces the same keys Arcade indexes with — `mach-uuid` / `mach-uuid-sym` for Apple and `elf-buildid` / `elf-buildid-sym` for Android — so a debugger will resolve the published symbols. Because that check runs on the real artifacts before publication, it is the pre-publication equivalent of a post-promotion MSDL/SymWeb lookup. Microsoft.SymbolStore and Microsoft.FileFormats are taken from the already-pinned `Microsoft.SymbolUploader.Build.Task` package on the existing `dotnet-eng` feed, so this adds no new feed and no unpinned download. The Mach-O and ELF readers are managed, so the validator deliberately avoids macOS-only tooling such as `dwarfdump`, `otool` and `lipo` and can run on the Windows package job. Reads package versions straight from `scripts/VERSIONS.txt` and covers both stable and preview identities. By default a package that was not produced on the current platform is skipped; `--require-all` fails closed for full-matrix CI runs. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9e6eac8f-9dc1-4268-8819-da125d2d700d
The validator added in the previous commit was a tool nobody called. Wire it into the packaging flow so the packed artifacts are actually checked. A new `nuget-validate` Cake target runs the validator against the real packed output directories, passing the same preview suffix the pack used so both the stable and preview channels are covered. `dotnet cake --target=nuget` now depends on it, so packing locally validates what it just produced. Because `DotNetRun` throws on a non-zero exit code, a validation failure fails the build. The validator's own regression suite runs first: logic that has regressed cannot be trusted to sign off on the packages. In CI, `scan_normal_windows` becomes the validation job. It already waited for packaging and already downloaded both the normal and symbol artifact sets, but it used the merger template, which hard-codes `skipSteps` and would silently swallow any target given to it. Switching it to the bootstrapper lets it run Cake after both artifact sets have landed. It deliberately opts out of build caching: a cached job sets `CACHE_SKIP` and skips its steps, and validation that can be skipped is not validation. The wiring is covered by tests that read the committed pipeline and build definitions, so the scan job cannot quietly stop downloading an artifact set, stop invoking the validator, or start allowing itself to be cached away. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9e6eac8f-9dc1-4268-8819-da125d2d700d
A read-only review of the validator surfaced seven defects, all of which let a real packaging regression reach customers or turned a bad package into a crash. The unknown-symbol-package guard never fired. It resolved a file's owning package by matching the file name against the version keys, and scripts/VERSIONS.txt lists the bare `SkiaSharp` and `HarfBuzzSharp` products before their `.NativeAssets.*` entries, so every input resolved to the bare product and failed the `.NativeAssets.` test. The identity now comes from the nuspec. Longest-prefix matching would not have been enough either, because the Win32, WinUI and NanoServer packages legitimately produce symbol packages from the same IncludeSymbols switch; those are now an explicit allow-list. MacCatalyst reconciliation never reached the binary customers consume. Catalyst ships only `<lib>.framework.zip`, and the validator merely asserted that entry existed while running the whole UUID chain against the unpacked Mach-O that lives only in the symbol package. A stale zip would have passed. The zip's inner `Versions/A/<lib>` is now opened and its UUIDs anchored to the module. Corrupt input crashed instead of reporting. Microsoft.FileFormats treats OverflowException as expected for malformed images, and GetSymbolStoreKeys forced lazy key generation with no handling at all, so a truncated binary aborted the run rather than failing the package. Malformed-image exceptions are now caught consistently and reported. A fat Mach-O with an unreadable slice silently lost it, under-reporting the architecture and UUID sets. When the loss hit matching slices on both the module and dSYM sides, reconciliation compared two equally truncated sets and passed. Unreadable slices are now surfaced and fail the package. Every extracted binary was retained for the whole run. With roughly a hundred extractions and DWARF payloads in the hundreds of megabytes, peak usage reached multiple gigabytes on a hosted agent. Extraction is now scoped to its use. NuGetPackage.Open leaked the ZipArchive and FileStream when the package was not a valid archive, leaving the .nupkg locked for the later signing and move steps on the same Windows job. Finally, the documented exit codes were not honoured: a malformed command line or a missing version threw out of Main and reported a crash instead of 2 or 1. Regression coverage is added for each: the prefix collision that hid the first defect, the allow-listed Windows packages, a stale and an empty Catalyst zip, truncated-but-valid-magic Mach-O and ELF images, and a fat image with a damaged slice. The Catalyst fixture now builds a real zip rather than a placeholder, which is what caught the missing anchor. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9e6eac8f-9dc1-4268-8819-da125d2d700d
1425519 to
a58f8c6
Compare
📦 Artifact size reportPackages from this PR (build Total Packages
+39 package(s) unchanged (< 50.0 KB). Per-file changes
|
| File | Size |
|---|---|
runtimes/win-arm64/native/libGLESv2.pdb |
64.5 MB → 64.4 MB (🟢 −144.0 KB) |
runtimes/win-x64/native/libGLESv2.pdb |
66.6 MB → 66.5 MB (🟢 −96.0 KB) |
runtimes/win-x86/native/libGLESv2.pdb |
67.3 MB → 67.2 MB (🟢 −96.0 KB) |
Informational only — this never blocks the PR. Native binaries are labelled by os/arch.
Description
Adds all validation for the native symbol packages — the Apple UUID/completeness checks that run while the packages are being produced, and a cross-platform validator that runs afterwards against the real packed artifacts rather than making assumptions about the source tree.
Why: #4846 makes us produce Apple dSYM symbol packages (and we already produce Android
.so.dbgones). It is deliberately production-only — every check lives here. Nothing otherwise proves those packages are actually usable. A symbol package that is missing a slice, ships a truncated dSYM bundle, ships a DWARF payload under the wrong name, or whose UUIDs drift from the shipped runtime binary, still packs and publishes perfectly happily — and then silently fails to resolve a stack trace for a customer months later. The failure mode is invisible until it matters.This PR closes that gap in three layers, each catching a different class of failure as close to its cause as possible.
1. Native build (
xcode.cake, macOS)Runs as the Apple native binaries are archived, where the toolchain output is still on disk:
dSYMs/<module>.dSYM/Contents/Resources/DWARF/<payload>;This layer may use
dwarfdump, because it only ever runs on the macOS build job.2. Pack (
nuget.cake)ValidateAppleSymbolPackages()runs insidenuget-normal, after the stable and preview packs but before the symbol packages are moved aside for signing, gated by--requireNativeSymbols. It walks the 8 product × platform specs and fails the pack itself the moment an Apple symbol package is malformed, keeping the failure next to the code that produced it rather than a stage later.3. Post-pack (
nuget-validate, cross-platform)The layer above both: it runs over the finished artifacts in their published locations, covers Android as well as Apple, and adds cross-package identity checks the earlier layers cannot make.
Apple (SkiaSharp + HarfBuzzSharp × macOS / iOS / tvOS / MacCatalyst):
Contents/Info.plistand the official extensionlessContents/Resources/DWARF/<module>payload name;arm64/x86_64device and simulator coverage is present;Versions/A/<library>Mach-O alongsideframework.zip, and the binary actually inside thatframework.zip— the only Mach-O a MacCatalyst customer ever consumes — is UUID-matched too;Android (both products, all four packaged ABIs):
.soand no.dbg;.so.dbg;For both platforms it then asserts that Microsoft.SymbolStore produces the same keys Arcade indexes with —
mach-uuid/mach-uuid-symfor Apple,elf-buildid/elf-buildid-symfor Android. Because that runs against the real artifacts before publication, it is the pre-publication equivalent of a post-promotion MSDL/SymWeb lookup: if the key generator emits the expected key here, a debugger will resolve the symbol after promotion. Post-promotion retrieval genuinely cannot run in this stage, so this is deliberately the closest correct substitute rather than a weaker approximation of it.Two constraints shaped this third layer specifically:
dwarfdump,otoolandlipoare out — which is exactly why it cannot simply be folded into layer 1. The Mach-O and ELF readers are fully managed.Microsoft.SymbolStore/Microsoft.FileFormatsare not published standalone on our feeds, but they ship inside the already-pinnedMicrosoft.SymbolUploader.Build.Taskon the existingdotnet-engfeed — the same implementation Arcade itself indexes with. It is referenced withExcludeAssets="all" PrivateAssets="all"so it contributes nothing to any shipping package.How it runs. A new
nuget-validateCake target invokes the validator against the packed output directories, passing the same preview suffix the pack used so both the stable and preview channels are covered.dotnet cake --target=nugetdepends on it, so packing locally validates what it just produced.DotNetRunthrows on a non-zero exit code, so a validation failure fails the build. The validator's own regression suite runs first — logic that has regressed cannot be trusted to sign off on the packages.In CI, the existing
scan_normal_windowsjob becomes the validation job. It already waited for packaging and already downloaded both the normal and symbol artifact sets, but it used the merger template, which hard-codesskipStepsand would silently swallow any target given to it; switching it to the bootstrapper lets it run Cake after both artifact sets have landed. It deliberately opts out of build caching — a cached job setsCACHE_SKIPand skips its steps, and validation that can be skipped is not validation. It runs with--requireAll=true, so a package that failed to produce is a hard failure rather than a silent skip.It reads package versions straight from
scripts/VERSIONS.txt(rather than taking 10+ version arguments) and covers both stable and preview identities. On a dev box a package that was not produced on the current platform is skipped, so the target is useful locally;--require-allfails closed for the full-matrix CI run.Stacking / merge order. This is the second PR in the native stack
main <- #4846 <- #4856 <- #4803and is based onmattleibow-apple-symbol-packaging-7c4. #4846 produces the packages and contains no validation; this PR contains the validation end-to-end. #4846 merges first.Invocation, for reference:
Exit codes:
0pass,1validation failure,2usage error. All problems are accumulated and reported in one run rather than failing on the first.Related issues
Related to #4846
Required skia PR
None.
Areas affected
binding/)externals/skia/src/c,include/c)Changes
None — no public API or behavior change. This adds build-time validation and the CI/Cake wiring that runs it; it ships in no package and is not referenced by any shipping project.
Testing
Verified locally on macOS (arm64) with the repo-pinned SDK:
dotnet test .../NativeSymbolValidator.Tests). The suite builds real.nupkgarchives on disk from hermetic synthetic Mach-O / fat Mach-O /MH_DSYM/ ELF-with-build-ID fixtures and runs the real validators over them — no mocks, no network, no platform tooling.Contents/Info.plist, unofficial DWARF payload name, missing architecture dSYM, module missing an architecture, debug payload leaked into the customer package, MacCatalyst missing its unpacked Mach-O, MacCatalyst leaking an unpacked framework, corrupt module, fat dSYM, and non-dSYM DWARF payload.framework.zipspecifically: a zip carrying a different binary, a zip missing the binary, and aframework.zipthat is not a zip at all..dbgleaked into the customer package, missing debug file, build-ID mismatch, unstripped library, missing ABI, corrupt debug file, a truncated library, and a library with no GNU build ID.Validator.Run(): skip-when-not-produced,--require-allfailing closed, a package produced without its symbol package, an unrecognised*.NativeAssets.*symbol package appearing on disk (including the case where a shorter product id shares its prefix), the WindowsNativeAssetspackages that legitimately produce symbol packages outside the matrix, and a guard that every id in the matrix actually has anugetversion inscripts/VERSIONS.txt.scripts/azure-templates-stages-package.yml,build.cakeandnuget.cake, so the scan job cannot quietly stop downloading an artifact set, stop invoking the validator, or start allowing itself to be cached away.dotnet cake --target=tests-apple-symbols→ passes. Covers the native layer's UUID reconciliation directly: a matching runtime/dSYM set, plus missing, duplicate and wrong UUID cases that must each be rejected.mach-uuid/mach-uuid-sym/elf-buildidkeys for those binaries — those assertions are hard errors in the validator, not warnings.dotnet cake --target=nuget-validate --requireAll=false→ enumerates the full 20-entry matrix (10 stable + 10 preview), skips what this box did not pack, exits0.dotnet cake --target=nuget-validate --requireAll=true→ reports every missing package individually and fails the Cake build. This is the mode that matters most: a validator that quietly passes when it validated nothing is worse than no validator.2with usage, a validation failure exits1, a clean skip exits0— each with a diagnosable message rather than a stack trace.Microsoft.SymbolStore/Microsoft.FileFormatsrestore cleanly out of the pinnedMicrosoft.SymbolUploader.Build.Taskwith no feed change.clang/lipo/dsymutil— a fatarm64+x86_64dylib, itsdsymutil-produced dSYM, and real.so/.so.dbgpairs — confirming the exact key shapes asserted here, and that a dSYM's identity key is byte-identical to its module's symbol key.What I could not test: the post-pack validator has not run against real packed Apple
.symbols.nupkgs, because producing those needs the full native Apple build matrix, which cannot run on this box. The first CI run on the package stage is the real proof. The dependency this has on thenativeartifact carrying the*.xcarchive/dSYMs/**trees has since been confirmed by the #4846 author: the native source jobs publish their complete output directories and the merger/download templates copy artifact contents recursively without filtering, and prior successful build 1564081 consumed that same mergednativeartifact and produced the complete Apple symbol packages that were inspected by hand. So--requireAll=trueis expected to be satisfiable on the first run rather than optimistic.Checklist
Changesabove lists all public API and behavioral changes (or "None.")mono/skiaPR linked above and bindings regenerated — n/a, no native change