install.html 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <html>
  3. <head>
  4. <link HREF="mailto:drh@cs.princeton.edu" REV="made" TITLE="David R. Hanson">
  5. <title>Installing lcc</title>
  6. </head>
  7. <body>
  8. <h1>Installing lcc</h1>
  9. <p ALIGN="LEFT"><strong><a HREF="http://www.research.microsoft.com/~cwfraser/">Christopher
  10. W. Fraser</a> and <a HREF="http://www.research.microsoft.com/~drh/">David R. Hanson</a>, <a
  11. HREF="http://www.research.microsoft.com/">Microsoft Research</a></strong></p>
  12. <h2>Contents</h2>
  13. <dir>
  14. <li><a HREF="#intro">Introduction</a></li>
  15. <li><a HREF="#unix">Installation on UNIX</a></li>
  16. <li><a HREF="#driver">Building the Driver</a></li>
  17. <li><a HREF="#rcc">Building the Compiler and Accessories</a></li>
  18. <li><a HREF="#win32">Installation on Windows NT 4.0 and Windows 95/98</a></li>
  19. <li><a HREF="#bugs">Reporting Bugs</a></li>
  20. <li><a HREF="#mailinglist">Keeping in Touch</a></li>
  21. </dir>
  22. <h2><a NAME="intro">Introduction</a></h2>
  23. <p><a HREF="http://www.cs.princeton.edu/software/lcc/">lcc</a> is the ANSI C compiler
  24. described in our book <cite>A Retargetable C Compiler: Design and Implementation</cite>
  25. (Addison-Wesley, 1995, ISBN 0-8053-1670-1).</p>
  26. <p>If you're installing lcc on a UNIX system, read the remainder of this section and
  27. continue with the next section. If you're installing lcc on a Windows NT 4.0 or Windows
  28. 95/98 system, and you intend only to <u>use</u> lcc, you can run the <a
  29. href="ftp://ftp.cs.princeton.edu/pub/packages/lcc/lcc41.exe">InstallShield executable</a>,
  30. which installs the binaries and the documentation. If you want to <u>modify</u> lcc or <u>rebuild</u>
  31. it from the source files, you need the <a
  32. href="ftp://ftp.cs.princeton.edu/packages/lcc/lcc41.zip">complete distribution</a>, and
  33. you should read the rest of the section, the following three sections, and the <a
  34. HREF="#win32">Windows NT/95/98</a> section.</p>
  35. <p>Extract the distribution into its own directory. All non-absolute paths below are
  36. relative to this directory. The distribution holds the following subdirectories.</p>
  37. <blockquote>
  38. <table BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="80%">
  39. <tr>
  40. <td><a HREF="../src"><code>src</code></a></td>
  41. <td></td>
  42. <td>source code</td>
  43. </tr>
  44. <tr>
  45. <td><a HREF="../etc"><code>etc</code></a></td>
  46. <td></td>
  47. <td>driver, accessories</td>
  48. </tr>
  49. <tr>
  50. <td><a HREF="../lib"><code>lib</code></a></td>
  51. <td></td>
  52. <td>runtime library source code</td>
  53. </tr>
  54. <tr>
  55. <td><a HREF="../cpp"><code>cpp</code></a></td>
  56. <td></td>
  57. <td>preprocessor source code</td>
  58. </tr>
  59. <tr>
  60. <td><a HREF="../lburg"><code>lburg</code></a></td>
  61. <td></td>
  62. <td>code-generator generator source code</td>
  63. </tr>
  64. <tr>
  65. <td><a HREF="../doc"><code>doc</code></a></td>
  66. <td></td>
  67. <td>this document, man pages</td>
  68. </tr>
  69. <tr>
  70. <td><code><a HREF="../include">include</a>/*/*</code></td>
  71. <td></td>
  72. <td>include files</td>
  73. </tr>
  74. <tr>
  75. <td><a HREF="../tst"><code>tst</code></a></td>
  76. <td></td>
  77. <td>test suite</td>
  78. </tr>
  79. <tr>
  80. <td><code><a HREF="../alpha">alpha</a>/*/tst</code></td>
  81. <td></td>
  82. <td>ALPHA test outputs</td>
  83. </tr>
  84. <tr>
  85. <td><code><a HREF="../mips">mips</a>/*/tst</code></td>
  86. <td></td>
  87. <td>MIPS test outputs</td>
  88. </tr>
  89. <tr>
  90. <td><code><a HREF="../sparc">sparc</a>/*/tst</code></td>
  91. <td></td>
  92. <td>SPARC test outputs</td>
  93. </tr>
  94. <tr>
  95. <td><code><a HREF="../x86">x86</a>/*/tst</code></td>
  96. <td></td>
  97. <td>X86 test outputs</td>
  98. </tr>
  99. </table>
  100. </blockquote>
  101. <p><code>doc/install.html</code> is the HTML file for this document. <a HREF="4.html"><code>doc/4.html</code></a>
  102. describes the internal differences between lcc 3.x and 4.1.</p>
  103. <p>The installation makefile is designed so that lcc can be installed from a read-only
  104. file system or directory, which is common in networked environments, so the distribution
  105. can be unloaded on a central file server. <strong>You will need an existing ANSI/ISO C
  106. compiler to build and install lcc.</strong></p>
  107. <h2><a NAME="unix">Installation on UNIX</a></h2>
  108. <p>The compilation components (the preprocessor, include files, and compiler proper, etc.)
  109. are installed in a single <em>build directory</em>. On multi-platform systems supported by
  110. a central file server, it's common to store the build directory in a location specific to
  111. the platform and to the version of lcc, and to point a symbolic link to this location. For
  112. example,</p>
  113. <blockquote>
  114. <pre>% ln -s /usr/local/lib/lcc-4.1/sparc-solaris /usr/local/lib/lcc</pre>
  115. </blockquote>
  116. <p>points <code>/usr/local/lib/lcc</code> to a build directory for lcc version 4.1 on the
  117. SPARC under Solaris. Links into <code>/usr/local/lib</code> are created for the programs <code>lcc</code>
  118. and <code>bprint</code>. Thus, a new distribution can be installed by building it in its
  119. own build directory and changing one symbolic link to point to that directory. If these
  120. conventions or their equivalents are followed, the host-specific parts of the driver
  121. program, <code>lcc</code>, can be used unmodified.</p>
  122. <p>Installation on a UNIX system involves the following steps. Below, the build directory
  123. is referred to as <code>BUILDDIR</code>.
  124. <ol>
  125. <li>Create the build directory, using a version- and platform-specific naming convention as
  126. suggested above, and record the name of this directory in the <code>BUILDDIR</code>
  127. environment variable:<blockquote>
  128. <pre>% setenv BUILDDIR /usr/local/lib/lcc-4.1/sparc-solaris
  129. % mkdir -p $BUILDDIR</pre>
  130. </blockquote>
  131. <p>Here and below, commands assume the C shell. Also, you'll need a version of <code>mkdir</code>
  132. that supports the <code>-p</code> option, which creates intermediate directories as
  133. necessary.</p>
  134. </li>
  135. <li>Copy the man pages to the repository for local man pages, e.g.,<blockquote>
  136. <pre>% cp doc/*.1 /usr/local/man/man1</pre>
  137. </blockquote>
  138. <p>Some users copy the man pages to the build directory and create the appropriate
  139. symbolic links, e.g., </p>
  140. <blockquote>
  141. <pre>% cp doc/*.1 $BUILDDIR
  142. % ln -s $BUILDDIR/*.1 /usr/local/man/man1</pre>
  143. </blockquote>
  144. </li>
  145. <li>Platform-specific include files are in directories named <code>include/</code><em>target</em><code>/</code><em>os</em>.
  146. Create the include directory in the build directory, and copy the include hierarchy for
  147. your platform to this directory, e.g.,<blockquote>
  148. <pre>% mkdir $BUILDDIR/include
  149. % cp -p -R include/sparc/solaris/* $BUILDDIR/include</pre>
  150. </blockquote>
  151. <p>Again, some users create a symbolic link to the appropriate directory in the
  152. distribution instead of copying the include files. For example, at Princeton, the
  153. distributions are stored under <code>/proj/pkg/lcc</code>, so the included files are
  154. &quot;installed&quot; by creating one symbolic link: </p>
  155. <blockquote>
  156. <pre>% ln -s /proj/pkg/lcc/4.1/include/sparc/solaris $BUILDDIR/include</pre>
  157. </blockquote>
  158. <p>If you're installing lcc on Linux, you <em>must</em> also plant a symbolic link named <code>gcc</code>
  159. to gcc's library directory, because lcc uses gcc's C preprocessor and most of gcc's header
  160. files:</p>
  161. <blockquote>
  162. <pre>% ln -s /usr/lib/gcc-lib/i486-linux/2.7.2.2 $BUILDDIR/gcc</pre>
  163. </blockquote>
  164. <p>The library directory shown above may be different on your Linux machine; to determine
  165. the correct directory, browse <code>/usr/lib/gcc-lib</code>, or execute</p>
  166. <blockquote>
  167. <pre>% cc -v tst/8q.c</pre>
  168. </blockquote>
  169. <p>and examine the diagnostic output. Make sure that <code>$BUILDDIR/gcc/cpp</code> and <code>$BUILDDIR/gcc/include</code>
  170. point to, respectively, gcc's C preprocessor and header files. On Linux, lcc looks for
  171. include files in <code>$BUILDDIR/include</code>, <code>$BUILDDIR/gcc/include</code>, and <code>/usr/include</code>,
  172. in that order; see <a HREF="#driver"><em>Building the Driver</em></a> and <a
  173. href="../etc/linux.c"><code>etc/linux.c</code></a> for details.</p>
  174. </li>
  175. <li>The <a HREF="../makefile"><code>makefile</code></a> includes the file named by the <code>CUSTOM</code>
  176. macro; the default is <code>custom.mk</code>, and an empty <code>custom.mk</code> is
  177. included in the distribution. If desired, prepare a site-specification customization file
  178. and define <code>CUSTOM</code> to the path of that file when invoking make in steps 5 and
  179. 6, e.g.,<blockquote>
  180. <pre>make CUSTOM=/users/drh/solaris.mk</pre>
  181. </blockquote>
  182. <p>You can, for example, use customization files to record site-specific values for macros
  183. instead of using environment variables, and to record targets for the steps in this list.</p>
  184. </li>
  185. <li>Build the host-specific driver, creating a custom host-specific part, if necessary. See <a
  186. HREF="#driver"><em>Building the Driver</em></a>.</li>
  187. <li>Build the preprocessor, compiler proper, library, and other accessories. See <a
  188. HREF="#rcc"><em>Building the Compiler</em></a>.</li>
  189. <li>Plant symbolic links to the build directory and to the installed programs, e.g.,<blockquote>
  190. <pre>% ln -s $BUILDDIR /usr/local/lib/lcc
  191. % ln -s /usr/local/lib/{lcc,bprint} /usr/local/bin</pre>
  192. </blockquote>
  193. <p>Some users copy <code>bprint</code> and <code>lcc</code> into <code>/usr/local/bin</code>
  194. instead of creating symbolic links. The advantange of creating the links for <code>lcc</code>
  195. and <code>bprint</code> as shown is that, once established, they point indirectly to
  196. whatever <code>/usr/local/lib/lcc</code> points to; installing a new version of lcc, say,
  197. 4.2, can be done by changing <code>/usr/local/lib/lcc</code> to point to the 4.2 build
  198. directory.</p>
  199. </li>
  200. </ol>
  201. <h2><a NAME="driver">Building the Driver</a></h2>
  202. <p>The preprocessor, compiler, assembler, and loader are invoked by a driver program, <code>lcc</code>,
  203. which is similar to <code>cc</code> on most systems. It's described in the man page <code>doc/lcc.1</code>.
  204. The driver is built by combining the host-independent part, <a href="../etc/lcc.c"><code>etc/lcc.c</code></a>,
  205. with a small host-specific part. Distributed host-specific parts are named <code>etc/</code><em>os</em><code>.c</code>,
  206. where <em>os</em> is the name of the operating system for the host on which <code>lcc</code>
  207. is being installed. If you're following the installations conventions described above, you
  208. can probably use one of the host-specific parts unmodified; otherwise, pick one that is
  209. closely related to your platform, copy it to <em>whatever</em><code>.c</code>, and edit it
  210. as described below. You should not have to edit <code>etc/lcc.c</code>.</p>
  211. <p>We'll use <a HREF="../etc/solaris.c"><code>etc/solaris.c</code></a> as an example in
  212. describing how the host-specific part works. This example illustrates all the important
  213. features. Make sure you have the environment variable <code>BUILDDIR</code> set correctly,
  214. and build the driver with a <code>make</code> command, e.g.,</p>
  215. <blockquote>
  216. <pre>% make HOSTFILE=etc/solaris.c lcc
  217. cc -g -c -DTEMPDIR=\&quot;/tmp\&quot; -o /usr/local/lib/lcc-4.1/sparc-solaris/lcc.o etc/lcc.c
  218. cc -g -c -o /usr/local/lib/lcc-4.1/sparc-solaris/host.o etc/solaris.c
  219. cc -g -o /usr/local/lib/lcc-4.1/sparc-solaris/lcc /usr/local/lib/lcc-4.1/sparc-solaris/lcc.o /usr/local/lib/lcc-4.1/sparc-solaris/host.o</pre>
  220. </blockquote>
  221. <p>The symbolic name <code>HOSTFILE</code> specifies the path to the host-specific part,
  222. either one in the distribution or <em>whatever</em><code>.c</code>. Some versions of make
  223. may require the <code>-e</code> option in order to read the environment.</p>
  224. <p>Here's <code>etc/solaris.c</code>:</p>
  225. <blockquote>
  226. <pre>/* Sparcs running Solaris 2.5.1 at CS Dept., Princeton University */
  227. #include &lt;string.h&gt;
  228. static char rcsid[] = &quot;$ Id: solaris.c,v 1.10 1998/09/14 20:36:33 drh Exp $&quot;;
  229. #ifndef LCCDIR
  230. #define LCCDIR &quot;/usr/local/lib/lcc/&quot;
  231. #endif
  232. #ifndef SUNDIR
  233. #define SUNDIR &quot;/opt/SUNWspro/SC4.2/lib/&quot;
  234. #endif
  235. char *suffixes[] = { &quot;.c&quot;, &quot;.i&quot;, &quot;.s&quot;, &quot;.o&quot;, &quot;.out&quot;, 0 };
  236. char inputs[256] = &quot;&quot;;
  237. char *cpp[] = { LCCDIR &quot;cpp&quot;,
  238. &quot;-D__STDC__=1&quot;, &quot;-Dsparc&quot;, &quot;-D__sparc__&quot;, &quot;-Dsun&quot;, &quot;-D__sun__&quot;, &quot;-Dunix&quot;,
  239. &quot;$1&quot;, &quot;$2&quot;, &quot;$3&quot;, 0 };
  240. char *include[] = { &quot;-I&quot; LCCDIR &quot;include&quot;, &quot;-I/usr/local/include&quot;,
  241. &quot;-I/usr/include&quot;, 0 };
  242. char *com[] = { LCCDIR &quot;rcc&quot;, &quot;-target=sparc/solaris&quot;,
  243. &quot;$1&quot;, &quot;$2&quot;, &quot;$3&quot;, 0 };
  244. char *as[] = { &quot;/usr/ccs/bin/as&quot;, &quot;-Qy&quot;, &quot;-s&quot;, &quot;-o&quot;, &quot;$3&quot;, &quot;$1&quot;, &quot;$2&quot;, 0 };
  245. char *ld[] = { &quot;/usr/ccs/bin/ld&quot;, &quot;-o&quot;, &quot;$3&quot;, &quot;$1&quot;,
  246. SUNDIR &quot;crti.o&quot;, SUNDIR &quot;crt1.o&quot;,
  247. SUNDIR &quot;values-xa.o&quot;, &quot;$2&quot;, &quot;&quot;,
  248. &quot;-Y&quot;, &quot;P,&quot; SUNDIR &quot;:/usr/ccs/lib:/usr/lib&quot;, &quot;-Qy&quot;,
  249. &quot;-L&quot; LCCDIR, &quot;-llcc&quot;, &quot;-lm&quot;, &quot;-lc&quot;, SUNDIR &quot;crtn.o&quot;, 0 };
  250. extern char *concat(char *, char *);
  251. int option(char *arg) {
  252. if (strncmp(arg, &quot;-lccdir=&quot;, 8) == 0) {
  253. cpp[0] = concat(&amp;arg[8], &quot;/cpp&quot;);
  254. include[0] = concat(&quot;-I&quot;, concat(&amp;arg[8], &quot;/include&quot;));
  255. ld[12] = concat(&quot;-L&quot;, &amp;arg[8]);
  256. com[0] = concat(&amp;arg[8], &quot;/rcc&quot;);
  257. } else if (strcmp(arg, &quot;-p&quot;) == 0) {
  258. ld[5] = SUNDIR &quot;mcrt1.o&quot;;
  259. ld[10] = &quot;P,&quot; SUNDIR &quot;libp:/usr/ccs/lib/libp:/usr/lib/libp:&quot;
  260. SUNDIR &quot;:/usr/ccs/lib:/usr/lib&quot;;
  261. } else if (strcmp(arg, &quot;-b&quot;) == 0)
  262. ;
  263. else if (strncmp(arg, &quot;-ld=&quot;, 4) == 0)
  264. ld[0] = &amp;arg[4];
  265. else
  266. return 0;
  267. return 1;
  268. }</pre>
  269. </blockquote>
  270. <p><code>LCCDIR</code> defaults to <code>&quot;/usr/local/lib/lcc/&quot;</code> unless
  271. it's defined by a <code>-D</code> option as part of <code>CFLAGS</code> in the make
  272. command, e.g.,</p>
  273. <blockquote>
  274. <pre>% make HOSTFILE=etc/solaris.c CFLAGS='-DLCCDIR=\&quot;/v/lib/lcc/\&quot;' lcc</pre>
  275. </blockquote>
  276. <p>Note the trailing slash; <code>SUNDIR</code> is provided so you can use <code>etc/solaris.c</code>
  277. even if you have a different version of the Sun Pro compiler suite. If you're using the
  278. gcc compiler tools instead of the Sun Pro tools, see <a HREF="../etc/gcc-solaris.c"><code>etc/gcc-solaris.c</code></a>.</p>
  279. <p>Most of the host-specific code is platform-specific data and templates for the commands
  280. that invoke the preprocessor, compiler, assembler, and loader. The <code>suffixes</code>
  281. array lists the file name suffixes for C source files, preprocessed source files, assembly
  282. language source files, object files, and executable files. <code>suffixes</code> must be
  283. terminated with a null pointer, as shown above. The initialization of <code>suffixes</code>
  284. in <code><a HREF="../etc/solaris.c">etc/solaris.c</a></code> are the typical ones for UNIX
  285. systems. Each element of <code>suffixes</code> is actually a list of suffixes, separated
  286. by semicolons; <code><a HREF="../etc/win32.c">etc/win32.c</a></code> holds an example:</p>
  287. <blockquote>
  288. <pre>char *suffixes[] = { &quot;.c;.C&quot;, &quot;.i;.I&quot;, &quot;.asm;.ASM;.s;.S&quot;, &quot;.obj;.OBJ&quot;, &quot;.exe&quot;, 0 };</pre>
  289. </blockquote>
  290. <p>When a list is given, the first suffix is used whenever lcc needs to generate a file
  291. name. For example, with <code><a HREF="../etc/win32.c">etc/win32.c</a></code>, lcc emits
  292. the generated assembly code into <code>.asm</code> files.</p>
  293. <p>The <code>inputs</code> array holds a null-terminated string of directories separated
  294. by colons or semicolons. These are used as the default value of <code>LCCINPUTS</code>, if
  295. the environment variable <code>LCCINPUTS</code> is not set; see the <a HREF="lcc.pdf">man
  296. page</a>.</p>
  297. <p>Each command template is an array of pointers to strings terminated with a null
  298. pointer; the strings are full path names of commands, arguments, or argument placeholders,
  299. which are described below. Commands are executed in a child process, and templates can
  300. contain multiple commands by separating commands with newlines. The driver runs each
  301. command in a new process.</p>
  302. <p>The <code>cpp</code> array gives the command for running lcc's preprocessor, <code>cpp</code>.
  303. Literal arguments specified in templates, e.g., <code>&quot;-Dsparc&quot;</code> in the <code>cpp</code>
  304. command above, are passed to the command as given.</p>
  305. <p>The strings <code>&quot;$1&quot;</code>, <code>&quot;$2&quot;</code>, and <code>&quot;$3&quot;</code>
  306. in templates are placeholders for <em>lists</em> of arguments that are substituted in a
  307. copy of the template before the command is executed. <code>$1</code> is replaced by the <em>options</em>
  308. specified by the user; for the preprocessor, this list always contains at least <code>-D__LCC__</code>.
  309. <code>$2</code> is replaced by the <em>input</em> files, and <code>$3</code> is replaced
  310. by the <em>output</em> file.</p>
  311. <p>Zero-length arguments after replacement are removed from the argument list before the
  312. command is invoked. So, for example, if the preprocessor is invoked without an output
  313. file, <code>&quot;$3&quot;</code> becomes <code>&quot;&quot;</code>, which is removed from
  314. the final argument list.</p>
  315. <p>The <code>include</code> array is a list of <code>-I</code> options that specify which
  316. directives should be searched to satisfy include directives. These directories are
  317. searched in the order given. The first directory should be the one to which the ANSI
  318. header files were copied as described in <a HREF="#unix">UNIX</a> or <a HREF="#win32">Windows</a>
  319. installation instructions. The driver adds these options to <code>cpp</code>'s arguments
  320. when it invokes the preprocessor, except when <code>-N</code> is specified.</p>
  321. <p><code>com</code> gives the command for invoking the compiler. This template can appear
  322. as shown above in a custom host-specific part, but the option <code>-target=sparc/solaris</code>
  323. should be edited to the <em>target</em><code>/</code><em>os</em> for your platform. If <code>com[1]</code>
  324. includes the string &quot;<code>win32</code>&quot;, the driver assumes it's running on
  325. Windows. lcc can generate code for <em>all</em> of the <em>target</em><code>/</code><em>os</em>
  326. combinations listed in the file <code>src/bind.c</code>. The <code>-target</code> option
  327. specifies the default combination. The driver's <code>-Wf</code> option can be used to
  328. specify other combinations; the <a HREF="lcc.pdf">man page</a> elaborates.</p>
  329. <p><code>as</code> gives the command for invoking the assembler. On Linux, you must be
  330. running at least version 2.8.1 of the GNU assembler; earlier versions mis-assemble some
  331. instructions emitted by lcc.</p>
  332. <p><code>ld</code> gives the command for invoking the loader. For the other commands, the
  333. list <code>$2</code> contains a single file; for <code>ld</code>, <code>$2</code> contains
  334. all &quot;.o&quot; files and libraries, and <code>$3</code> is <code>a.out</code>, unless
  335. the <code>-o</code> option is specified. As suggested in the code above, <code>ld</code>
  336. must also specify the appropriate startup code and default libraries, including the lcc
  337. library, <code>liblcc.a</code>.</p>
  338. <p>The <code>option</code> function is described below; the minimal <code>option</code>
  339. function just returns 0.</p>
  340. <p>You can test <code>lcc</code> with the options <code>-v -v</code> to display the
  341. commands that would be executed, e.g.,</p>
  342. <blockquote>
  343. <pre>% $BUILDDIR/lcc -v -v foo.c baz.c mylib.a -lX11
  344. /usr/local/lib/lcc-4.1/lcc $ Id: solaris.c,v 1.10 1998/09/14 20:36:33 drh Exp $
  345. foo.c:
  346. /usr/local/lib/lcc/cpp -D__STDC__=1 -Dsparc -D__sparc__ -Dsun -D__sun__ -Dunix -D__LCC__ -I/usr/local/lib/lcc/include -I/usr/local/include -I/usr/include foo.c /tmp/lcc266290.i
  347. /usr/local/lib/lcc/rcc -target=sparc/solaris -v /tmp/lcc266290.i /tmp/lcc266291.
  348. s
  349. /usr/ccs/bin/as -Qy -s -o /tmp/lcc266292.o /tmp/lcc266291.s
  350. baz.c:
  351. /usr/local/lib/lcc/cpp -D__STDC__=1 -Dsparc -D__sparc__ -Dsun -D__sun__ -Dunix -D__LCC__ -I/usr/local/lib/lcc/include -I/usr/local/include -I/usr/include baz.c /tmp/lcc266290.i
  352. /usr/local/lib/lcc/rcc -target=sparc/solaris -v /tmp/lcc266290.i /tmp/lcc266291.s
  353. /usr/ccs/bin/as -Qy -s -o /tmp/lcc266293.o /tmp/lcc266291.s
  354. /usr/ccs/bin/ld -o a.out /opt/SUNWspro/SC4.2/lib/crti.o /opt/SUNWspro/SC4.2/lib/crt1.o /opt/SUNWspro/SC4.2/lib/values-xa.o /tmp/lcc266292.o /tmp/lcc266293.o mylib.a -lX11 -Y P,/opt/SUNWspro/SC4.2/lib/:/usr/ccs/lib:/usr/lib -Qy -L/usr/local/lib/lcc/ -llcc -lm -lc /opt/SUNWspro/SC4.2/lib/crtn.o
  355. rm /tmp/lcc266293.o /tmp/lcc266290.i /tmp/lcc266291.s /tmp/lcc266292.o</pre>
  356. </blockquote>
  357. <p>As the output shows, <code>lcc</code> places temporary files in <code>/tmp</code>; if
  358. any of the environment variables <code>TMP</code>, <code>TEMP</code>, and <code>TMPDIR</code>
  359. are set, they override this default (in the order shown) as does the <code>-tempdir=</code><em>dir</em>
  360. option. The default can be changed by defining <code>TEMPDIR</code> in <code>CFLAGS</code>
  361. when building the driver.</p>
  362. <p>The <code>option</code> function is called for the options <code>-Wo</code>, <code>-g</code>,
  363. <code>-p</code>, <code>-pg</code>, and <code>-b</code> because these compiler options
  364. might also affect the loader's arguments. For these options, the driver calls <code>option(arg)</code>
  365. to give the host-specific code an opportunity to edit the <code>ld</code> command, if
  366. necessary. <code>option</code> can change <code>ld</code>, if necessary, and return 1 to
  367. announce its acceptance of the option. If the option is unsupported, <code>option</code>
  368. should return 0.</p>
  369. <p>For example, in response to <code>-g</code>, the <code>option</code> function shown
  370. above accepts the option but does nothing else, because the <code>ld</code> and <code>as</code>
  371. commands don't need to be modified on the SPARC. <code>-g</code> will also be added to the
  372. compiler's options by the host-independent part of the driver. The <code>-p</code> causes <code>option</code>
  373. to change the name of the startup code and changed the list of libraries. The <code>-b</code>
  374. option turns on <code>lcc</code>'s per-expression profiling, the code for which is in <code>liblcc.a</code>,
  375. so <code>option</code> need no nothing.</p>
  376. <p>On SPARCs, the driver also recognizes <code>-Bstatic</code> and <code>-Bdynamic</code>
  377. as linker options. The driver recognizes but ignores &quot;<code>-target</code> <em>name</em>&quot;
  378. option.</p>
  379. <p>The option <code>-Wo</code><em>arg</em> causes the driver to pass <em>arg</em> to <code>option</code>.
  380. Such options have no other effect; this mechanism is provided to support system-specific
  381. options that affect the commands executed by the driver. As illustrated above,
  382. host-specific parts should support the <code>-Wo-lccdir=</code><em>dir</em> option, which
  383. causes lcc's compilation components to be found in <em>dir</em>, because this option is
  384. used by the test scripts, and because the driver simulates a <code>-Wo-lccdir</code>
  385. option with the value of the environment variable <code>LCCDIR</code>, if it's defined.
  386. The code above rebuilds the paths to the include files, preprocessor, compiler, and
  387. library by calling <code>concat</code>, which is defined in <code>etc/lcc.c</code>.</p>
  388. <h2><a NAME="rcc">Building the Compiler and Accessories</a></h2>
  389. <p>To build the rest of compilation components make sure <code>BUILDDIR</code> is set
  390. appropriately and type &quot;<code>make all</code>&quot;. This command builds <code>librcc.a</code>
  391. (the compiler's private library), <code>rcc</code> (the compiler proper), <code>lburg</code>
  392. (the code-generator generator), <code>cpp</code> (the preprocessor), <code>liblcc.a</code>
  393. (the runtime library), and <code>bprint</code> (the profile printer), all in <code>BUILDDIR</code>.
  394. There may be warnings, but there should be no errors. If you're using an ANSI/ISO compiler
  395. other than <code>cc</code>, specify its name with the <code>CC=</code> option, e.g.,
  396. &quot;<code>make CC=gcc all</code>&quot;. If you're running on a DEC ALPHA, use &quot;<code>make
  397. CC='cc -std1' all</code>&quot;; the <code>-std1</code> option is essential on the ALPHA.
  398. If you're on a DEC 5000 running Ultrix 4.3, use &quot;<code>make CC=c89 all</code>&quot;.</p>
  399. <p>Once <code>rcc</code> is built with the host C compiler, run the test suite to verify
  400. that <code>rcc</code> is working correctly. If any of the steps below fail, contact us
  401. (see <a HREF="#bugs"><em>Reporting Bugs</em></a>). The commands in the makefile run the
  402. shell script <code>src/run.sh</code> on each C program in the test suite, <code>tst/*.c</code>.
  403. It uses the driver, <code>$BUILDDIR/lcc</code>, so you must have the driver in the build
  404. directory before testing <code>rcc</code>. The <em>target</em><code>/</code><em>os</em>
  405. combination is read from the variable <code>TARGET</code>, which must be specified when
  406. invoking <code>make</code>:</p>
  407. <blockquote>
  408. <pre>% make TARGET=sparc/solaris test
  409. mkdir -p /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst
  410. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/8q.s:
  411. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/array.s:
  412. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/cf.s:
  413. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/cq.s:
  414. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/cvt.s:
  415. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/fields.s:
  416. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/front.s:
  417. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/incr.s:
  418. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/init.s:
  419. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/limits.s:
  420. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/paranoia.s:
  421. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/sort.s:
  422. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/spill.s:
  423. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/stdarg.s:
  424. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/struct.s:
  425. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/switch.s:
  426. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/wf1.s:
  427. /usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/yacc.s:</pre>
  428. </blockquote>
  429. <p>Each line in the output above is of the form</p>
  430. <blockquote>
  431. <p><code>$BUILDDIR/rcc -target=</code><em>target</em><code>/</code><em>os</em><code>$BUILDDIR/</code><em>target</em><code>/</code><em>os</em><code>/</code><em>X</em><code>.s:</code></p>
  432. </blockquote>
  433. <p>where <em>X</em> is the base name of the C program <em>X</em><code>.c</code> in the
  434. test suite. This output identifies the compiler and the target, e.g., &quot;<code>$BUILDDIR/rcc</code>
  435. is generating code for a <code>sparc</code> running the <code>solaris</code> operating
  436. system.&quot;</p>
  437. <p>For each program in the test suite, <code>src/run.sh</code> compiles the program, drops
  438. the generated assembly language code in <code>BUILDDIR</code>/<em>target</em><code>/</code><em>os</em>,
  439. and uses <code>diff</code> to compare the generated assembly code with the expected code
  440. (the code expected for <code>tst/8q.c</code> on the SPARC under Solaris is in <code>sparc/solaris/tst/8q.sbk</code>,
  441. etc.). If there are differences, the script executes the generated code with the input
  442. given in <code>tst</code> (the input for <code>tst/8q.c</code> is in <code>tst/8q.0</code>,
  443. etc.) and compares the output with the expected output (the expected output from <code>tst/8q.c</code>
  444. on the SPARC under Solaris is in <code>sparc/solaris/tst/8q.1bk</code>, etc.). The script
  445. also compares the diagnostics from the compiler with the expected diagnostics.</p>
  446. <p>On some systems, there may be a few differences between the generated code and the
  447. expected code. These differences occur because the expected code is generated by cross
  448. compilation and the least significant bits of some floating-point constants differ from
  449. those bits in constants generated on your system. On Linux, there may be differences
  450. because of differences in the header files between our system and yours. There should be
  451. no differences in the output from executing the test programs.</p>
  452. <p>Next, run the &quot;triple test&quot;, which builds <code>rcc</code> using itself:</p>
  453. <blockquote>
  454. <pre>% make triple
  455. /usr/local/lib/lcc-4.1/sparc-solaris/lcc -o /usr/local/lib/lcc-4.1/sparc-solaris/1rcc -d0.6 -Wo-lccdir=/usr/local/lib/lcc-4.1/sparc-solaris -B/usr/local/lib/lcc-4.1/sparc-solaris/ -Isrc src/*.c
  456. src/alloc.c:
  457. ...
  458. src/x86.c:
  459. /usr/local/lib/lcc-4.1/sparc-solaris/lcc -o /usr/local/lib/lcc-4.1/sparc-solaris/1rcc -d0.6 -Wo-lccdir=/usr/local/lib/lcc-4.1/sparc-solaris -B/usr/local/lib/lcc-4.1/sparc-solaris/ -Isrc src/*.c
  460. src/alloc.c:
  461. ...
  462. src/x86.c:
  463. strip /usr/local/lib/lcc-4.1/sparc-solaris/[12]rcc
  464. dd if=/usr/local/lib/lcc-4.1/sparc-solaris/1rcc of=/usr/local/lib/lcc-4.1/sparc-solaris/rcc1 bs=512 skip=1
  465. 769+1 records in
  466. 769+1 records out
  467. dd if=/usr/local/lib/lcc-4.1/sparc-solaris/2rcc of=/usr/local/lib/lcc-4.1/sparc-solaris/rcc2 bs=512 skip=1
  468. 769+1 records in
  469. 769+1 records out
  470. if cmp /usr/local/lib/lcc-4.1/sparc-solaris/rcc[12]; then \
  471. mv /usr/local/lib/lcc-4.1/sparc-solaris/2rcc /usr/local/lib/lcc-4.1/sparc-solaris/rcc; \
  472. rm -f /usr/local/lib/lcc-4.1/sparc-solaris/1rcc /usr/local/lib/lcc-4.1/sparc-solaris/rcc[12]; fi</pre>
  473. </blockquote>
  474. <p>This command builds <code>rcc</code> twice; once using the <code>rcc</code> built by <code>cc</code>
  475. and again using the <code>rcc</code> built by <code>lcc</code>. The resulting binaries are
  476. compared. They should be identical, as shown at the end of the output above. If they
  477. aren't, our compiler is generating incorrect code; <a HREF="#bugs">contact</a> us.</p>
  478. <p>The final version of <code>rcc</code> should also pass the test suite; that is, the
  479. output from</p>
  480. <blockquote>
  481. <pre>% make TARGET=sparc/solaris test</pre>
  482. </blockquote>
  483. <p>should be identical to that from the previous <code>make test</code>.</p>
  484. <p>The command &quot;<code>make clean</code>&quot; cleans up, but does not remove <code>rcc</code>,
  485. etc., and &quot;<code>make clobber</code>&quot; cleans up and removes <code>lcc</code>, <code>rcc</code>,
  486. and the other accessories. Test directories under <code>BUILDDIR</code> are <em>not</em>
  487. removed; you'll need to remove these by hand, e.g.,</p>
  488. <blockquote>
  489. <pre>% rm -fr $BUILDDIR/sparc</pre>
  490. </blockquote>
  491. <p>The code generators for the other targets can be tested by specifying the desired <em>target</em><code>/</code><em>os</em>
  492. and setting an environment variable that controls what <code>src/run.sh</code> does. For
  493. example, to test the MIPS code generator, type</p>
  494. <blockquote>
  495. <pre>% setenv REMOTEHOST noexecute
  496. % make TARGET=mips/irix test</pre>
  497. </blockquote>
  498. <p>As above, <code>src/run.sh</code> compares the MIPS code generated with what's
  499. expected. There should be no differences. Setting <code>REMOTEHOST</code> to <code>noexecute</code>
  500. suppresses the assembly and execution of the generated code. If you set <code>REMOTEHOST</code>
  501. to the name of a MIPS machine to which you can <code>rlogin</code>, <code>src/run.sh</code>
  502. will <code>rcp</code> the generated code to that machine and execute it there, if
  503. necessary. See <code>src/run.sh</code> for the details.</p>
  504. <p>You can use lcc as a cross compiler. The options <code>-S</code> and <code>-Wf-target=</code><em>target/os</em>
  505. generate assembly code for the specified target, which is any of those listed in the file <code>src/bind.c</code>.
  506. For example, </p>
  507. <blockquote>
  508. <pre>% lcc -Wf-target=mips/irix -S tst/8q.c</pre>
  509. </blockquote>
  510. <p>generates MIPS code for <code>tst/8q.c</code> in <code>8q.s</code>.</p>
  511. <p>lcc can also generate code for a &quot;symbolic&quot; target. This target is used
  512. routinely in front-end development, and its output is a printable representation of the
  513. input program, e.g., the dags constructed by the front end are printed, and other
  514. interface functions print their arguments. You can specify this target with the option <code>-Wf-target=symbolic</code>.
  515. For example,</p>
  516. <blockquote>
  517. <pre>% lcc -Wf-target=symbolic -S tst/8q.c</pre>
  518. </blockquote>
  519. <p>generates symbolic output for <code>tst/8q.c</code> in <code>8q.s</code>. Adding <code>-Wf-html</code>
  520. causes the symbolic target to emit HTML instead of plain text. Finally, the option <code>-Wf-target=null</code>
  521. specifies the &quot;null&quot; target for which lcc emits nothing and thus only checks the
  522. syntax and semantics of its input files.</p>
  523. <h2><a NAME="win32">Installation on Windows NT 4.0 or Windows 95/98</a></h2>
  524. <p>On Windows NT 4.0 and Windows 95/98, lcc is designed to work with Microsoft's Visual
  525. C++ 5.0 (VC) and Microsoft's Assembler, MASM 6.11d. It uses the VC header files,
  526. libraries, and command-line tools, and it uses MASM to assemble the code it generates. If
  527. you have MASM 6.11, make sure you <a
  528. HREF="http://support.microsoft.com/support/kb/articles/Q138/9/83.asp">upgrade to 6.11d</a>,
  529. because earlier 6.11 releases do not generate correct COFF object files.</p>
  530. <p>Building the distribution components from the ground up requires Microsoft's Visual
  531. C/C++ 5.0 compiler, Microsoft's make, <code>nmake</code>, and the standard Windows command
  532. interpreter. <a HREF="../makefile.nt"><code>makefile.nt</code></a> is written to use only <code>nmake</code>.
  533. As on UNIX systems, the compilation components are installed in a single <em>build
  534. directory</em>, and the top-level programs, <code>lcc.exe</code> and <code>bprint.exe</code>,
  535. are installed in a directory on the PATH. If the conventions used below are followed, the
  536. Windows-specific parts of the driver program, <code>lcc.exe</code>, can be used
  537. unmodified.</p>
  538. <p>Building from the source distribution on a Windows system involves the following steps.
  539. Below, the build directory is referred to as <code>BUILDDIR</code>, and the distribution
  540. is in <code>\dist\lcc\4.1</code>.
  541. <ol>
  542. <li>Create the build directory, perhaps using a version- and platform-specific naming
  543. convention as suggested in <a HREF="#unix"><em>Installation on UNIX</em></a>, and record
  544. the name of this directory in the <code>BUILDDIR</code> environment variable:<blockquote>
  545. <pre>C:\dist\lcc\4.1&gt;set BUILDDIR=\progra~1\lcc\4.1\bin
  546. C:\dist\lcc\4.1&gt;mkdir %BUILDDIR%</pre>
  547. </blockquote>
  548. <p>The default build, or installation, directory is <code>\Program Files\lcc\4.1\bin</code>,
  549. but the <code>nmake</code> commands require that you use the corresponding 8.3 file name, <code>progra~1</code>,
  550. instead of <code>Program Files</code>.</p>
  551. </li>
  552. <li><a HREF="../etc/win32.c"><code>etc\win32.c</code></a> is the Windows-specific part of
  553. the driver. It assumes that environment variable <code>include</code> gives the locations
  554. of the VC header files and that the linker (<code>link.exe</code>) and the assembler (<code>ml.exe</code>)
  555. are on the PATH. It also assumes that the macro <code>LCCDIR</code> gives the build
  556. directory. If necessary, revise a copy of <a HREF="../etc/win32.c"><code>etc\win32.c</code></a>
  557. to reflect the conventions on your computer (see <a HREF="#driver"><em>Building the Driver</em></a>),
  558. then build the driver, specifying the default temporary directory, if necessary:<blockquote>
  559. <pre>C:\dist\lcc\4.1&gt;nmake -f makefile.nt TEMPDIR=\\temp HOSTFILE=etc/win32.c lcc
  560. ...
  561. cl -nologo -Zi -MLd -Fd\progra~1\lcc\4.1\bin\ -c -DTEMPDIR=\&quot;\\temp\&quot; -Fo\progra~1\lcc\4.1\bin\lcc.obj etc/lcc.c
  562. lcc.c
  563. cl -nologo -Zi -MLd -Fd\progra~1\lcc\4.1\bin\ -c -Fo\progra~1\lcc\4.1\bin\host.obj etc/win32.c
  564. win32.c
  565. cl -nologo -Zi -MLd -Fd\progra~1\lcc\4.1\bin\ -Fe\progra~1\lcc\4.1\bin\lcc.exe \progra~1\lcc\4.1\bin\lcc.obj \progra~1\lcc\4.1\bin\host.obj</pre>
  566. </blockquote>
  567. <p>If you make a copy of <code>etc\win32.c</code>, specify the path of the copy as the
  568. value of <code>HOSTFILE</code>. For example, if you copy <code>etc\win32.c</code> to <code>BUILDDIR</code>
  569. and edit it, use the command</p>
  570. <blockquote>
  571. <pre>C:\dist\lcc\4.1&gt;nmake -f makefile.nt TEMPDIR=\\temp HOSTFILE=%BUILDDIR%\win32.c lcc</pre>
  572. </blockquote>
  573. </li>
  574. <li>Build the preprocessor, compiler proper, library, and other accessories (see <a
  575. HREF="#rcc"><em>Building the Compiler</em></a>):<blockquote>
  576. <pre>C:\dist\lcc\4.1&gt;nmake -f makefile.nt all</pre>
  577. </blockquote>
  578. <p>This command uses the VC command-line tools <code>cl</code> and <code>lib</code> to
  579. build <code>bprint.exe</code>, <code>cpp.exe</code>, <code>lburg.exe</code>, <code>liblcc.lib</code>,
  580. <code>librcc.lib</code>, and <code>rcc.exe</code>, all in <code>BUILDDIR</code>. There may
  581. be some warnings, but there should be no warnings.</p>
  582. </li>
  583. <li>Create a test directory and run the test suite:<blockquote>
  584. <pre>C:\dist\lcc\4.1&gt;mkdir %BUILDDIR%\x86\win32\tst
  585. C:\dist\lcc\4.1&gt;nmake -f makefile.nt test</pre>
  586. </blockquote>
  587. <p>This command compiles each program in <a HREF="../tst">tst</a>, compares the generated
  588. assembly code and diagnostics with the expected assembly code and diagnostics, executes
  589. the program, and compares the output with the expected output (using <code>fc</code>). For
  590. example, when the nmake command compiles <a HREF="../tst/8q.c"><code>tst\8q.c</code></a>,
  591. it leaves the generated assembly code and diagnostic output in <code>%BUILDDIR%\x86\win32\tst\8q.s</code>
  592. and <code>%BUILDDIR%\x86\win32\tst\8q.2</code>, and it compares them with the expected
  593. results in <code>x86\win32\tst\8q.sbk</code>. It builds the executable program in <code>%BUILDDIR%\x86\win32\tst\8q.exe</code>,
  594. runs it, and redirects the output to <code>%BUILDDIR%\x86\win32\tst\8q.1</code>, which it
  595. compares with <code>x86\win32\tst\8q.1bk</code>. The output from this step is voluminous,
  596. but there should be no differences and no errors.</p>
  597. </li>
  598. <li>Run the &quot;triple&quot; test, which compiles <code>rcc</code> with itself and
  599. verifies the results:<blockquote>
  600. <pre>C:\dist\lcc\4.1&gt;nmake -f makefile.nt triple
  601. ...
  602. \progra~1\lcc\4.1\bin\x86.c:
  603. Assembling: C:/TEMP/lcc2001.asm
  604. fc /b \progra~1\lcc\4.1\bin\1rcc.exe \progra~1\lcc\4.1\bin\2rcc.exe
  605. Comparing files \progra~1\lcc\4.1\bin\1rcc.exe and \progra~1\lcc\4.1\bin\2RCC.EXE
  606. 00000088: B4 D5</pre>
  607. </blockquote>
  608. <p>This command builds <code>rcc</code> twice; once using the <code>rcc</code> built by VC
  609. and again using the <code>rcc</code> built by <code>lcc</code>. The resulting binaries are
  610. compared using <code>fc</code>. They should be identical, except for one or two bytes of
  611. timestamp data, as shown at the end of the output above. If they aren't, our compiler is
  612. generating incorrect code; <a HREF="#bugs">contact</a> us.</p>
  613. </li>
  614. <li>Copy <code>lcc.exe</code> and <code>bprint.exe</code> to a directory on your PATH, e.g.,<blockquote>
  615. <pre>C:\dist\lcc\4.1&gt;copy %BUILDDIR%\lcc.exe \bin
  616. 1 file(s) copied.
  617. C:\dist\lcc\4.1&gt;copy %BUILDDIR%\bprint.exe \bin
  618. 1 file(s) copied.</pre>
  619. </blockquote>
  620. </li>
  621. <li>Finally, clean up:<blockquote>
  622. <pre>C:\dist\lcc\4.1&gt;nmake -f makefile.nt clean</pre>
  623. </blockquote>
  624. <p>This command removes the derived files in <code>BUILDDIR</code>, but does not remove <code>rcc.exe</code>,
  625. etc.; &quot;<code>nmake -f makefile.nt clobber</code>&quot; cleans up and removes all
  626. executables and libraries. Test directories under <code>BUILDDIR</code> are <em>not</em>
  627. removed; you'll need to remove these by hand, e.g.,</p>
  628. <blockquote>
  629. <pre>C:\dist\lcc\4.1&gt;rmdir %BUILDDIR%\x86 /s
  630. \progra~1\lcc\4.1\bin\x86, Are you sure (Y/N)? y</pre>
  631. </blockquote>
  632. </li>
  633. </ol>
  634. <h2><a NAME="bugs">Reporting Bugs</a></h2>
  635. <p>lcc is a large, complex program. We find and repair errors routinely. If you think that
  636. you've found a error, follow the steps below, which are adapted from the instructions in
  637. Chapter 1 of <cite>A Retargetable C Compiler: Design and Implementation</cite>.
  638. <ol>
  639. <li>If you don't have a source file that displays the error, create one. Most errors are
  640. exposed when programmers try to compile a program they think is valid, so you probably
  641. have a demonstration program already.</li>
  642. <li>Preprocess the source file and capture the preprocessor output. Discard the original
  643. code.</li>
  644. <li>Prune your source code until it can be pruned no more without sending the error into
  645. hiding. We prune most error demonstrations to fewer than five lines.</li>
  646. <li>Confirm that the source file displays the error with the <em>distributed</em> version of
  647. lcc. If you've changed lcc and the error appears only in your version, then you'll have to
  648. chase the error yourself, even if it turns out to be our fault, because we can't work on
  649. your code.</li>
  650. <li>Annotate your code with comments that explain why you think that lcc is wrong. If lcc
  651. dies with an assertion failure, please tell us where it died. If lcc crashes, please
  652. report the last part of the call chain if you can. If lcc is rejecting a program you think
  653. is valid, please tell us why you think it's valid, and include supporting page numbers in
  654. the ANSI Standard, Appendix A in <cite>The C Programming Language</cite>, or the
  655. appropriate section in <cite>C: A Reference Manual</cite>, 4th edition by S. B. Harbison
  656. and G. L. Steele, Jr. (Prentice Hall, 1995). If lcc silently generates incorrect code for
  657. some construct, please include the corrupt assembly code in the comments and flag the
  658. incorrect instructions if you can.</li>
  659. <li>Confirm that your error hasn't been fixed already. The latest version of lcc is always
  660. available for anonymous <code>ftp</code> from <code>ftp.cs.princeton.edu</code> in <a
  661. HREF="ftp://ftp.cs.princeton.edu/pub/lcc"><code>pub/lcc</code></a>. A <a
  662. HREF="ftp://ftp.cs.princeton.edu/pub/lcc/README"><code>README</code></a> file there gives
  663. acquistion details, and the <a HREF="../LOG"><code>LOG</code></a> file reports what errors
  664. were fixed and when they were fixed. If you report a error that's been fixed, you might
  665. get a canned reply.</li>
  666. <li>Send your program by electronic mail to <code>lcc-bugs@cs.princeton.edu</code>. Please
  667. send only valid C programs; put all remarks in C comments so that we can process reports
  668. semiautomatically.</li>
  669. </ol>
  670. <h2><a NAME="mailinglist">Keeping in Touch</a></h2>
  671. <p>There is an lcc mailing list for general information about lcc. To be added to the
  672. list, send a message with the 1-line body</p>
  673. <blockquote>
  674. <pre>subscribe lcc</pre>
  675. </blockquote>
  676. <p>to <code>majordomo@cs.princeton.edu</code>. This line must appear in the message body;
  677. &quot;Subject:&quot; lines are ignored. To learn more about mailing lists served by <code>majordomo</code>,
  678. send a message with the 1-word body &quot;<code>help</code>&quot; to <code>majordomo@cs.princeton.edu</code>.
  679. Mail sent to <code>lcc@cs.princeton.edu</code> is forwarded to everyone on the mailing
  680. list.</p>
  681. <p>There is also an <code>lcc-bugs</code> mailing list for reporting bugs; subscribe to it
  682. by sending a message with the 1-line body </p>
  683. <blockquote>
  684. <pre>subscribe lcc-bugs</pre>
  685. </blockquote>
  686. <p>to <code>majordomo@cs.princeton.edu</code>. Mail addressed to <var>lcc-bugs@cs.princeton.edu</var>
  687. is forwarded to everyone on this list.</p>
  688. <hr>
  689. <address>
  690. <a HREF="http://www.research.microsoft.com/~cwfraser/">Chris Fraser</a> / <a
  691. HREF="mailto:cwfraser@microsoft.com">cwfraser@microsoft.com</a><br>
  692. <a HREF="http://www.research.microsoft.com/~drh/">David Hanson</a> / <a
  693. HREF="mailto:drh@microsoft.com">drh@microsoft.com</a><br>
  694. $Revision: 145 $ $Date: 2001-10-17 16:53:10 -0500 (Wed, 17 Oct 2001) $
  695. </address>
  696. </body>
  697. </html>