Hi,
I've now done a fresh checkout of emsdk and followed the
instructions you posted in
https://github.com/kripken/emscripten/issues/4682#issuecomment-260159020
. Unfortunately I still experienced some issues with the prebuilt
Clang and Emscripten distributions. This was on a 64bit Ubuntu 14.04
box. Fortunately I did manage to work around these issue. Details below:
The binary toolchain downloaded fine, and the SDK activated fine. Unfortunately emcc would not run:
ljw@ljw-desktop:~/src/emsdk$ ./emsdk activate --embedded sdk-nightly-latest-64bit
Writing .emscripten configuration file to Emscripten SDK directory /home/ljw/src/emsdk
The Emscripten configuration file /home/ljw/src/emsdk/.emscripten has been rewritten with the following contents:
import os
emsdk_path=os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\', '/')
LLVM_ROOT='' + emsdk_path + '/clang/nightly-e1.36.14-2016_12_08_07_01'
NODE_JS='' + emsdk_path + '/node/4.1.1_64bit/bin/node'
EMSCRIPTEN_ROOT='' + emsdk_path + '/emscripten/nightly-1.36.14-2016_12_08_07_01'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = '' + emsdk_path + '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
To
conveniently access the selected set of tools from the command line,
consider adding the following directories to PATH, or call 'source
./emsdk_env.sh' to do this for you.
/home/ljw/src/emsdk:/home/ljw/src/emsdk/clang/nightly-e1.36.14-2016_12_08_07_01:/home/ljw/src/emsdk/node/4.1.1_64bit/bin:/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01
ljw@ljw-desktop:~/src/emsdk$ source ./emsdk_env.sh
Adding directories to PATH:
PATH += /home/ljw/src/emsdk
PATH += /home/ljw/src/emsdk/clang/nightly-e1.36.14-2016_12_08_07_01
PATH += /home/ljw/src/emsdk/node/4.1.1_64bit/bin
PATH += /home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01
Setting environment variables:
EMSDK = /home/ljw/src/emsdk
EM_CONFIG = /home/ljw/src/emsdk/.emscripten
EM_CACHE = /home/ljw/src/emsdk/.emscripten_cache
EMSCRIPTEN = /home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01
I then ran emcc and got the following error:
ljw@ljw-desktop:~/src/emsdk$ emcc
CRITICAL:root:Could not verify LLVM version: argument of type 'NoneType' is not iterable
/home/ljw/src/emsdk/clang/nightly-e1.36.14-2016_12_08_07_01/llc:
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not
found (required by
/home/ljw/src/emsdk/clang/nightly-e1.36.14-2016_12_08_07_01/llc)
/home/ljw/src/emsdk/clang/nightly-e1.36.14-2016_12_08_07_01/llc:
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not
found (required by
/home/ljw/src/emsdk/clang/nightly-e1.36.14-2016_12_08_07_01/llc)
CRITICAL:root:fastcomp in use, but LLVM has not been built with the JavaScript backend as a target, llc reports:
===========================================================================
(no targets could be identified: need more than 1 value to unpack)
===========================================================================
CRITICAL:root:you
can fall back to the older (pre-fastcomp) compiler core, although that
is not recommended, see
http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.htmlINFO:root:(Emscripten: Running sanity checks)
CRITICAL:root:failing sanity checks due to previous fastcomp failure
As
I mentioned in my previous message, the "'GLIBCXX_*' not found" errors
above are due to emscripten-fastcomp being built with GCC 5.X. In order
to run these programs I needed a copy of libstdc++.so from GCC5.
Building GCC5 would be time consuming, so I instead obtained an
appropriate libstdc++.so binary from the ubuntu-toolchain-r PPA. I
didn't want to modify my host system so I downloaded the deb, verified
and extracted it, and then put the libstdc++.so in my path:
wget
http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/pool/main/g/gcc-5/libstdc++6_5.1.0-0ubuntu11~10.04.2_amd64.debwget
http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/dists/lucid/Releasewget
http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/dists/lucid/Release.gpgwget
http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/dists/lucid/main/binary-amd64/PackagesNote that I've downloaded the Lucid version (Ubuntu 10.04). I just did this so I could use the same binary on both Ubuntu 12.04 and 14.04 (though I've not tested 12.04 yet).
mv Release.gpg Release.asc
Then verified:
ljw@ljw-desktop:~/src/emsdk/my_deb$ gpg --verify Release.asc
gpg: Signature made Sun 26 Apr 2015 05:11:17 BST using RSA key ID BA9EF27F
gpg: Good signature from "Launchpad Toolchain builds"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 60C3 1780 3A41 BA51 845E 371A 1E93 77A2 BA9E F27F
ljw@ljw-desktop:~/src/emsdk/my_deb$ sha256sum Packages
fed61ce85f21b5a5e9c5d9e6c76ad3f5b24a775750fff61c5b224e2c8357f606 Packages
ljw@ljw-desktop:~/src/emsdk/my_deb$ grep fed61ce85f21b5a5e9c5d9e6c76ad3f5b24a775750fff61c5b224e2c8357f606 Release
fed61ce85f21b5a5e9c5d9e6c76ad3f5b24a775750fff61c5b224e2c8357f606 328682 main/binary-amd64/Packages
ljw@ljw-desktop:~/src/emsdk/my_deb$ sha256sum libstdc++6_5.1.0-0ubuntu11~10.04.2_amd64.deb
3742f82b49b214f03c3531dd63be860ee63409788497f1b368cd465cabb5ec1c libstdc++6_5.1.0-0ubuntu11~10.04.2_amd64.deb
ljw@ljw-desktop:~/src/emsdk/my_deb$ grep 3742f82b49b214f03c3531dd63be860ee63409788497f1b368cd465cabb5ec1c -A 9 -B 15 Packages
Package: libstdc++6
Source: gcc-5
Priority: important
Section: libs
Installed-Size: 2040
Maintainer: Ubuntu Core developers <
ubuntu-dev...@lists.ubuntu.com>
Architecture: amd64
Version: 5.1.0-0ubuntu11~10.04.2
Replaces: libstdc++6-5-dbg (<< 4.9.0-3)
Depends: gcc-5-base (= 5.1.0-0ubuntu11~10.04.2), libc6 (>= 2.11), libgcc1 (>= 1:4.1.1)
Conflicts: scim (<< 1.4.2-1)
Filename: pool/main/g/gcc-5/libstdc++6_5.1.0-0ubuntu11~10.04.2_amd64.deb
Size: 525688
MD5sum: 91e20fab6550dbe12ba4287a2cabc737
SHA1: 4f79929ae9f17ab7ca95fbd9b9629c1ec8c66421
SHA256: 3742f82b49b214f03c3531dd63be860ee63409788497f1b368cd465cabb5ec1c
Description: GNU Standard C++ Library v3
This package contains an additional runtime library for C++ programs
built with the GNU compiler.
.
libstdc++-v3 is a complete rewrite from the previous libstdc++-v2, which
was included up to g++-2.95. The first version of libstdc++-v3 appeared
in g++-3.0.
Original-Maintainer: Debian GCC Maintainers <
debia...@lists.debian.org>
I then extracted the deb and put the libstdc++.so in my LD_LIBRARY_PATH:
ljw@ljw-desktop:~/src/emsdk/my_deb$ ar xv libstdc++6_5.1.0-0ubuntu11~10.04.2_amd64.deb
x - debian-binary
x - control.tar.gz
x - data.tar.gz
ljw@ljw-desktop:~/src/emsdk/my_deb$ tar xvf data.tar.gz
./
./usr/
./usr/lib/
./usr/lib/libstdc++.so.6.0.21
...
./usr/lib/libstdc++.so.6
./usr/share/doc/libstdc++6
ljw@ljw-desktop:~/src/emsdk/my_deb$ cd usr/lib/
ljw@ljw-desktop:~/src/emsdk/my_deb/usr/lib$ ls
libstdc++.so.6 libstdc++.so.6.0.21
ljw@ljw-desktop:~/src/emsdk/my_deb/usr/lib$ export LD_LIBRARY_PATH=${PWD}:$LD_LIBRARY_PATH
I was then able to run emcc:
ljw@ljw-desktop:~$ emcc
INFO:root:(Emscripten: Running sanity checks)
WARNING:root:no input files
I then attempted to run:
python $EMSCRIPTEN/embuilder.py build ALL
This was mostly successful, but it errored out building the native_optimizer:
INFO:root:building and verifying native_optimizer
module.js:338
throw err;
^
Error: Cannot find module '../tools/eliminator/node_modules/uglify-js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/js-optimizer.js:132:14)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
Traceback (most recent call last):
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/emcc", line 13, in <module>
emcc.run()
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/emcc.py", line 1877, in run
JSOptimizer.flush()
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/emcc.py", line 1773, in flush
run_passes(chunks[0], title, just_split=False, just_concat=False)
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/emcc.py", line 1746, in run_passes
final = shared.Building.js_optimizer(final, passes, debug_level >=
4, JSOptimizer.extra_info, just_split=just_split,
just_concat=just_concat)
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/shared.py", line 1829, in js_optimizer
ret = js_optimizer.run(filename, passes, NODE_JS, debug, extra_info, just_split, just_concat)
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/js_optimizer.py", line 559, in run
return temp_files.run_and_clean(lambda: run_on_js(filename, passes,
js_engine, source_map, extra_info, just_split, just_concat))
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/tempfiles.py", line 78, in run_and_clean
return func()
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/js_optimizer.py", line 559, in <lambda>
return temp_files.run_and_clean(lambda: run_on_js(filename, passes,
js_engine, source_map, extra_info, just_split, just_concat))
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/js_optimizer.py", line 378, in run_on_js
asm_shell_pre, asm_shell_post = minifier.minify_shell(asm_shell,
'minifyWhitespace' in passes, source_map).split('EMSCRIPTEN_FUNCS();');
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/js_optimizer.py", line 247, in minify_shell
assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + output
AssertionError: Error in js optimizer:
Traceback (most recent call last):
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/embuilder.py", line 147, in <module>
''', ['optimizer.2.exe'], ['-O2'])
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/embuilder.py", line 69, in build
shared.Building.emcc(temp, args, output_filename=temp_js)
File "/home/ljw/src/emsdk/emscripten/nightly-1.36.14-2016_12_08_07_01/tools/shared.py", line 1722, in emcc
assert os.path.exists(output_filename), 'emcc could not create output file: ' + output_filename
AssertionError: emcc could not create output file: /home/ljw/src/emsdk/tmp/tmpMioyG3.js
For
some reason uglify-js does not seem to be distributed with the
Emscripten tarball downloaded by emsdk. Is this intended? I was able to
resolve this issue by copying across tools/eliminator/node_modules from a
git checkout of Emscripten.
I'm also slightly dubious about my approach of using libstdc++.so from
GCC5. This makes emscripten-fastcomp binaries work, but I expected it to fail when I attempted
to run the native optimizer. The native optimizer will be built using
the system copy of GCC 4.8. This will link against libstdc++ from GCC
4.8, but at runtime (due to the LD_LIBRARY_PATH) it will run against the
libstdc++ from GCC5. In theory these two versions of libstdc++ are ABI
incompatible for C++11 code. I ran python tests/runner.py random100 and
got no unexpected failures (other than SIMD/pthread stuff). Maybe we got
lucky and the native optimizer just doesn't happen to hit any of the
incompatible ABI paths. I suppose that if it did become a problem I
could just reset the LD_LIBRARY_PATH whenever executing the native
optimizer.
Thanks
Liam Wilson