Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

F# il2cpp

Discussion in 'Scripting' started by RazaTech, Jun 27, 2020.

  1. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Hello

    How to Make F# work with Il2cpp

    this is simplest code that is causing issue

    Code (CSharp):
    1.  
    2. namespace Domain
    3. module GerenalTypes =
    4.     type OnlyPositive = OnlyPositive of int
    5.  
    6.     module OnlyPositive =
    7.         let AddOne (OnlyPositive value) = value + 1 |> OnlyPositive

    then include FSharp.Core.dll

    with mono everything work fine
    but during il2cpp build its creating issues.

    <1>
    Failed running C:\Program Files\Unity 2020.1.0b9\Editor\Data\il2cpp\build/deploy/net471/UnityLinker.exe -out="E:/Unity Work Space/Delete me/Temp/StagingArea/assets/bin/Data/Managed/tempStrip" -x="E:/Unity Work Space/Delete me/Temp/StagingArea/assets/bin/Data/Managed/../platform_native_link.xml" -x="E:/Unity Work Space/Delete me/Temp/StagingArea/assets/bin/Data/Managed/TypesInScenes.xml" -d="E:/Unity Work Space/Delete me/Temp/StagingArea/assets/bin/Data/Managed" --include-unity-root-assembly="E:/Unity Work Space/Delete me/Temp/StagingArea/assets/bin/Data/Managed/Assembly-CSharp.dll" --dotnetruntime=il2cpp --dotnetprofile=unityaot --use-editor-options --include-directory="E:/Unity Work Space/Delete me/Temp/StagingArea/assets/bin/Data/Managed" --rule-set=Conservative --editor-data-file="E:/Unity Work Space/Delete me/Temp/StagingArea/assets/bin/Data/Managed/EditorToUnityLinkerData.json" --platform=Android --enable-engine-module-stripping --engine-modules-asset-file="C:/Program Files/Unity 2020.1.0b9/Editor/Data/PlaybackEngines/AndroidPlayer/Whitelists/../modules.asset"

    stdout:
    Fatal error in Unity CIL Linker
    System.NullReferenceException: Object reference not set to an instance of an object.
    at Mono.Linker.Steps.SweepStep.SweepDebugInfo(Collection`1 methods)
    at Mono.Linker.Steps.SweepStep.SweepMethods(Collection`1 methods)
    at Mono.Linker.Steps.SweepStep.SweepType(TypeDefinition type)
    at Mono.Linker.Steps.SweepStep.SweepAssembly(AssemblyDefinition assembly)
    at Unity.Linker.Steps.UnitySweepStep.SweepAssembly(AssemblyDefinition assembly)
    at Mono.Linker.Steps.SweepStep.Process()
    at Unity.Linker.Steps.UnitySweepStep.Process()
    at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
    at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
    at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
    at Mono.Linker.Pipeline.Process(LinkContext context)
    at Unity.Linker.UnityDriver.Run()
    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling()
    at Unity.Linker.UnityDriver.RunDriver()
    stderr:

    UnityEngine.Debug:LogError(Object)
    UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase)
    UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1)
    UnityEditorInternal.AssemblyStripper:RunAssemblyLinker(IEnumerable`1, String&, String&, String, String)
    UnityEditorInternal.AssemblyStripper:StripAssembliesTo(String, String&, String&, IEnumerable`1, UnityLinkerRunInformation)
    UnityEditorInternal.AssemblyStripper:RunAssemblyStripper(UnityLinkerRunInformation)
    UnityEditorInternal.AssemblyStripper:StripAssemblies(String, BaseUnityLinkerPlatformProvider, IIl2CppPlatformProvider, RuntimeClassRegistry, ManagedStrippingLevel)
    UnityEditorInternal.IL2CPPBuilder:Run()
    UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)



    </1>


    <2>

    Exception: C:\Program Files\Unity 2020.1.0b9\Editor\Data\il2cpp\build/deploy/net471/UnityLinker.exe did not run properly!
    UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditorInternal.AssemblyStripper.RunAssemblyLinker (System.Collections.Generic.IEnumerable`1[T] args, System.String& out, System.String& err, System.String linkerPath, System.String workingDirectory) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditorInternal.AssemblyStripper.StripAssembliesTo (System.String outputFolder, System.String& output, System.String& error, System.Collections.Generic.IEnumerable`1[T] linkXmlFiles, UnityEditorInternal.UnityLinkerRunInformation runInformation) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditorInternal.AssemblyStripper.RunAssemblyStripper (UnityEditorInternal.UnityLinkerRunInformation runInformation) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditorInternal.AssemblyStripper.StripAssemblies (System.String managedAssemblyFolderPath, UnityEditorInternal.BaseUnityLinkerPlatformProvider unityLinkerPlatformProvider, UnityEditorInternal.IIl2CppPlatformProvider il2cppPlatformProvider, UnityEditor.RuntimeClassRegistry rcr, UnityEditor.ManagedStrippingLevel managedStrippingLevel) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditorInternal.IL2CPPBuilder.Run () (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <33452e28b45949f4a08b01714189516c>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <33452e28b45949f4a08b01714189516c>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <33452e28b45949f4a08b01714189516c>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <33452e28b45949f4a08b01714189516c>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <b85fd61302f04ebc817d5c985c202647>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)


    </2>
     
    Last edited: Jun 27, 2020
  2. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    538
    Unity does not support F#.
     
  3. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    It does in some extend and it's getting better
    https://jacksondunstan.com/articles/5058
    I just want any unity person to check what and why is this error.
    and how they can help me.
     
  4. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    538
    Being able to make it work is not the same as having support. No one from Unity will help you here because anything about F# is unofficial, sorry.
    All I can contribute is that, since IL2CPP is a Unity-developed tool with very specific goals in mind, failing to complie F# is probably out of scope and not fixable
     
  5. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Yes u are right But thing if it would be C#2Cpp then I could not expect it but since its IL2cpp
    and F# is also IL supported language theoretically it should support F# as well.
    hmm I'm just hoping if someone can help me.
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    21,569
    Again, as @JoNax97 pointed out, it might WORK, but it won't likely be supported.

    If you want to investigate further, rewrite your little code snippet above in C# and compile it, then study the IL and compare the C# IL to the F# IL, as it clearly differs in some regard. Perhaps the difference is minor enough that you can transmogrify the F# IL enough that IL2CPP eats it without complaint.

    Good luck!
     
    RazaTech likes this.
  7. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Thanks MAN!! I will certainly do it.
    but this time I go other way around.

    I decompiled Il2cpp.exe to find where were errors
    found them and fix them(fix in term of now they are not throwing) and compiling F#.

    it was useful. bcs it compiles my real F# domain library.
    now I'm facing two issues

    NotSupportedException: IL2CPP encountered a managed type which it cannot convert ahead-of-time. The type uses generic or array types which are nested beyond the maximum depth which can be converted.
    I don't know what type it is

    06-28 06:26:09.283 24774 24790 E Unity : at Microsoft.FSharp.Collections.SeqModule+Map@593-1[T,TResult]..ctor (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] mapping) [0x00000] in <00000000000000000000000000000000>:0
    06-28 06:26:09.283 24774 24790 E Unity : at Microsoft.FSharp.Collections.SeqModule.Map[T,TResult] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] mapping, System.Collections.Generic.IEnumerable`1[T] source) [0x00000] in <00000000000000000000000000000000>:0
    06-28 06:26:09.283 24774 24790 E Unity : at Microsoft.FSharp.Collections.SeqModule+mkDelayedSeq@471[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <00000000000000000000000000000000>:0
    06-28 06:26:09.283 24774 24790 E Unity : at Microsoft.FSharp.Collections.SeqModule+revamp@576[b,a].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <00000000000000000000000000000000>:0
    06-28 06:26:09.283 24774 24790 E Unity : at Microsoft.FSharp.Collections.MapTreeModule.ofSeq[TKey,T] (System.Collections.Generic.IComparer`1[T] compare

    I think is bcs of first one, or there are the types lets see
     
    Last edited: Jun 28, 2020
  8. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    706
    The fastest way to get someone from Unity to look at an issue is to file a bug report for it. The forums don't get visited by Unity devs systematically, some just do it voluntarily.

    The bug report might just be marked Won't Fix, like this one, but bug reports are also the best way to campaign for features you'd like to see.
     
    RazaTech likes this.
  9. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    I did decompile F# to C# it is using seme functionality from Microsoft.FSharp.Core in comparison and tostring implementation Which i think I can not tweek


    Yes I have done it 1259322
     
    Last edited: Jun 29, 2020
unityunity