Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build-tools/create-packs/Microsoft.Android.Sdk.proj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ core workload SDK packs imported by WorkloadManifest.targets.
<_PackageFiles Include="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.Android.Sdk\Sdk\**" PackagePath="Sdk" />
<_PackageFiles Include="$(XamarinAndroidSourcePath)src\Microsoft.Android.Sdk.ILLink\PreserveLists\**" PackagePath="PreserveLists" />
<_PackageFiles Include="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.Android.Sdk\targets\**" PackagePath="targets" />
<_PackageFiles Include="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\dotnet.aotprofile" PackagePath="targets" />
<_PackageFiles Include="$(IntermediateOutputPath)UnixFilePermissions.xml" PackagePath="data" Condition=" '$(HostOS)' != 'Windows' " />
<None Include="$(MSBuildThisFileDirectory)SignList.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ They run in a context of an inner build with a single $(RuntimeIdentifier).
TempDirectory="$([MSBuild]::EnsureTrailingSlash($(_AotOutputDirectory)))%(FileName)"
AotArguments="$(_AotArguments),temp-path=$([System.IO.Path]::GetFullPath(%(_MonoAOTAssemblies.TempDirectory)))"
/>
<AndroidAotProfile Include="$(MSBuildThisFileDirectory)dotnet.aotprofile" Condition=" '$(AndroidEnableProfiledAot)' == 'true' and '$(AndroidUseDefaultAotProfile)' != 'false' " />
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)aot\;@(_MonoAOTAssemblies->'%(TempDirectory)')" />
<MonoAOTCompiler
Assemblies="@(_MonoAOTAssemblies)"
CompilerBinaryPath="$(_MonoAOTCompilerPath)"
AotProfilePath="@(AndroidAotProfile->'%(FullPath)')"
DisableParallelAot="$(_DisableParallelAot)"
LibraryFormat="So"
Mode="$(AndroidAotMode)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Copyright (C) 2019 Microsoft Corporation. All rights reserved.
DependsOnTargets="$(_BeginAotProfilingDependsOnTargets)">
</Target>
<Target Name="FinishAotProfiling"
DependsOnTargets="_ResolveSdks">
DependsOnTargets="_ResolveSdks;_ResolveMonoAndroidSdks">
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) forward tcp:$(AndroidAotProfilerPort) tcp:$(AndroidAotProfilerPort)" />
<Exec Command="&quot;$(MonoAndroidBinDirectory)aprofutil&quot; $(AProfUtilExtraOptions) -s -v -p $(AndroidAotProfilerPort) -o &quot;$(AndroidAotCustomProfilePath)&quot;" />
<Exec Command="&quot;$(AProfUtilToolPath)aprofutil&quot; $(AProfUtilExtraOptions) -s -v -p $(AndroidAotProfilerPort) -o &quot;$(AndroidAotCustomProfilePath)&quot;" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ because xbuild doesn't support framework reference assemblies.
/>
</CreateProperty>

<!-- We should slowly port all the <CreateProperty/> calls to <PropertyGroup/> here -->
<PropertyGroup>
<AProfUtilToolPath Condition=" '$(AProfUtilToolPath)' == '' ">$(MonoAndroidBinDirectory)</AProfUtilToolPath>
</PropertyGroup>

<!-- Get the defined constants for this API Level -->
<GetAndroidDefineConstants AndroidApiLevel="$(_AndroidApiLevel)" ProductVersion="$(MonoAndroidVersion)">
<Output TaskParameter="AndroidDefineConstants" ItemName="AndroidDefineConstants" />
Expand Down
Binary file not shown.
48 changes: 46 additions & 2 deletions src/monodroid/jni/monodroid-glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1582,8 +1582,52 @@ MonodroidRuntime::set_profile_options ()
value.assign (prop_value);
}

// setenv(3) makes copies of its arguments
setenv ("DOTNET_DiagnosticPorts", value.get (), 1);
// NET6+ supports only the AOT Mono profiler, if the prefix is absent or different than 'aot:' we consider the
// property to contain value for the dotnet tracing profiler.
constexpr char AOT_PREFIX[] = "aot:";
if (!value.starts_with (AOT_PREFIX)) {
// setenv(3) makes copies of its arguments
setenv ("DOTNET_DiagnosticPorts", value.get (), 1);
return;
}

constexpr char OUTPUT_ARG[] = "output=";
constexpr size_t OUTPUT_ARG_LEN = sizeof(OUTPUT_ARG) - 1;
constexpr size_t start_index = sizeof(AOT_PREFIX); // one char past ':'

dynamic_local_string<SENSIBLE_PATH_MAX> output_path;
bool have_output_arg = false;
string_segment param;

while (value.next_token (start_index, ',', param)) {
dynamic_local_string<SENSIBLE_PATH_MAX> temp;
temp.assign (param.start (), param.length ());
if (!param.starts_with (OUTPUT_ARG)) {
continue;
}

output_path.assign (param.start () + OUTPUT_ARG_LEN, param.length () - OUTPUT_ARG_LEN);
have_output_arg = true;
break;
}

if (!have_output_arg) {
constexpr char PROFILE_FILE_NAME_PREFIX[] = "profile.";
constexpr char AOT_EXT[] = "aotprofile";

output_path
.assign_c (androidSystem.get_override_dir (0))
.append (MONODROID_PATH_SEPARATOR)
.append (PROFILE_FILE_NAME_PREFIX)
.append (AOT_EXT);

value
.append (OUTPUT_ARG)
.append (output_path.get (), output_path.length ());
}

log_warn (LOG_DEFAULT, "Initializing profiler with options: %s", value.get ());
debug.monodroid_profiler_load (androidSystem.get_runtime_libdir (), value.get (), output_path.get ());
}
#else // def NET6
inline void
Expand Down