This is a bit disappointing, really goes against the whole point of Unity being able to build everywhere from one editor. If this will never be added to the windows editor (I don’t know if this is a temporary limitation or here to stay) can we atleast seperate the backend setting for mac, windows linux? Because right now we can only turn all of them to IL2CPP, which is really annoying since we can ONLY build windows to IL2CPP
Well, you can’t compile C++ code for macOS on Windows. That’s way that restriction exists.
The suggestion to separate the setting is interesting, but it might be hard to implement without breaking scripting backwards compatibility as right now you set it according to BuildTargetGroup.
May I suggest you change scripting backend and build player via script in your project rather than using default build window?
Is there any way to detect if IL2CPP is supported on the current installation for a given build target? If so, then I gladly would. Would make things a lot easier. If IL2CPP is selected AND it is supported for this editor + target combo, use IL2CPP, otherwise, use mono
My current experimentation shows the API only lets us set and get the backend for a given group, but given Mac and Windows are both standalone, this doesn’t help. Am I missing anything?
static bool CanBuildTargetToIL2CPP(BuildTarget target)
{
return Application.platform == GetHostPlatform(target);
}
static RuntimePlatform GetHostPlatform(BuildTarget target)
{
switch (target)
{
case BuildTarget.StandaloneOSX:
#pragma warning disable 612, 618
case BuildTarget.StandaloneOSXUniversal:
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
#pragma warning restore 612, 618
return RuntimePlatform.OSXEditor;
break;
case BuildTarget.StandaloneLinux:
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneLinuxUniversal:
return RuntimePlatform.LinuxEditor;
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
return RuntimePlatform.WindowsEditor;
default:
throw new Exception(string.Format("BuildTarget.{0} is not a standalone player build target!");
}
}
So essentially just doing it manually? If I’m not mistaken, Windows IL2CPP is a seperate module to the base Windows mono, meaning this test would be incorrect if the user has not installed windows IL2CPP?
Yeah, you’d have to check that too if you want to include that scenario. I thought you just cared about “running on X platform editor cannot build IL2CPP”.
static bool AreIl2CppPlayersInstalled(BuildTarget target)
{
string playerPackage, playerName;
string[] il2cppVariations;
switch (target)
{
case BuildTarget.StandaloneOSX:
#pragma warning disable 612, 618
case BuildTarget.StandaloneOSXUniversal:
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
#pragma warning restore 612, 618
{
playerPackage = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.StandaloneOSX, BuildOptions.None);
playerName = "UnityPlayer.app/Contents/MacOS/UnityPlayer";
il2cppVariations = new[]
{
"macosx64_development_il2cpp",
"macosx64_nondevelopment_il2cpp",
};
}
break;
case BuildTarget.StandaloneLinux:
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneLinuxUniversal:
{
playerPackage = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.StandaloneLinux, BuildOptions.None);
playerName = "LinuxPlayer";
il2cppVariations = new[]
{
"linux32_headless_development_il2cpp",
"linux32_headless_nondevelopment_il2cpp",
"linux32_withgfx_development_il2cpp",
"linux32_withgfx_nondevelopment_il2cpp",
"linux64_headless_development_il2cpp",
"linux64_headless_nondevelopment_il2cpp",
"linux64_withgfx_development_il2cpp",
"linux64_withgfx_nondevelopment_il2cpp",
};
}
break;
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
{
playerPackage = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.StandaloneWindows, BuildOptions.None);
playerName = "UnityPlayer.dll";
il2cppVariations = new[]
{
"win32_development_il2cpp",
"win32_nondevelopment_il2cpp",
"win64_development_il2cpp",
"win64_nondevelopment_il2cpp"
};
}
break;
default:
throw new Exception(string.Format("BuildTarget.{0} is not a standalone player build target!");
}
foreach (var variation in il2cppVariations)
{
if (File.Exists(Paths.Combine(playerPackage, "Variations", variation, playerName)))
return true;
}
return false;
}
I see, so just check if the files exist? Any plans to add a proper API for this in the future? Windows store has IL2CPP as a seperate module too right? Whereas Android and iOS come with it? (Windows store also has .net as a module?)
Yeah, that’s how Unity checks it. We had no plans to add anything like this, maybe it’s worth it. And yes, UWP has two modules (.NET and IL2CPP), while iOS and Android come with both in one.
Thanks, let me know if it comes back that a more proper API will be added. In the mean time, I’ll probably take what you have and perhaps try and flesh it out more
Could you look into this? Also, it seems whenever theres an IL2CPP error (IL2CPP doesnt exist, crashes etc) the build will fail but the build reporting api will say that the build succeeded, I think you should have this looked into
Anyways thanks for the help, let me know about the whole IL2CPP on windows x86 stuff
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: Bulk_Rewired_Core_9.cpp
c:\users\yusuf\unity projects\games\subsideria\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_9.cpp(50030) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 260)
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
c:\users\yusuf\unity projects\games\subsideria\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_9.cpp(50030) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\common\error.c', line 792)
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
Invocation was: Executable: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\bin\HostX64\x86\cl.exe"
Arguments: "C:\Users\Yusuf\Unity Projects\Games\Subsideria\Temp\StagingArea\Data\il2cppOutput\Bulk_Rewired_Core_9.cpp" /nologo /c /bigobj /W3 /Zi /EHs /GR- /Gy /wd4715 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /MT /DNET_4_0 /DUNITY_JIT /DGC_NOT_DLL /DRUNTIME_IL2CPP /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /DWINDOWS_SDK_BUILD_VERSION=16299 /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP /I"C:\Program Files\Unity\Editor\Data\il2cpp\libil2cpp" /I"C:\Program Files\Unity\Editor\Data\il2cpp\external\boehmgc\include" /I"C:\Program Files\Unity\Editor\Data\il2cpp\libil2cpp\mono-runtime" /I"C:\Program Files\Unity\Editor\Data\il2cpp\libil2cpp\mono-runtime" /I"C:\Users\Yusuf\Unity Projects\Games\Subsideria\Temp\StagingArea\Data\il2cppOutput" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt" /Fo"C:\Users\Yusuf\Unity Projects\Games\Subsideria\Library\il2cpp_cache\AB4C0CC03C82BBB9B1FFAB7447689AA8.obj" /Fd"C:\Users\Yusuf\Unity Projects\Games\Subsideria\Library\il2cpp_cache\AB4C0CC03C82BBB9B1FFAB7447689AA8.pdb"
EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\bin\HostX64\x64
at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
at Unity.IL2CPP.Building.Statistics.BuildingTestRunnerHelper.BuildAndLogStatsForTestRunner(CppProgramBuilder builder, IBuildStatistics& statistics)
at il2cpp.Program.DoRun(String[] args)
at il2cpp.Program.Run(String[] args)
at il2cpp.Program.Main(String[] args)
We’ll need a bug report to look at this and fix it. It will likely involve us contacting Microsoft as this is a bug in the Visual C++ compiler, not IL2CPP. Does it also happen if you target 64-bit?
ouch So nothing wrong on my end then? At least I’m glad I can help improve Unity by catching this error
Nope, only x86. x64 + IL2CPP for Windows works fine, so I’m not too bothered given most users will be x64 at this point
Tried a smaller project that didn’t use any plugins btw, and it worked there, in case that helps