[LLVMdev] How much memory clang llvm needs for debug compiling?

1,076 views
Skip to first unread message

Nancy

unread,
Jun 2, 2014, 9:41:01 AM6/2/14
to llvm...@cs.uiuc.edu, llv...@cs.uiuc.edu
Hi,


--
Best Regards,
Yu Rong Tan
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Nancy

unread,
Jun 2, 2014, 9:50:35 AM6/2/14
to llvm...@cs.uiuc.edu, llv...@cs.uiuc.edu
$cd llvm-build
$../llvm/configure --enable-targets=x86


make[4]:正在离开目录 `/home/nancy/work/build-llvm/tools/clang/tools/libclang'
make[4]: 正在进入目录 `/home/nancy/work/build-llvm/tools/clang/tools/c-index-test'
llvm[4]: Linking Debug+Asserts executable c-index-test
llvm[4]: ======= Finished Linking Debug+Asserts Executable c-index-test
make[4]:正在离开目录 `/home/nancy/work/build-llvm/tools/clang/tools/c-index-test'
make[4]: 正在进入目录 `/home/nancy/work/build-llvm/tools/clang/tools/c-arcmt-test'
llvm[4]: Linking Debug+Asserts executable c-arcmt-test
llvm[4]: ======= Finished Linking Debug+Asserts Executable c-arcmt-test
make[4]:正在离开目录 `/home/nancy/work/build-llvm/tools/clang/tools/c-arcmt-test'
make[4]: 正在进入目录 `/home/nancy/work/build-llvm/tools/clang/tools/driver'
llvm[4]: Linking Debug+Asserts executable clang
/usr/bin/ld: 最终连接失败: 内存耗尽 ( in english : Memory exhausted)
collect2: error: ld returned 1 exit status
make[4]: *** [/home/nancy/work/build-llvm/Debug+Asserts/bin/clang] 错误 1
make[4]:正在离开目录 `/home/nancy/work/build-llvm/tools/clang/tools/driver'
make[3]: *** [driver/.makeall] 错误 2
make[3]:正在离开目录 `/home/nancy/work/build-llvm/tools/clang/tools'
make[2]: *** [all] 错误 1
make[2]:正在离开目录 `/home/nancy/work/build-llvm/tools/clang'
make[1]: *** [clang/.makeall] 错误 2
make[1]:正在离开目录 `/home/nancy/work/build-llvm/tools'
make: *** [all] 错误 1


What should I do to make debug enabled compiling successful? Anyone
can tell me a tiny configuration which can save memory? I only have 3G
RAM, Ubuntu kylin.

Ronaldo Ferreira

unread,
Jun 2, 2014, 10:14:42 AM6/2/14
to Nancy, llv...@cs.uiuc.edu
I have a 7 years old computer with 1 GB RAM and I was able to build clang in debug mode. I created a swap file of 4 GB I think, and I've stopped using the computer at all, just grab some tea and wait.

This link shows you how you can create a swap file:
http://askubuntu.com/questions/178712/how-to-increase-swap-space

At least for me it worked well.

Tim Northover

unread,
Jun 2, 2014, 10:20:58 AM6/2/14
to Nancy, llvm...@cs.uiuc.edu, LLVM Developers Mailing List
Hi,

> What should I do to make debug enabled compiling successful? Anyone
> can tell me a tiny configuration which can save memory? I only have 3G
> RAM, Ubuntu kylin.

3GB is probably going to be painful no matter what you do, but there
are a few things to try.

First, you could switch to ld.gold instead of ld.bfd. It uses much
less memory when linking. It can also be helpful to reduce the
parallelism of the build so that only one thing is linking at any one
time.

Finally, you can build clang with the debug info in separate files.
This needs a newer gdb & gcc/clang to work properly, but 14.04 should
be fine. This made a massive difference to me, so I'm really keen on
the idea. I think for autoconf you need ".../configure
--enable-split-dwarf" to use this.

Good luck!

Tim.

David Tweed

unread,
Jun 2, 2014, 10:47:17 AM6/2/14
to Nancy, llvm...@cs.uiuc.edu, llv...@cs.uiuc.edu
Hi,

Just a question: are you doing the actual build on a 32-bit x86 machine (not
a 64-bit x86-64 machine)? This seems to be sensible, but I've rarely had
problems doing a debug build on x86 within 2GB of memory (after ensuring
only one link at once); it's always been the x86-64 builds that are tricky
under low memory.

