Search Unity

Problem with building project on Linux with non-default clang installation path

Discussion in 'Linux' started by 010101010101, Mar 19, 2020.

  1. 010101010101

    010101010101

    Joined:
    Feb 14, 2014
    Posts:
    20
    Hello

    Guys, can you please help us?!
    We are trying to build our Unity project on Jenkins Linux build node and we have stumbled upon an issue which we can't solve:
    il2cpp.exe didn't catch exception: System.InvalidOperationException: C++ code builder is unable to build C++ code for Linux: Could not find valid clang executable at /usr/bin/clang

    The problem is that clang is installed to a diffirent folder on this node and we can't change it...
    Can you please tell me if there is a way to tell Unity which path to clang (and probably other tools) should be used? Maybe an environment variable or something...

    Or maybe there is another solution?

    Please help!
     
  2. andrews_unity

    andrews_unity

    Unity Technologies

    Joined:
    Dec 11, 2015
    Posts:
    264
    Ahoy,

    So there is a potential way you can make this work if you are running and building on a linux machine:

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEditor.LinuxStandalone;
    4. namespace UnityEditor.LinuxStandalone
    5. {
    6.     public class MySysroot: Sysroot
    7.     {
    8.         public override string Name           => "MySysroot";
    9.         public override string HostPlatform   => "linux";
    10.         public override string HostArch       => "x86_64";
    11.         public override string TargetPlatform => "linux";
    12.         public override string TargetArch     => "x86_64";
    13.         public override bool Initialize() { return true; }
    14.         public override IEnumerable<string> GetIl2CppArguments()
    15.         {
    16.             yield return "--sysroot-path=/";
    17.             yield return "--tool-chain-path=<path-to-root-clang-folder>"; //
    18. /home/andrews/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04
    19.         }
    20.     }
    21. }
    You should be able to just drop this in as an Editor script into your project; you will also need the latest version of 2019.3 in order for this to work. If you have any other issues let me know!
     
  3. 010101010101

    010101010101

    Joined:
    Feb 14, 2014
    Posts:
    20
    Thank you very much!
     
  4. dmitriy_yesarev

    dmitriy_yesarev

    Joined:
    Feb 12, 2019
    Posts:
    5
    I'v tried this on 2019.3.7f1, but it didnt help because there is still no ELF binaries in this distro. Only windows tools, and it tries to invoke those:

    Code (Boo):
    1. .../unity/2019.3.7f1/Editor/Data/il2cpp/build/deploy/net471/UnityLinker.exe exited after 11814 ms.
    2.  
    3. ...
    4. Exception: /home/builduser/buildtools/unity/2019.3.7f1/Editor/Data/il2cpp/build/deploy/net471/il2cpp.exe did not run properly!
     
    Last edited: Apr 2, 2020
  5. andrews_unity

    andrews_unity

    Unity Technologies

    Joined:
    Dec 11, 2015
    Posts:
    264
    So on 2019.3 the il2cpp executables are mono executables so they do are executed via mono which is why they have a .exe ext. Can you attach your editor log ? or post the full text of the error?
     
  6. dmitriy_yesarev

    dmitriy_yesarev

    Joined:
    Feb 12, 2019
    Posts:
    5
    Thanks for the answer
    The exact logfile part with error is here https://pastebin.com/Q0VwuYjR

    I've attached a full logfile in 2 parts. The error is on the 2nd part
     

    Attached Files:

  7. andrews_unity

    andrews_unity

    Unity Technologies

    Joined:
    Dec 11, 2015
    Posts:
    264
    Couple of questions what distro is this running on ? and can you run the command
    2>/dev/null find / -iname limits


    and provide the output from that ? I suspect what is happening here is that the standard include path is not being found and thus its not resolving things properly.
     
  8. dmitriy_yesarev

    dmitriy_yesarev

    Joined:
    Feb 12, 2019
    Posts:
    5
    Code (Boo):
    1. [root@builder-centos7-06 ~]# cat /etc/os-release
    2. NAME="CentOS Linux"
    3. VERSION="7 (Core)"
    4. ID="centos"
    5. ID_LIKE="rhel fedora"
    6. VERSION_ID="7"
    7. PRETTY_NAME="CentOS Linux 7 (Core)"
    8. ANSI_COLOR="0;31"
    9. CPE_NAME="cpe:/o:centos:centos:7"
    10. HOME_URL="https://www.centos.org/"
    11. BUG_REPORT_URL="https://bugs.centos.org/"
    12.  
    13. CENTOS_MANTISBT_PROJECT="CentOS-7"
    14. CENTOS_MANTISBT_PROJECT_VERSION="7"
    15. REDHAT_SUPPORT_PRODUCT="centos"
    16. REDHAT_SUPPORT_PRODUCT_VERSION="7"
    17.  
    18. [root@builder-centos7-06 ~]# uname -a
    19. Linux builder-centos7-06 4.13.16-1-pve #1 SMP PVE 4.13.16-45 (Wed, 28 Mar 2018 15:47:11 +0200) x86_64 x86_64 x86_64 GNU/Linux
    20.  
    21. [root@builder-centos7-06 ~]#  2>/dev/null find / -iname limits
    22.  
    23. /home/builduser/buildtools/gnu/gcc-7.4.0/include/c++/7.4.0/limits
    24. /home/builduser/buildtools/unity/2019.3.5f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/llvm-libc++/test/std/language.support/support.limits/limits
    25. /home/builduser/buildtools/unity/2019.3.5f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/llvm-libc++/test/libcxx/language.support/support.limits/limits
    26. /home/builduser/buildtools/unity/2019.3.5f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/llvm-libc++/include/limits
    27. /home/builduser/buildtools/unity/2019.3.5f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/limits
    28. /home/builduser/buildtools/unity/2019.3.7f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/llvm-libc++/test/std/language.support/support.limits/limits
    29. /home/builduser/buildtools/unity/2019.3.7f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/llvm-libc++/test/libcxx/language.support/support.limits/limits
    30. /home/builduser/buildtools/unity/2019.3.7f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/llvm-libc++/include/limits
    31. /home/builduser/buildtools/unity/2019.3.7f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/limits
    32. /usr/include/c++/4.8.2/limits
    33.  
    34.  
    And here is some more info:

    Centos 7 has an old gcc toolset in its packages and i dont use them.
    Instead, i have compiled gcc-7.4.0 (/home/builduser/buildtools/gnu/gcc) and llvm-10.0.0 (/home/builduser/buildtools/llvm/) by hand.

    I use symlinks for the gcc and llvm versions :

    /home/builduser/buildtools/gnu/gcc -> /home/builduser/buildtools/gnu/gcc-7.4.0
    /home/builduser/buildtools/llvm -> /home/builduser/buildtools/llvm-10.0.0

    The configured run-time environment:

    Code (Boo):
    1. PATH=/home/builduser/buildtools/gnu/gcc/bin:/home/builduser/buildtools/llvm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin
    2. LD_LIBRARY_PATH=/home/builduser/buildtools/gnu/gcc/lib64:/home/builduser/buildtools/gnu/mpc/lib:/home/builduser/buildtools/gnu/mpfr/lib:/home/builduser/buildtools/gnu/gmp/lib

    The llvm tool-chain-path is in the Editor/MySysroot.cs and it points the correct llvm path:

    Code (CSharp):
    1. using System;
    2.    using System.Collections.Generic;
    3.    using UnityEditor.LinuxStandalone;
    4.    namespace UnityEditor.LinuxStandalone
    5.    {
    6.        public class MySysroot: Sysroot
    7.        {
    8.            public override string Name           => "MySysroot";
    9.            public override string HostPlatform   => "linux";
    10.            public override string HostArch       => "x86_64";
    11.            public override string TargetPlatform => "linux";
    12.            public override string TargetArch     => "x86_64";
    13.  
    14.            public override bool Initialize() { return true; }
    15.  
    16.            public override IEnumerable<string> GetIl2CppArguments()
    17.            {
    18.                yield return "--sysroot-path=/";
    19.                yield return "--tool-chain-path=/home/builduser/buildtools/llvm";
    20.            }
    21.        }
    22.    }