Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0.1xx-xcode14.2] [dotnet] Ensure any trimmer components are restored properly. #17254

Conversation

vs-mobiletools-engineering-service2
Copy link
Collaborator

.NET 8 will load the ILLink component based on the target framework of the
project file - so if .NET 8 is building a net7.0-ios app, the build will
restore and use the ILLink component from .NET 7.

There is a problem however:

  • The inclusion of the ILLink component is dpendent on the PublishTrimmed
    property - if PublishTrimmed is true, then the ILLink component is restored
    (which makes sense, why restore it if it's not going to be used?).
  • We always PublishTrimmed, because the linker must always be executed for our
    projects. So far so good - we can just always enable PublishTrimmed, right?
  • Nope, when building on Windows, we only enable PublishTrimmed when connected
    to a Mac, because that's where the ILLink target must be executed (and if
    we're not connected to a Mac, we can't run the ILLink target, and things
    fall apart - so just disable PublishTrimmed in that, since it won't work
    anyway).
  • Early on in the build we have no idea if we're connected to a Mac or not,
    which means we can only enable PublishTrimmed in a target, and not as an
    early-on default value. This is way to late for the ILLink component,
    which needs PublishTrimmed set quite early in the build process.
  • Fortunately, the ILLink inclusion is actually gated on a different variable
    (_IsTrimmingEnabled) - which is initialized from PublishTrimmed if it's not
    set. So the way out here is to set _IsTrimmingEnabled early enough, and now
    the ILLink component is included and restored.
  • The additional hurdle is that we need to set _IsTrimmingEnabled in our .NET
    6 and .NET 7 workloads as well, it's not enough to set it in our .NET 8
    workload (which isn't even loaded when building an earlier TFM).

Backport of #17227

.NET 8 will load the ILLink component based on the target framework of the
project file - so if .NET 8 is building a net7.0-ios app, the build will
restore and use the ILLink component from .NET 7.

There is a problem however:

* The inclusion of the ILLink component is dpendent on the PublishTrimmed
  property - if PublishTrimmed is true, then the ILLink component is restored
  (which makes sense, why restore it if it's not going to be used?).
* We always PublishTrimmed, because the linker must always be executed for our
  projects. So far so good - we can just always enable PublishTrimmed, right?
* Nope, when building on Windows, we only enable PublishTrimmed when connected
  to a Mac, because that's where the ILLink target must be executed (and if
  we're not connected to a Mac, we can't run the ILLink target, and things
  fall apart - so just disable PublishTrimmed in that, since it won't work
  anyway).
* Early on in the build we have no idea if we're connected to a Mac or not,
  which means we can only enable PublishTrimmed in a target, and not as an
  early-on default value. This is *way* to late for the ILLink component,
  which needs PublishTrimmed set quite early in the build process.
* Fortunately, the ILLink inclusion is actually gated on a different variable
  (_IsTrimmingEnabled) - which is initialized from PublishTrimmed if it's not
  set. So the way out here is to set _IsTrimmingEnabled early enough, and now
  the ILLink component is included and restored.
* The additional hurdle is that we need to set _IsTrimmingEnabled in our .NET
  6 and .NET 7 workloads as well, it's not enough to set it in our .NET 8
  workload (which isn't even loaded when building an earlier TFM).
@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

🔥 [PR Build] Build failed 🔥

Build failed for the job 'Build packages'

Pipeline on Agent
Hash: [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

🔥 Failed to compare API and create generator diff 🔥

Error: 'make' failed for the hash 59651fc.

Pipeline on Agent
Hash: ed5039f7b89ed556dabe7de3c6a63c31e6ed9a31 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

💻 [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: ed5039f7b89ed556dabe7de3c6a63c31e6ed9a31 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1036.Monterey'
Hash: ed5039f7b89ed556dabe7de3c6a63c31e6ed9a31 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: simulator tests.

🎉 All 77 tests passed 🎉

Tests counts

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. [attempt 2] Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch: All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: [PR build]

@rolfbjarne rolfbjarne merged commit 8901a02 into dotnet:release/7.0.1xx-xcode14.2 Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants