[runtime] Generate trusted platform assemblies at build time Fixes #16744 - #26245
[runtime] Generate trusted platform assemblies at build time Fixes #16744#26245rolfbjarne wants to merge 3 commits into
Conversation
Generate trusted platform assembly data from final publish items for non-debug builds while retaining runtime discovery for debug builds. Optimize single-RID startup and preserve universal bundle handling on supported platforms. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b6c903d4-d655-47d4-9e0c-636bea8e7d37
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build #fae4375] Test results 🔥Test results❌ Tests failed on VSTS: test results 30 tests crashed, 0 tests failed, 0 tests passed. Failures❌ assembly-processing tests🔥 Failed catastrophically on VSTS: test results - assembly-processing (no summary found). Html Report (VSDrops) Download ❌ cecil tests🔥 Failed catastrophically on VSTS: test results - cecil (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (iOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_ios (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - dotnettests_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (macOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_macos (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (Multiple platforms)🔥 Failed catastrophically on VSTS: test results - dotnettests_multiple (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_tvos (no summary found). Html Report (VSDrops) Download ❌ framework tests🔥 Failed catastrophically on VSTS: test results - framework (no summary found). Html Report (VSDrops) Download ❌ fsharp tests🔥 Failed catastrophically on VSTS: test results - fsharp (no summary found). Html Report (VSDrops) Download ❌ generator tests🔥 Failed catastrophically on VSTS: test results - generator (no summary found). Html Report (VSDrops) Download ❌ interdependent-binding-projects tests🔥 Failed catastrophically on VSTS: test results - interdependent-binding-projects (no summary found). Html Report (VSDrops) Download ❌ introspection tests🔥 Failed catastrophically on VSTS: test results - introspection (no summary found). Html Report (VSDrops) Download ❌ linker tests (iOS)🔥 Failed catastrophically on VSTS: test results - linker_ios (no summary found). Html Report (VSDrops) Download ❌ linker tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - linker_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ linker tests (macOS)🔥 Failed catastrophically on VSTS: test results - linker_macos (no summary found). Html Report (VSDrops) Download ❌ linker tests (tvOS)🔥 Failed catastrophically on VSTS: test results - linker_tvos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (iOS)🔥 Failed catastrophically on VSTS: test results - monotouch_ios (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - monotouch_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (macOS)🔥 Failed catastrophically on VSTS: test results - monotouch_macos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (tvOS)🔥 Failed catastrophically on VSTS: test results - monotouch_tvos (no summary found). Html Report (VSDrops) Download ❌ msbuild tests🔥 Failed catastrophically on VSTS: test results - msbuild (no summary found). Html Report (VSDrops) Download ❌ sharpie tests🔥 Failed catastrophically on VSTS: test results - sharpie (no summary found). Html Report (VSDrops) Download ❌ windows tests🔥 Failed catastrophically on VSTS: test results - windows (no summary found). Html Report (VSDrops) Download ❌ xcframework tests🔥 Failed catastrophically on VSTS: test results - xcframework (no summary found). Html Report (VSDrops) Download ❌ xtro tests🔥 Failed catastrophically on VSTS: test results - xtro (no summary found). Html Report (VSDrops) Download ❌ Tests on macOS Monterey (12) testsHtml Report (VSDrops) Download ❌ Tests on macOS Ventura (13) testsHtml Report (VSDrops) Download ❌ Tests on macOS Sonoma (14) testsHtml Report (VSDrops) Download ❌ Tests on macOS Sequoia (15) testsHtml Report (VSDrops) Download ❌ Tests on macOS Tahoe (26) testsHtml Report (VSDrops) Download SuccessesmacOS testsLinux Build VerificationPipeline on Agent |
🔥 [PR Build #fae4375] Build failed (Detect API changes) 🔥Build failed for the job 'Detect API changes' (with job status 'Failed') Pipeline on Agent |
🔥 [PR Build #fae4375] Build failed (Build packages) 🔥Build failed for the job 'Build packages' (with job status 'Failed') Pipeline on Agent |
|
🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire Pipeline on Agent |
…he dylib Commit fae4375 made the runtime reference three symbols that are generated at app build time (GenerateTrustedPlatformAssemblySource): xamarin_trusted_platform_assemblies, xamarin_trusted_platform_assembly_count and xamarin_is_multi_rid_build. They're declared weak_import in main.h, with a runtime null-check fallback for debug builds where they aren't generated. The compiler correctly emits them as weak external undefined, but the Xcode 26 linker still errors ("Undefined symbols ...") when building the standalone libxamarin-dotnet.dylib, because no linked dylib exports them. Pass -Wl,-U for each of these symbols so they're allowed to be undefined (resolved via dynamic lookup) in the runtime dylib. The final app link provides the real definitions, and debug builds keep resolving them to NULL via weak_import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4aa93657-2767-43e8-ab51-f761657b87fd
There was a problem hiding this comment.
Pull request overview
This PR reduces startup overhead by generating the trusted platform assemblies (TPA) list at build time for non-Debug builds, so the runtime can avoid enumerating the app bundle on startup (fixing #16744). Debug builds keep the existing runtime discovery behavior to avoid extra build work.
Changes:
- Add an MSBuild task to generate per-architecture native source containing the TPA names and count, and compile it into the native executable inputs.
- Update the runtime to prefer the build-time generated TPA list (with a fallback to runtime discovery when symbols aren’t present).
- Document the new
GenerateTrustedPlatformAssembliesbuild property and add task-level unit tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GenerateTrustedPlatformAssemblySourceTests.cs | Adds unit tests validating filtering, ordering, escaping, and Multi-RID behavior of the generated TPA source. |
| runtime/xamarin/main.h | Declares weak-imported build-time TPA symbols and introduces a platform macro for universal-build support. |
| runtime/runtime.m | Switches xamarin_compute_trusted_platform_assemblies to use build-time TPA symbols when available, with Multi-RID handling on supported platforms. |
| runtime/Makefile | Allows weak undefined references to the new build-time TPA symbols when building the runtime dylib. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/GenerateTrustedPlatformAssemblySource.cs | New task that generates native source for the TPA list/count and optional Multi-RID flag. |
| dotnet/targets/Xamarin.Shared.Sdk.targets | Wires in the new task/target, defaults property based on Debug, compiles generated sources, and forces export of the new native symbols. |
| docs/building-apps/build-properties.md | Documents GenerateTrustedPlatformAssemblies and its default behavior. |
Comments suppressed due to low confidence (2)
runtime/xamarin/main.h:139
- Use the corrected macro name here as well ("SUPPORTS_UNIVERSAL_BUILDS"), to match the definition and avoid inconsistencies.
#if defined (SUPPORTS_UNIVERAL_BUILDS)
extern const bool xamarin_is_multi_rid_build __attribute__ ((weak_import));
#endif
runtime/runtime.m:2406
- Typo in the macro name: "UNIVERAL" should be "UNIVERSAL" (and match the header + generated source).
#if defined (SUPPORTS_UNIVERAL_BUILDS)
if (xamarin_is_multi_rid_build) {
Resolve the overlapping bundler-debug defaults, correct the universal-build macro spelling, and safely fall back when generated weak TPA symbols are incomplete. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b6c903d4-d655-47d4-9e0c-636bea8e7d37
Generate the trusted platform assembly list from final publish items for non-debug builds, avoiding app bundle enumeration during startup.
Retain runtime discovery for debug builds to minimize build overhead, optimize single-RID path expansion, and preserve universal bundle handling on supported platforms.
Fixes #16744
🤖 Pull request created by Copilot