Compiling in low-memory conditions

Tom Ritter tom at ritter.vg
Mon Apr 4 00:51:42 CEST 2011


I was compiling libgcrypt and gnupg on a low-memory VPS, and ran into
a few problems. First, I compiled libgcrypt, and ran into a gcc crash,
when it ran out of memory trying to compile twofish.o.  It looked like
this:

gcc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/usr/local/include -g
-O2 --param ggc-min-expand=0 --param ggc-min-heapsize=32768
-fvisibility=hidden -Wall -MT twofish.lo -MD -MP -MF .deps/twofish.Tpo
-c twofish.c  -fPIC -DPIC -o .libs/twofish.o

cc1: out of memory allocating 3082800 bytes after a total of 4681728 bytes
make[2]: *** [twofish.lo] Error 1

I worked around that, I'll explain in a minute but I did compile
libgcrypt, and moved onto gnupg.  For gnupg I ran ./configure and
after installing the libraries I needed, I began to compile gnupg.
However it failed with an error about missing zlib.h - I would have
though configure would pick that up.  But no worries, after getting
it, I continued the compile and ran into the same gcc out-of-memory
crashes on :
 - keyedit.o
 - gpg.o
 - keygen.o

To get around the out of memory issue, I tried using ulimit, but this
did not help.  What did work was editing the Makefile and temporarily
setting the optimization level to -O0.  After the module was compiled
I killed the build, and set it back to O2.  Repeating for each module
that crashed it.  I don't know if there's any way this could be
prevented without unnecessary work, so I mainly just wanted to
document it for anyone who ran into the same problem as me.

Finally, i believe the 'status_codes.h' getting deleted that I
reported last summer[1] is still active.

-tom

[1] http://lists.gnupg.org/pipermail/gnupg-devel/2010-July/025642.html



More information about the Gcrypt-devel mailing list