binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

Closure warnings in Emscripten builds

Open tlively opened this issue 1 year ago • 1 comments

Building binaryen.js gives warnings like the following:

building:WARNING: /tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9381:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9381|  this["ptr"] = relooper;
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9382:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9382|  this["addBlock"] = function(code) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9385:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9385|  this["addBranch"] = function(from, to, condition, code) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9388:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9388|  this["addBlockWithSwitch"] = function(code, condition) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9391:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9391|  this["addBranchForSwitch"] = function(from, to, indexes, code) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9394:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9394|  this["renderAndDispose"] = function(entry, labelHelper) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9401:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9401|  this["ptr"] = runner;
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9402:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9402|  this["setLocalValue"] = function(index, valueExpr) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9405:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9405|  this["setGlobalValue"] = function(name, valueExpr) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:9408:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  9408|  this["runAndDispose"] = function(expr) {
         ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:10209:11: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  10209|     return this.constructor[memberName](this[thisPtr], ...args);
                    ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:10209:40: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  10209|     return this.constructor[memberName](this[thisPtr], ...args);
                                                 ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:10231:1: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  10231|  this[thisPtr] = expr;
          ^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:11524:10: WARNING - [JSC_NOT_A_CONSTRUCTOR] cannot instantiate non-constructor
  11524|    return new Function(func);
                   ^^^^^^^^^^^^^^^^^^

/tmp/emscripten_temp_vx7q3baw/binaryen_js.js.pp.js.jso.js.jso.js.jso.js.jso.js:11527:2: WARNING - [JSC_USED_GLOBAL_THIS] dangerous use of the global this object
  11527|   this[thisPtr] = func;
           ^^^^

externs.zip//webassembly.js:29:18: WARNING - [JSC_TYPE_MISMATCH] initializing variable
found   : {
  CompileError: (typeof WebAssembly.CompileError),
  Exception: (typeof WebAssembly.Exception),
  Global: (typeof WebAssembly.Global),
  Instance: (typeof WebAssembly.Instance),
  LinkError: (typeof WebAssembly.LinkError),
  Memory: (typeof WebAssembly.Memory),
  Module: (typeof WebAssembly.Module),
  RuntimeError: (typeof WebAssembly.RuntimeError),
  Table: (typeof WebAssembly.Table),
  Tag: (typeof WebAssembly.Tag),
  ...
}
required: {
  Instance: (typeof WebAssembly.Instance),
  Memory: (typeof WebAssembly.Memory),
  Module: function((ArrayBuffer|ArrayBufferView)): ?,
  RuntimeError: (typeof Error),
  instantiate: function((ArrayBuffer|ArrayBufferView), (Object|null)=): Promise<{
    instance: WebAssembly.Instance,
    module: WebAssembly.Module
  }>
}
  29| var WebAssembly = {};
                        ^^

0 error(s), 16 warning(s), 63.6% typed

These should be fixed!

tlively avatar Sep 20 '22 20:09 tlively

It will be great if someone from Google who very good familiar help improve this. Closure Compiler also have a lot of special annotations which may improve glue quality I guess: https://github.com/google/closure-compiler/wiki/Annotating-Types

MaxGraey avatar Sep 20 '22 20:09 MaxGraey

With #5075, warnings except

externs.zip//webassembly.js:29:18: WARNING - [JSC_TYPE_MISMATCH] initializing variable
found   : {
  CompileError: (typeof WebAssembly.CompileError),
  Exception: (typeof WebAssembly.Exception),
  Global: (typeof WebAssembly.Global),
  Instance: (typeof WebAssembly.Instance),
  LinkError: (typeof WebAssembly.LinkError),
  Memory: (typeof WebAssembly.Memory),
  Module: (typeof WebAssembly.Module),
  RuntimeError: (typeof WebAssembly.RuntimeError),
  Table: (typeof WebAssembly.Table),
  Tag: (typeof WebAssembly.Tag),
  ...
}
required: {
  Instance: (typeof WebAssembly.Instance),
  Memory: (typeof WebAssembly.Memory),
  Module: function((ArrayBuffer|ArrayBufferView)): ?,
  RuntimeError: (typeof Error),
  instantiate: function((ArrayBuffer|ArrayBufferView), (Object|null)=): Promise<{
    instance: WebAssembly.Instance,
    module: WebAssembly.Module
  }>
}
  29| var WebAssembly = {};
                        ^^

should be fixed. The remaining one originates in a conflict between the WebAssembly externs shipped by Closure Compiler and those shipped by Emscripten as it seems. Suggesting to upstream what's in Emscripten but not yet in Closure to Closure, and then remove the Emscripten one.

cc @sbc100 as a contributor on both files. Wdyt? :)

dcodeIO avatar Sep 22 '22 23:09 dcodeIO