1.\" $Id: cc.1,v 1.42 2014/06/20 19:07:34 plunky Exp $ 2.\" 3.\" Copyright (c) 2007 Jeremy C. Reed <reed@reedmedia.net> 4.\" 5.\" Permission to use, copy, modify, and/or distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM 10.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11.\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND 12.\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 15.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 16.\" THIS SOFTWARE. 17.\" 18.Dd June 20, 2014 19.Dt CC 1 20.Os 21.Sh NAME 22.Nm cc 23.Nd front-end to the C compiler 24.Sh SYNOPSIS 25.Nm 26.Op Fl cEgkMPStvX 27.Op Fl B Ns Ar prefix 28.Op Fl D Ar macro Ns Oo = Ns Ar value Oc 29.Op Fl d Ns Ar flags 30.Op Fl f Ns Ar feature 31.Op Fl I Ar path 32.Op Fl include Ar file 33.Op Fl isystem Ar path 34.Op Fl L Ns Ar path 35.Op Fl m Ns Ar option 36.Op Fl nodefaultlibs 37.Op Fl nostartfiles 38.Op Fl nostdinc 39.Op Fl nostdlib 40.Op Fl O Ns Oo Ar level Oc 41.Op Fl o Ar outfile 42.Op Fl pg 43.Op Fl pthread 44.Op Fl shared 45.Op Fl static 46.Op Fl U Ar macro 47.Op Fl Wa Ns , Ns Ar options 48.Op Fl Wc Ns , Ns Ar options 49.Op Fl Wl Ns , Ns Ar options 50.Op Fl Wp Ns , Ns Ar options 51.Op Fl x Ar language 52.Op Ar 53.Sh DESCRIPTION 54The 55.Nm 56utility provides a front-end to the 57.Dq portable C compiler . 58Multiple files may be given on the command line. 59Unrecognized options are all sent directly to 60.Xr ld 1 . 61.Pp 62.\" Brief description of its syntax: 63Filenames that end with 64.Sy \&.c 65are passed via 66.Xr cpp 1 67\(-> 68.Xr ccom 1 69\(-> 70.Xr as 1 71\(-> 72.Xr ld 1 . 73.Pp 74Filenames that end with 75.Sy \&.i 76are passed via 77.Xr ccom 1 78\(-> 79.Xr as 1 80\(-> 81.Xr ld 1 . 82.Pp 83Filenames that end with 84.Sy \&.s 85are passed via 86.Xr as 1 87\(-> 88.Xr ld 1 . 89.Pp 90Filenames that end with 91.Sy \&.S 92are passed via 93.Xr cpp 1 94\(-> 95.Xr as 1 96\(-> 97.Xr ld 1 . 98.Pp 99Filenames that end with 100.Sy \&.o 101are passed directly to 102.Xr ld 1 . 103.Pp 104.\" 105The options are as follows: 106.Bl -tag -width Ds 107.It Fl B Ns Ar prefix 108Define alternate prefix path for 109.Xr cpp 1 , 110.Xr ccom 1 , 111.Xr as 1 , 112or 113.Xr ld 1 114executables. 115.\" TODO: provide an example of -B 116.It Fl C 117Passed to the 118.Xr cpp 1 119preprocessor to not discard comments. 120.It Fl c 121Stop after generating object code with 122.Xr as 1 . 123Do not link. 124The resulting object output is saved 125as a filename with a 126.Dq \&.o 127suffix unless 128.Fl o 129option is used. 130Note: cannot be combined with 131.Fl o 132if multiple files are given. 133.It Fl D Ar macro Ns Oo = Ns Ar value Oc 134Passed to the 135.Xr cpp 1 136preprocessor to define 137.Ar macro 138with an optional 139.Ar value . 140.It Fl d Ns Ar flags 141Debug options. 142.Ar flags 143is a string of characters, which signify the following actions. 144.Bl -tag -width ".Sy M" 145.It Sy M 146Cause the preprocessor to output a list of macro definitions. 147.El 148.Lp 149any unknown flags are ignored. 150.It Fl E 151Stop after preprocessing with 152.Xr cpp 1 . 153Do not compile, assemble, or link. 154Output is sent to standard output unless the 155.Fl o 156option is used. 157.It Fl ffreestanding 158Assume a freestanding environment. 159.It Fl fPIC 160Generate PIC code. 161.\" TODO: document about avoiding machine-specific maximum size? 162.It Fl fpic 163Tells C compiler to generate PIC code 164and tells assembler that PIC code has been generated. 165.\" TODO: document difference between PIC and pic 166.It Fl funsigned-char 167Tell the compiler to treat 168.Sq char 169types as if they were unsigned unless explicitly defined otherwise. 170.Fl fsigned-char 171can be used to signify the opposite behaviour. 172The default for the 173.Sq char 174type depends on the compiler target architecture. 175.It Fl fstack-protector 176Tell the compiler to wrap functions with code which checks at 177runtime that a stack overflow has not occurred. 178When stack protection is in effect, the 179.Dv __SSP__ 180macro will be defined. 181.\" other -f GCC compatibility flags are ignored for now 182.It Fl g 183Send 184.Fl g 185flag to 186.Xr ccom 1 187to create debug output. 188Debug information output can be disabled with 189.Fl g0 . 190.It Fl I Ar path 191Passed to the 192.Xr cpp 1 193preprocessor to add header search directory to override system defaults. 194.It Fl include Ar file 195Tells the 196.Xr cpp 1 197preprocessor to include the 198.Ar file 199during preprocessing. 200.It Fl isystem Ar path 201Defines 202.Ar path 203as a system header directory for the 204.Xr cpp 1 205preprocessor. 206.It Fl k 207Generate PIC code. 208See 209.Fl fpic 210option. 211.It Fl L Ns Ar path 212Passed to the linker, to add 213.Ar path 214to the list of directories searched for shared libraries. 215.It Fl M 216Pass 217.Fl M 218flag to 219.Xr cpp 1 220to generate dependencies for 221.Xr make 1 . 222.It Fl m Ns Ar option 223Target-dependent options. 224Multiple 225.Fl m 226options can be given, the following are supported: 227.Bl -tag -width PowerPC 228.It ARM 229\-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 230.It HPPA 231.It i386 232.It MIPS 233\-mlittle-endian \-mbig-endian \-mhard-float \-msoft-float 234.It PDP-10 235.It PowerPC 236.It Sparc64 237.It VAX 238.El 239.It Fl nodefaultlibs 240Do not link with the system default libraries (libc, etc.) 241.It Fl nostartfiles 242Do not link with the system startup files (crt0.c, etc.) 243.It Fl nostdinc 244Do not use the system include paths (/usr/include, etc.) 245.It Fl nostdlib 246Do not link with the system default libraries or startup files. 247.It Fl O Ns Oo Ar level Oc 248Enable compiler optimizations. 249Currently, for levels higher than zero, 250this defines 251.Dv __OPTIMIZE__ 252in the 253.Xr cpp 1 254preprocessor, and passes 255.Fl xdce , 256.Fl xdeljumps , 257.Fl xtemps 258and 259.Fl xinline 260to 261.Xr ccom 1 . 262If no level is given the optimization level is increased, or 263optimizations can be disabled using 264.Fl O0 . 265.It Fl o Ar outfile 266Save result to 267.Ar outfile . 268.It Fl P 269Inhibit generation of line markers in preprocessor output. 270This is sometimes useful when running the preprocessor on something other than C code. 271.It Fl pg 272Enable profiling on the generated executable. 273.It Fl pthread 274Defines the 275.Dv _PTHREADS 276preprocessor identifier for 277.Xr cpp 1 , and 278adds 279.Fl lpthread 280to the 281.Xr ld 1 282linker arguments. 283.It Fl S 284Stop after compilation by 285.Xr ccom 1 . 286Do not assemble and do not link. 287The resulting assembler-language output is saved 288as a filename with a 289.Dq \&.s 290suffix unless the 291.Fl o 292option is used. 293Note: cannot be combined with 294.Fl o 295if multiple files are given. 296.It Fl shared 297Create a shared object of the result. 298Tells the linker not to generate an executable. 299.It Fl static 300Do not use dynamic linkage. 301By default, it will link using the dynamic linker options 302and/or shared objects for the platform. 303.It Fl t 304Passed to 305.Xr cpp 1 306to suppress some default macro definitions and enable use 307of traditional C preprocessor syntax. 308.It Fl U Ar macro 309Passes to the 310.Xr cpp 1 311preprocessor to remove the initial macro definition. 312.It Fl v 313Outputs the version of 314.Nm 315and shows what commands will be run with their command line arguments. 316.It Fl Wa Ns , Ns Ar options 317Comma separated list of options for the assembler. 318.It Fl Wc Ns , Ns Ar options 319Comma separated list of options for the compiler. 320.It Fl Wl Ns , Ns Ar options 321Comma separated list of options for the linker. 322.It Fl Wp Ns , Ns Ar options 323Comma separated list of options for the preprocessor. 324.It Fl X 325Don't remove temporary files on exit. 326.It Fl x Ar language 327GCC compatibility option; specify the language in use rather than 328interpreting the filename extension. 329Currently known language values are 330.Sy none , 331.Sy c , 332.Sy c++ , 333.Sy assembler 334and 335.Sy assembler-with-cpp . 336Any unknown 337.Fl x 338options are passed to 339.Xr ccom 1 . 340.El 341.Ss Predefined Macros 342A few 343macros are predefined by 344.Nm 345when sent to 346.Xr cpp 1 . 347.Bl -diag 348.It __PCC__ 349Set to the major version of 350.Xr pcc 1 . 351These macros can be used to select code based on 352.Xr pcc 1 353compatibility. 354See the 355.Fl v 356option. 357.It __PCC_MINOR__ 358Set to the minor version. 359.It __PCC_MINORMINOR__ 360Set to the minor-minor version \(em the number after the minor version. 361.It _PTHREADS 362Defined when 363.Fl pthread 364switch is used. 365.It __ASSEMBLER__ 366Defined when input files have a .S suffix, or if the 367.Fl x Ns assembler-with-cpp 368option is specified. 369.El 370.Pp 371Also system- and/or machine-dependent macros may also be predefined; 372for example: 373.Dv __NetBSD__ , 374.Dv __ELF__ , 375and 376.Dv __i386__ . 377.Sh SEE ALSO 378.Xr as 1 , 379.Xr ccom 1 , 380.Xr cpp 1 , 381.Xr ld 1 382.Sh HISTORY 383The 384.Nm 385command comes from the original Portable C Compiler by 386.An "S. C. Johnson" , 387written in the late 70's. 388.Pp 389This product includes software developed or owned by Caldera 390International, Inc. 391