Search Unity

Feedback Reduce il2cpp incremental build time by ignoring timestamp in the assembly

Discussion in 'Scripting' started by Alan-Liu, Sep 9, 2022.

  1. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    392
    I'm investigating the slow build issue for our project and found il2cpp task took about 200 seconds even there is no code change between two builds(Android build).

    After comparing the assemblies, I found there were two bytes difference in the two Assembly-CSharp.dll. According to the documentation from Microsoft, the different two bytes were in the TIMESTAMP part (4 bytes totally). I tried to set the timestamp to 0 and found the running time of il2cpp task became about 60 seconds. Based on this, it seems that il2cpp takes the timestamp into account, so it can't do the incremental build for our Assembly-CSharp.dll.

    Here is the code:
    Code (CSharp):
    1. public class ClearAssemblyTimestamp : IPostBuildPlayerScriptDLLs
    2. {
    3.     public int callbackOrder { get { return 0; } }
    4.  
    5.     public void OnPostBuildPlayerScriptDLLs(BuildReport report)
    6.     {
    7.         string dll = report.files.Single(file => file.path.EndsWith("Assembly-CSharp.dll")).path;
    8.  
    9.         using var f = File.Open(dll, FileMode.Open);
    10.         f.Seek(128 + 8, SeekOrigin.Begin);
    11.         f.WriteByte(0);
    12.         f.WriteByte(0);
    13.         f.WriteByte(0);
    14.         f.WriteByte(0);
    15.     }
    16. }
    We're using Unity 2020.3.30 and not sure if it's supported in the newer versions. If not, maybe il2cpp team can consider to ignore the timestamp in the assembly to make the incremental build faster in this circumstance.
     
    mariozhou and oscarAbraham like this.
  2. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    392