gcc

Compile and link a program (GNU)


Note: We recommend you use qcc instead of invoking gcc directly. You can use the -V option to qcc to invoke gcc. For example:
qcc -Vgcc_ntoarmle my_file.c

Syntax:

gcc_variant [ option | filename ]...
g++_variant [ option | filename ]...

Runs on:

QNX Neutrino, Linux, Microsoft Windows

Options:

The gcc_variant depends on the target platform, as follows:

Target platform: gcc_variant:
ARM ntoarm-gcc
MIPS ntomips-gcc
PowerPC ntoppc-gcc
SH4 ntosh-gcc
x86 ntox86-gcc

The g++_variant depends on the target platform, as follows:

Target platform: g++_variant:
ARM ntoarm-g++
MIPS ntomips-g++
PowerPC ntoppc-g++
SH4 ntosh-g++
x86 ntox86-g++

QNX Neutrino cross-development options

-b [ntox86 | ntomips | ntoppc | ntosh]

Overall options

-c  -S  -E  -o file  -pipe  -v  -x language

C language options

-ansi  -fallow-single-precision  -fcond-mismatch  
-fno-asm  -fno-builtin  -ffreestanding  -fhosted  
-fsigned-bitfields  -fsigned-char  
-funsigned-bitfields  -funsigned-char  
-traditional  -traditional-cpp  -trigraphs

C++ language options

-fall-virtual  -fdollars-in-identifiers  
-felide-constructors  -fenum-int-equiv  
-fexternal-templates  -ffor-scope  -fno-for-scope
-fhandle-signatures  -fmemoize-lookups  
-fname-mangling-version-n  -fno-default-inline  
-fno-gnu-keywords -fnonnull-objects -fguiding-decls
-foperator-names  -fstrict-prototype  -fthis-is-variable
-ftemplate-depth-n  -nostdinc++  -traditional  +en

Warning options

-fsyntax-only  -pedantic  -pedantic-errors
-w  -W  -Wall  -Waggregate-return  
-Wbad-function-cast  -Wcast-align  -Wcast-qual  
-Wchar-subscript  -Wcomment  -Wconversion  -Werror  
-Wformat  -Wid-clash-len  -Wimplicit -Wimplicit-int 
-Wimplicit-function-declarations -Wimport  -Winline
-Wlarger-than-len  -Wmain  -Wmissing-declarations
-Wmissing-prototypes  -Wnested-externs
-Wno-import  -Wold-style-cast  -Woverloaded-virtual  
-Wparentheses  -Wpointer-arith  -Wredundant-decls  
-Wreorder  -Wreturn-type  -Wshadow  -Wsign-compare  
-Wstrict-prototypes  -Wswitch  -Wsynth
-Wtemplate-debugging  -Wtraditional  -Wtrigraphs
-Wundef  -Wuninitialized  -Wunused  -Wwrite-strings

Debugging options

-a  -ax  -dletters  -fpretend-float
-fprofile-arcs  -ftest-coverage
-g  -glevel  -gcoff  -gdwarf  -gdwarf-1  -gdwarf-1+  
-gdwarf-2  -ggdb  -gstabs  -gstabs+  -gxcoff  -gxcoff+
-p  -pg  -print-file-name=library  
-print-libgcc-file-name  -print-prog-name=program  
-print-search-dirs  -save-temps

QNX extension:

-MAP

Optimization options

-fbranch-probabilities
-fcaller-saves  -fcse-follow-jumps  -fcse-skip-blocks
-fdelayed-branch   -fexpensive-optimizations
-ffast-math  -ffloat-store  -fforce-addr  -fforce-mem
-ffunction-sections  -finline-functions
-fkeep-inline-functions  -fno-default-inline
-fno-defer-pop  -fno-function-cse
-fno-inline  -fno-peephole  -fomit-frame-pointer
-frerun-cse-after-loop  -fschedule-insns
-fschedule-insns2  -fstrength-reduce  -fthread-jumps
-funroll-all-loops  -funroll-loops
-O  -O0  -O1  -O2  -O3

Preprocessor options

-Aquestion(answer)  -C  -dD  -dM  -dN
-Dmacro[=defn]  -E  -H
-idirafter dir
-include file  -imacros file
-iprefix file  -iwithprefix dir
-iwithprefixbefore dir  -isystem dir
-M  -MD  -MM  -MMD  -MG  -nostdinc  -P  -trigraphs
-undef  -Umacro  -Wp,option

Assembler option

-Wa,option

Linker options

object-file-name  -llibrary
-nostartfiles  -nodefaultlibs  -nostdlib
-s  -static  -shared  -symbolic
-Wl,option  -Xlinker option
-u symbol

