lord / wargo

Easy Rust to WebAssembly
MIT License
261 stars 9 forks source link

failure to link with emcc #10

Closed durka closed 7 years ago

durka commented 7 years ago

wargo build doesn't work on my machine. OSX 10.9.5, rustc beta 1.22:

durska:wasm-meow alex$ wargo build
  Setup wasm using emcc already in $PATH
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.1
clang version 3.9.0  (emscripten 1.37.1 : 1.37.1)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /usr/local/opt/emscripten/libexec/llvm/bin
INFO:root:(Emscripten: Running sanity checks)
  Setup wasm running 'cargo build --target=wasm32-unknown-emscripten'
   Compiling wasm-meow v0.1.0 (file:///Users/alex/Programming/rust/wasm-meow)
error: linking with `emcc` failed: exit code: 1
  |
  = note: "emcc" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib" "/Users/alex/Programming/rust/wasm-meow/target/wasm32-unknown-emscripten/debug/deps/wasm_meow.wasm_meow0.rust-cgu.o" "/Users/alex/Programming/rust/wasm-meow/target/wasm32-unknown-emscripten/debug/deps/wasm_meow.wasm_meow1.rust-cgu.o" "-o" "/Users/alex/Programming/rust/wasm-meow/target/wasm32-unknown-emscripten/debug/deps/wasm_meow.js" "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"___rdl_usable_size\",\"___rdl_alloc\",\"___rdl_oom\",\"___rdl_realloc_excess\",\"___rdl_realloc\",\"___rdl_alloc_zeroed\",\"___rdl_dealloc\",\"___rdl_grow_in_place\",\"___rdl_shrink_in_place\",\"___rdl_alloc_excess\",\"_rust_eh_personality\"]" "/Users/alex/Programming/rust/wasm-meow/target/wasm32-unknown-emscripten/debug/deps/wasm_meow.crate.allocator.rust-cgu.o" "-O0" "--memory-init-file" "0" "-g4" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "/Users/alex/Programming/rust/wasm-meow/target/wasm32-unknown-emscripten/debug/deps" "-L" "/Users/alex/Programming/rust/wasm-meow/target/debug/deps" "-L" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libstd-fd5a5994a7119be8.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc_system-374bc440b9662bf0.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/librand-203741dee36916a0.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libpanic_unwind-0dd559b18d33e598.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc-a4098e5f2362fad4.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libstd_unicode-33573075d0137284.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libunwind-7a681ccc5f56153b.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/liblibc-961feb37bd08a60c.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libcore-ec8cb847d01a1f4d.rlib" "/Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libcompiler_builtins-86c9d660ff58949a.rlib" "-l" "c" "-s" "BINARYEN=1" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1"
  = note: WARNING:root:retrieving port: binaryen from https://github.com/WebAssembly/binaryen/archive/version_21.zip
          WARNING:root:unpacking port: binaryen
          INFO:root:generating port: binaryen_tag_version_21.txt... (this will be cached in "/Users/alex/.emscripten_cache/asmjs/binaryen_tag_version_21.txt" for subsequent builds)
          INFO:root:building port: binaryen
          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.

          INFO:root: - ok
          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libstd-fd5a5994a7119be8.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc_system-374bc440b9662bf0.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/librand-203741dee36916a0.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libpanic_unwind-0dd559b18d33e598.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc-a4098e5f2362fad4.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libstd_unicode-33573075d0137284.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libunwind-7a681ccc5f56153b.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/liblibc-961feb37bd08a60c.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libcore-ec8cb847d01a1f4d.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          /usr/local/opt/emscripten/libexec/llvm/bin/llvm-nm: /Users/alex/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-emscripten/lib/libcompiler_builtins-86c9d660ff58949a.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered

          INFO:root:generating system library: wasm-libc.bc... (this will be cached in "/Users/alex/.emscripten_cache/asmjs/wasm-libc.bc" for subsequent builds)
          INFO:root: - ok
          error: Invalid record (Producer: 'LLVM4.0.1' Reader: 'LLVM 3.9.0')
          Traceback (most recent call last):
            File "/usr/local/bin/emcc", line 13, in <module>
              emcc.run()
            File "/usr/local/Cellar/emscripten/1.37.1/libexec/emcc.py", line 1605, in run
              final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL)
            File "/usr/local/Cellar/emscripten/1.37.1/libexec/tools/shared.py", line 1637, in llvm_opt
              assert os.path.exists(target), 'Failed to run llvm optimizations: ' + output
          AssertionError: Failed to run llvm optimizations:
          -- The C compiler identification is AppleClang 6.0.0.6000057
          -- The CXX compiler identification is AppleClang 6.0.0.6000057
          -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
          -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
          -- Detecting C compiler ABI info
          -- Detecting C compiler ABI info - done
          -- Detecting C compile features
          -- Detecting C compile features - done
          -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
          -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
          -- Detecting CXX compiler ABI info
          -- Detecting CXX compiler ABI info - done
          -- Detecting CXX compile features
          -- Detecting CXX compile features - 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
          -- Generating done
          -- Build files have been written to: /Users/alex/.emscripten_ports/binaryen/binaryen-version_21
          Scanning dependencies of target asmjs
          Scanning dependencies of target support
          Scanning dependencies of target wasm
          [  1%] Building CXX object src/asmjs/CMakeFiles/asmjs.dir/asm_v_wasm.cpp.o
          [  2%] Building CXX object src/support/CMakeFiles/support.dir/archive.cpp.o
          [  4%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm.cpp.o
          Scanning dependencies of target passes
          [  5%] Building CXX object src/passes/CMakeFiles/passes.dir/pass.cpp.o
          [  7%] Building CXX object src/support/CMakeFiles/support.dir/bits.cpp.o
          [  8%] Building CXX object src/support/CMakeFiles/support.dir/colors.cpp.o
          [ 10%] Building CXX object src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o
          [ 11%] Building CXX object src/support/CMakeFiles/support.dir/command-line.cpp.o
          [ 13%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm-binary.cpp.o
          [ 14%] Linking CXX static library ../../lib/libasmjs.a
          [ 14%] Built target asmjs
          [ 16%] Building CXX object src/passes/CMakeFiles/passes.dir/CoalesceLocals.cpp.o
          Scanning dependencies of target emscripten-optimizer
          [ 17%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o
          [ 19%] Building CXX object src/support/CMakeFiles/support.dir/file.cpp.o
          [ 20%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o
          [ 22%] Building CXX object src/support/CMakeFiles/support.dir/safe_integer.cpp.o
          [ 23%] Building CXX object src/support/CMakeFiles/support.dir/threads.cpp.o
          [ 25%] Linking CXX static library ../../lib/libsupport.a
          [ 25%] Built target support
          [ 26%] Building CXX object src/passes/CMakeFiles/passes.dir/CodePushing.cpp.o
          [ 28%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/simple_ast.cpp.o
          [ 29%] Building CXX object src/passes/CMakeFiles/passes.dir/DeadCodeElimination.cpp.o
          [ 31%] Linking CXX static library ../../lib/libemscripten-optimizer.a
          [ 31%] Built target emscripten-optimizer
          [ 32%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm-s-parser.cpp.o
          [ 34%] Building CXX object src/passes/CMakeFiles/passes.dir/DuplicateFunctionElimination.cpp.o
          [ 35%] Building CXX object src/passes/CMakeFiles/passes.dir/ExtractFunction.cpp.o
          [ 37%] Building CXX object src/passes/CMakeFiles/passes.dir/Inlining.cpp.o
          [ 38%] Building CXX object src/passes/CMakeFiles/passes.dir/LegalizeJSInterface.cpp.o
          [ 40%] Building CXX object src/passes/CMakeFiles/passes.dir/MemoryPacking.cpp.o
          [ 41%] Building CXX object src/passes/CMakeFiles/passes.dir/MergeBlocks.cpp.o
          [ 43%] Linking CXX static library ../../lib/libwasm.a
          [ 43%] Built target wasm
          [ 44%] Building CXX object src/passes/CMakeFiles/passes.dir/Metrics.cpp.o
          [ 46%] Building CXX object src/passes/CMakeFiles/passes.dir/NameManager.cpp.o
          [ 47%] Building CXX object src/passes/CMakeFiles/passes.dir/NameList.cpp.o
          [ 49%] Building CXX object src/passes/CMakeFiles/passes.dir/OptimizeInstructions.cpp.o
          [ 50%] Building CXX object src/passes/CMakeFiles/passes.dir/PostEmscripten.cpp.o
          [ 52%] Building CXX object src/passes/CMakeFiles/passes.dir/Precompute.cpp.o
          [ 53%] Building CXX object src/passes/CMakeFiles/passes.dir/Print.cpp.o
          [ 55%] Building CXX object src/passes/CMakeFiles/passes.dir/PrintCallGraph.cpp.o
          [ 56%] Building CXX object src/passes/CMakeFiles/passes.dir/RelooperJumpThreading.cpp.o
          [ 58%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveImports.cpp.o
          [ 59%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveMemory.cpp.o
          [ 61%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveUnusedBrs.cpp.o
          [ 62%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveUnusedNames.cpp.o
          [ 64%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveUnusedFunctions.cpp.o
          [ 65%] Building CXX object src/passes/CMakeFiles/passes.dir/ReorderLocals.cpp.o
          [ 67%] Building CXX object src/passes/CMakeFiles/passes.dir/ReorderFunctions.cpp.o
          [ 68%] Building CXX object src/passes/CMakeFiles/passes.dir/SimplifyLocals.cpp.o
          [ 70%] Building CXX object src/passes/CMakeFiles/passes.dir/Vacuum.cpp.o
          [ 71%] Linking CXX static library ../../lib/libpasses.a
          [ 71%] Built target passes
          Scanning dependencies of target wasm-opt
          Scanning dependencies of target wasm-as
          Scanning dependencies of target wasm-shell
          Scanning dependencies of target asm2wasm
          [ 73%] Building CXX object CMakeFiles/wasm-opt.dir/src/tools/wasm-opt.cpp.o
          [ 74%] Building CXX object CMakeFiles/wasm-as.dir/src/tools/wasm-as.cpp.o
          [ 76%] Building CXX object CMakeFiles/wasm-shell.dir/src/tools/wasm-shell.cpp.o
          [ 77%] Building CXX object CMakeFiles/asm2wasm.dir/src/tools/asm2wasm.cpp.o
          [ 79%] Linking CXX executable bin/wasm-as
          [ 79%] Built target wasm-as
          [ 80%] Linking CXX executable bin/wasm-opt
          [ 82%] Building CXX object CMakeFiles/wasm-shell.dir/src/wasm-interpreter.cpp.o
          [ 82%] Built target wasm-opt
          [ 83%] Building CXX object CMakeFiles/asm2wasm.dir/src/wasm-emscripten.cpp.o
          Scanning dependencies of target wasm-dis
          [ 85%] Building CXX object CMakeFiles/wasm-dis.dir/src/tools/wasm-dis.cpp.o
          [ 86%] Linking CXX executable bin/wasm-shell
          [ 86%] Built target wasm-shell
          Scanning dependencies of target s2wasm
          [ 88%] Building CXX object CMakeFiles/s2wasm.dir/src/tools/s2wasm.cpp.o
          Scanning dependencies of target binaryen
          [ 89%] Building CXX object CMakeFiles/binaryen.dir/src/binaryen-c.cpp.o
          [ 91%] Linking CXX executable bin/wasm-dis
          [ 91%] Built target wasm-dis
          [ 92%] Building CXX object CMakeFiles/s2wasm.dir/src/wasm-emscripten.cpp.o
          [ 94%] Linking CXX executable bin/asm2wasm
          [ 94%] Built target asm2wasm
          [ 95%] Building CXX object CMakeFiles/binaryen.dir/src/cfg/Relooper.cpp.o
          [ 97%] Building CXX object CMakeFiles/s2wasm.dir/src/wasm-linker.cpp.o
          [ 98%] Linking CXX shared library lib/libbinaryen.dylib
          [ 98%] Built target binaryen
          [100%] Linking CXX executable bin/s2wasm
          [100%] Built target s2wasm

error: aborting due to previous error

error: Could not compile `wasm-meow`.
lord commented 7 years ago

Looks like you've already got an emscripten compiler installed on your computer? If you remove the emcc binary from your $PATH and then rerun, does it work?

durka commented 7 years ago

Yes, it seems to be from brew install emscripten. But maybe it's too old or something?

lord commented 7 years ago

Hrm, yes, perhaps? I'm not sure about the specifics of homebrew's emscripten. Since you have errors from binaryen, it's also possible your emscripten can compile to asm.js, but not wasm?

(Also still curious if removing it fixes the problem!)

durka commented 7 years ago

After removing it wargo tries to install emcc and work around the macOS linking bug, but sadly LLVM fails to build: https://gist.github.com/b9e1548232ddae04c15591374c6af7c1

Maybe OSX 10.9.5 is just too old at this point.

On Sun, Oct 22, 2017 at 10:26 PM, Robert Lord notifications@github.com wrote:

Hrm, yes, perhaps? I'm not sure about the specifics of homebrew's emscripten. Since you have errors from binaryen, it's also possible your emscripten can compile to asm.js, but not wasm?

(Also still curious if removing it fixes the problem!)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lord/wargo/issues/10#issuecomment-338531621, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC3n5FBnXgfb_bRgvKiQwhLdotGIU_6ks5su_lagaJpZM4QCLKZ .

lord commented 7 years ago

Hrm, yea, it's possible that it's too old for emsdk to have a prebuilt binary for? Which would explain why it's trying to build, on more recent machines it's a quick download of a binary. That's frustrating. 😕

lord commented 7 years ago

I'm going to close now, but if you find a fix that we can automate please do let us know!