Mincpp: Efficient, Portable Compilation of C Programs
Total Page:16
File Type:pdf, Size:1020Kb
Mincpp: Efficient, Portable Compilation of C Programs George Moberly B.S., Boston University A thesis submitted to the faculty of the Oregon Graduate Institute of Science & Technology in partial fulfillment of the requirements for the degree Master of Science in Computer Science April, 1994 The thesis "Mincpp:Efficient, Port; le Compilation of C Programs" by George Moberly has been examined and approved b: the following Examination Committee: .-------------______--s---------------------- a Sheard, Ph.D. 1 sistant Professor The s Research Advisor eve Otto, Ph.D. sistant Professor Acknowledgment This thesis and supporting degree program was made possible only with the financial, intellectual, and emotional support of many corporations, institutions, and individuals. Past and present employers Digital Equipment Corporation, Mentor Graphics Corporation, and SpaceLabs Medical, Incorporated generously paid for the vast majority of the educational expenses involved, and have actively supported my work. Degree credit was transferred from Tufts University, The University of Washington, and Oregon State University. The following individuals shared generously of their time to discuss issues with me: Phil Brooks and Mike Gresham of Mentor Graphics, Bill Bregar of Oregon State University, Aki Fujimura of Pure Software, Greg Kostal, Jeff Small, and of course Tim Sheard and Steve Otto of OGI. Finally, my wife Julie deserves profound credit and thanks for not letting me give up when it would have been easier to have done so, and for unwavering belief and support of this effort. Table of Contents TABLE OF CONTENTS....................................................................................................... IV LIST OF TABLES ..............................................................................................................VIII LIST OF FIGURES ................................................................................................................M ABSTRACT ..............................................................................................................................X 1. INTRODUCTIONffROBLEM STATEMENT................................................................... 1 1.1 HELLO.WORLD ..................................................................................................................... 2 1.2 NOVA.................................................................................................................................... 4 1.3 THESISPROBLEMS ................................................................................................................. 6 1.3.1 High Compile Times...................................................................................................... 6 1.3.2 Too Many Builds ........................................................................................................... 6 1.3.3 Too Few Builds ............................................................................................................. 7 1.4 CHAPTERSUMMARIES ............................................................................................................ 7 2. RELATED WORK ...............................................................................................................9 2.1 OVERVIEW............................................................................................................................. 9 2.2 SYSTEMDESCRIPTIONS ........................................................................................................ 11 2.2.1 Standard UNIX Compilers: cc. ace and cfront ............................................................. II 2.2.2 Cfront/cback ............................................................................................................... 13 2.2.3 Centerline Objectcenter.............................................................................................. 15 2.2.4 Lucid Energize ............................................................................................................ 18 2.2.5 MicrosoJ C/C++ ........................................................................................................ 20 2.2.6 BorlandC++ ..............................................................................................................20 2.2.7 IBM Tokyo Research Compile Server ..........................................................................20 2.2.8 NeST Smart Preprocessor ...........................................................................................20 2.3 DISCUSSION......................................................................................................................... 21 3. MINCPP .............................................................................................................................22 3.1 IMPLEMENTATIONRATIONALE .............................................................................................. 22 3.2 SYMBOLTABLE BASICS ........................................................................................................ 23 3.3 SCANNER............................................................................................................................. 25 3.4 PARSERBASICS .................................................................................................................... 26 3.5 A SINGLESIMPLE DECLARATION .......................................................................................... 28 3.6 SYMBOLTABLE: PART 2 ...................................................................................................... 31 3.7 EXTERNALDECLARATIONS ................................................................................................... 32 3.7.1 Simple Declarations .................................................................................................... 33 3.7.2 Function Prototypes .................................................................................................. 35 3.7.3 Enumerations .............................................................................................................. 37 3.7.4 Structures and Unions................................................................................................. 38 3.7.5 Typedef Declarations .................................................................................................. 40 3.8 FUNCTIONDEFINITIONS ....................................................................................................... 41 3.8.1 Old-Style Parameters .................................................................................................. 41 3.8.2ANSI-Style Parameters ................................................................................................ 42 3.8.3 Local Declarations ......................................................................................................43 3.8.4 Referencing .................................................................................................................44 3.9 SAVEAND REPLAY............................................................................................................... 44 3.9.1 Save ............................................................................................................................ 45 3.9.2 Replay ......................................................................................................................... 45 3.10 USINGMINCPP ................................................................................................................... 46 3.11 IMPLEMENTATIONSUMMARY .............................................................................................. 47 4 .RESULTS ........................................................................................................................... 48 4.1 BENCHMARKDESCRIPTIONS ................................................................................................. 48 4.1.1 Small Benchmarks..................................................................................................... 49 4.1.2 Large Benchmarks ....................................................................................................... 49 4.2 DIRECTORYSTRUCTURE ....................................................................................................... 50 4.3 HEADERFILE STRUCTURES ................................................................................................... 50 4.4 Noco~............................................................................................................................... 58 4.5 MAKEFILESAND BUILDSCRIPTS ........................................................................................... 58 4.6 COLLECTIONMETHODOLOGY ANDTOOLS ............................................................................. 65 4.7 RESULT DATA...................................................................................................................... 66 4.7.1 File Sizes .....................................................................................................................66 4.7.2 Cpp and Mincpp Times................................................................................................ 69 4.7.3 Compile Times ............................................................................................................71 4.7.4 Object File Sizes ......................................................................................................... 74 4.7.5 Linker and Binary Results