Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Building for Apple Silicon from script doesnt include lib_burst_generated.bundle

Discussion in 'Burst' started by Baggers_, Nov 21, 2021.

  1. Baggers_

    Baggers_

    Joined:
    Sep 10, 2017
    Posts:
    97
    I'm not sure if this is a bug or user error.

    If I build for Apple Silicon from Windows from the Unity Editor "Build Settings" window, the app does include the lib_burst_generated.bundle file (under the "Plugins" folder) but if I build the project from a script (using BuildPipeline.BuildPlayer) it does not.

    Here is my build script:

    Code (CSharp):
    1.  
    2. using UnityEditor;
    3. using UnityEditor.OSXStandalone;
    4.  
    5. public static class BuildStuff
    6. {
    7.     [MenuItem("BUILD TEST/Build")]
    8.     static void BuildIt()
    9.     {
    10.         UserBuildSettings.architecture = MacOSArchitecture.ARM64;
    11.      
    12.         BuildPipeline.BuildPlayer(new BuildPlayerOptions()
    13.         {
    14.             locationPathName = @"C:\home\Code\TestBuild\cubeTestMac\FromScript",
    15.             scenes = new [] { "Assets/Scenes/SampleScene.unity" },
    16.             target = BuildTarget.StandaloneOSX,
    17.             options = BuildOptions.Development,
    18.             extraScriptingDefines = null
    19.         });
    20.     }
    21. }
    22.  
    23.  
    Has anyone had experience with this? I'm happy to provide any additional info to help narrow this down.
     
    Last edited: Nov 21, 2021
  2. Baggers_

    Baggers_

    Joined:
    Sep 10, 2017
    Posts:
    97
    I've tested this from Mac as well as Windows now and the results were the same. lib_burst_generated.bundle is included when building from the Build Settings window and does not if I build from script.

    I have pushed the test case here: https://github.com/Bouncyrock/AppleBuildTest
     
  3. fabrizio_unity

    fabrizio_unity

    Unity Technologies

    Joined:
    May 3, 2018
    Posts:
    47
    Hello,
    thanks for reporting the issue.

    Could you please try to build a universal library instead? (as in, remove line 10 and do not specify the architecture). If it produces the bundle, you can check that it's indeed a universal build by running
    file <bundle path>
    and verify that both architectures are present.

    Also, what editor version are you using? (so i can try to reproduce it for you)

    Thank you,
    The Burst Team
     
  4. fabrizio_unity

    fabrizio_unity

    Unity Technologies

    Joined:
    May 3, 2018
    Posts:
    47
    Oh sorry, another thing; i'm assuming you created https://github.com/Bouncyrock/AppleBuildTest as private repository, because i get 404 when i try to fetch it. It would be great if you can open this up so we can reproduce with what you are using.

    Thanks,
    The Burst Team
     
  5. Baggers_

    Baggers_

    Joined:
    Sep 10, 2017
    Posts:
    97
    Oh look at that, I'm a muppet. It should be public now. I'll go try your recommendations now and get right back to you.
    Cheers!
     
  6. Baggers_

    Baggers_

    Joined:
    Sep 10, 2017
    Posts:
    97
    The editor version is 2021.2.3f
     
  7. Baggers_

    Baggers_

    Joined:
    Sep 10, 2017
    Posts:
    97
    I removed the
    UserBuildSettings.architecture = MacOSArchitecture.ARM64;
    line, but I'm not sure of where else you'd like me to not specify the architecture. I think that was the only place unless it's an editor setting.

    I tried building using this script on macOS (big sur) and Windows and neither have the burst bundle unfortunately
     
  8. fabrizio_unity

    fabrizio_unity

    Unity Technologies

    Joined:
    May 3, 2018
    Posts:
    47
    Alright i figured out what is the issue here. Basically, when you specify the destination for your player build, you should append
    .app
    . In your specific case,

    Code (CSharp):
    1. public static class BuildStuff
    2. {
    3.     static string _lastPath = "";
    4.  
    5.     [MenuItem("BUILD TEST/Build")]
    6.     static void BuildIt()
    7.     {
    8.         UserBuildSettings.architecture = MacOSArchitecture.ARM64;
    9.  
    10.         var path = EditorUtility.SaveFolderPanel("Build location", _lastPath, "test");
    11.  
    12.         if (!string.IsNullOrEmpty(path))
    13.         {
    14.             _lastPath = path;
    15.             BuildPipeline.BuildPlayer(new BuildPlayerOptions()
    16.             {
    17.                 locationPathName = Path.Combine(path, "test.app"),
    18.                 scenes = new [] { "Assets/Scenes/SampleScene.unity" },
    19.                 target = BuildTarget.StandaloneOSX,
    20.                 options = BuildOptions.Development,
    21.                 extraScriptingDefines = null
    22.             });
    23.         }
    24.     }
    25. }
    This code works for us, but please do not hesitate to let us know if it's not working for you.
    We will look more closely to find the root of the problem and get it fixed as soon as possible.

    Thanks,
    The Burst Team
     
  9. Baggers_

    Baggers_

    Joined:
    Sep 10, 2017
    Posts:
    97
    That was it! Fantastic, thanks for the help.
     
    fabrizio_unity likes this.
  10. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    77
    This code only works if the current platform is set to "Windows, Mac, Linux" and macOS is selected:
    Code (CSharp):
    1. UserBuildSettings.architecture = MacOSArchitecture.ARM64;
    The lack of a BuildTarget for StandaloneOSXARM64 (and StandaloneOSXIntel64AndARM64, so all three items in the Architecture dropdown is represented), makes it impossible to reliably build for anything else than Intel64 when calling BuildPipeline.BuildPlayer().

    It could also be made possible by letting us specify a MacOSArchitecture in the BuildPlayerOptions.