MichalStrehovsky / zerosharp

Demo of the potential of C# for systems programming with the .NET native ahead-of-time compilation technology.
2k stars 103 forks source link

(efinoruntime) Unresolved external symbol String___ctor #17

Closed valentinbreiz closed 3 years ago

valentinbreiz commented 3 years ago

Hello, I'm trying to build the efinoruntime sample and I have this error:

.\build.cmd

C:\Users\valentin.charbonnier\Documents\Clone\NativeAOT\efi-no-runtime>csc /nologo /debug:embedded /noconfig /nostdlib /runtimemetadataversion:v4.0.30319 zerosharp.cs /out:zerosharp.ilexe /langversion:latest /unsafe

C:\Users\valentin.charbonnier\Documents\Clone\NativeAOT\efi-no-runtime>"C:\Users\valentin.charbonnier\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\6.0.0-preview.7.21327.1"\tools\ilc zerosharp.ilexe -o                                                                                                                                                                                                                   zerosharp.obj --systemmodule zerosharp --map zerosharp.map -O

C:\Users\valentin.charbonnier\Documents\Clone\NativeAOT\efi-no-runtime>link /nologo /subsystem:EFI_APPLICATION zerosharp.obj /entry:EfiMain /incremental:no /out:BOOTX64.EFI
zerosharp.obj : error LNK2001: unresolved external symbol String___ctor
BOOTX64.EFI : fatal error LNK1120: 1 unresolved externals
MichalStrehovsky commented 3 years ago

You should be able to work around by adding a private parameterless constructor to the String class.

Something changed in the AOT compiler that is breaking this. I'll have to fix it in the compiler when I get a chance.

valentinbreiz commented 3 years ago

Changing String from sealed class to abstract class fixed my issue

MichalStrehovsky commented 3 years ago

This was caused by the AOT compiler being out of sync. Fixed in https://github.com/MichalStrehovsky/zerosharp/commit/26b8800c63f2ddbbfc1927861299008a59f916d9.