[setup/question] File not found for hello.c demo #822

Closed
jadekler opened this Issue Nov 4, 2016 · 23 comments

Projects

None yet

9 participants

@jadekler
jadekler commented Nov 4, 2016

Hello! I'm on a clean mac gcc and cmake installed. When I try to run through the getting-started guides, I run into the following. Any ideas?

 2016-11-04 11:47:43 ☆  |2.3.0| DEN_Recently_Imaged in ~/dev/webassembly/hello
○ → emcc hello.c -s WASM=1 -o hello.html
INFO:root:generating system asset: is_vanilla.txt... (this will be cached in "/Users/pivotal/.emscripten_cache/is_vanilla.txt" for subsequent builds)
INFO:root: - ok
INFO:root:(Emscripten: Running sanity checks)
WARNING:root:retrieving port: binaryen from https://github.com/WebAssembly/binaryen/archive/version_18.zip
WARNING:root:unpacking port: binaryen
INFO:root:generating port: binaryen_tag_version_18.txt... (this will be cached in "/Users/pivotal/.emscripten_cache/asmjs/binaryen_tag_version_18.txt" for subsequent builds)
INFO:root:building port: binaryen
-- The C compiler identification is Clang 3.9.0
-- The CXX compiler identification is Clang 3.9.0
-- Check for working C compiler: /Users/pivotal/dev/webassembly/emsdk_portable/clang/fastcomp/build_incoming_64/bin/clang
-- Check for working C compiler: /Users/pivotal/dev/webassembly/emsdk_portable/clang/fastcomp/build_incoming_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /Users/pivotal/dev/webassembly/emsdk_portable/clang/fastcomp/build_incoming_64/bin/clang++
-- Check for working CXX compiler: /Users/pivotal/dev/webassembly/emsdk_portable/clang/fastcomp/build_incoming_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Building with -std=c++11
-- Building with -msse2
-- Building with -mfpmath=sse
-- Building with -Wall
-- Building with -Werror
-- Building with -Wextra
-- Building with -Wno-unused-parameter
-- Building with -fno-omit-frame-pointer
-- Building with -fPIC
-- Building with -O2
-- Building with -UNDEBUG
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   binaryen

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18
Scanning dependencies of target asmjs
Scanning dependencies of target wasm
Scanning dependencies of target support
Scanning dependencies of target emscripten-optimizer
Scanning dependencies of target passes
[  4%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/simple_ast.cpp.o
[  6%] Building CXX object src/asmjs/CMakeFiles/asmjs.dir/asm_v_wasm.cpp.o
[  6%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o
[  6%] Building CXX object src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o
[  7%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o
[  9%] Building CXX object src/support/CMakeFiles/support.dir/archive.cpp.o
[ 10%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm.cpp.o
In file included from In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/asmjs/asm_v_wasm.cpp/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/support/archive.cpp::1717:
:
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/asm_v_wasm.h:/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/support/archive.h20::
27:10/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/mixed_arena.h:: 20:10fatal error::  'cstdint'fatal error/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/emscripten-optimizer/optimizer-shared.cpp:  :file17 :'atomic'not10  :filefound  not
 foundfatal error:
'limits'In file included from  /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/emscripten-optimizer/simple_ast.cppfile: 17not:
 found/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/emscripten-optimizer/simple_ast.h:
20:10: fatal error: #include <atomic>#include <cstdint>'algorithm'

 file         ^         ^

not found
#include <limits>
         ^
#include <algorithm>
         ^
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/emscripten-optimizer/parser.cpp:17:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/emscripten-optimizer/parser.h:25:10: fatal error: 'algorithm' file not found
#include <algorithm>
         ^
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/asmjs/shared-constants.cpp:17:
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/asmjs/shared-constants.h:20:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/emscripten-optimizer/istring.h:22:10: fatal error: 'unordered_set' file not found
#include <unordered_set>
         ^
[ 12%] Building CXX object src/passes/CMakeFiles/passes.dir/pass.cpp.o
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm/wasm.cpp:17:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm.h:46:10: fatal error: 'cassert' file not found
#include <cassert>
         ^
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/passes/pass.cpp:17:10: fatal error: 'chrono' file not found
#include <chrono>
         ^
1 error generated.
make[2]: *** [src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
1 error generated.
[ 13%] Building CXX object src/support/CMakeFiles/support.dir/bits.cpp.o
make[2]: *** [src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 15%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm-binary.cpp.o
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/support/bits.cpp:19:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/support/bits.h:20:10: fatal error: 'climits' file not found
#include <climits>
         ^
1 error generated.
make[2]: *** [src/support/CMakeFiles/support.dir/bits.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm/wasm-binary.cpp:17:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm-binary.h:24:10: fatal error: 'cassert' file not found
#include <cassert>
         ^
1 error generated.
[ 16%] Building CXX object src/passes/CMakeFiles/passes.dir/CoalesceLocals.cpp.o
make[2]: *** [src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/simple_ast.cpp.o] Error 1
1 error generated.
make[2]: *** [src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o] Error 1
make[1]: *** [src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 18%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm-s-parser.cpp.o
[ 20%] Building CXX object src/passes/CMakeFiles/passes.dir/CodePushing.cpp.o
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/passes/CoalesceLocals.cpp:25:10: fatal error: 'algorithm' file not found
#include <algorithm>
         ^
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm/wasm-s-parser.cpp:17:
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm-s-parser.h:25:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm.h:46:10: fatal error: 'cassert' file not found
#include <cassert>
         ^
1 error generated.
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/passes/CodePushing.cpp:22:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm.h:46:10: fatal error: 'cassert' file not found
#include <cassert>
         ^
make[2]: *** [src/support/CMakeFiles/support.dir/archive.cpp.o] Error 1
make[1]: *** [src/support/CMakeFiles/support.dir/all] Error 2
[ 21%] Building CXX object src/passes/CMakeFiles/passes.dir/DeadCodeElimination.cpp.o
1 error generated.
make[2]: *** [src/asmjs/CMakeFiles/asmjs.dir/asm_v_wasm.cpp.o] Error 1
make[1]: *** [src/asmjs/CMakeFiles/asmjs.dir/all] Error 2
[ 23%] Building CXX object src/passes/CMakeFiles/passes.dir/DuplicateFunctionElimination.cpp.o
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/passes/DeadCodeElimination.cpp:31:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm.h:46:10: fatal error: 'cassert' file not found
#include <cassert>
         ^
1 error generated.
make[2]: *** [src/wasm/CMakeFiles/wasm.dir/wasm.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/passes/DuplicateFunctionElimination.cpp:23:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm.h:46:10: fatal error: 'cassert' file not found
#include <cassert>
         ^
1 error generated.
[ 24%] Building CXX object src/passes/CMakeFiles/passes.dir/ExtractFunction.cpp.o
make[2]: *** [src/passes/CMakeFiles/passes.dir/pass.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/passes/ExtractFunction.cpp:21:
/Users/pivotal/.emscripten_ports/binaryen/binaryen-version_18/src/wasm.h:46:10: fatal error: 'cassert' file not found
#include <cassert>
         ^
1 error generated.
make[2]: *** [src/passes/CMakeFiles/passes.dir/CoalesceLocals.cpp.o] Error 1
1 error generated.
make[2]: *** [src/passes/CMakeFiles/passes.dir/CodePushing.cpp.o] Error 1
1 error generated.
make[2]: *** [src/passes/CMakeFiles/passes.dir/DeadCodeElimination.cpp.o] Error 1
1 error generated.
1 error generated.
make[2]: *** [src/passes/CMakeFiles/passes.dir/ExtractFunction.cpp.o] Error 1
make[2]: *** [src/passes/CMakeFiles/passes.dir/DuplicateFunctionElimination.cpp.o] Error 1
make[1]: *** [src/passes/CMakeFiles/passes.dir/all] Error 2
1 error generated.
1 error generated.
make[2]: *** [src/wasm/CMakeFiles/wasm.dir/wasm-s-parser.cpp.o] Error 1
make[2]: *** [src/wasm/CMakeFiles/wasm.dir/wasm-binary.cpp.o] Error 1
make[1]: *** [src/wasm/CMakeFiles/wasm.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/emcc", line 13, in <module>
    emcc.run()
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/emcc.py", line 1337, in run
    compile_source_file(i, input_file)
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/emcc.py", line 1326, in compile_source_file
    args = get_bitcode_args([input_file]) + ['-emit-llvm', '-c', '-o', output_file]
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/emcc.py", line 1309, in get_bitcode_args
    args = system_libs.process_args(args, shared.Settings)
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/tools/system_libs.py", line 636, in process_args
    args = port.process_args(Ports, args, settings, shared)
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/tools/ports/binaryen.py", line 34, in process_args
    get(ports, settings, shared)
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/tools/ports/binaryen.py", line 29, in get
    return [shared.Cache.get('binaryen_tag_' + TAG, create, what='port', extension='.txt')]
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/tools/cache.py", line 95, in get
    temp = creator()
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/tools/ports/binaryen.py", line 24, in create
    ports.build_native(os.path.join(ports.get_dir(), 'binaryen', 'binaryen-' + TAG))
  File "/Users/pivotal/dev/webassembly/emsdk_portable/emscripten/incoming/tools/system_libs.py", line 607, in build_native
    subprocess.check_call(['cmake', '--build', '.'] + make_args, env=env)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--', '-j', '8']' returned non-zero exit status 2

@kripken
Member
kripken commented Nov 4, 2016

Hmm, looks like some OS X-specific issue I don't understand. First thing I would try, though, is to try to clone and build binaryen manually yourself using cmake . and then make, instead of letting emcc do it. If that works, maybe emcc is building it wrong somehow. It not, maybe cmake isn't set up properly on your machine?

@EvanWieland

@jadekler I'm on MacOs too and am having the same issue. Any luck?

@jadekler
jadekler commented Nov 5, 2016

@EvanWieland Not yet. :/ Thanks @kripken will give it a shot

@ojii
ojii commented Nov 10, 2016

@kripken I manually built binaryen from master from git, set BINARYEN_ROOT to that directory in ~/.emscripten and ran the tutorial again with no problem. so looks like it's a problem with how emcc builds it.

@tomgwozdz

I'm having the same issue, but it worked fine for me around November 1st or so, on OSX. a few days later it started having trouble, if that helps narrow down the cause.

@kripken
Member
kripken commented Nov 10, 2016

If this recently changed, can you please bisect to find when exactly?

@tomgwozdz

I'm not sure how to do that. I was just following these steps to get it running: http://webassembly.org/getting-started/developers-guide/ At what stage would I be bisecting? And on what repo? I'm sure how emsdk does things internally.

@kripken
Member
kripken commented Nov 11, 2016

I believe under the sdk directory is a directory with a git repo, that you can bisect in. Alternatively, you could just do your own git checkout of the main emscripten repo and bisect on that. Bisecting on current incoming (which breaks) vs Nov 1 (or when it still worked).

@kripken kripken referenced this issue in WebAssembly/website Nov 15, 2016
Closed

Cant compile Hello World example on macOS Sierra #54

@kripken
Member
kripken commented Nov 15, 2016

@juj - this looks like a cmake issue on OS X, which you know a lot about, if you have time please take a look.

@Nithanaroy

I was able to get it working by following these steps https://gitlab.sd.apple.com/npasumarthy/my-first-webassembly
README.pdf

@jbajwa
jbajwa commented Nov 15, 2016 edited

@kripken
Hi, I am experiencing the same issue on my mac. I did a git bisect, and the first bad commit is kripken/emscripten@1f5e49b
Removing env from subprocess.check_call(['cmake', '--build', '.'] + make_args, env=env) and subprocess.check_call(['cmake', '-DCMAKE_BUILD_TYPE=' + cmake_build_type, '.'], env=env) fixes the issue, so maybe an env variable is incorrectly being deleted on mac? Hope this helps.

@MarkHarper

@jbajwa, what steps did you follow after removing env?

@jbajwa
jbajwa commented Nov 16, 2016

I'm able to generate the wasm/html file by not passing the env variable to cmake, but when I run the html file it gives an exception thrown error, haven't looked into it further. For now I've manually built binaryen as suggested in the earlier comments (if you don't want to build manually then the other option is to checkout a branch in your local repo from kripken/emscripten@a28973d)

@juanpicado

I'm experiencing the same issue, I share this http://stackoverflow.com/a/40625922/308341 FYI.

@kripken
Member
kripken commented Nov 16, 2016 edited

Thanks @jbajwa, that's very helpful.

What I think is going on here is that that commit makes us use the clang from fastcomp to build. And it seems to not work properly. While when you build binaryen yourself, you are using your machine's system compiler which does work.

To verify that theory, if you build binaryen yourself but force fastcomp to be used, does it fail? Can try CC=/home/..path-to-fastcomp../clang CXX=/home/../clang++ LD=/home/../clang++ cmake . and then make, instead of just cmake . and make.

If that is the issue, then the solution is for that python script to not use fastcomp's clang. But also we can't use the inherited env, as it may be modified by emmake. So we need to either

  1. Find the system compiler and set that.
  2. Find a way in python to create a subprocess that does not inherit the env, so it does the exact same as if you run in the shell, and so gets the system compiler.
@jbajwa
jbajwa commented Nov 16, 2016

@kripken
Yes, you're correct, it is failing to build with fastcomp/../clang. Maybe in the python script could have some logic for mac?

if sys.platform.startswith('darwin') 
  call cmake without env
else
  call cmake with env

Although, the system compiler might not be as upto date as fastcomp/clang?

@kripken
Member
kripken commented Nov 17, 2016

Yeah, there are risks either way. But using the system compiler seems safer for now, unless someone else has a better idea. I have a proposed fix in kripken/emscripten#4734, please test if you can (I don't have an OS X machine, so I can't).

@kripken
Member
kripken commented Nov 17, 2016

The proposed fix was merged, and is confirmed to work, so this should now be ok. Please comment/reopen if not.

@kripken kripken closed this Nov 17, 2016
@jbajwa
jbajwa commented Nov 17, 2016

@kripken
Sorry for the delay. I just tried to compile with your changes and its building without error although when I open the html file in the browser I get this error "Exception thrown, see JavaScript console"
Following information in the console log:

input.html:1249 trying binaryen method: native-wasm
printErr @ input.html:1249
input.html:1249 no native wasm support detected
printErr @ input.html:1249
input.js:336 Uncaught no binaryen method succeeded. consider enabling more options, like interpreting, if you want that: https://github.com/kripken/emscripten/wiki/WebAssembly#binaryen-methods

I don't see this error if I checkout from kripken/emscripten@a28973d

@kripken
Member
kripken commented Nov 17, 2016

That looks unrelated. We recently changed binaryen's default from trying native support, then interpreting if not, to just using native support. That makes sense since at this point browser support in dev versions is pretty consistent, and including interpreter support can be confusing (when it ends up running, it's slow, and also the build is very big).

The link in that error message shows how to turn on interpreting, as it was before, if you want that.

Otherwise, make sure you have wasm enabled in a browser that supports it.

@jbajwa
jbajwa commented Nov 17, 2016

I enabled webassembly in chrome chrome://flags/#enable-webassembly. Getting this error now

input.html:1249 trying binaryen method: native-wasm
printErr @ input.html:1249
input.js:172 Uncaught TypeError: Right-hand side of 'instanceof' is not an object
    at doNativeWasm (http://localhost:8080/input.js:172:32)
    at Object.Module.asm (http://localhost:8080/input.js:326:23)
    at http://localhost:8080/input.js:2176:1

Am I missing anything?

@kripken
Member
kripken commented Nov 18, 2016

What's on the failing line? What is it trying to instanceof?

Worth making sure that is very latest chrome canary, as bugs are constantly being fixed. Also I would try it in latest firefox nightly for comparison.

@jbajwa
jbajwa commented Nov 18, 2016

OK, so I realized my mistake. I wasn't using chrome canary. :) Its working as expected on Canary with webassembly enabled. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment