emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 660 forks source link

set -sMAXIMUM_MEMORY = 4GB & use uuid #1384

Open XiaoShu2020ace opened 1 month ago

XiaoShu2020ace commented 1 month ago

If MAXIMUM-MEMORY=4GB is set and the uuid library is used, there will be issues with the code in the'. js' file after compilation;

Interface: _uid_unparse (uu, out) {}

The function uses the 'upper' parameter, but it is not declared;

But if automatic growth is not set and the MAXIMUM-MEMORY compilation instruction is removed, the above function takes the parameter: 'upper'

sbc100 commented 1 month ago

Can you give more context here? The uuid_unparse function takes an optional third parameter: https://github.com/emscripten-core/emscripten/blob/2e3d7f108f0c278f1aab56bebac4497f7a28ec46/src/library_uuid.js#L103-L106

Where is this parameter not declared? Are you referring perhaps the automaticly generated typescript bindings? Can you perhaps share all of the link flags you are using?

When I build a program using this function I see the correct signature in the output, and it does use the upper argument:

/** @param {number|boolean=} upper */ function _uuid_unparse(uu, out, upper) {   
  uu >>>= 0;                                                                     
  out >>>= 0;                                                                    
  var i = 0;                                                                     
  var uuid = "xxxx-xx-xx-xx-xxxxxx".replace(/[x]/g, function(c) {                
    var r = upper ? (HEAPU8[(uu) + (i) >>> 0]).toString(16).toUpperCase() : (HEAPU8[(uu) + (i) >>> 0]).toString(16);
    r = (r.length === 1) ? "0" + r : r;                                          
    i++;                                                                         
    return r;                                                                    
  });                                                                            
  stringToUTF8(uuid, out, 37);                                                   
}