Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,8 @@ def phase_linker_setup(options, state, newargs):
settings.MIN_CHROME_VERSION < 49 or
settings.MIN_SAFARI_VERSION < 110000 or
settings.MIN_IE_VERSION != 0x7FFFFFFF)
if not feature_matrix.caniuse(feature_matrix.Feature.OPTIONAL_CHAINING):
settings.TRANSPILE_TO_ES5 = True

if options.use_closure_compiler is None and settings.TRANSPILE_TO_ES5:
diagnostics.warning('transpile', 'enabling transpilation via closure due to browser version settings. This warning can be suppressed by passing `--closure=1` or `--closure=0` to opt into our explicitly.')
Expand Down
8 changes: 4 additions & 4 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1764,10 +1764,10 @@ var AUTO_NATIVE_LIBRARIES = true;
// versions >= MIN_FIREFOX_VERSION
// are desired to work. Pass -sMIN_FIREFOX_VERSION=majorVersion to drop support
// for Firefox versions older than < majorVersion.
// Firefox ESR 68 was released on July 9, 2019.
// Firefox ESR 74 was released on March 10, 2020
// MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported.
// [link]
var MIN_FIREFOX_VERSION = 68;
var MIN_FIREFOX_VERSION = 74;

// Specifies the oldest version of desktop Safari to target. Version is encoded
// in MMmmVV, e.g. 70101 denotes Safari 7.1.1.
Expand Down Expand Up @@ -1806,10 +1806,10 @@ var MIN_EDGE_VERSION = 0x7FFFFFFF;

// Specifies the oldest version of Chrome. E.g. pass -sMIN_CHROME_VERSION=58 to
// drop support for Chrome 57 and older.
// Chrome 75.0.3770 was released on 2019-06-04
// Chrome 80 was released on February 4, 2020
// MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported.
// [link]
var MIN_CHROME_VERSION = 75;
var MIN_CHROME_VERSION = 80;

// Specifies minimum node version to target for the generated code. This is
// distinct from the minimum version required run the emscripten compiler.
Expand Down
10 changes: 8 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -12819,6 +12819,10 @@ def test_es5_transpile(self, args):
};
global['foo'] = obj3;
err('value2: ' + obj3.myMethod());

// optional chaining
let result = Module.foo?.doSomething();
err('result: ' + result);
}
});
''')
Expand All @@ -12833,13 +12837,15 @@ def check_for_es6(filename, expect):
self.assertContained(['() => 2', '()=>2'], js)
self.assertContained('const ', js)
self.assertContained('let ', js)
self.assertContained('foo?.doSomething()', js)
else:
self.verify_es5(filename)
self.assertNotContained('foo(arg=', js)
self.assertNotContained('() => 2', js)
self.assertNotContained('()=>2', js)
self.assertNotContained('const ', js)
self.assertNotContained('let ', js)
self.assertNotContained('foo?.doSomething()', js)

# Check that under normal circumstances none of these features get
# removed / transpiled.
Expand Down Expand Up @@ -13336,10 +13342,10 @@ def test_reproduce(self):
self.assertTextDataIdentical(expected, response)

def test_min_browser_version(self):
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Werror', '-sWASM_BIGINT', '-sMIN_SAFARI_VERSION=120000'])
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Werror', '-sWASM_BIGINT', '-sMIN_SAFARI_VERSION=120000', '-Wno-transpile'])
self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (150000 or above required)', err)

err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Werror', '-pthread', '-sMIN_CHROME_VERSION=73'])
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Werror', '-pthread', '-sMIN_CHROME_VERSION=73', '-Wno-transpile'])
self.assertContained('emcc: error: MIN_CHROME_VERSION=73 is not compatible with pthreads (74 or above required)', err)

def test_signext_lowering(self):
Expand Down
7 changes: 7 additions & 0 deletions tools/feature_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Feature(IntEnum):
THREADS = auto()
GLOBALTHIS = auto()
PROMISE_ANY = auto()
OPTIONAL_CHAINING = auto()


default_features = {Feature.SIGN_EXT, Feature.MUTABLE_GLOBALS}
Expand Down Expand Up @@ -71,6 +72,12 @@ class Feature(IntEnum):
'safari': 140000,
'node': 150000,
},
Feature.OPTIONAL_CHAINING: {
'chrome': 80,
'firefox': 74,
'safari': 130400,
'node': 140000,
},
}


Expand Down