[LLVMdev] A small doubt
Chris Lattner
sabre at nondot.org
Mon Oct 27 23:09:01 PST 2003
On Mon, 27 Oct 2003, Brian R. Gaeke wrote:
> __main is used primarily to call static constructors. The way you
> satisfy this dependency is to link the bytecode file against crtend.o
> (aka libcrtend.bc). This is normally accomplished by using gccld
> (or by llvm-gcc <bytecode files> -o program, which calls gccld).
Brian is absolutely right. Note that static constructors really only
happen in C++ programs (or C programs which use the GCC
constructor/destructor extensions, which are really really rare).
However, gccld should elimination all of the overhead of the __main
function if the functionality is not used, so C programs don't suffer any
overhead, and you can just delete the call to __main if it is causing you
grief.
If you're interested, the source code for __main lives in:
llvm/runtime/GCCLibraries/crtend/crtend.c & listend.ll
-Chris
--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/
More information about the llvm-dev
mailing list