Google Closure Compiler hard errors
Summary
After Dupe of h$rts_isProfiled raises the question of further actions over Google Closure Compiler execution support. For now trivial build with google closure compiler will result in failure.
Further MR will contain description how this was handled (with details over applied compromises).
Steps to reproduce
Need to build hello world and execute closure compiler over its javascript-backend output.
The HelloJS.hs
:
module Main where
main :: IO ()
main = putStrLn "Hello, JavaScript!"
Builing:
$ ../ghc-js/_build/stage1/bin/javascript-unknown-ghcjs-ghc -fforce-recomp HelloJS.hs
...
$ google-closure-compiler --compilation_level ADVANCED_OPTIMIZATIONS ./HelloJS.jsexe/all.js --js_output_file ./HelloJS.jsexe/all.min.js
See hard errors (not warnings, for this issue they are skipped) at the end
./HelloJS.jsexe/all.js:7795:8: ERROR - [JSC_UNDEFINED_VARIABLE] variable java is undeclared
7795| java.lang.System.out.print(s);
^^^^
./HelloJS.jsexe/all.js:8432:27: ERROR - [JSC_UNDEFINED_VARIABLE] variable Buffer is undeclared
8432| h$fs.read(real_fd, Buffer.alloc(n), 0, n, pos, function(err, bytesRead, nbuf) {
^^^^^^
./HelloJS.jsexe/all.js:8495:8: ERROR - [JSC_UNDEFINED_VARIABLE] variable putstr is undeclared
8495| putstr(h$decodeUtf8(buf, n, buf_offset));
^^^^^^
./HelloJS.jsexe/all.js:8499:8: ERROR - [JSC_UNDEFINED_VARIABLE] variable printErr is undeclared
8499| printErr(h$decodeUtf8(buf, n, buf_offset));
^^^^^^^^
./HelloJS.jsexe/all.js:8507:37: ERROR - [JSC_UNDEFINED_VARIABLE] variable debug is undeclared
8507| var h$base_stderrLeftover = { f: debug, val: null };
^^^^^
./HelloJS.jsexe/all.js:9747:68: ERROR - [JSC_UNDEFINED_VARIABLE] variable null_ is undeclared
9747| var p = (((ptr_d).arr && (ptr_d).arr[off]) ? (ptr_d).arr[off] : null_); var o = (ptr_d).dv.getInt32(off,true);;
^^^^^
./HelloJS.jsexe/all.js:10273:26: ERROR - [JSC_UNDEFINED_VARIABLE] variable j is undeclared
10273| for(j=x.length-1;j>=0;j--) {
^
./HelloJS.jsexe/all.js:12247:9: ERROR - [JSC_UNDEFINED_VARIABLE] variable ptr is undeclared
12247| return ptr = h$initHeapBufferLen(str_d, str_o, str_d.len);
^^^
./HelloJS.jsexe/all.js:12498:25: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$setCcs_e is undeclared
12498| if(h$stack[h$sp] !== h$setCcs_e) {
^^^^^^^^^^
./HelloJS.jsexe/all.js:12808:11: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$vt_int is undeclared
12808| case h$vt_int:
^^^^^^^^
./HelloJS.jsexe/all.js:12941:22: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$checkInvariants_e is undeclared
12941| h$stack[h$sp] = h$checkInvariants_e;
^^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:13834:33: ERROR - [JSC_UNDEFINED_VARIABLE] variable arr is undeclared
13834| return h$charCodeArrayToString(arr);
^^^
./HelloJS.jsexe/all.js:13925:12: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$EINVAL is undeclared
13925| h$errno = h$EINVAL;
^^^^^^^^
./HelloJS.jsexe/all.js:14112:2: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$fds is undeclared
14112| h$fds[fd].waitRead.push(h$currentThread);
^^^^^
./HelloJS.jsexe/all.js:24517:13: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$stg_cloneMyStackzh is undeclared
24517| if(c) {var g=h$stg_cloneMyStackzh();
^^^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:24518:6: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$stg_decodeStackzh is undeclared
24518| var i=h$stg_decodeStackzh(g);
^^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:25814:6: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$libdwLookupLocation is undeclared
25814| var h=h$libdwLookupLocation(d,e,a,c,f,g);
^^^^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:26282:21: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$libdwPoolRelease is undeclared
26282| h$r3=h$mkFunctionPtr(h$libdwPoolRelease);
^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:26290:2: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$libdwPoolTake is undeclared
26290| a=h$libdwPoolTake();
^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:26307:2: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$libdwGetBacktrace is undeclared
26307| c=h$libdwGetBacktrace(a,b);
^^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:26335:21: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$backtraceFree is undeclared
26335| h$r3=h$mkFunctionPtr(h$backtraceFree);
^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:33154:5: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$fdReady is undeclared
33154| h$r1=h$fdReady(a,1,f,(c>>>0),0);
^^^^^^^^^
./HelloJS.jsexe/all.js:37760:5: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$lookupIPE is undeclared
37760| h$r1=h$lookupIPE(a,c,d,0);
^^^^^^^^^^^
./HelloJS.jsexe/all.js:47403:0: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$reportStackOverflow is undeclared
47403| h$reportStackOverflow(c);
^^^^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:47407:8: ERROR - [JSC_UNDEFINED_VARIABLE] variable h$reportHeapOverflow is undeclared
47407| case(2):h$reportHeapOverflow();
^^^^^^^^^^^^^^^^^^^^
./HelloJS.jsexe/all.js:57052:22: ERROR - [JSC_UNDEFINED_VARIABLE] variable __dirname is undeclared
57052| scriptDirectory = __dirname + '/';
^^^^^^^^^
./HelloJS.jsexe/all.js:57067:4: ERROR - [JSC_VAR_MULTIPLY_DECLARED_ERROR] Variable fs declared more than once. First occurrence: ./HelloJS.jsexe/all.js:7767:8
57067| var fs, nodePath;
^^
27 error(s), 81 warning(s)
Expected behavior
No hard errors. Warnings are fine for now.
Environment
- GHC master hash used:
0acfe391583d77a72051d505f05fab0ada056c49
Optional:
- Operating System: MacOS 13.6.3 (22G436)
- System Architecture: M1