Skip to content

Commit b5ec625

Browse files
authored
Migrate Closure to be located via npm install (#9989)
* Migrate Closure to be located via npm install * Add node to PATH for Closure * Remove littering source map file * Update package-lock.json * Add more heap space to Closure invocation * Work around Closure bug(?) * Skip asm3.test_files because it runs out of memory on CI
1 parent 78aa8ea commit b5ec625

File tree

12 files changed

+258
-755
lines changed

12 files changed

+258
-755
lines changed

package-lock.json

Lines changed: 197 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"private": true,
33
"devDependencies": {
44
"ws": "~0.4.28"
5+
},
6+
"dependencies": {
7+
"google-closure-compiler": "20191111.0.0"
58
}
69
}

src/library_browser.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var LibraryBrowser = {
2424
method: '',
2525
// Each main loop is numbered with a ID in sequence order. Only one main loop can run at a time. This variable stores the ordinal number of the main loop that is currently
2626
// allowed to run. All previous main loops will quit themselves. This is incremented whenever a new main loop is created.
27+
/** @type{number} */
2728
currentlyRunningMainloop: 0,
2829
func: null, // The main loop tick function that will be called at each iteration.
2930
arg: 0, // The argument that will be passed to the main loop. (of type void*)
@@ -1194,7 +1195,20 @@ var LibraryBrowser = {
11941195
};
11951196
}
11961197

1198+
#if USE_CLOSURE_COMPILER
1199+
// Closure compiler bug(?): Closure does not see that the assignment
1200+
// var thisMainLoopId = Browser.mainLoop.currentlyRunningMainloop
1201+
// is a value copy of a number (even with the JSDoc @type annotation)
1202+
// but optimizeis the code as if the assignment was a reference assignment,
1203+
// which results in Browser.mainLoop.pause() not working. Hence use a
1204+
// workaround to make Closure believe this is a value copy that should occur:
1205+
// (TODO: Minimize this down to a small test case and report - was unable
1206+
// to reproduce in a small written test case)
1207+
/** @type{number} */
1208+
var thisMainLoopId = (function(){return Browser.mainLoop.currentlyRunningMainloop; })();
1209+
#else
11971210
var thisMainLoopId = Browser.mainLoop.currentlyRunningMainloop;
1211+
#endif
11981212

11991213
Browser.mainLoop.runner = function Browser_mainLoop_runner() {
12001214
if (ABORT) return;

tests/test_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4847,6 +4847,7 @@ def test_files(self):
48474847
elif '-O3' in self.emcc_args and not self.is_wasm():
48484848
print('closure 2')
48494849
self.emcc_args += ['--closure', '2', '-Wno-almost-asm'] # Use closure 2 here for some additional coverage
4850+
return self.skipTest('TODO: currently skipped because CI runs out of memory running Closure in this test!')
48504851

48514852
self.emcc_args += ['-s', 'FORCE_FILESYSTEM=1', '--pre-js', 'pre.js']
48524853

tests/test_sanity.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -245,34 +245,6 @@ def make_executable(name):
245245
elif 'runner.py' not in ' '.join(command):
246246
self.assertContained('ERROR', output) # sanity check should fail
247247

248-
def test_closure_compiler(self):
249-
CLOSURE_FATAL = 'fatal: closure compiler'
250-
CLOSURE_WARNING = 'does not exist'
251-
252-
# Sanity check should find closure
253-
restore_and_set_up()
254-
output = self.check_working(EMCC)
255-
self.assertNotContained(CLOSURE_FATAL, output)
256-
self.assertNotContained(CLOSURE_WARNING, output)
257-
258-
# Append a bad path for closure, will warn
259-
f = open(CONFIG_FILE, 'a')
260-
f.write('CLOSURE_COMPILER = "/tmp/nowhere/nothingtoseehere/kjadsfkjwelkjsdfkqgas/nonexistent.txt"\n')
261-
f.close()
262-
output = self.check_working(EMCC, CLOSURE_WARNING)
263-
264-
# And if you actually try to use the bad path, will be fatal
265-
f = open(CONFIG_FILE, 'a')
266-
f.write('CLOSURE_COMPILER = "/tmp/nowhere/nothingtoseehere/kjadsfkjwelkjsdfkqgas/nonexistent.txt"\n')
267-
f.close()
268-
output = self.check_working([EMCC, '-s', '--closure', '1'] + MINIMAL_HELLO_WORLD + ['-O2'], CLOSURE_FATAL)
269-
270-
# With a working path, all is well
271-
restore_and_set_up()
272-
try_delete('a.out.js')
273-
output = self.check_working([EMCC, '-s', '--closure', '1'] + MINIMAL_HELLO_WORLD + ['-O2'], '')
274-
self.assertExists('a.out.js', output)
275-
276248
def test_llvm(self):
277249
LLVM_WARNING = 'LLVM version appears incorrect'
278250

0 commit comments

Comments
 (0)