emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.77k stars 3.3k forks source link

macOS: binaryen port sometimes builds with Emscripten instead of native compiler #6303

Closed rgov closed 5 years ago

rgov commented 6 years ago

I passed -s WASM=1 to emcc and it kicked off a build of binaryen:

INFO:root:generating port: binaryen_tag_version_44.txt... (this will be cached in "/Users/rzg/.emscripten_cache/asmjs/binaryen_tag_version_44.txt" for subsequent builds)
INFO:root:building port: binaryen
-- Building with -std=c++11
CMake Warning at CMakeLists.txt:132 (message):
  Unknown target architecture!

-- 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/rzg/.emscripten_ports/binaryen/binaryen-version_44
[  1%] Linking CXX static library ../../lib/libasmjs.a
[  2%] Linking CXX static library ../../lib/libir.a
[  3%] Linking CXX static library ../../lib/libwasm.a
[  4%] Linking CXX static library ../../lib/libcfg.a
fatal error: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: fatal error in /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
fatal error: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: fatal error in /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
fatal error: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: fatal error in /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
make[5]: *** [lib/libasmjs.a] Error 1
make[5]: *** Deleting file `lib/libasmjs.a'
make[5]: *** [lib/libir.a] Error 1
make[5]: *** Deleting file `lib/libir.a'
make[4]: *** [src/ir/CMakeFiles/ir.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....
make[4]: *** [src/asmjs/CMakeFiles/asmjs.dir/all] Error 2
make[5]: *** [lib/libcfg.a] Error 1
make[5]: *** Deleting file `lib/libcfg.a'
make[4]: *** [src/cfg/CMakeFiles/cfg.dir/all] Error 2
fatal error: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: fatal error in /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
make[5]: *** [lib/libwasm.a] Error 1
make[5]: *** Deleting file `lib/libwasm.a'
make[4]: *** [src/wasm/CMakeFiles/wasm.dir/all] Error 2
make[3]: *** [all] Error 2
rgov commented 6 years ago

It seems to build OK if I just clone the repo from WebAssembly/binaryen.

rgov commented 6 years ago

When it messes up, the CMakeCache.txt file says CMAKE_CXX_COMPILER is pointed to em++. When it works, it's using the regular compiler.

kripken commented 6 years ago

Was this maybe when using emmake or emconfigure? Or were the env vars CC/CXX set to emcc/em++ manually? It seems like that could cause this. If it's the cause, we should probably prevent that or at least warn about it.

rgov commented 6 years ago

I was doing emcmake cmake {options} .. && cmake --build .

kripken commented 6 years ago

What does cmake --build do? Perhaps we incorrectly detect it as running cmake's configuration stage.

rgov commented 6 years ago

I don't think I was running emcmake -- build . just regular cmake --build . but anyway the command invokes the build tool. It's useful so you don't have to remember how to invoke the specific generator.

kripken commented 6 years ago

I see. Not sure what could cause that, then, but I admit I don't know much about MacOS as well as CMake.

Maybe you can get a set of concrete steps that reproduce this problem consistently?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.