Modified the linker so that it always links in an object from an archive
[oota-llvm.git] / docs / FAQ.html
index d0c5148763acae2fc191979b4c28b2198a53b155..f4afc266cbcbb34aa113c7267561a199d60a23bf 100644 (file)
   errors.</li>
   <li>I've built LLVM and am testing it, but the tests freeze.</li>
   <li>Why do test results differ when I perform different types of builds?</li>
+  <li>Compiling LLVM with GCC 3.3.2 fails, what should I do?</li>
   </ol></li>
 
-  <li><a href="#cfe">GCC Front End</a>
+  <li><a href="#cfe">Using the GCC Front End</a>
   <ol>
     <li>
     When I compile software that uses a configure script, the configure script
     </li>
   </ol>
   </li>
+
+  <li><a href="#cfe_code">Questions about code generated by the GCC front-end</a>
+  <ol>
+     <li>What is this <tt>__main()</tt> call that gets inserted into
+         <tt>main()</tt>?</li>
+     <li>Where did all of my code go??</li>
+  </ol>
+  </li>
 </ol>
 
 <!-- *********************************************************************** -->
@@ -320,9 +329,18 @@ build.</p>
 
 </div>
 
+<div class="question">
+<p>Compiling LLVM with GCC 3.3.2 fails, what should I do?</p>
+</div>
+
+<div class="answer">
+<p>This is <a href="http://gcc.gnu.org/PR?13392">a bug in GCC</a>, and 
+   affects projects other than LLVM.  Try upgrading or downgrading your GCC.</p>
+</div>
+
 <!-- *********************************************************************** -->
 <div class="doc_section">
-  <a name="cfe">GCC Front End</a>
+  <a name="cfe">Using the GCC Front End</a>
 </div>
 
 <div class="question">
@@ -367,14 +385,14 @@ not linking on your system because the feature isn't available on your system.
 </p>
 </div>
 
-<div class="question"
+<div class="question">
 <p>
 When I compile code using the LLVM GCC front end, it complains that it cannot
 find crtend.o.
 </p>
 </div>
 
-<div class="answer"
+<div class="answer">
 <p>
 In order to find crtend.o, you must have the directory in which it lives in
 your LLVM_LIB_SEARCH_PATH environment variable.  For the binary distribution of
@@ -382,6 +400,55 @@ the LLVM GCC front end, this will be the full path of the bytecode-libs
 directory inside of the LLVM GCC distribution.
 </p>
 </div>
+
+
+<!-- *********************************************************************** -->
+<div class="doc_section">
+  <a name="cfe_code">Questions about code generated by the GCC front-end</a>
+</div>
+
+<div class="question"><p>
+What is this <tt>__main()</tt> call that gets inserted into <tt>main()</tt>?
+</p></div>
+
+<div class="answer">
+<p>
+The <tt>__main</tt> call is inserted by the C/C++ compiler in order to guarantee
+that static constructors and destructors are called when the program starts up
+and shuts down.  In C, you can create static constructors and destructors by
+using GCC extensions, and in C++ you can do so by creating a global variable
+whose class has a ctor or dtor.
+</p>
+
+<p>
+The actual implementation of <tt>__main</tt> lives in the
+<tt>llvm/runtime/GCCLibraries/crtend/</tt> directory in the source-base, and is
+linked in automatically when you link the program.
+</p>
+</div>
+
+<!--=========================================================================-->
+
+<div class="question"><p>
+Where did all of my code go??
+</p></div>
+
+<div class="answer">
+<p>
+If you are using the LLVM demo page, you may often wonder what happened to all
+of the code that you typed in.  Remember that the demo script is running the
+code through the LLVM optimizers, so if you code doesn't actually do anything
+useful, it might all be deleted.
+</p>
+
+<p>
+To prevent this, make sure that the code is actually needed.  For example, if
+you are computing some expression, return the value from the function instead of
+leaving it in a local variable.  If you really want to constrain the optimizer,
+you can read from and assign to <tt>volatile</tt> global variables.
+</p>
+</div>
+
 <!-- *********************************************************************** -->
 <!-- *********************************************************************** -->