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

Another set of changes from #9572 #9807

Merged
merged 11 commits into from
Feb 21, 2025
Merged

Another set of changes from #9572 #9807

merged 11 commits into from
Feb 21, 2025

Conversation

grendello
Copy link
Contributor

Some changes that affect the MonoVM runtime or are generic enough to be placed in main.

@jonpryor
Copy link
Member

@grendello: Windows fails to build:

       D:\a\_work\1\s\src\native\native.targets(99,5): error : "C:\Android\android-sdk\cmake\3.30.3\bin\cmake -DOUTPUT_PATH="D:\a\_work\1\s\bin\Release\lib\runtimes\mono\" -DRUNTIME_FLAVOR="MonoVM" --preset default-release-armeabi-v7a -DBUILD_ARCHIVE_DSO_STUB=ON -DSTRIP_DEBUG=ON "D:\a\_work\1\s\src\native\"" failed with code: 1  Error output:  [D:\a\_work\1\s\src\native\native-mono.csproj]
       D:\a\_work\1\s\src\native\native.targets(99,5): error : CMake Warning: [D:\a\_work\1\s\src\native\native-mono.csproj]
       D:\a\_work\1\s\src\native\native.targets(99,5): error :   No source or binary directory provided.  Both will be assumed to be the [D:\a\_work\1\s\src\native\native-mono.csproj]
       D:\a\_work\1\s\src\native\native.targets(99,5): error :   same as the current working directory, but note that this warning will [D:\a\_work\1\s\src\native\native-mono.csproj]
       D:\a\_work\1\s\src\native\native.targets(99,5): error :   become a fatal error in future CMake releases. [D:\a\_work\1\s\src\native\native-mono.csproj]
       D:\a\_work\1\s\src\native\native.targets(99,5): error : CMake Error: The source directory "D:/a/_work/1/s/src/native/obj/Release/MonoVM/android-arm-archive-dso-stub" does not appear to contain CMakeLists.txt. [D:\a\_work\1\s\src\native\native-mono.csproj]

@grendello grendello force-pushed the dev/grendel/clr-bits-two branch from cacdf4d to 0d3ea36 Compare February 19, 2025 08:43
@@ -48,6 +49,8 @@ internal struct JnienvInitializeArgs {

internal static JniRuntime? androidRuntime;

public static DotNetRuntimeType RuntimeType { get; private set; } = DotNetRuntimeType.Unknown;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this value be set by a trimmer switch instead of passing it in?

The build knows the runtime it targets, so it could do the work at build time.

This would make this property treated as a constant and code for other runtimes would be trimmed away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that eventually turning it into a trimmer feature is the goal. But right now, I need it to be a runtime check since I sometimes work without the trimmer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trimmer feature switches use AppContext.TryGetSwitch() if the app isn't trimmed, here is an example:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree on both counts: I'd rather avoid the trimmer switch until we actually need it, and I don't see why we want/need this RuntimeType field as well.

See e.g. #9812: any place that would be "switching" on RuntimeType is probably better served as a virtual method invocation on JNIEnvInit.androidRuntime or equivalent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be the better solution, but we can make that change at a later time, when everything is in main, I think

@jonpryor
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

grendello and others added 10 commits February 20, 2025 12:02
By convention (and often enforced requirement), `$(OutputPath)` ends
with `\`, which means that quoting it for use with `<Exec/>`:

    <Exec Command="whatever &quot;$(OutputPath)&quot;" />

will often result in an *invalid* command, because the `\` escapes the quote!

    whatever "C:\path\to\output\" # ruh roh!

The fix is to instead use `$(OutputPath.OutputPath.TrimEnd('\')`,
which ensures that the path does *not* end in `\`, preventing
the unintentional escape usage:

    whatever "C:\path\to\output" # yay!
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=11036370&view=ms.vss-test-web.build-test-results-tab&runId=122368005&resultId=100098&paneView=attachments

Will hopefully fix/avoid the build error:

       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7015: System.NotSupportedException: Internal error: unsupported runtime NativeAOT [D:\a\_work\1\a\TestRelease\02-19_09.11.14\temp\NativeAOT\Hello.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7015:    at Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease(Boolean skipJniAddNativeMethodRegistrationAttributeScan, String outputDirectory) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs:line 452 [D:\a\_work\1\a\TestRelease\02-19_09.11.14\temp\NativeAOT\Hello.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7015:    at Xamarin.Android.Tasks.TypeMapGenerator.Generate(Boolean debugBuild, Boolean skipJniAddNativeMethodRegistrationAttributeScan, String outputDirectory, Boolean generateNativeAssembly) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs:line 175 [D:\a\_work\1\a\TestRelease\02-19_09.11.14\temp\NativeAOT\Hello.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7015:    at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(NativeCodeGenState state) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 484 [D:\a\_work\1\a\TestRelease\02-19_09.11.14\temp\NativeAOT\Hello.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7015:    at Xamarin.Android.Tasks.GenerateJavaStubs.Run(Boolean useMarshalMethods) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 272 [D:\a\_work\1\a\TestRelease\02-19_09.11.14\temp\NativeAOT\Hello.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7015:    at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask() in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 115 [D:\a\_work\1\a\TestRelease\02-19_09.11.14\temp\NativeAOT\Hello.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7015:    at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/builder/azdo/_work/4/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25 [D:\a\_work\1\a\TestRelease\02-19_09.11.14\temp\NativeAOT\Hello.csproj]
Context: 7d04764
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=11036370&view=ms.vss-test-web.build-test-results-tab&runId=122366823&resultId=100099&paneView=attachments

Commit 7d04764 asserts that CoreCLR *builds*.

This set of changes starts adding incremental support for CoreCLR,
but typemap support is still lacking, meaning
`BasicApplicationOtherRuntime(True)` fails:

       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7000: System.NotImplementedException: CoreCLR support not implemented yet [D:\a\_work\1\a\TestRelease\02-19_09.08.39\temp\BasicApplicationOtherRuntimeTrue\UnnamedProject.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7000:    at Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease(Boolean skipJniAddNativeMethodRegistrationAttributeScan, String outputDirectory) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs:line 451 [D:\a\_work\1\a\TestRelease\02-19_09.08.39\temp\BasicApplicationOtherRuntimeTrue\UnnamedProject.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7000:    at Xamarin.Android.Tasks.TypeMapGenerator.Generate(Boolean debugBuild, Boolean skipJniAddNativeMethodRegistrationAttributeScan, String outputDirectory, Boolean generateNativeAssembly) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs:line 175 [D:\a\_work\1\a\TestRelease\02-19_09.08.39\temp\BasicApplicationOtherRuntimeTrue\UnnamedProject.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7000:    at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(NativeCodeGenState state) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 484 [D:\a\_work\1\a\TestRelease\02-19_09.08.39\temp\BasicApplicationOtherRuntimeTrue\UnnamedProject.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7000:    at Xamarin.Android.Tasks.GenerateJavaStubs.Run(Boolean useMarshalMethods) in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 272 [D:\a\_work\1\a\TestRelease\02-19_09.08.39\temp\BasicApplicationOtherRuntimeTrue\UnnamedProject.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7000:    at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask() in /Users/builder/azdo/_work/4/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 115 [D:\a\_work\1\a\TestRelease\02-19_09.08.39\temp\BasicApplicationOtherRuntimeTrue\UnnamedProject.csproj]
       D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.99.0-ci.dev-grendel-clr-bits-two.174\tools\Xamarin.Android.Common.targets(1509,3): error XAGJS7000:    at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/builder/azdo/_work/4/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25 [D:\a\_work\1\a\TestRelease\02-19_09.08.39\temp\BasicApplicationOtherRuntimeTrue\UnnamedProject.csproj]

Skip LLVM-IR typemaps for CoreCLR for now.
This is needed until #9572 is merged, since the != 'NativeAOT'
would enable the guarded code to run also for `CoreCLR`, which
is not fully functional in this PR.
@grendello grendello force-pushed the dev/grendel/clr-bits-two branch from 7be27a0 to c6b29f2 Compare February 20, 2025 11:20
@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jonpryor jonpryor merged commit 3822f2b into main Feb 21, 2025
59 checks passed
@jonpryor jonpryor deleted the dev/grendel/clr-bits-two branch February 21, 2025 14:26
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.

3 participants