<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/67998>67998</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Build Error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Anime-Fan012
      </td>
    </tr>
</table>

<pre>
    So I am creating a unity webgl game. I want my script to know at runtime if the webgl game in the browser is on Desktop or A mobile device so I used the following method:

-I created a file named "MyPlugin.jslib" in Assets/Plugins/webgl/MyPlugin.jslib
that isn what i wrote inside this file:
var MyPlugin = {
    IsMobile: function()
 {
        return Module.SystemInfo.mobile;
 }
};

mergeInto(LibraryManager.library, MyPlugin);

-Then I added following to my unity script:

using System.Runtime.InteropServices;
        #region WebGL is on mobile check

                [DllImport("__Internal")]
                private static extern bool IsMobile();

                public bool isMobile()
                {
                        #if !UNITY_EDITOR && UNITY_WEBGL
                            return IsMobile();
                        #endif
                             return false;
                }

                #endregion

I used bool isMobile() to Check if the device on which my webgl game is running is a mobile device or not. Everything worked fun in editor. But when I sarted to build the game. The build failed and these errors showed:

'Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js: undefined symbol: IsMobile (referenced by top-level compiled C/C++ code)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()'

'Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
error: undefined symbol: IsMobile (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: _IsMobile 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:/Software/unity 2021 new/2021.3.11f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/node/node.exe" "C:\Software\unity 2021 new\2021.3.11f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten\src\compiler.js" C:\Users\Hp\AppData\Local\Temp\tmpjf_g3fkj.txt' failed (1)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
'

Please help resolve this and if there is some other way from which I can check device type then that will work too. Thanks
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VlFv6joS_jXmZdQomAbKAw-QkLtItD0CqrP3CTnJBFwcO7Idcvj3KzuBUs7Zp92LECS2Z-bzzDefzYzhB4k4I9GCRMmANfao9GwueYVPKZPhkA4yVVxmWwUrYBXkGpnl8gAMGsntBVrMDgIOrMIAVtAyaaG6gMk1ry1YBSepWmAWdCMtrxB4CfaId2bApR_JtGoNauAGlIQEzcmqGpSGOVQq4wKhwDPPEYyD0hgsvFmphFCtQ1ShPaqCjOYkTEjY_z6tOshYAIPSeZGswgIIpa-XH6I5cBl8GsEzQqlDMjcGrSE07ebck4dKaPqw3ru3R2aBGwmtf4BWK-t2ZHiBYI_c-Jg3TGem4eoGyCgBMll0MwAAK_PqN0pGcygbmVuuJKEvhE77Nd9Wu49G22gJr6poBAbbi7FYrWSpgqp3tLhZJn1WJslttPutUB9wJa0i9GXNM8305ZVJdkAdiO6V0PiG2oH5bv-0O6J05CgKLO7KYZUjQkeSjg4PpWmMW9aBDjYdPYKVtKhVvUXtam2-dtB_CB1pPHAl4Sdmf617tvQEyY-Yn-5DkHDqvtEiEWJV1Upbn0-63_s4kglCqdtSlNwb1JqfmUUwllmeA_5yayFTSnzVqKvL91T01k0meN4t59-X34OaLL69hlNCR7wEQocfb6vd3_tlstq9b4DQMaFj6MZ-Lhd_rR_M7njwX8F9RUBZ8PIPHq4uSiYMPlreyHM_6H11tbif7VvzD7t3jIhdha4a0Pezct3D86Ojy70sGKcZ0nGEG2APIqA0SGUDWJ5RX-zRrWqVPjkGNtI1MhbcKh3AorHQdgw1TDsdsAqyhotO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