Adam Lee
Adam Lee

Reputation: 25768

How to make emcc work?

When I tried to use emcc to compile a C code into Javascript, I received the following error:

emcc tests/hello_world.c 
CRITICAL root: fastcomp in use, but LLVM has not been built with the JavaScript backend as a target, llc reports:
===========================================================================
LLVM (http://llvm.org/):
  LLVM version 3.5.1
  Optimized build with assertions.
  Built Feb 22 2015 (00:08:56).
  Default target: x86_64-apple-darwin13.4.0
  Host CPU: corei7-avx

  Registered Targets:
    x86    - 32-bit X86: Pentium-Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64
===========================================================================
CRITICAL root: you can fall back to the older (pre-fastcomp) compiler core, although that is not recommended, see https://github.com/kripken/emscripten/wiki/LLVM-Backend
INFO     root: (Emscripten: Running sanity checks)
CRITICAL root: failing sanity checks due to previous fastcomp failure

How to solve this? How to fallback to pre-fast-comp?

Upvotes: 11

Views: 6885

Answers (4)

bensch128
bensch128

Reputation: 63

I had the same problem after deleting and reinstalling emsdk

Solution:

  1. Open a new terminal
  2. Goto emsdk install dir
  3. source ./emsdk_env.sh

It's critical to reset the environment variables.

Upvotes: 0

J Evans
J Evans

Reputation: 1122

I am late to the party here but for anyone else with the same problem(s).

Running here on Windows 10 with emscripten-fastcomp built using CMake files for VS2015. Both emscripten and emscripten-fastcomp were cloned from their Github repos.

The documentation here is either out of date or simply incorrect. For starters try running emcc -v, i.e. without any files to compile.

R:\src\tools\emscripten>emcc -v

which should get you this:

> Welcome to Emscripten!
> 
> This is the first time any of the Emscripten tools has been run.
> 
> A settings file has been copied to ~/.emscripten, at absolute path:
> C:\Users\user/.emscripten
> 
> It contains our best guesses for the important paths, which are:
> 
> LLVM_ROOT       = /usr/bin   
> NODE_JS         = R:\apps\nodejs\node.exe   
> EMSCRIPTEN_ROOT = R:\src\tools\emscripten
> 
> Please edit the file if any of those are incorrect.
> 
> This command will now exit. When you are done editing those paths,
> re-run it.
> 

Now edit the LLVM_ROOT variable in

C:\Users\user\.emscripten

such that the default

LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or '/usr/bin') # directory

is changed to something like this

LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or 'R:\\src\\tools\\emscripten-fastcomp\\build\\Debug\\bin') # directory.

Note the escaped backslashes, the standard single backslash \ will not work.

Now you should be able to run the tests and get sensible results as in

emcc -v tests/hello_world.cpp

which will then spew something like this:

> R:\src\tools\emscripten>emcc -v tests/hello_world.cpp
> INFO:root:generating system asset: is_vanilla.txt... (this will be
> cached in "C:\Users\user\.emscripten_cache\is_vanilla.txt" for
> subsequent builds) INFO:root: - ok INFO:root:(Emscripten: Running
> sanity checks) INFO:root:(Emscripten: Running sanity checks) clang
> version 3.9.0 (https://github.com/kripken/emscripten-fastcomp-clang
> 60a7e9a9c22b67309e5b1258d38fadfa481a25d3)
> (https://github.com/kripken/emscripten-fastcomp
> 881bd352731d21c7117ad7e2ece347aacae83965) (emscripten 1.37.0 : 1.37.0)
> Target: asmjs-unknown-emscripten Thread model: posix InstalledDir:
> R:\src\tools\emscripten-fastcomp\build\Debug\bin 
> "R:\\src\\tools\\emscripten-fastcomp\\build\\Debug\\bin\\clang++.exe"
> -cc1 -triple asmjs-unknown-emscripten -emit-llvm-bc -emit-llvm-uselists -disable-free -main-file-name hello_world.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -no-integrated-as -mconstructor-aliases -v -dwarf-column-info -debugger-tuning=gdb -coverage-file "C:\\Users\\user\\AppData\\Local\\Temp\\tmpk4sar7\\hello_world_0.o"
> -nostdsysteminc -nobuiltininc -resource-dir "R:\\src\\tools\\emscripten-fastcomp\\build\\Debug\\bin\\..\\lib\\clang\\3.9.0"
> -D __EMSCRIPTEN_major__=1 -D __EMSCRIPTEN_minor__=37 -D __EMSCRIPTEN_tiny__=0 -D _LIBCPP_ABI_VERSION=2 -Werror=implicit-function-declaration -std=c++03 -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir "R:\\src\\tools\\emscripten" -ferror-limit 19 -fmessage-length 80
> -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -nobuiltininc -nostdsysteminc "-isystemR:\\src\\tools\\emscripten\\system\\include\\libcxx"
> "-isystemR:\\src\\tools\\emscripten\\system\\lib\\libcxxabi\\include"
> "-isystemR:\\src\\tools\\emscripten\\system\\include\\compat"
> "-isystemR:\\src\\tools\\emscripten\\system\\include"
> "-isystemR:\\src\\tools\\emscripten\\system\\include\\SSE"
> "-isystemR:\\src\\tools\\emscripten\\system\\include\\libc"
> "-isystemR:\\src\\tools\\emscripten\\system\\lib\\libc\\musl\\arch\\emscripten"
> "-isystemR:\\src\\tools\\emscripten\\system\\local\\include"
> "-isystemR:\\src\\tools\\emscripten\\system\\include\\SDL" -o
> "C:\\Users\\user\\AppData\\Local\\Temp\\tmpk4sar7\\hello_world_0.o" -x
> c++ tests/hello_world.cpp clang -cc1 version 3.9.0 based upon LLVM
> 3.9.0 default target i686-pc-windows-msvc
> #include "..." search starts here:
> #include <...> search starts here:  R:\src\tools\emscripten\system\include\libcxx 
> R:\src\tools\emscripten\system\lib\libcxxabi\include 
> R:\src\tools\emscripten\system\include\compat 
> R:\src\tools\emscripten\system\include 
> R:\src\tools\emscripten\system\include\SSE 
> R:\src\tools\emscripten\system\include\libc 
> R:\src\tools\emscripten\system\lib\libc\musl\arch\emscripten 
> R:\src\tools\emscripten\system\local\include 
> R:\src\tools\emscripten\system\include\SDL End of search list.

Hope this saves someone else Boxing Day hair-tearing. Good luck.

Upvotes: 2

abcoep
abcoep

Reputation: 646

I solved the same error while I was building Emscripten manually from source.

Emscripten uses its own fork of LLVM - Fastcomp; build it from source by following the instructions here. Then edit ~/.emscripten to have LLVM_ROOT like this

LLVM_ROOT = os.path.expanduser('/home/yourpath/to/emscripten-fastcomp/build/Release/bin') # directory

(it can even be /home/yourpath/to/emscripten-fastcomp/build/bin)

Upvotes: 11

JF Bastien
JF Bastien

Reputation: 6863

This looks like a badly configured install of Emscripten. Did you install with the SDK? It looks like emcc is finding the wrong clang (probably one you already had installed, present in your PATH before the one emcc expects) and not the clang version that usually comes with Emscripten.

Which OS are you on?

On Linux check which clang and echo $PATH to figure out which clang is present.

Try invoking emcc with: EMMAKEN_COMPILER=/path/to/emscripten-fastcomp/bin emcc test/hello.cc this should override the bad path above.

Also try invoking emcc with the -v option to get verbose output.

If none of this works, please post the output of these commands and information on how to reproduce the problem.

Upvotes: 3

Related Questions