Regards,
Dave

Anton Korobeynikov

unread,
Jun 2, 2014, 11:12:05 AM6/2/14
to David Tweed, llvm...@cs.uiuc.edu, LLVM Developers Mailing List
Also, here the problem is ld. Switching to gold may help to resolve the problem.

On Mon, Jun 2, 2014 at 6:42 PM, David Tweed <david...@arm.com> wrote:
> Hi,
>
> Just a question: are you doing the actual build on a 32-bit x86 machine (not
> a 64-bit x86-64 machine)? This seems to be sensible, but I've rarely had
> problems doing a debug build on x86 within 2GB of memory (after ensuring
> only one link at once); it's always been the x86-64 builds that are tricky
> under low memory.
>
> Regards,
> Dave
>
> -----Original Message-----
> From: llvmdev...@cs.uiuc.edu [mailto:llvmdev...@cs.uiuc.edu] On
> Behalf Of Nancy
> Sent: 02 June 2014 14:47
> To: llvm...@cs.uiuc.edu; llv...@cs.uiuc.edu
> Subject: Re: [LLVMdev] How much memory clang llvm needs for debug compiling?
>

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University

Eric Christopher

unread,
Jun 2, 2014, 12:48:38 PM6/2/14
to Nancy, llvm...@cs.uiuc.edu, llv...@cs.uiuc.edu
Debug information is pretty large, especially for the link step. If
you have a recent gdb you can use the split dwarf configure option
which should reduce the memory requirements of the link quite
significantly (nearly back to no debug information).

-eric

Nancy

unread,
Jun 3, 2014, 11:04:37 AM6/3/14
to Tim Northover, llvm...@cs.uiuc.edu, LLVM Developers Mailing List
> First, you could switch to ld.gold instead of ld.bfd. It uses much
$ln -s `which gold` /usr/local/bin/ld

> the idea. I think for autoconf you need ".../configure
> --enable-split-dwarf" to use this.
>
$.../configure --enable-targets=x86 --enable-split-dwarf
$ make -j2
$ sudo make install

It works for me. Thanks a lot!

