如何在低内存系统上使用RVM编译ruby? [英] How to compile ruby with RVM on a low memory system?

查看:183
本文介绍了如何在低内存系统上使用RVM编译ruby?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  rvm install 1.9.3 

会导致错误在make.log中:

  ... 
编译./enc/trans/emoji_sjis_docomo.c
编译./enc/trans/emoji_sjis_kddi.c
gcc:内部编译器错误:Killed(程序cc1)
gcc:内部编译器错误:Killed(程序cc1)
gcc:内部编译器错误:杀死(程序cc1)
请提交完整的错误报告,
和预处理源(如果适用)。
...

dmesg 显示

  [180031.341709] send sigkill to 3705(cc1),adj 0,size 3394 

free 显示某个点运行configure过程:

 使用的空闲共享缓冲区总数缓存
Mem:241668 238676 2992 0 92 2020
- / + buffers / cache:236564 5104
Swap:262140 262140 0

所以我假设256MB RAM和256MB Swap不足以编译Ruby

我读过应该可以使用gcc的一些参数,请参阅:
http://hostingfu.com/article/compiling-with-gcc-on-low-memory-vps



但是

  rvm install 1.9.3 --with-CFLAGS = $ CFLAGS --param ggc -min-expand = 0 --param ggc-min-heapsize = 8192

不适用将标志赋予gcc,日志对于标志仍然是相同的:

 命令(2):__rvm_make -j4 
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -O3 -ggdb -Wall -Wextra -Wno -unused-parameter -Wno-括弧-Wno-long-long -Wno-missing-fiel $
XCFLAGS = -include ruby​​ / config.h -include ruby​​ / missing.h -fvisibility = hidden -DRUBY_EXPORT
CPPFLAGS = -I。 -I.ext / include / x86_64-linux -I./include -I。
DLDFLAGS = -Wl,-soname,libruby.so.1.9
SOLIBS = -lpthread -lrt -ldl -lcrypt -lm

如何在该机器上编译ruby?

解决方案

文件解决了这个问题。这里是步骤:

$ pre $ $ $ $ $ sudo mkdir -p / var / cache / swap /
sudo dd if = / dev / zero of = / var / cache / swap / swap0 bs = 1M count = 512
sudo chmod 0600 / var / cache / swap / swap0
sudo mkswap / var / cache / swap / swap0
sudo swapon / var / cache / swap / swap0

重启后不使用交换文件。它可以集成到 / etc / fstab 中,以便在重新启动后使用它:

  / var / cache / swap / swap0 none swap sw 0 0 

以上步骤创建一个我在这里找到的交换文件(德文): http://wiki.ubuntuusers.de/Swap#Swap-als -Datei - 上述内容的许可: http://creativecommons.org /licenses/by-nc-sa/2.0/de/deed.en (署名 - 非商业性使用 - 相同方式2.0德国(CC BY-NC-SA 2.0 DE))

rvm install 1.9.3

leads to the error in the make.log:

...
compiling ./enc/trans/emoji_sjis_docomo.c
compiling ./enc/trans/emoji_sjis_kddi.c
gcc: internal compiler error: Killed (program cc1)
gcc: internal compiler error: Killed (program cc1)
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
...

dmesg shows

[180031.341709] send sigkill to 3705 (cc1), adj 0, size 3394

free shows at some point running configure process:

             total       used       free     shared    buffers     cached
Mem:        241668     238676       2992          0         92       2020
-/+ buffers/cache:     236564       5104
Swap:       262140     262140          0

So I assume that 256MB RAM and 256MB Swap is not enough to compile Ruby on it.

I read that it should be possible using some parameters for gcc, see: http://hostingfu.com/article/compiling-with-gcc-on-low-memory-vps

But

  rvm install 1.9.3 --with-CFLAGS="$CFLAGS --param ggc-min-expand=0 --param ggc-min-heapsize=8192"

Does not work to give the flags to gcc, log is still the same for the flags:

command(2): __rvm_make -j4
        CC = gcc
        LD = ld
        LDSHARED = gcc -shared
        CFLAGS = -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-fiel$
        XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
        CPPFLAGS =   -I. -I.ext/include/x86_64-linux -I./include -I.
        DLDFLAGS = -Wl,-soname,libruby.so.1.9
        SOLIBS = -lpthread -lrt -ldl -lcrypt -lm

How to compile ruby on that machine?

解决方案

Creating a 512MB swap-file solved the problem. Here are the steps:

sudo mkdir -p /var/cache/swap/
sudo dd if=/dev/zero of=/var/cache/swap/swap0 bs=1M count=512
sudo chmod 0600 /var/cache/swap/swap0
sudo mkswap /var/cache/swap/swap0 
sudo swapon /var/cache/swap/swap0

The swap file is not used after a restart. It can be integrated in /etc/fstab to use it after restart:

 /var/cache/swap/swap0    none    swap    sw      0 0

The above steps to create a swap-file I found here (in German): http://wiki.ubuntuusers.de/Swap#Swap-als-Datei - licence for the above content: http://creativecommons.org/licenses/by-nc-sa/2.0/de/deed.en (Attribution-NonCommercial-ShareAlike 2.0 Germany (CC BY-NC-SA 2.0 DE))

这篇关于如何在低内存系统上使用RVM编译ruby?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