简体   繁体   English

Node.js源代码构建在ARM上给出了分段错误

[英]Node.js source code build giving segmentation fault on ARM

tl;dr: I tried to install node.js on my ARMv7-based Cubox running Ubuntu 12.10 (quantal). tl; dr:我试图在运行Ubuntu 12.10(量子)的基于ARMv7的Cubox上安装node.js. When compiling node.js from source (see "Second attempt" below), node produces a segmentation fault. 从源代码编译node.js时(参见下面的“第二次尝试”), node会产生分段错误。 What can I do here? 我能在这做什么?

First attempt 第一次尝试

First of all, I tried to install node.js via the package manager, following the instructions for Ubuntu that are given here: Installing Node.js via package manager: Ubuntu, Mint 首先,我尝试通过包管理器安装node.js,遵循这里给出的Ubuntu的说明: 通过包管理器安装Node.js:Ubuntu,Mint

Adding the repository mentioned there using sudo add-apt-repository ppa:chris-lea/node.js seems to work fine: 使用sudo add-apt-repository ppa:chris-lea/node.js似乎工作正常:

You are about to add the following PPA to your system:
 Evented I/O for V8 javascript. Node's goal is to provide an easy way to build scalable network programs
 More info: https://launchpad.net/~chris-lea/+archive/node.js
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpp0owib/secring.gpg' created
gpg: keyring `/tmp/tmpp0owib/pubring.gpg' created
gpg: requesting key C7917B12 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpp0owib/trustdb.gpg: trustdb created
gpg: key C7917B12: public key "Launchpad chrislea" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

However, sudo apt-get install nodejs gives me the error: 但是, sudo apt-get install nodejs给出了错误:

E: Unable to locate package nodejs

I assume this is because I have an ARM-based system. 我认为这是因为我有一个基于ARM的系统。 As far as I can tell from the package details , the repo only contains builds for i386 and amd64. 据我所知, 从包详细信息来看 ,repo只包含i386和amd64的构建版本。 Is my assumption right? 我的假设是对的吗?

Second attempt 第二次尝试

So my next attempt was to install node.js from source. 所以我的下一次尝试是从源安装node.js。 I used the instructions given in the following gist: Node.js and NPM in 30 seconds . 我使用了以下要点中给出的指令: Node.js和NPM在30秒内完成 Everything seems to work, including make install . 一切似乎都有效,包括make install But the execution of the install.sh script in the last line of the gist fails since node produces a segmentation fault. 但是,由于node产生了分段错误,因此在gist的最后一行中执行install.sh脚本失败。 Now I wonder what I can do to properly install node.js on my machine? 现在我想知道如何在我的机器上正确安装node.js?

In order to illustrate my problem, here is some output: 为了说明我的问题,这里有一些输出:

install.sh output install.sh输出

This is the ouput of install.sh after running make install , as described in the gist installation instructions mentioned above. 这是运行make installinstall.sh的输出,如上面提到的gist安装说明中所述。

cyroxx@cubox:~/node-latest-install$ curl https://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7882  100  7882    0     0  11251      0 --:--:-- --:--:-- --:--:-- 14984
tar=/bin/tar
version:
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-1.2.21.tgz
Segmentation fault
Segmentation fault
You need node  to run this program.
node --version reports: v0.10.7
Please upgrade node before continuing.
It failed

node output 节点输出

cyroxx@cubox:~/node-latest-install$ node
Segmentation fault

make Debug build make Debug build

Running make with BUILDTYPE=Debug produces this output: 使用BUILDTYPE=Debug运行make会产生以下输出:

cyroxx@cubox:~/node-latest-install$ make -C out BUILDTYPE=Debug
make: Entering directory `/home/cyroxx/node-latest-install/out'
  CXX(target) /home/cyroxx/node-latest-install/out/Debug/obj.target/v8_base/deps/v8/src/arm/stub-cache-arm.o
../deps/v8/src/arm/stub-cache-arm.cc: In function 'void v8::internal::ProbeTable(v8::internal::Isolate*, v8::internal::MacroAssembler*, v8::internal::Code::Flags, v8::internal::StubCache::Table, v8::internal::Register, v8::internal::Register, v8::internal::Register, v8::internal::Register, v8::internal::Register, v8::internal::Register)':
../deps/v8/src/arm/stub-cache-arm.cc:106:15: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
cc1plus: all warnings being treated as errors
make: *** [/home/cyroxx/node-latest-install/out/Debug/obj.target/v8_base/deps/v8/src/arm/stub-cache-arm.o] Error 1
make: Leaving directory `/home/cyroxx/node-latest-install/out'

What's wrong here? 这有什么不对? Is this a bug in the ARM implementation of V8? 这是V8的ARM实现中的错误吗? Maybe any compiler flags that are not (properly) set? 也许没有(正确)设置的任何编译器标志? Anything else? 还要别的吗? I am totally stuck. 我完全陷入困境。

I had this problem too on a few different ARM computers. 我在几台不同的ARM计算机上也遇到过这个问题。 Compiling without the snapshot feature worked for me. 没有快照功能的编译对我有用。 Snapshot is a V8 feature that allows node to start faster, and there seems to be a bug for ARM. 快照是一种V8功能,允许节点更快启动,并且似乎存在ARM的错误。

./configure --without-snapshot
make
sudo make install

http://www.armhf.com/index.php/node-js-for-the-beaglebone-black/ http://www.armhf.com/index.php/node-js-for-the-beaglebone-black/

I had trouble building on a Samsung Chromebook XE303C12I with Crouton running Unity, even with --without-snapshot and --with-arm-float-abi=hard , so I used the precompiled binaries for Linux ARM devices. 我在使用Crouton运行Unity的三星Chromebook XE303C12I上遇到了麻烦,即使使用--without-snapshot--with-arm-float-abi=hard ,我也使用了预编译的Linux ARM设备二进制文件。

Binaries can be found in the release directory at nodejs.org/dist/{version number} 二进制文件可以在nodejs.org/dist/{version number}的发布目录中找到

For example, the ARM binary for v0.10.24 can be downloaded [here].( http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz ) 例如,可以在[这里]下载v0.10.24的ARM二进制文件。( http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz

Here's a script to download and install a binary. 这是一个下载和安装二进制文件的脚本 Once you have node installed, make sure to add path/to/bin/node to your $PATH . 安装节点后,确保将path/to/bin/node添加path/to/bin/node$PATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM