Skip to content

Commit c6a5188

Browse files
authored
XCode.cs: Statically link libraries when forcing AOT (#48156)
The fix in #48135 wasn't fully correct since it just fixed the problem for libSystem.Native but not the other libraries. The real problem is that we're setting `preferDylib` to true via `!isDevice` but still generate the pinvoke mapping to `__Internal` for all files where an `.a` file is found. The reason why this works in the simulator on non-AOT cases is because we only call the `register_dllmap` function when we're actually forcing AOT on the simulator: https://github.com/dotnet/runtime/blob/42009d1f33b52e40e5471d5c0d3ff4a8d5b2b83a/src/tasks/AppleAppBuilder/Templates/runtime.m#L239-L240 The better fix is to extend the check to always apply when forceAOT is true.
1 parent 59465d6 commit c6a5188

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tasks/AppleAppBuilder/Xcode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public string GenerateXCode(
8484
{
8585
string libName = Path.GetFileNameWithoutExtension(lib);
8686
// libmono must always be statically linked, for other librarires we can use dylibs
87-
bool dylibExists = libName != "libmonosgen-2.0" && libName != "libSystem.Native" && dylibs.Any(dylib => Path.GetFileName(dylib) == libName + ".dylib");
87+
bool dylibExists = libName != "libmonosgen-2.0" && dylibs.Any(dylib => Path.GetFileName(dylib) == libName + ".dylib");
8888

89-
if (!preferDylibs || !dylibExists)
89+
if (forceAOT || !(preferDylibs && dylibExists))
9090
{
9191
// these libraries are pinvoked
9292
// -force_load will be removed once we enable direct-pinvokes for AOT

0 commit comments

Comments
 (0)