How to compile ruby with RVM on a low memory syste

2019-01-22 21:14发布

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?

1条回答
叼着烟拽天下
2楼-- · 2019-01-22 21:47

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))

查看更多
登录 后发表回答