Search Unity

Resolved Build fails with undefined symbol _ZN6il2cpp2os6Thread16HasCurrentThreadEv

Discussion in 'Web' started by JesseSTG, Nov 9, 2022.

  1. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    I'm trying to build my game with WebGL, using Unity 2022.1.22f1 on Windows 10. However, WebGL builds fail with this error:

    Code (csharp):
    1. Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
    2. wasm-ld: warning: function signature mismatch: unity_debugger_agent_is_global_breakpoint_active
    3. >>> defined as (i32) -> i32 in C:\\Users\\Jesse\\AppData\\Local\\Temp\\tmp1xadfdhsGameAssembly.a(uqj5_tils0.lump.o)
    4. >>> defined as () -> i32 in C:\\Users\\Jesse\\AppData\\Local\\Temp\\tmp1xadfdhsGameAssembly.a(jo3y_gger-agent.o)
    5. error: undefined symbol: _ZN6il2cpp2os6Thread16HasCurrentThreadEv (referenced by top-level compiled C/C++ code)
    6. warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
    7. warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
    8. warning: __ZN6il2cpp2os6Thread16HasCurrentThreadEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
    9. Error: Aborting compilation due to previous errors
    10. emcc2: error: '"C:/Program Files/Unity/Hub/Editor/2022.1.22f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/node/node.exe" "C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten\src\compiler.js" C:\Users\Jesse\AppData\Local\Temp\tmpe7d7j2du.txt' failed (1)
    11. UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
    Any suggestions?
     
  2. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    273
    It looks like you're using C++ threads here which we added support for in Unity 2022.2 release with Emscripten 3.1.8. Could you try that version?
     
  3. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    I'm not explicitly using C++ threads, but it's possible that one of my dependencies is. How can I check?

    As for Unity 2022.2, I'll try it and report back. Thanks for the tip.
     
  4. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    @unityruba No dice. I get this build error in 2022.2.0b14:

    And when I do a clean build, wasm-ld takes an ungodly amount of time to execute. I'll try letting it run overnight, but I'm not confident it'll actually finish (since 2022.1.22's wasm-ld was still chugging along after 12 hours).
     
  5. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    273
    So two things here:

    The first I failed to mention which is that you'd have to enable multithreading using this scripting API: https://docs.unity3d.com/ScriptReference/PlayerSettings.WebGL-threadsSupport.html

    The second is that since you haven't explicitly used threads and it might be in a dependency you aren't aware of, it'll be hard to pinpoint what is using threads and we haven't (yet) done the work to make warnings abundantly clear about which functions are using multithreading (but we're working on it!), so if using that scripting option doesn't result in this magically getting fixed, the error message will continue to be unhelpful.

    Bonus last thing, if you do see an error message like:
    Code (CSharp):
    1. Compiler Error at Internal build system error. read the full binlog without getting a BuildFinishedMessage
    2.  
    please share any logs you get from that build because the error message alone doesn't convey much.
     
    Last edited: Nov 14, 2022
  6. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    I'll give it a shot, thanks!
     
  7. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    @unityruba Nope, back to square one. The symbol in this thread (_ZN6il2cpp2os6Thread16HasCurrentThreadEv) appears to be resolved, but now _ZN4FMOD12ChannelGroup21getAbsoluteAudibilityEPf isn't being found. Here's the error:

    Code (csharp):
    1. Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
    2. emcc: warning: USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271 [-Wpthreads-mem-growth]
    3. error: undefined symbol: _ZN4FMOD12ChannelGroup21getAbsoluteAudibilityEPf (referenced by top-level compiled C/C++ code)
    4. warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
    5. warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
    6. warning: __ZN4FMOD12ChannelGroup21getAbsoluteAudibilityEPf may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
    7. Error: Aborting compilation due to previous errors
    8. emcc: error: '"C:/Program Files/Unity/Hub/Editor/2022.2.0b14/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/node/node.exe" "C:\Program Files\Unity\Hub\Editor\2022.2.0b14\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten\src\compiler.js" C:\Users\Jesse\AppData\Local\Temp\tmp7d4l_mzl.json' failed (returned 1)
    9. UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
    Some possibly relevant facts:
    • I'm using Unity 2022.2.0b14.
    • WebGL's debug symbol mode is set to External.
    • WebGL's exception support is set to Full with Stacktrace.
    • Analyze Build Size is set to true.
    • WebGL threading support is set to true.
    • IL2CPP compiler config is set to Debug.
    • Managed stripping level is set to Low.
    • The Development and AllowDebugging BuildOption flags are set.
     
  8. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    273
    This specific error you're seeing I had fixed just recently and that fix landed in 2022.2.0b15 :)
     
  9. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    In that case, I'll try again when that version launches and will report back with the results. Thanks!
     
  10. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    That fixed the issue, thanks!
     
    unityruba likes this.
  11. yukunlinykl

    yukunlinykl

    Joined:
    Dec 17, 2021
    Posts:
    21
    UnityEditor Version: 2022.1.9f1c1.3418.178
    OS: Windows 11, 22H2
    target platform: WebGL
    development build: enable
    WebGL threading support: false
    C++ compiler configuration: Debug

    error:

    Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
    wasm-ld: warning: function signature mismatch: unity_debugger_agent_is_global_breakpoint_active
    >>> defined as (i32) -> i32 in C:\\Users\\yukun\\AppData\\Local\\Temp\\tmp7i9zo62wGameAssembly.a(g9d6_tils0.lump.o)
    >>> defined as () -> i32 in C:\\Users\\yukun\\AppData\\Local\\Temp\\tmp7i9zo62wGameAssembly.a(obpb_gger-agent.o)
    error: undefined symbol: _ZN6il2cpp2os6Thread16HasCurrentThreadEv (referenced by top-level compiled C/C++ code)
    warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
    warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
    warning: __ZN6il2cpp2os6Thread16HasCurrentThreadEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
    Error: Aborting compilation due to previous errors
    emcc2: error: '"C:/Program Files/Unity/Hub/Editor/2022.1.9f1c1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/node/node.exe" "C:\Program Files\Unity\Hub\Editor\2022.1.9f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten\src\compiler.js" C:\Users\yukun\AppData\Local\Temp\tmpqcprjayo.txt' failed (1)
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)


    But:
    1. if I disable development build, the error gone.
    2. if I trigger the build in C# script instead of click the "Build and Run" button on "File" menu, the error gone, no matter I enable or disable development build.
    Code (CSharp):
    1.         BuildPlayerOptions buildPlayerOptions = new()
    2.         {
    3.             scenes = new[] { "Assets/Scenes/MappingScene.unity" },
    4.             locationPathName = versionPath + "/" + dirName + (target != BuildTarget.WebGL ? "/" + applicationName : ""),
    5.             target = target,
    6.             options = development ? BuildOptions.Development : BuildOptions.None,
    7.             extraScriptingDefines = new string[] { "HAVE_DATE_TIME_OFFSET" }  // for Newtonsoft.Json.Schema
    8.         };
    9.  
    10.         BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
    11.         BuildSummary summary = report.summary;
    12.