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

Blazor + marshal methods failure #8800

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Conversation

grendello
Copy link
Member

@grendello grendello commented Mar 8, 2024

TODO: rebase on #8478 once it's in

Migrated from #7927

The PR is not even remotely ready for review, it's also broken atm (migration issues, to be investigated)

@grendello grendello changed the title Migrating from the fork Blazor + marshal methods failure Mar 11, 2024
* main:
  [runtime] Remove the last vestiges of desktop builds (#8810)
  [ci] Don't auto-retry APK test suites. (#8811)
  [Microsoft.Android.Templates] Update EN l10n template strings (#8808)
  Bump to xamarin/java.interop@651de42 (#8809)
  [Mono.Android] is now "trimming safe" (#8778)
  [Mono.Android] Fix missing enum issues that cause BG8800 warnings. (#8707)
  Bump external/Java.Interop from `3436a30` to `5bca8ad` (#8803)
  Bump to xamarin/monodroid@77124dc1 (#8804)
  Bump to dotnet/installer@e911f5c82c 9.0.100-preview.3.24161.2 (#8802)
  Bump to xamarin/java.interop@3436a30 (#8799)
* main:
  [Xamarin.Android.Build.Tasks] %(AndroidAsset.AssetPack) Support (#8631)
* main:
  [ci] Use managed identity for ApiScan (#8823)
  [Xamarin.Android.Build.Tasks] DTBs should not rm generator output (#8706)
  [Xamarin.Android.Build.Tasks] Bump to NuGet 6.7.1 (#8833)
  $(AndroidPackVersionSuffix)=preview.4; net9 is 34.99.0.preview.4 (#8831)
  Localized file check-in by OneLocBuild Task (#8824)
  [Xamarin.Android.Build.Tasks] Enable POM verification features. (#8649)
  [runtime] Optionally disable inlining (#8798)
  Fix assembly count when satellite assemblies are present (#8790)
  [One .NET] new "greenfield" projects are trimmed by default (#8805)
  Localized file check-in by OneLocBuild Task (#8819)
  LEGO: Merge pull request 8820
  LEGO: Merge pull request 8818
  Bump to dotnet/installer@b40c44502d 9.0.100-preview.3.24165.20 (#8817)
  Bump com.android.tools:r8 from 8.2.47 to 8.3.37 (#8816)
  [Mono.Android] Prevent NullPointerException in TranslateStackTrace (#8795)
  Localized file check-in by OneLocBuild Task (#8815)
  [Xamarin.Android.Build.Tasks] Make all assemblies RID-specific (#8478)
  Localized file check-in by OneLocBuild Task (#8813)
Still doesn't build, libunwind cmake fails, but we're a step closer.
* main:
  Bump to dotnet/installer@dc43d363d2 9.0.100-preview.4.24175.5 (#8828)
  [Xamarin.Android.Build.Tasks] Update to newer ILRepack which supports debug files. (#8839)
  Bump 'NuGet.*' and 'Newtonsoft.Json' NuGet versions. (#8825)
  Localized file check-in by OneLocBuild Task (#8844)
  [LayoutBindings] Fix '[Preserve]' is obsolete warnings (#8529)
  LEGO: Merge pull request 8837
* main:
  Switch 64-bit hashes to xxhash3 (#8721)
  Bump to xamarin/monodroid@fefc158ef3 (#8850)
  Bump binutils to 17.0.6-7.2.1 (#8806)
* main:
  Update THIRD-PARTY-NOTICES.txt generation code (#8853)
  [APIScan] Scan extra symbols and update parameters (#8812)
* main:
  Bump to xamarin/xamarin-android-binutils@758d2e7 (#8885)
  [Mono.Android] Bind API-VanillaIceCream Beta 1 (#8891)
  [AndroidToolTask] Log tool output as error  (#8861)
  [Xamarin.Android.Build.Tasks] Remove "Xamarin" from messages (#8884)
  [Mono.Android] Bind API-VanillaIceCream Developer Preview 2 (#8741)
  Bump to dotnet/installer@22ffa42d6c 9.0.100-preview.4.24221.5 (#8887)
  Bump external/xamarin-android-tools from `37d79c9` to `05f9a90` (#8869)
  Bump external/Java.Interop from `e1c7832` to `06214ff` (#8878)
  Bump to dotnet/installer@7380c301c1 9.0.100-preview.4.24215.2 (#8874)
  [Mono.Android] Commit baseline PublicAPI files for API-35 (#8840)
  Add a unit test to check environment processing (#8856)
  Don't use azureedge.net CDN (#8846)
  Bump to dotnet/installer@0bfd2dd757 9.0.100-preview.4.24208.2 (#8862)
  [ci] Update dependabot ignore list (#8864)
  Bump external/Java.Interop from `651de42` to `e1c7832` (#8836)
  Bumps LLVM to v18.1.3 and XA utils version to 8.0.0 (#8852)
jonpryor pushed a commit that referenced this pull request May 16, 2024
)

Context: #8800
Context: 8bc7a3e
Context: 6836818
Context: libunwind/libunwind#702

Begin adding native method call tracing infrastructure based on
[libunwind][0], initially used in tracing the reasons for why
[Blazor][1] apps break when LLVM marshal methods are enabled
(8bc7a3e, 6836818).  The utility of such infrastructure, however,
is beyond just that particular task; it should be available for
general use by both us and applications.

Method call tracing support is not enabled by default.
To enable it, set the `$(_AndroidEnableNativeStackTracing)` MSBuild
property to `true`.  This will enable the ability to print native, 
managed and Java stack traces by invoking the `monodroid_log_traces`
function from either managed or native application code.

Additionally, change the directory layout for native code.

Previously, `src/monodroid` would produce *five* native libs:

  * `libmono-android.debug.so`
  * `libmono-android.release.so`
  * `libxa-internal-api.so`
  * `libxamarin-app.so`
  * `libxamarin-debug-app-helper.so`

This made for a large `src/monodroid/CMakeLists.txt`, complicating
maintenance.  We had considered trying to move these into separate
`src/LIBRARY-NAME` directories, but it makes things easier with
CMake if we introduce an intermediate directory.

Introduce a new `src/native` directory, to hold native binaries:

  * `src/native/monodroid`: new location for `libmono-android.*.so`

  * `src/native/xamarin-debug-app-helper`: source for
    `libxamarin-debug-app-helper.so`, containing code moved from
    previous `src/monodroid`

  * `src/native/xamarin-app-stub`: source for the "stub"
    `libxamarin-app.so`; the "real" one is produced in the app build.

Some `src/native/*` directories produce libraries (`.so` files). and
some produce *static* archives (`.a` files) to simplify using code
across native libraries.

A [cmake-presets file][2] is processed by `xaprepare`, to create a
`src/native/CMakePresets.json` which contains all the version-specific
bits replacements such as Android API levels, paths to utilities etc.

Developers can create a `src/native/CMakeUserPresets.json` file to
provide local modifications to config options within
`src/native/CMakePresets.json.in`.

Other changes:

  * `src/native/libunwind/fixes/aarch64/Gos-linux.c` is an altered
    copy of [`libunwind/src/aarch64/Gos-linux.c`][3] in order to
    workaround libunwind/libunwind#702.

  * *Begin* turning some instance member functions into static member
    functions, as we don't otherwise need instances of those classes.

  * Begin using `std::source_location` for better crash messages,
    instead of using `__FILE__` and `__LINE__`.

  * Fix endless recursion from a typo in `Util::ends_with()` overload.

[0]: https://github.com/libunwind/libunwind
[1]: https://learn.microsoft.com/aspnet/core/blazor/hybrid/tutorials/maui?view=aspnetcore-8.0
[2]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
[3]: https://github.com/libunwind/libunwind/blob/9cc4d98b22ae57bc1d8c253988feb85d4298a634/src/aarch64/Gos-linux.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant