Hi all, Disclaimer: I'm a long time gnu toolchain user for unix and just got interested in llvm this week, so my questions could be *very* naive. I've read lots of the good documentation on the website and wiki, tutorials, reference manual etc. and have been following this list for a few days. But there's still a lot to read, so excuse me if the answers are already on some FAQ, I'd be glad to be quickly pointed out to more docs. The problem: I got a few very simple programs to compile with both gnu and llvm toolchain and inspect the elf information and optimizations done (attached a zip with the code and the makefile). For the C code I got smaller and faster programs, excellent! But for the C++ it was a bit of a shock to see a 100x increase in size. The execution time is 2-fold, but the programs are to simple and too fast to make any difference meaningful. When inspecting the final binaries, I found lots (~2000) of ".llvm.linkonce.t.*" PROGBITS sections. As far as I could see they're all stdlibc++ calls (types, IO, exceptions etc.), which g++ didn't generate, nor did llvm-gcc or gcc for the libc. Shouldn't the shared libraries be only linked instead of incorporated into the program? Am I missing something? To compile, I'm only calling: $ llvm-g++ source.cpp -o program cheers, --renato Reclaim your digital rights, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-test.zip Type: application/zip Size: 2521 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090702/c6589108/attachment.zip>
Hi Renato,> For the C code I got smaller and faster programs, excellent! But for > the C++ it was a bit of a shock to see a 100x increase in size. The > execution time is 2-fold, but the programs are to simple and too fast > to make any difference meaningful.with llvm-g++ from subversion, and on x86-64 linux, I also see that virtual.llvm-gpp is larger than virtual.gpp, but by a factor of 3. The sizes of the .o files are: g++: 9704 bytes llvm-g++: 10728 bytes so the size difference comes from linking. If I link them both using g++ then the final executable sizes are: g++: 19881 bytes llvm-g++: 21721 bytes so the actual difference is due to some details of how llvm-g++ is doing the linking. I don't know what these details are though. Ciao, Duncan.
On Thu, Jul 2, 2009 at 2:15 PM, Duncan Sands<baldrick at free.fr> wrote:> with llvm-g++ from subversion, and on x86-64 linux, I also see that > virtual.llvm-gpp is larger than virtual.gpp, but by a factor of 3.Hi Duncan, I'm using mainstream 2.5 (from Ubuntu repo). I should be compiling the svn tree this weekend, though.> The sizes of the .o files are: > g++: 9704 bytes > llvm-g++: 10728 bytes > so the size difference comes from linking. If I link them both > using g++ then the final executable sizes are: > g++: 19881 bytes > llvm-g++: 21721 bytes > so the actual difference is due to some details of how llvm-g++ is > doing the linking. I don't know what these details are though.Yeah, I forgot to check the object files, but the ELF information made it pretty clear that the linking was bloating the final target with unnecessary code. Once I get llvm compiled, I'll try to get a bit deeper into the problem. cheers, --renato Reclaim your digital rights, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm