Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

I compiled Net Core with EFCore but waiting a long time #7333

Closed
ifew opened this issue Apr 22, 2019 · 16 comments
Closed

I compiled Net Core with EFCore but waiting a long time #7333

ifew opened this issue Apr 22, 2019 · 16 comments

Comments

@ifew
Copy link
Contributor

ifew commented Apr 22, 2019

I developing some native app and using MySql.Data.EntityFrameworkCore but waiting a long time for compile, I'm not sure to correct or not.

and then I try another code from other (https://github.com/rubin55/dot-hello). it's same

I don't know why?

My Code
https://github.com/ifew/aws-lambda-lambdanative-db/tree/master/src/aws-lambda-lambdanative

My OS: MacOS Mojave
CPU Intel Core i5 2.9 GHz
Memory: 8 GB

px. sorry for bad English

@jkotas
Copy link
Member

jkotas commented Apr 22, 2019

EntityFramework is a big and complex library, so it takes a while to compile to native code.

@ifew
Copy link
Contributor Author

ifew commented Apr 22, 2019

Have any example?

@ifew
Copy link
Contributor Author

ifew commented Apr 23, 2019

EntityFramework is a big and complex library, so it takes a while to compile to native code.

I waiting more than 1 hour and then process terminate

  Generating compatible native code. To optimize for size or speed, visit https://aka.ms/OptimizeCoreRT
EXEC : warning : RD.XML processing will change before release (https://github.com/dotnet/corert/issues/5001) [/Users/chitpong/Sourcecode/dot-hello/hello.csproj]
  Process is terminating due to StackOverflowException.
  /var/folders/j_/dz2fhccj2b97xx_lv7mgvnv00000gn/T/tmpa6f40bc79f2049ab8c129c7319a41bd3.exec.cmd: line 2: 65131 Abort trap: 6           "/Users/chitpong/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-27527-01/tools/ilc" @"obj/release/netcoreapp2.1/osx-x64/native/hello.ilc.rsp"
/Users/chitpong/.nuget/packages/microsoft.dotnet.ilcompiler/1.0.0-alpha-27527-01/build/Microsoft.NETCore.Native.targets(239,5): error MSB3073: The command ""/Users/chitpong/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-27527-01/tools/ilc" @"obj/release/netcoreapp2.1/osx-x64/native/hello.ilc.rsp"" exited with code 134. [/Users/chitpong/Sourcecode/dot-hello/hello.csproj]

Our environment
dotnet 2.2.104
cmake 3.14.2
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
OS: MacOS Mojave
CPU: Intel Core i5 2.9 GHz
Memory: 8 GB

@MichalStrehovsky
Copy link
Member

Try adding <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies> to a PropertyGroup in your csproj file.

I don't have time to investigate, but I'm guessing there's a generic recursion somewhere (#363, #6372).

@ifew
Copy link
Contributor Author

ifew commented Apr 23, 2019

Try adding <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies> to a PropertyGroup in your csproj file.

I don't have time to investigate, but I'm guessing there's a generic recursion somewhere (#363, #6372).

Hi @MichalStrehovsky

I try to use <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies> and executing on AWS Lambda has an error

{
  "errorType": "Runtime.ExitError",
  "errorMessage": "RequestId: 26569e11-3333-4891-a36d-dff625582aaf Error: Runtime exited with error: signal: segmentation fault (core dumped)"
}

@MichalStrehovsky
Copy link
Member

Entity framework is reflection heavy and disabling RootAllApplicationAssemblies makes reflection less likely to work out of box. You'll need to build RD.XML for this. #6477 has a sample RD.XML that will likely be a good starting point.

@ifew
Copy link
Contributor Author

ifew commented Apr 23, 2019

Entity framework is reflection heavy and disabling RootAllApplicationAssemblies makes reflection less likely to work out of box. You'll need to build RD.XML for this. #6477 has a sample RD.XML that will likely be a good starting point.

OK, I will try again with RD.XML

And last question, How can I get a list of assemblies, types, methods for insert in RD.XML?

I use this code to generate RD.XML, correct or not?

public static void GetAssemblies()
        {
            StringBuilder result = new StringBuilder();
            result.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?><Directives xmlns=\"http://schemas.microsoft.com/netfx/2013/01/metadata\"><Application>");
            
            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            
            foreach (Assembly asm in assemblies)
            {
                AssemblyName asmName = asm.GetName();
                string name = asmName.Name;
                result.Append("<Assembly Name=\"" + name + "\" Dynamic=\"Required All\"></Assembly>\n");
            }

            result.Append("</Application></Directives>\n");

            using (StreamWriter outputFile = new StreamWriter(Path.Combine("./", "rd.xml"), false))
            {
                outputFile.WriteLine(result);
            }
        }

@MichalStrehovsky
Copy link
Member

Applying Dynamic="Required All" to all assemblies is equivalent to leaving RootAllApplicationAssemblies at the default value. I'm afaid if you do that, you'll get the compilation failure back.

You'll have to do some trial and error. I would suggest starting with the RD.XML in #6477 and tweak it to your needs.

@ifew
Copy link
Contributor Author

ifew commented Apr 25, 2019

@MichalStrehovsky
I try to pull the latest code from https://github.com/rubin55/dot-hello in #6477
but I waiting a long time to compile and it's process terminated.
Do you have any suggestion?

ps. I asked @rubin55 and he has reproduced and it's work!. may be a problem from my environment?

@MichalStrehovsky
Copy link
Member

I try to pull the latest code from https://github.com/rubin55/dot-hello in #6477 but I waiting a long time to compile and it's process terminated.

You have to add <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies> to the project. The project is older than the <RootAllApplicationAssemblies> setting.

@rubin55
Copy link

rubin55 commented Apr 25, 2019

Hey Michal :-) Where would one set this option? Then I'll try and get my little example working again :-)

@MichalStrehovsky
Copy link
Member

Hey Rubin! Just add it to a PropertyGroup in the project. We changed reflection defaults in #6820, but seems like EF has problems with that and RootAllApplicationAssemblies=false is needed to opt out.

Also, we now publish the compiler to a different feed, so you might want to update nuget.config too (#7268).

Thanks!

@ifew
Copy link
Contributor Author

ifew commented Apr 25, 2019

Hey Michal :-) Where would one set this option? Then I'll try and get my little example working again :-)

In your .csproj file

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
    <RuntimeIdentifiers>win10-x64;osx.10.11-x64;linux-x64</RuntimeIdentifiers>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies>
  </PropertyGroup>

@rubin55
Copy link

rubin55 commented Apr 25, 2019

@MichalStrehovsky Alright, I'll get on it. Thanks for the pointer + will also look at the feed shizzle.

@rubin55
Copy link

rubin55 commented Apr 25, 2019

It's compiling again, but I'm getting a new virtual method pointer lookup failure:

Let's do some SQlite!
Generic virtual method pointer lookup failure.

Declaring type handle: EEType:0x00000001021F3C08
Target type handle: EEType:0x0000000102092E68
Method name: CreateGeneric
Instantiation:
  Argument 00000000: EEType:0x00000001020216B0
  Argument 00000001: EEType:0x0000000102070010
  Argument 00000002: EEType:0x0000000102070010

Abort trap: 6

It's been a while since I tackled with this, but I seem to remember @MichalStrehovsky explaining to me that you need to add a specific stanza for these kinds of errors in rd.xml. This seems to be about CreateGeneric method which takes three EEType type arguments?. Can you refresh my memory? Then I'll go and see if I can get dot-hello working again.

Update: Hah, I ran into this one before, but at the time couldn't always reproduce, see: #6477 (comment)

Hah and you mentioned at the time: "That's unfortunate. If you still had the EXE/PDB, we could use the EEType values in the message to look up what's missing. If you hit it again, please save them somewhere!"

Alright, I have them:
hello-exe-and-pdb.zip

@MichalStrehovsky
Copy link
Member

I'll try to have a look at this over the weekend. Generic virtual method pointer lookup failure. is a bug. RD.XML can probably work around, but we should fix the bug...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants