Newbie question

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

llvm-test.zip (2.46 KB)

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.

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

Jolly good! Seems to be an Ubuntu problem! I've just compiled the
whole shebang (llvm, gcc front-end) and the sizes are very similar. C
binaries a bit smaller (20%), C++ a bit bigger (20%), but all in all,
very good.

Will report the problem to the Ubuntu people.

cheers,
--renato

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm