[dotnet] Fix typo causing universal builds to not keep any symbols when stripped. Fixes #19860. (#19900)

Fixes https://github.com/xamarin/xamarin-macios/issues/19860.
This commit is contained in:
Rolf Bjarne Kvinge 2024-01-29 20:19:11 +01:00 коммит произвёл GitHub
Родитель 6f8cfc8354
Коммит fc7688cf8d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 47 добавлений и 15 удалений

Просмотреть файл

@ -364,7 +364,7 @@
Properties="
RuntimeIdentifier=%(_RuntimeIdentifiersAsItems.Identity);
_CodesignItemsPath=%(_RuntimeIdentifiersAsItems.RidSpecificCodesignItemsPath);
_MtouchSymbolsList=%(_RuntimeIdentifiersAsItems.RidSpecificSymbolsList);
_MtouchSymbolsList=%(_RuntimeIdentifiersAsItems.RidSpecificSymbolsListPath);
_UserFrameworksWithoutDebugSymbolsPath=%(_RuntimeIdentifiersAsItems.RidSpecificUserFrameworksWithoutDebugSymbolsPath);
$(_RidSpecificProperties);
">

Просмотреть файл

@ -1215,5 +1215,23 @@ namespace Xamarin.Tests {
[DllImport ("libc")]
static extern int sysctlbyname (string name, ref int value, ref IntPtr size, IntPtr zero, IntPtr zeroAgain);
public static IEnumerable<string> GetNativeSymbols (string file, string arch = null)
{
var arguments = new List<string> (new [] { "-gUjA", file });
if (!string.IsNullOrEmpty (arch)) {
arguments.Add ("-arch");
arguments.Add (arch);
}
var symbols = ExecutionHelper.Execute ("nm", arguments, hide_output: true).Split ('\n');
return symbols.Where ((v) => {
return !v.EndsWith (": no symbols", StringComparison.Ordinal);
}).Select ((v) => {
var idx = v.LastIndexOf (": ", StringComparison.Ordinal);
if (idx <= 0)
return v;
return v.Substring (idx + 2);
});
}
}
}

Просмотреть файл

@ -1634,5 +1634,32 @@ namespace Xamarin.Tests {
AssertErrorCount (errors, 1, "Error count");
AssertErrorMessages (errors, $"The property '{property}' is deprecated, please remove it from the project file. Use 'RuntimeIdentifier' or 'RuntimeIdentifiers' instead to specify the target architecture.");
}
[Test]
// The trailing semi-colon for single-arch platforms is significant:
// it means we'll use "RuntimeIdentifiers" (plural) instead of "RuntimeIdentifier" (singular)
[TestCase (ApplePlatform.iOS, "ios-arm64;")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64;")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64;")]
public void StrippedRuntimeIdentifiers (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["NoSymbolStrip"] = "false";
DotNet.AssertBuild (project_path, properties);
var appExecutable = GetNativeExecutable (platform, appPath);
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);
var symbols = Configuration.GetNativeSymbols (appExecutable);
Assert.That (symbols, Does.Contain ("_xamarin_release_managed_ref"), "_xamarin_release_managed_ref");
}
}
}

Просмотреть файл

@ -4715,20 +4715,7 @@ public class TestApp {
public static IEnumerable<string> GetNativeSymbols (string file, string arch = null)
{
var arguments = new List<string> (new [] { "-gUjA", file });
if (!string.IsNullOrEmpty (arch)) {
arguments.Add ("-arch");
arguments.Add (arch);
}
var symbols = ExecutionHelper.Execute ("nm", arguments, hide_output: true).Split ('\n');
return symbols.Where ((v) => {
return !v.EndsWith (": no symbols", StringComparison.Ordinal);
}).Select ((v) => {
var idx = v.LastIndexOf (": ", StringComparison.Ordinal);
if (idx <= 0)
return v;
return v.Substring (idx + 2);
});
return Configuration.GetNativeSymbols (file, arch);
}
static bool? is_apfs;