.\" $OpenBSD: cc.1,v 1.4 2008/04/11 20:45:52 stefan Exp $ .\" .\" Copyright (c) 2007 Jeremy C. Reed .\" .\" Permission to use, copy, modify, and/or distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND .\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" .Dd September 14, 2007 .Dt CC 1 .Os .Sh NAME .Nm cc .Nd front-end to the C compiler .Sh SYNOPSIS .Nm .Op Fl cEgkLMPOStvXx .Op Fl fPIC .Op Fl fpic .Op Fl m Ns Ar option .Op Fl nostartfiles .Op Fl nostdinc .Op Fl nostdlib .Op Fl pg .Op Fl pthread .Op Fl static .Op Fl B Ar prefix .Op Fl D Ar macro[=value] .Op Fl d Ar option .Op Fl I Ar directory .Op Fl include Ar path .Op Fl isystem Ar path .Op Fl o Ar outfile .Op Fl Wl Ar flags .Op Ar .Sh DESCRIPTION The .Nm utility provides a front-end to the .Dq portable C compiler . Multiple files may be given on the command line. Unrecognized options are all sent directly to .Xr ld 1 . .Pp .\" Brief description of its syntax: Filenames that end with .Sy \&.c are passed via .Xr cpp 1 -\*[Gt] .Xr ccom 1 -\*[Gt] .Xr as 1 -\*[Gt] .Xr ld 1 . .Pp Filenames that end with .Sy \&.i are passed via .Xr ccom 1 -\*[Gt] .Xr as 1 -\*[Gt] .Xr ld 1 . .Pp Filenames that end with .Sy \&.s are passed via .Xr as 1 -\*[Gt] .Xr ld 1 . .Pp Filenames that end with .Sy \&.o are passed directly to .Xr ld 1 . .Pp .\" The options are as follows: .Bl -tag -width Ds .It Fl B Ar prefix Define alternate prefix path for .Xr cpp 1 , .Xr ccom 1 , .Xr as 1 , or .Xr ld 1 executables. .\" TODO: provide an example of -B .It Fl C Passed to the .Xr cpp 1 preprocessor to not discard comments. .It Fl c Only compile or assemble and then stop. Do not link. The resulting object output is saved as a filename with a .Dq \&.o suffix unless .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl D Ar macro[=value] Passed to the .Xr cpp 1 preprocessor to define .Ar macro . .It Fl d Ar option Passed to the .Xr as 1 assembler. .\" TODO: what is as -dfoo for? .It Fl E Stop after preprocessing with .Xr cpp 1 . Do not compile, assemble, or link. Output is sent to standard output unless the .Fl o option is used. .It Fl fPIC Generate PIC code. .\" TODO: document about avoiding machine-specific maximum size? .It Fl fpic Tells C compiler to generate PIC code and tells assembler that PIC code has been generated. .\" TODO: document difference between PIC and pic .\" other -f GCC compatibility flags are ignored for now .It Fl g Send .Fl g flag to .Xr ccom 1 to create debug output. This unsets the .Fl O option. .It Fl I Ar path Passed to the .Xr cpp 1 preprocessor to add header search directory to override system defaults. .It Fl include Ar file Tells the .Xr cpp 1 preprocessor to include the .Ar file during preprocessing. .It Fl isystem Ar path Defines .Ar path as a system header directory for the .Xr cpp 1 preprocessor. .It Fl k Generate PIC code. See .Fl fpic option. .It Fl L TODO .It Fl M Pass .Fl M flag to .Xr cpp 1 to generate dependencies for .Xr make 1 . .It Fl m Ns options Target-dependent option. .Bl -tag -width PowerPC .It ARM -mlittle-endian -mbig-endian -mfpe=fpa -mfpe=vpf -msoft-float -march=armv1 -march=armv2 -march=armv2a -march=armv3 -march=armv4 -march=armv4t -march=armv4tej -march=armv5 -march=armv6 -march=armv6t2 -march=armv6kz -march=armv6k -march=armv7 .It HPPA .It i386 .It MIPS -mlittle-endian -mbig-endian -mhard-float -msoft-float .It PDP-10 .It PowerPC .It Sparc64 .It VAX .El .It Fl nostartfiles Do not link with the system startup files (crt0.c, etc.) .It Fl nostdinc Do not use the system include paths (/usr/include, etc.) .It Fl nostdlib Do not link with the system C library (libc). .\" implies -nostartfiles ?? .It Fl O Enable optimizations. Currently passes .Fl xdeljumps and .Fl xtemps to .Xr ccom 1 . Note: this is unset if the .Fl g option is used. .It Fl o Ar outfile Save result to .Ar outfile . .It Fl P TODO .\" TODO: what is this? .\" TODO: Looks like it does cpp only, but I couldn't get it to work for me. .It Fl pg Enable profiling on the generated executable. .It Fl pthread Defines .Sy _PTHREADS preprocessor directive for .Xr cpp 1 . Uses .Sy -lpthread for the .Xr ld 1 linker. .It Fl S Stop after compilation by .Xr ccom 1 . Do not assemble and do not link. The resulting assembler-language output is saved as a filename with a .Dq \&.s suffix unless the .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl static Do not use dynamic linkage. By default, it will link using the dynamic linker options and/or shared objects for the platform. .It Fl t Passes .Fl t to .Xr cpp 1 for traditional C preprocessor syntax. .It Fl U Ar macro Passes to the .Xr cpp 1 preprocessor to remove the initial macro definition. .It Fl v Outputs the version of .Nm and shows what commands will be run with their command line arguments. .It Fl Wl Ar flags Options for the linker. .\" what is ignored? llist? .It Fl X Don't remove temporary files on exit. .It Fl x TODO .El .Ss Predefined Macros A few macros are predefined by .Nm when sent to .Xr cpp 1 . .Bl -diag .\" TODO: .\" .It __ASSEMBLER__ .\" Defined if suffix is .S -- why not with .s? what does this mean? .It __PCC__ Set to the major version of .Xr pcc 1 . These macros can be used to select code based on .Xr pcc 1 compatibility. See the .Fl v option. .It __PCC_MINOR__ Set to the minor version. .It __PCC_MINORMINOR__ Set to the minor-minor version -- the number after the minor version. .It _PTHREADS Defined when .Fl pthread switch is used. .El .Pp Also system- and/or machine-dependent macros may also be predefined; for example: .Dv __NetBSD__ , .Dv __ELF__ , and .Dv __i386__ . .Sh SEE ALSO .Xr as 1 , .Xr ccom 1 , .Xr cpp 1 , .Xr ld 1 .Sh HISTORY The .Nm command comes from the original Portable C Compiler by S. C. Johnson, written in the late 70's. .Pp This product includes software developed or owned by Caldera International, Inc.