我正在尝试按照网络组装说明 ( http://webassembly.org/getting-started/developers-guide/ ) 安装 emsdk。它在 OSX 上编译得很好,但是当我试图在 Ubuntu 16.04 上构建它时遇到以下错误:
[ 94%] Built target llvm-lto2
[ 94%] Built target llvm-diff
[ 94%] Linking CXX executable ../../bin/llvm-c-test
collect2: error: ld returned 1 exit status
tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/build.make:425: recipe for target 'bin/llvm-c-test' failed
make[2]: *** [bin/llvm-c-test] Error 1
CMakeFiles/Makefile2:15474: recipe for target 'tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/all' failed
make[1]: *** [tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
Build failed due to exception!
Working directory: /opt/emsdk/clang/fastcomp/build_incoming_64
Command '['make', '-j1']' returned non-zero exit status 2
Installation failed!
有人知道这是怎么回事吗?
最佳答案
对我来说,构建 emsdk 时的主要问题是交换,因为看起来安装脚本检测到 4 个逻辑处理器核心并开始 3 线程编译。当一切都被编译时,几个链接器进程 (ld
) 似乎同时启动并且它们耗尽了我的 8 Gb RAM(至少当同时运行具有许多选项卡的 Firefox 时)。系统变得无响应,我必须停止使用它并等待或终止其中一个 ld
进程,然后在我的情况下,其他两个将完成链接,虽然安装会失败,但当我重新运行它时,有要链接的二进制文件少 2 个 :)。
我试过模拟内存耗尽而不交换
$ ulimit -v 2000000
$ ./emsdk install sdk-incoming-64bit
得到了同样的错误 collect2: error: ld returned 1 exit status
但是有类似 /usr/bin/ld: failed to set dynamic section sizes: Memory exhausted
就在它之前。
我完全不确定您是否确实遇到了这个问题(特别是因为您没有任何Memory exhausted
消息并且您正在执行单线程编译(make -j1
)),但当内存耗尽时,ld
中可能还有其他失败场景。您可以重新运行安装,同时观察另一个终端上的 top
输出,检查可用内存 + buff/cache 是否接近 0(只是 free mem几乎为 0 可能没问题)。如果是这样,您可以尝试使用交换分区或文件。不幸的是,您不能使用终止 ld
进程之一的技巧,因为您已经只有单线程编译 (make -j1
)。
关于ubuntu - 尝试在 Ubuntu 16.04 上构建 emsdk 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45603545/