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

Add architecture info to the 0141 warning #9547

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1063,11 +1063,13 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
{1} - NuGet package version</comment>
</data>
<data name="XA0141" xml:space="preserve">
<value>NuGet package '{0}' version '{1}' contains a shared library '{2}' which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details</value>
<value>NuGet package '{0}' version '{1}' contains a shared library '{2}' ({3}) which is not aligned to the {4} byte boundary. Google will require such alignment in the future. See https://developer.android.com/guide/practices/page-sizes for more details</value>
<comment>The following is a literal name and should not be translated: NuGet
{0} - NuGet package id
{1} - NuGet package version
{2} - shared library file name
{3} - target architecture name
{4} - is an integer (size in bytes)
</comment>
</data>
<data name="XA4249" xml:space="preserve">
Expand Down
18 changes: 17 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Utilities/ELFHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ static void AssertValidLibraryAlignment (TaskLoggingHelper log, uint pageSize, s
throw new InvalidOperationException ($"Internal error: {elf} is not ELF<ulong>");
}

string archName = elf.Machine switch {
Machine.AArch64 => "arm64-v8a",
Machine.AMD64 => "x86_64",
_ => throw new NotSupportedException ($"Internal error: ELF architecture {elf.Machine} is not supported")
};

// We need to find all segments of Load type and make sure their alignment is as expected.
foreach (ISegment segment in elf64.Segments) {
if (segment.Type != SegmentType.Load) {
Expand All @@ -66,7 +72,17 @@ static void AssertValidLibraryAlignment (TaskLoggingHelper log, uint pageSize, s
log.LogDebugMessage ($" expected segment alignment of 0x{pageSize:x}, found 0x{segment64.Alignment:x}");

(string packageId, string packageVersion) = GetNugetPackageInfo ();
log.LogCodedWarning ("XA0141", Properties.Resources.XA0141, packageId, packageVersion, Path.GetFileName (path));
log.LogCodedWarning (
"XA0141",
path,
lineNumber: 0,
Properties.Resources.XA0141,
packageId,
packageVersion,
Path.GetFileName (path),
archName,
pageSize
);
break;
}

Expand Down
Loading