Skip export without EntryPoints from linker script (#71307)
authorAdeel Mujahid <3840695+am11@users.noreply.github.com>
Mon, 27 Jun 2022 08:54:23 +0000 (11:54 +0300)
committerGitHub <noreply@github.com>
Mon, 27 Jun 2022 08:54:23 +0000 (17:54 +0900)
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExportedMethodsRootProvider.cs

index eb2878f..65047e2 100644 (file)
@@ -29,7 +29,8 @@ namespace ILCompiler
                     foreach (var method in type.GetMethods())
                     {
                         EcmaMethod ecmaMethod = (EcmaMethod)method;
-                        if (ecmaMethod.IsRuntimeExport || ecmaMethod.IsUnmanagedCallersOnly)
+                        if ((ecmaMethod.IsRuntimeExport && ecmaMethod.GetRuntimeExportName() != null) ||
+                            (ecmaMethod.IsUnmanagedCallersOnly && ecmaMethod.GetUnmanagedCallersOnlyExportName() != null))
                             yield return ecmaMethod;
                     }
                 }
@@ -43,14 +44,12 @@ namespace ILCompiler
                 if (ecmaMethod.IsRuntimeExport)
                 {
                     string runtimeExportName = ecmaMethod.GetRuntimeExportName();
-                    if (runtimeExportName != null)
-                        rootProvider.AddCompilationRoot((MethodDesc)ecmaMethod, "Runtime export", runtimeExportName);
+                    rootProvider.AddCompilationRoot((MethodDesc)ecmaMethod, "Runtime export", runtimeExportName);
                 }
                 else if (ecmaMethod.IsUnmanagedCallersOnly)
                 {
                     string unmanagedCallersOnlyExportName = ecmaMethod.GetUnmanagedCallersOnlyExportName();
-                    if (unmanagedCallersOnlyExportName != null)
-                        rootProvider.AddCompilationRoot((MethodDesc)ecmaMethod, "Native callable", unmanagedCallersOnlyExportName);
+                    rootProvider.AddCompilationRoot((MethodDesc)ecmaMethod, "Native callable", unmanagedCallersOnlyExportName);
                 }
             }
         }