Search Unity

5.3.2p1 IL2CPP and Rewired undeclared identifier _p0_marchaled

Discussion in 'Windows' started by AVOlight, Jan 30, 2016.

  1. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    doesn't happen in 5.3.1p4

    the build error points to this line

    // Marshaling of parameter 'p0' to native representation
    Guid_t...._marshal(p0, _p0_marshaled);
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,675
    Can you show the whole function where the error occurs?
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    The bug he reported is happening when compiling my plugin Rewired on iOS or Windows Store in IL2CPP mode. According to AVOlight, this bug did not exist in 5.3.1p4 but does in 5.3.2p1. This is very important to me since it looks like new changes to IL2CPP have introduced a new bug that will break Rewired from compiling on iOS. I will try to reproduce the bug on the latest Unity and file a bug report.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Update: I can verify this does not happen in iOS on 5.3.2f1. I haven't tested 5.3.2p1 yet.

    Update 2: I didn't realize this was a Windows support forum. I think I can explain the Windows build issue anyway. Rewired is not compatible with Windows 10 Universal yet. This is not a supported platform listed on the website. The Windows Store libraries provided only support 8.0 and 8.1. The OP didn't mention it, but to build to IL2CPP requires that he be building to Windows 10 Universal. This simply isn't going to happen until I make a Windows 10 specific DLL for Rewired.
     
  5. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    @guavaman all my Rewired 1.0.0.78.U5 controls work with Windows 10 Universal IL2CPP in 5.3.1p4

    i specifically don't use the windows integration dll because its not needed with IL2CPP

    I will rebuild now to report the method, pretty sure it was the same as the one on the iOS side
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Okay, thanks! That will help a lot to know how to reproduce it.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    I have been able to reproduce the error in Windows 10 Universal using IL2CPP. The error is not generated when Unity builds the project. The error is in the CPP code output by IL2CPP and will only show you the error when you try to build the final project in Visual Studio. Based on the error, there is no possible workaround I can come up with for this. Unity is generating bad C++ code that won't compile, trying to use a variable that was never declared anywhere.

    I haven't tested iOS, but I'm assuming the error is the same. No error on building from Unity, but generation of invalid C++ code that will not compile in XCode.

    I have filed a bug report: 766642

    There are 2 instances of '_p0_marshaled': undeclared identifier' in the generated file Bulk_Rewired_Core_5.cpp:
    Code (csharp):
    1. // System.IntPtr UmxmzpPrXXVyftfjBVdCCafDNCI/FYLrfNPeDesPWdnQkqCTtmHNZHV::nIEBOpwZcOjjqZIqRsvgmmvOJRK(System.Guid)
    2. extern "C"  IntPtr_t FYLrfNPeDesPWdnQkqCTtmHNZHV_nIEBOpwZcOjjqZIqRsvgmmvOJRK_m3943275339 (Object_t * __this /* static, unused */, Guid_t756539922  p0, const MethodInfo* method)
    3. {
    4.     // Marshaling of parameter 'p0' to native representation
    5.     Guid_t756539922_marshal(p0, _p0_marshaled);
    6. }
    7.  
    8. // System.IntPtr UmxmzpPrXXVyftfjBVdCCafDNCI/EFcZJfSWVBXhdKKjOBpPLqvtiqo::nIEBOpwZcOjjqZIqRsvgmmvOJRK(System.Guid)
    9. extern "C"  IntPtr_t EFcZJfSWVBXhdKKjOBpPLqvtiqo_nIEBOpwZcOjjqZIqRsvgmmvOJRK_m3375284006 (Object_t * __this /* static, unused */, Guid_t756539922  p0, const MethodInfo* method)
    10. {
    11.     // Marshaling of parameter 'p0' to native representation
    12.     Guid_t756539922_marshal(p0, _p0_marshaled);
    13. }
    The original code for these calls:
    Code (csharp):
    1. // UmxmzpPrXXVyftfjBVdCCafDNCI.FYLrfNPeDesPWdnQkqCTtmHNZHV
    2. [SuppressUnmanagedCodeSecurity]
    3. [DllImport("SDL2", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "SDL_GameControllerMappingForGUID")]
    4. private static extern IntPtr nIEBOpwZcOjjqZIqRsvgmmvOJRK(IntPtr);
    5.  
    6. // UmxmzpPrXXVyftfjBVdCCafDNCI.EFcZJfSWVBXhdKKjOBpPLqvtiqo
    7. [SuppressUnmanagedCodeSecurity]
    8. [DllImport("libSDL2-2.0.so.0", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "SDL_GameControllerMappingForGUID")]
    9. private static extern IntPtr nIEBOpwZcOjjqZIqRsvgmmvOJRK(IntPtr);
    There is no declaration of _p0_marshaled in either generated C++ function,
     
    Last edited: Feb 1, 2016
    AVOlight likes this.
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    @guavaman

    Thanks for reporting this bug, we will investigate it.
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    We've now been able to isolate the cause of this issue and correct it. The fix will miss our internal cut-off for 5.3.2p2, but it should make 5.3.2p3.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Excellent! Thank you so much for doing this so quickly! You're awesome! :cool:

    I'm very happy to hear the fix will make it out before the next normal release so there won't be any official releases with this problem.

    I'm assuming the IL2CPP code base is unified and this problem was fixed on both iOS and Windows 10 Universal.
     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    @guavaman

    Yes, the code here is not platform specific, so all IL2CPP platforms will get the fix at the same time.
     
    AVOlight and guavaman like this.
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Wonderful! Thank you!
     
  13. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
  14. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    @JoshPeterson @Tautvydas-Zilys @guavaman

    It looks like the error has come back for Rewired? If I'm not mistaken.

    I can share the test project that's giving the il2cpp error if you'd like.

    Any help would be appreciated.
    Thank you

    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.

    Failed running C:\Program Files\Unity\Hub\Editor\2018.4.5f1\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="ReleasePlus" --outputpath="D:\DeleteUnityPorj\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="D:\DeleteUnityPorj\Assets\..\Library/il2cpp_cache" --map-file-parser="C:\Program Files\Unity\Hub\Editor\2018.4.5f1\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --directory="D:\DeleteUnityPorj\Temp\StagingArea\Data\Managed" --generatedcppdir="D:\DeleteUnityPorj\Temp\StagingArea\Data\il2cppOutput"
    stdout:
    Building GameAssembly.dll with MsvcDesktopToolChain
    Msvc Install Version: 15.0
    Msvc Install SDK Directory: C:\Windows Kits\10
    Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe
    Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe
    Output directory: D:\DeleteUnityPorj\Temp\StagingArea\Data\Native
    Cache directory: D:\DeleteUnityPorj\Library\il2cpp_cache
    ObjectFiles: 646 of which compiled: 199
    Time Compile: 9006 milliseconds Bulk_mscorlib_11.cpp
    Time Compile: 8946 milliseconds Bulk_mscorlib_9.cpp
    Time Compile: 8856 milliseconds Bulk_Rewired_Core_8.cpp
    Time Compile: 8680 milliseconds Bulk_Rewired_Core_20.cpp
    Time Compile: 8532 milliseconds Bulk_Rewired_Core_6.cpp
    Time Compile: 8459 milliseconds Bulk_System.Xml_7.cpp
    Time Compile: 7810 milliseconds Bulk_System_0.cpp
    Time Compile: 7106 milliseconds Bulk_System.Xml_5.cpp
    Time Compile: 5384 milliseconds Bulk_Generics_6.cpp
    Time Compile: 4847 milliseconds Il2CppTypeDefinitions.cpp
    Total compilation time: 68646 milliseconds.
    il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /out:"D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /OPT:REF /OPT:ICF /LTCG /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "kernel32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" "version.lib" "MsWSock.lib" "ws2_32.lib" "Iphlpapi.lib" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.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\Community\VC\Tools\MSVC\14.16.27023\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\PC\AppData\Local\Temp\tmpAC8F.tmp"
    Creating library D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.lib and object D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.exp
    Generating code
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\common\error.c', line 835)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    LINK : fatal error LNK1257: code generation failed
    at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    at il2cpp.Program.DoRun(String[] args)
    at il2cpp.Program.Run(String[] args)
    at il2cpp.Program.Main(String[] args)
    stderr:
    Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /out:"D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /OPT:REF /OPT:ICF /LTCG /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "kernel32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" "version.lib" "MsWSock.lib" "ws2_32.lib" "Iphlpapi.lib" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.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\Community\VC\Tools\MSVC\14.16.27023\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\PC\AppData\Local\Temp\tmpAC8F.tmp"
    Creating library D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.lib and object D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.exp
    Generating code
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\common\error.c', line 835)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    LINK : fatal error LNK1257: code generation failed
    at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    at il2cpp.Program.DoRun(String[] args)
    at il2cpp.Program.Run(String[] args)
    at il2cpp.Program.Main(String[] args)
    UnityEngine.Debug:LogError(Object)
    UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
    UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
    UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:368)
    UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
    UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
    UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:42)
    DesktopStandalonePostProcessor:SetupStagingArea(BuildPostProcessArgs, HashSet`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:245)
    DesktopStandalonePostProcessor:postProcess(BuildPostProcessArgs) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:46)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    This is not the same error as the OP had. The error is this:
    fatal error C1001: An internal error has occurred in the compiler.

    A compiler error is very bad. I don't have any way of dealing with something like that.
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Yes, this is pretty ugly. Please drop us a bug report via the Unity editor. If we can reproduce it, we might be able to submit a bug report to Microsoft for the C++ compiler issue and maybe suggest a work around.

    It might also be worth trying a different (maybe newer) MSVC version, if you don't have the latest.
     
  17. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Thanks a lot for the help! @JoshPeterson @Tautvydas-Zilys @guavaman

    Ok I'll send in the project via bug report.

    I'm on 2017 at the moment. I'll try updating to 2019 and see if it help?
     

    Attached Files:

  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Thanks Josh. Just so you know, this is a perfect storm situation caused by the randomness of Rewired's obfuscation combined with IL2CPP's processing of it. I've had the same thing in the past reveal compiler errors in Android NDK 13b which were fixed in a later version of the compiler. This is probably another one just like it. While the code works in .Net, it can't compile after IL2CPP generates the C++ code. It's possible it may be revealing a bug in IL2CPP's conversion or the compiler. Either way, it's something that is random and there really are no workarounds on my end but to remove obfuscation or to test every single build by manually making IL2CPP test Unity builds using IL2CPP on every platform and Unity version that faces this issue for every version of the Rewired library (4, 5, 2017, 2018, 2019 release and trial builds) whenever I make a new build.

    I can submit a bug report since it's easily reproduced with the current build of Rewired 1.1.27.2 U2018 on the Asset Store.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    @JoshPeterson I've submitted a bug report on this. I'll PM you the fogbugz url.
     
    KarlKarl2000 likes this.
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Apparently the bug does not occur with the same version of Rewired using the latest version of VS 2019, but does in an earlier version of 2019, so this bug was fixed by MS at some point between then. That doesn't help anything because I have to support old VS versions so it looks I have to make Windows Standalone IL2CPP test builds before every release now too.