I want to use emacs+gdb to trace the code work flow.
M-x gdb
Run like gdb --annotate=3 clang
(gdb) set args test.c
(gdb) b main
(gdb) b /home/nancy/work/llvm/tools/clang/lib/Lex/Lexer.cpp:57
(gdb) r
It block at llvm/tools/clang/tools/driver/driver.cpp main() fucntion.
(gdb) c
program exit normally
why? why it not call Lexer.cpp:InitLexer()? And I really can't find
any entry point to clang/lib/*.cpp files within help of SourceInsight
code view start from llvm/tools/clang/tools/driver/driver.cpp main()
function.

What's wrong with me?

--
Best Regards,
Yu Rong Tan

Nancy

unread,
Jun 3, 2014, 11:16:56 AM6/3/14
to David Tweed, llvm...@cs.uiuc.edu, LLVM Developers Mailing List
On Mon, Jun 2, 2014 at 10:42 PM, David Tweed <david...@arm.com> wrote:
> Hi,
>
> Just a question: are you doing the actual build on a 32-bit x86 machine (not
> a 64-bit x86-64 machine)? This seems to be sensible, but I've rarely had
> problems doing a debug build on x86 within 2GB of memory (after ensuring
> only one link at once); it's always been the x86-64 builds that are tricky
> under low memory.

Yes, I'm sure it is X86. Thinkpad T61. Maybe you had tried the older
version. Latest version do not work. The problem solved. Thank you all
the same!

Nancy

unread,
Jun 3, 2014, 11:18:51 AM6/3/14
to Ronaldo Ferreira, LLVM Developers Mailing List
On Mon, Jun 2, 2014 at 10:10 PM, Ronaldo Ferreira
<ronaldor...@gmail.com> wrote:
> I have a 7 years old computer with 1 GB RAM and I was able to build clang in
> debug mode. I created a swap file of 4 GB I think, and I've stopped using
> the computer at all, just grab some tea and wait.
>
> This link shows you how you can create a swap file:
> http://askubuntu.com/questions/178712/how-to-increase-swap-space
>
> At least for me it worked well.

Oh, Another way to make it work. Thank you :)

Eric Christopher

unread,
Jun 3, 2014, 5:19:08 PM6/3/14
to Nancy, LLVM Developers Mailing List, llvm...@cs.uiuc.edu
On Tue, Jun 3, 2014 at 7:59 AM, Nancy <nancyd...@gmail.com> wrote:
>> First, you could switch to ld.gold instead of ld.bfd. It uses much
> $ln -s `which gold` /usr/local/bin/ld
>
>> the idea. I think for autoconf you need ".../configure
>> --enable-split-dwarf" to use this.
>>
> $.../configure --enable-targets=x86 --enable-split-dwarf
> $ make -j2
> $ sudo make install
>
> It works for me. Thanks a lot!
>
> I want to use emacs+gdb to trace the code work flow.
> M-x gdb
> Run like gdb --annotate=3 clang
> (gdb) set args test.c
> (gdb) b main
> (gdb) b /home/nancy/work/llvm/tools/clang/lib/Lex/Lexer.cpp:57
> (gdb) r
> It block at llvm/tools/clang/tools/driver/driver.cpp main() fucntion.
> (gdb) c
> program exit normally
> why? why it not call Lexer.cpp:InitLexer()? And I really can't find
> any entry point to clang/lib/*.cpp files within help of SourceInsight
> code view start from llvm/tools/clang/tools/driver/driver.cpp main()
> function.
>
> What's wrong with me?
>

You need to use the -cc1 option that clang is being reinvoked with,
use the -v option on your original command line to take a look at it.

Also, if you're just doing development you don't need to install the
binary. The clang in build/Debug+Asserts/bin/clang will work just
fine.

-eric

Nancy

unread,
Jun 4, 2014, 10:45:35 AM6/4/14
to Eric Christopher, LLVM Developers Mailing List
Hi, eric

Thank you for your -v advice

$clang -v test.c
....

Selected GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Candidate multilib: .;@m32
Selected multilib: .;@m32
"/usr/local/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj
-mrelax-all -disable-free -main-file-name test.c -mrelocation-model
static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu pentium4
-target-linker-version 2.24 -v -resource-dir
/usr/local/bin/../lib/clang/3.5.0 -internal-isystem /usr/local/include
-internal-isystem /usr/local/bin/../lib/clang/3.5.0/include
-internal-externc-isystem /usr/include/i386-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -fdebug-compilation-dir /home/nancy/work/test
-ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -o /tmp/test-85913a.o -x c test.c

clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target
i386-pc-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/bin/../lib/clang/3.5.0/include
/usr/include/i386-linux-gnu
/usr/include
End of search list.
......

I use
"-cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name test.c -mrelocation-model static -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array
-target-cpu pentium4 -target-linker-version 2.24 -v -resource-dir
/usr/local/bin/../lib/clang/3.5.0 -internal-isystem /usr/local/include
-internal-isystem /usr/local/bin/../lib/clang/3.5.0/include
-internal-externc-isystem /usr/include/i386-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -fdebug-compilation-dir /home/nancy/work/test
-ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -o /tmp/test-85913a.o -x c
/home/nancy/work/test/test.c"

as (gdb)set args parameters and setup those breakpoins and run, it
still normally exist without stopping at breakpoint I set in
Lexer.cpp.

Could you please tell me the specific steps?

--
Best Regards,
Yu Rong Tan

Gabor Ballabas

unread,
Jun 4, 2014, 12:24:57 PM6/4/14
to Nancy, llv...@cs.uiuc.edu
Hi Nancy,

Have you tried setting follow-fork-mode to the child process?

https://sourceware.org/gdb/onlinedocs/gdb/Forks.html

Best regards,
Gabor Ballabas

Nancy

unread,
Jun 5, 2014, 10:48:08 AM6/5/14
to Gabor Ballabas, Eric Christopher, LLVM Developers Mailing List
Hi Gabor,
Thank you very much for your information! I learn how to use GDB
debug Multiple Interior/Threads today.
It works!

Hi Eric,
So sorry for the wrong feedback I gave yesterday. It also works!
Maybe because some wrong emacs enviroment setting or ....Today I try
again, this way is more directly and efficient!
Thank you very much !!!
--
Best Regards,
Yu Rong Tan
Reply all
Reply to author
Forward
0 new messages