Directory options

-Bprefix  -Idir  -I-  -Ldir  -specs=file

Target options

-b machine  -V version

Machine-dependent options

PowerPC options:

-mcpu=cpu type
-mtune=cpu type
-mpower  -mno-power  -mpower2  -mno-power2
-mpowerpc  -mno-powerpc
-mpowerpc-gpopt  -mno-powerpc-gpopt
-mpowerpc-gfxopt  -mno-powerpc-gfxopt
-mnew-mnemonics  -mno-new-mnemonics
-mfull-toc   -mminimal-toc  -mno-fop-in-toc  
-mno-sum-in-toc  -mxl-call  -mno-xl-call  -mthreads  
-mpe -msoft-float  -mhard-float  -mmultiple  
-mno-multiple  -mstring  -mno-string  -mupdate  
-mno-update  -mfused-madd  -mno-fused-madd  
-mbit-align  -mno-bit-align
-mstrict-align  -mno-strict-align  -mrelocatable
-mno-relocatable  -mrelocatable-lib  
-mno-relocatable-lib
-mtoc  -mno-toc  -mtraceback  -mno-traceback
-mlittle  -mlittle-endian  -mbig  -mbig-endian
-mcall-aix  -mcall-sysv  -mprototype  -mno-prototype
-msim  -mmvme  -mads  -myellowknife  -memb
-msdata  -msdata=opt  -G num

MIPS options:

-mabicalls  -mcpu=cpu type  -membedded-data
-membedded-pic  -mfp32  -mfp64  -mgas  -mgp32  -mgp64
-mgpopt  -mhalf-pic  -mhard-float  -mint64  -mips1
-mips2  -mips3  -mlong64  -mlong-calls  -mmemcpy
-mmips-as  -mmips-tfile  -mno-abicalls
-mno-embedded-data  -mno-embedded-pic
-mno-gpopt  -mno-long-calls
-mno-memcpy  -mno-mips-tfile  -mno-rnames  
-mno-stats  -mrnames  -msoft-float
-m4650  -msingle-float  -mmad
-mstats  -EL  -EB  -G num  -nocpp

The MIPS options include the following QNX extension:

-mqnxpic

i386 options:

-mcpu=cpu type
-march=cpu type
-mieee-fp  -mno-fancy-math-387
-mno-fp-ret-in-387  -msoft-float  -msvr3-shlib
-mno-wide-multiply  -mrtd  -malign-double
-mreg-alloc=list  -mregparm=num
-malign-jumps=num  -malign-loops=num
-malign-functions=num

SH options:

-m1 -m2 -m3 -m3e -m4
-ml -mb
-mdalign -mbigtable -mrelax -mspace -msmall

Code-generation options

-fcall-saved-reg  -fcall-used-reg
-ffixed-reg  -finhibit-size-directive
-fcheck-memory-usage  -fprefix-function-name
-fno-common  -fno-ident  -fno-gnu-linker
-fpcc-struct-return  -freg-struct-return
-fshared-data  -fpic  -fPIC  -fexceptions
-fshort-enums  -fshort-double  -fvolatile  
-fvolatile-global  -fverbose-asm  -fpack-struct  
-fstack-check  +e0  +e1

Note:
  • If you use exceptions, you must link with the -lang-c++ option to qcc. This option is the default for QCC.

    Even with exceptions disabled, the default new() operator throws a std::out_of_memory exception if there isn't enough memory. If you want new() to return NULL instead of throwing an exception, you can provide a custom new handler via std::set_new_handler() to do so, or use std::nothrow.

  • On most platforms, the -fpic and -fPIC options are synonymous, but on PPC they're different and incompatible. We chose -fpic over -fPIC for performance reasons, and our PPC OS is built that way.

    If you see problems (such as relocation-truncation errors) at link time when you build a shared object, consider splitting it into multiple shared objects.


QNX Neutrino extension:

-mno-fp-moves
Prevent the code generator from using floating point registers to move integers. Using floating point registers for this is very slow on systems that use floating point emulation.

Description:

We recommend you use qcc or QCC instead of gcc to compile and link your programs.

For detailed documentation about gcc, see the GNU website at http://www.gnu.org/.


Note: If you have trouble using the default debug format (-gdwarf), switch to -gdwarf-2 or -gstabs.

Exit status:

0
Success.
33
A nonfatal compilation error was encountered.
34
A fatal compilation error was encountered.
35
Unable to open a required file.

Contributing author:

GNU

See also:

as, gcov, gdb, qcc