Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Windows IL2CPP - LNK1170 error

Discussion in 'Experimental Scripting Previews' started by pavelkouril, Apr 6, 2018.

  1. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    Hello,

    I am hitting a LNK1170 error when compiling a project on Windows, because we need to generate a lot dummy calls to generic methods that are called via reflection in our custom deserialization code with all the value type parameters and object parameter.

    Are there any possible workarounds on our side, or is this a hard limitation from MSVC which cannot be circuimveited in any way from "userland code"?

    We might be able to put the deserializers into another assembly, that would be dependent on Assembly-CSharp, but I'm not sure if the linker and IL2CPP generator would pick that assembly up?
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Can you provide the specific error message from the linker?
     
  3. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    Here it is.

    Code (CSharp):
    1. Failed running c:\Program Files\Unity\Hub\Editor\2018.1.0b13\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --development-mode --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="Debug" --outputpath="C:\work\unity\foo\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="C:\work\unity\foo\Assets\..\Library/il2cpp_cache" --map-file-parser="c:\Program Files\Unity\Hub\Editor\2018.1.0b13\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Assembly-CSharp-firstpass.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Assembly-UnityScript-firstpass.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Assembly-UnityScript.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Zlib.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Bar.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\CommonBaseline.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Baz.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Foo.Common.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Xyz.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Aaa.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Bbb.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\Foo.World.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\UnityEngine.UI.dll" --assembly="C:\work\unity\foo\Temp\StagingArea\Data\Managed\UnityEngine.dll" --generatedcppdir="C:\work\unity\foo\Temp\StagingArea\Data\il2cppOutput"
    2.  
    3. stdout:
    4. Building GameAssembly.dll with MsvcDesktopToolChain.
    5.     Output directory: C:\work\unity\foo\Temp\StagingArea\Data\Native
    6.     Cache directory: C:\work\unity\foo\Library\il2cpp_cache
    7. ObjectFiles: 4468 of which compiled: 4002
    8.     Time Compile: 977879 milliseconds Il2CppGenericMethodPointerTable.cpp
    9.     Time Compile: 228824 milliseconds Il2CppInvokerTable.cpp
    10.     Time Compile: 189437 milliseconds Il2CppMetadataUsage.cpp
    11.     Time Compile: 118884 milliseconds Il2CppTypeDefinitions.cpp
    12.     Time Compile: 26881 milliseconds Il2CppGenericMethodTable.cpp
    13.     Time Compile: 24517 milliseconds Il2CppGenericMethodDefinitions.cpp
    14.     Time Compile: 21911 milliseconds Il2CppGenericInstDefinitions.cpp
    15.     Time Compile: 21897 milliseconds Il2CppGenericClassTable.cpp
    16.     Time Compile: 12058 milliseconds UnresolvedVirtualCallStubs.cpp
    17.     Time Compile: 4647 milliseconds Il2CppAttributes.cpp
    18. Total compilation time: 1037484 milliseconds.
    19. il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\bin\HostX64\x64\link.exe /out:"C:\work\unity\foo\Library\il2cpp_cache\linkresult_308AB25702A617CD4010ECB4BDE096F7\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /MAP /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "ws2_32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\kourilpav\AppData\Local\Temp\tmp1F8A.tmp"
    20.  
    21. Microsoft (R) Incremental Linker Version 14.13.26129.0
    22. Copyright (C) Microsoft Corporation.  All rights reserved.
    23.  
    24. C:\Users\kourilpav\AppData\Local\Temp\tmp1F8A.tmp : fatal error LNK1170: line in command file contains 131071 or more characters
    25.  
    26.   at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(IEnumerable`1 objectFiles, CppToolChainContext toolChainContext)
    27.   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    28.   at Unity.IL2CPP.Building.Statistics.BuildingTestRunnerHelper.BuildAndLogStatsForTestRunner(CppProgramBuilder builder, IBuildStatistics& statistics)
    29.   at il2cpp.Program.DoRun(String[] args)
    30.   at il2cpp.Program.Run(String[] args)
    31.   at il2cpp.Program.Main(String[] args)
    32. stderr:
    33.  
    34. Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\bin\HostX64\x64\link.exe /out:"C:\work\unity\foo\Library\il2cpp_cache\linkresult_308AB25702A617CD4010ECB4BDE096F7\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /MAP /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "ws2_32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\kourilpav\AppData\Local\Temp\tmp1F8A.tmp"
    35.  
    36. Microsoft (R) Incremental Linker Version 14.13.26129.0
    37. Copyright (C) Microsoft Corporation.  All rights reserved.
    38.  
    39. C:\Users\kourilpav\AppData\Local\Temp\tmp1F8A.tmp : fatal error LNK1170: line in command file contains 131071 or more characters
    40.  
    41.   at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(IEnumerable`1 objectFiles, CppToolChainContext toolChainContext)
    42.   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    43.   at Unity.IL2CPP.Building.Statistics.BuildingTestRunnerHelper.BuildAndLogStatsForTestRunner(CppProgramBuilder builder, IBuildStatistics& statistics)
    44.   at il2cpp.Program.DoRun(String[] args)
    45.   at il2cpp.Program.Run(String[] args)
    46.   at il2cpp.Program.Main(String[] args)
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Can you provide the contents of the linker respond file located at C:\Users\kourilpav\AppData\Local\Temp\tmp1F8A.tmp? It looks like we are hitting some limit in the size of the input the linker can parse.
     
  5. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    I had to try to build the project again, so the filename is different, but it failed on this file (also, renamed ot to txt to be able to upload it; and I also renamed the project to a random name, with the same amount of characters as the existing one).
     

    Attached Files:

  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    This file looks valid - but just really large. Can you submit a bug report with this project? We may need to try it here.
     
  7. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    Unfortunately, I can't provide the project. :(

    But I will try to do a repro case over the weekend, since I know what code addition breaks the build process on our side.
     
    JoshPeterson likes this.
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    I've just learned that we have an existing bug for this issue. The fix in is progress now.
     
    pavelkouril likes this.
  9. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    Would it be possible to post the bug number, so I can look for it in future release notes? :)
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Sure, the bug is case number 1022765. I don't see a public issue tracker link for it yet though.
     
    pavelkouril likes this.
  11. Lukasce

    Lukasce

    Unity Technologies

    Joined:
    Dec 1, 2016
    Posts:
    4
    Hello,

    Were you by chance able to make the reproduction project you have mentioned before? As JoshPeterson has mentioned we do indeed have a fix being worked on for this issue. But we are struggling a bit with a reproduction of the issue itself. If you could provide us with a reproduction project we would be able to confirm that it is fixed.
     
  12. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    Hello,

    unfortunately, I wasn't able to get to it, got overwhelmed by other work -- but I tried to compile similarly big assembly (AFAIK) today, and it seemed ok in the latest 2018.1 release. :)

    As for the case in the project where it failed before - there were like 5 generic calls, each of them with object + several hundred value-types as generic parameters (for generating dummy AOT calls for our serialization system), all of this generated using Mono.Cecil.