PAGE DATE 19990615
SYNOPSIS
cc1 [options] [standard_redirection]
cc1 is usually called from gcc/cc , along with cpp , as , and ld . That is, in typical use cc1 is not used as a stand-alone program. The complete options to cc1 are documented under see gcc, but which options are passed to cc1 is somewhat ambiguous. --help is not among them, oddly enough, even to gcc. Here's a few of the more interesting ones I assume do get passed to (and accepted by) cc1....
Warning Options
-Wall "warn all". Produces "lint"-like output. Note that
warnings are not fatal errors.
Optimization Options
-O -O2 the basic optimization options. Some code, such as the
Linux kernel, may require other options to compile
correctly.
LANGUAGE OPTIONS
-ansi
Support all ANSI standard C programs.
This turns off certain features of GNU C that are incompatible
with ANSI C, such as the asm, inline and typeof keywords, and
predefined macros such as unix and vax that identify the type
of system you are using. It also enables the undesirable and
rarely used ANSI trigraph feature, and disallows `$' as part of
identifiers.
-fno-builtin
Don't recognize built-in functions that do not begin with two
leading underscores. Currently, the functions affected include
_exit, abort, abs, alloca, cos, exit, fabs, labs, memcmp,
memcpy, sin, sqrt, strcmp, strcpy, and strlen.
The `-ansi' option prevents alloca and _exit from being builtin
functions.
-traditional
Attempt to support some aspects of traditional "K&R" C compilers.
DESCRIPTION
gcc, when invoked on a file with a name like hello.c, might first call
the cpp C preprocessor, then call cc1, the C compiler, then call as, the
assembler, then call ld, the linker. cpp handles text macro (alias)
replacement in the source file, performs inclusions of other files as
specified with #include, removes all comments, and performs other C
language pre-processing tasks. Then the actual C processing, or
compilation, is performed by cc1. GCC has analagous executables to cc1 for
other programming languages that GCC supports, including FORTRAN, C++ and
Objective-C, but only C is supported in cLIeNUX Core. Compilation is the
process of converting pre-processed C code into assembly language text,
which the assembler can then convert to binary machine code, and the
linker can then link as a command, library component, or bootable program.
EXAMPLE
gcc passes the results of the various stages of the process of building a
compiled program or library to the subsequent programs via temporary
files, but cc1 itself accepts normal shell redirection of standard input,
output, and error. This can be pretty cool. The following is the log of an
interactive session of typing C code at cc1 on stdin. My typed input is
emphasized.
shellprompt$ cc1 --help
cc1: Invalid option `--help'
int bla;
.file "stdin"
.version "01.01"
gcc2_compiled.:
int main(){
main
return 6;
}
.text
.align 16
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
movl $6,%eax
jmp .L1
.align 16
.L1:
movl %ebp,%esp
popl %ebp
ret
.Lfe1:
.size main,.Lfe1-main
^d
.comm bla,4,4
.ident "GCC: (GNU) 2.7.2.3"
time in parse: 0.000000
time in integration: 0.000000
time in jump: 0.000000
time in cse: 0.000000
time in loop: 0.000000
time in cse2: 0.000000
time in flow: 0.000000
time in combine: 0.000000
time in sched: 0.000000
time in local-alloc: 0.000000
time in global-alloc: 0.000000
time in sched2: 0.000000
time in dbranch: 0.000000
time in shorten-branch: 0.000000
time in stack-reg: 0.000000
time in final: 0.010000
time in varconst: 0.000000
time in symout: 0.000000
time in dump: 0.000000
shellprompt$
So, had that output been sent to a file instead of the terminal, it could
apparently be assembled and linked into a little program that just returns
a 6 to it's caller.
cLIeNUX is currently only for x86 platforms. The above code is 32 bit x86 GAS format assembly language, with linker directives and so on. I guess. Note that you can see from the alternation of input and output what groups of things the compiler works on as chunks. It can do it's thing once it has a complete code unit, such as the function main(){} in the above example. Well, *I* think that's kinda neat, anyway. There are probably lots of things one could learn from this use of cc1, such as how things get optimized and so on.
Copyright 1999 Richard Allen Hohensee
This file is released for redistribution only as part of an intact entire
cLIeNUX Core.