Unix-commands-gcc

提供:Dev Guides
移動先:案内検索

gcc-Unix、Linuxコマンド

NAME

*gcc*

概要

gcc [-c|-S|-E] [-std=standard]

*-cSE-std = * *standard -g-pg-O * *level -W * *warn -pedantic-I * *dir -L * *dir -D * *macrodefn -U * *macro -f * *option -m * *machine-option *-o * *outfileinfile

最も有用なオプションだけがここにリストされています。残りについては下記を参照してください。* g ++ は、 *gcc とほぼ同じオプションを受け入れます。

説明

GCC -c

他のオプションは、処理の1つのステージに渡されます。 一部のオプションはプリプロセッサを制御し、他のオプションはコンパイラ自体を制御します。 さらに他のオプションは、アセンブラーとリンカーを制御します。これらのいずれかを使用する必要はめったにないので、これらのほとんどはここでは文書化されていません。

GCCで使用できるコマンドラインオプションのほとんどは、Cプログラムに役立ちます。オプションが別の言語(通常はC ++)でのみ有用な場合、説明はそう明示的に述べています。 特定のオプションの説明にソース言語が記載されていない場合、サポートされているすべての言語でそのオプションを使用できます。

*gcc* プログラムは、オプションとファイル名をオペランドとして受け入れます。 多くのオプションには複数文字の名前があります。したがって、複数の単一文字オプションをグループ化することはできません: *-dr* は *-d -r* とは大きく異なります。

オプションと他の引数を混在させることができます。 ほとんどの場合、使用する順序は関係ありません。 同じ種類の複数のオプションを使用する場合、順序は重要です。たとえば、*-L *を複数回指定すると、指定した順序でディレクトリが検索されます。

多くのオプションには、-f *または *-W で始まる長い名前があります。たとえば、-fstrength-reduce *、-Wformat などです。 これらのほとんどには、正と負の両方の形式があります。 *-ffoo の否定形は -fno-foo になります。 このマニュアルでは、これら2つの形式のうち、デフォルトではない方のいずれか1つのみを文書化します。

Tag Description
Overall Options -c -S -E -o *file -combine -pipe -pass-exit-codes -x language -v -# --help --target-help --version*
C Language Options -ansi -std=standard -fgnu89-inline -aux-info *filename -fno-asm -fno-builtin -fno-builtin-*function -fhosted -ffreestanding -fms-extensions -trigraphs -no-integrated-cpp -traditional -traditional-cpp -fallow-single-precision -fcond-mismatch -fsigned-bitfields -fsigned-char -funsigned-bitfields -funsigned-char
C++ Language Options -fabi-version=n -fno-access-control -fcheck-new -fconserve-space -ffriend-injection -fno-const-strings -fno-elide-constructors -fno-enforce-eh-specs -ffor-scope -fno-for-scope -fno-gnu-keywords -fno-implicit-templates -fno-implicit-inline-templates -fno-implement-inlines -fms-extensions -fno-nonansi-builtins -fno-operator-names -fno-optional-diags -fpermissive -frepo -fno-rtti -fstats -ftemplate-depth-n -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc -fno-default-inline -fvisibility-inlines-hidden -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Weffc -Wno-deprecated -Wstrict-null-sentinel -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo
Objective-C and Objective-C++ Language Options -fconstant-string-class=class-name -fgnu-runtime -fnext-runtime -fno-nil-receivers -fobjc-call-cxx-cdtors -fobjc-direct-dispatch -fobjc-exceptions -fobjc-gc -freplace-objc-classes -fzero-link -gen-decls -Wassign-intercept -Wno-protocol -Wselector -Wstrict-selector-match -Wundeclared-selector
Language Independent Options -fmessage-length=n -fdiagnostics-show-location=[once
every-line] -fdiagnostics-show-options Warning Options
-fsyntax-only -pedantic -pedantic-errors -w -Wextra -Wall -Waggregate-return -Wno-attributes -Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels -Werror -Werror-implicit-function-declaration -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wimport -Wno-import -Winit-self -Winline -Wno-int-to-pointer-cast -Wno-invalid-offsetof -Winvalid-pch -Wlarger-than-len -Wunsafe-loop-optimizations -Wlong-long -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wno-multichar -Wnonnull -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wno-pointer-to-int-cast -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings C-only Warning Options
-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wtraditional -Wdeclaration-after-statement -Wpointer-sign Debugging Options
-dletters -dumpspecs -dumpmachine -dumpversion -fdump-unnumbered -fdump-translation-unit[-n] -fdump-class-hierarchy[-n] -fdump-ipa-all -fdump-ipa-cgraph -fdump-tree-all -fdump-tree-original[-n] -fdump-tree-optimized[-n] -fdump-tree-inlined[-n] -fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias -fdump-tree-ch -fdump-tree-ssa[-n] -fdump-tree-pre[-n] -fdump-tree-ccp[-n] -fdump-tree-dce[-n] -fdump-tree-gimple[-raw] -fdump-tree-mudflap[-n] -fdump-tree-dom[-n] -fdump-tree-dse[-n] -fdump-tree-phiopt[-n] -fdump-tree-forwprop[-n] -fdump-tree-copyrename[-n] -fdump-tree-nrv -fdump-tree-vect -fdump-tree-sink -fdump-tree-sra[-n] -fdump-tree-salias -fdump-tree-fre[-n] -fdump-tree-vrp[-n] -ftree-vectorizer-verbose=n -fdump-tree-storeccp[-n] -feliminate-dwarf2-dups -feliminate-unused-debug-types -feliminate-unused-debug-symbols -fmem-report -fprofile-arcs -frandom-seed=string -fsched-verbose=n -ftest-coverage -ftime-report -fvar-tracking -g -glevel -gcoff -gdwarf-2 -ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ -p -pg -print-file-name=library -print-libgcc-file-name -print-multi-directory -print-multi-lib -print-prog-name=program -print-search-dirs -Q -save-temps -time Optimization Options
-falign-functions[=n] -falign-jumps[=n] -falign-labels[=n] -falign-loops[=n] -fmudflap -fmudflapth -fmudflapir -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize -fbranch-target-load-optimize2 -fbtr-bb-exclusive -fcaller-saves -fcprop-registers -fcse-follow-jumps -fcse-skip-blocks -fcx-limited-range -fdata-sections -fdelayed-branch -fdelete-null-pointer-checks -fearly-inlining -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -ffunction-sections -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload -floop-optimize -fcrossjumping -fif-conversion -fif-conversion2 -finline-functions -finline-functions-called-once -finline-limit=n -fkeep-inline-functions -fkeep-static-consts -fmerge-constants -fmerge-all-constants -fmodulo-sched -fno-branch-count-reg -fno-default-inline -fno-defer-pop -floop-optimize2 -fmove-loop-invariants -fno-function-cse -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 -funsafe-math-optimizations -funsafe-loop-optimizations -ffinite-math-only -fno-trapping-math -fno-zero-initialized-in-bss -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls -fprefetch-loop-arrays -fprofile-generate -fprofile-use -fregmove -frename-registers -freorder-blocks -freorder-blocks-and-partition -freorder-functions -frerun-cse-after-loop -frerun-loop-opt -frounding-math -fschedule-insns -fschedule-insns2 -fno-sched-interblock -fno-sched-spec -fsched-spec-load -fsched-spec-load-dangerous -fsched-stalled-insns[=n] -fsched-stalled-insns-dep[=n*] -fsched2-use-superblocks -fsched2-use-traces -freschedule-modulo-scheduled-loops -fsignaling-nans -fsingle-precision-constant -fstack-protector -fstack-protector-all -fstrength-reduce -fstrict-aliasing -ftracer -fthread-jumps -funroll-all-loops -funroll-loops -fpeel-loops -fsplit-ivs-in-unroller -funswitch-loops -fvariable-expansion-in-unroller -ftree-pre -ftree-ccp -ftree-dce -ftree-loop-optimize -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon -fivopts -ftree-dominator-opts -ftree-dse -ftree-copyrename -ftree-sink -ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre -ftree-vectorize -ftree-vect-loop-version -ftree-salias -fweb -ftree-copy-prop -ftree-store-ccp -ftree-store-copy-prop -ftree-vrp -funit-at-a-time -fwhole-program --param* name=value -O -O0 -O1 -O2 -O3 -Os Preprocessor Options
-Aquestion=answer -A-question[=answer] -C -dD -dI -dM -dN -Dmacro[=defn] -E -H -idirafter *dir -include file -imacros file -iprefix file -iwithprefix dir -iwithprefixbefore dir -isystem dir -isysroot dir -M -MM -MF -MG -MP -MQ -MT -nostdinc -P -fworking-directory -remap -trigraphs -undef -Umacro-Wp,*option -Xpreprocessor option Assembler Option
-Wa,option *-Xassembler *option Linker Options
object-file-name* -llibrary-nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic -s -static -static-libgcc -shared -shared-libgcc -symbolic -Wl,*option -Xlinker *option -u* symbol Directory Options
-Bprefix -Idir -iquotedir -Ldir -specs=file -I- --sysroot=dir Target Options
-V *version -b *machine Machine Dependent Options

ARC Options* -EB -EL -mmangle-cpu -mcpu=cpu-mtext=text-section-mdata=data-section-mrodata=*readonly-data-section

ARMオプション *-mapcs-frame -mno-apcs-frame -mabi = * *name -mapcs-stack-check -mno-apcs-stack-check -mapcs-float -mno-apcs-float -mapcs-reentrant -mno-apcs-reentrant -msched-prolog -mno-sched-prolog -mlittle-endian -mbig-endian -mwords-little-endian -mfloat-abi = * *name -msoft-float -mhard-float -mfpe -mthumb-interwork -mno-thumb-interwork -mcpu = * *name -march = * *name -mfpu = * *name -mstructure-size-boundary = * *n -mabort-on -noreturn -mlong-calls -mno-long-calls -msingle-pic-base -mno-single-pic-base -mpic-register = * *reg *-mnop-fun-dllimport -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns -mpoke-function-name -mthumb -marm -mtpcs-frame -mtpcs-leaf-frame -mcaller-super-interworking -mcallee-super-interworking -mtp = * *name

AVRオプション* -mmcu = * *mcu -msize -minit-stack = * *n -mno-interrupts -mcall-prologues -mno-tablejump -mtiny-stack -mint8 *

Blackfinオプション* -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly -mlow-64k -mno-low64k -mid-shared-library -mno-id-shared-library -mshared-library-id = * *n -mlong-calls -mno-long-calls *

CRISオプション* -mcpu = * *cpu -march = * *cpu -mtune = * *cpu -mmax-stack-frame = * *n -melinux-stacksize = * *n - metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects -mstack-align -mdata-align -mconst-align -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt- melf -maout -melinux -mlinux -sim -sim2 -mmul-bug-workaround -mno-mul-bug-workaround *

CRXオプション* -mmac -mpush-args *

ダーウィンのオプション-headerpad_max_install_names -image_base -init -install_name -keep_private_externs -multi_module -multiply_defined -multiply_defined_unused -noall_load -no_dead_strip_inits_and_terms -nofixprebinding -nomultidefs -noprebind -noseglinkedit -pagezero_size -prebind -prebind_all_twolevel_modules -private_bundle -read_only_relocs -sectalign -sectobjectsymbols -whyload -seg1addr -sectcreate -sectobjectsymbols -sectorder -segaddr -segs_read_only_addr -segs_read_write_addr -seg_addr_table -seg_addr_table_filename -seglinkedit -segprot -segs_read_only_addr -segs_read_write_addr -single_module -static -sub_library -sub_umbrella -twolevel_name brella -undefined -unexported_symbols_list -weak_reference_mismatches -whatsloaded -F -gused -gfull -mmacosx-version-min =* version -mone-byte-bool *

DEC Alphaオプション* -mno-fp-regs -msoft-float -malpha-as -mgas -mieee -mieee-with-inexact -mieee-conformant -mfp-trap-mode = * *mode -mfp-rounding- mode = * *mode -mtrap-precision = * *mode -mbuild-constants -mcpu = * *cpu-type -mtune = * *cpu-type *-mbwx -mmax -mfix -mcix- mfloat-vax -mfloat-ieee -mexplicit-relocs -msmall-data -mlarge-data -msmall-text -mlarge-text -mmemory-latency = * *time

DEC Alpha/VMSオプション* -mvms-return-codes *

FRVオプション* *-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 -mhard-float -msoft-float -malloc-cc -mfixed-cc -mdword -mno-dword -mdouble -mno-double -mmedia -mno-media -mmuladd -mno-muladd -mfdpic -minline-plt -mgprel-ro -multilib-library-pic -mlinked-fp -mlong-calls -malign-labels -mlibrary-pic -macc-4 -macc-8 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move -moptimize-membar -mno-optimize-membar -mscc -mno-scc -mcond-exec -mno-cond-exec -mvliw-branch -mno-vliw-branch -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec -mno-nested-cond-exec -mtomcat-stats -mTLS -mtls -mcpu = * *cpu

H8/300オプション* -mrelax -mh -ms -mn -mint32 -malign-300 *

HPPAオプション* -march = * *architecture-type -mbig-switch -mdisable-fpregs -mdisable-indexing -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld -mfixed-range = * *register -range -mjump-in-delay -mlinker-opt -mlong-calls -mlong-load-store -mno-big-switch -mno-disable-fpregs -mno-disable-indexing -mno-fast-indirect-calls -mno-gas -mno-jump-in-delay -mno-long-load-store -mno-portable-runtime -mno-soft-float -mno-space-regs -msoft-float -mpa-risc-1-0 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime -mschedule = * *cpu-type -mspace-regs -msio -mwsio -munix = * *unix-std -nolibdld-静的-スレッド *

i386およびx86-64オプション* -mtune = * *cpu-type -march = * *cpu-type -mfpmath = * *unit -masm = * *dialect -mno-fancy-math -387 -mno-fp-ret-in-387 -msoft-float -msvr3-shlib -mno-wide-multiply -mrtd -malign-double -mpreferred-stack-boundary = * *num -mmmx -msse -msse2 -msse3 -mssse3 -msse4a -msse5 -m3dnow -mpopcnt -mabm -mthreads -mno-align-stringops -minline-all-stringops -mpush-args -maccumulate-outgoing-args -m128bit-long-double -m96bit-long-double -mregparm = * *num -msseregparm -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs -mcmodel = * *code-model -m32 -m64 -mlarge -data-threshold = * *num -mfused-madd -mno-fused-madd *

IA-64オプション* -mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic -mvolatile-asm-stop -mregister-names -mno-sdata -mconstant-gp -mauto-pic -minline -float-divide-min-latency -minline-float-divide-max-throughput -minline-int-divide-min-latency -minline-int-divide-max-throughput -minline-sqrt-min-latency -minline-sqrt -max-throughput -mno-dwarf2-asm -mearly-stop-bits -mfixed-range = * *register-range -mtls-size = * *tls-size -mtune = * *cpu-type - mt -pthread -milp32 -mlp64 *

M32R/Dオプション* -m32r2 -m32rx -m32r -mdebug -malign-loops -mno-align-loops -missue-rate = * *number -mbranch-cost = * *number -mmodel = * *code -size-model-type -msdata = * *sdata-type -mno-flush-func -mflush-func = * *name -mno-flush-trap -mflush-trap = * *number - G *num

M32Cオプション* -mcpu = * *cpu *-msim -memregs = * *number

M680x0オプション* -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 -mnobitfield -mrtd -mshort -msoft-float -mpcrel -malign-int- mstrict-align -msep-data -mno-sep-data -mshared-library-id = n -mid-shared-library -mno-id-shared-library *

M68hc1xオプション* *-m6811 -m6812 -m68hc11 -m68hc12 -m68hcs12 -mauto-incdec -minmax -mlong-calls -mshort -msoft-reg-count = * *count

MCoreオプション* -mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields -m4byte-functions -mno-4byte-functions -mcallgraph-data- mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment *

MIPSオプション* -EL -EB -march = * *arch -mtune = * *arch -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips64 -mips16 -mno-mips16 -mabi = * *abi -mabicalls -mno-abicalls -mxgot -mno-xgot -mgp32 -mgp64 -mfp32 -mfp64 -mhard-float -msoft-float -msingle-float -mdouble-float -mdsp -mpaired-single -mips3d -mlong64 -mlong32 -msym32 -mno-sym32 -G * *num -membedded-data -mno-embedded-data -muninit-const-in-rodata -mno-uninit-const-in-rodata -msplit-addresses -mno-split-アドレス-mexplicit-relocs -mno-explicit-relocs -mcheck-zero-division -mno-check-zero-division -mdivide-traps -mdivide-breaks -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls- mmad -mno-mad -mfused-madd -mno-fused-madd -nocpp -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 -mfix-vr4120 -mno-fix-vr4120 -mfix- vr4130 -mfix-sb1 -mno-fix-sb1 -mflush-func = * *func -mno-flush-func -mbranch-likely -mno-branch-likely -mfp-exceptions -mno-fp-exceptions -mvr4130-align -mno-vr4130-align *

MMIXオプション* -mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi = gnu -mabi = mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols -melf -mbranch-predict -mno-branch-predict -mbase-addresses- mno-base-addresses -msingle-exit -mno-single-exit *

MN10300オプション* -mmult-bug -mno-mult-bug -mam33 -mno-am33 -mam33-2 -mno-am33-2 -mreturn-pointer-on-d0 -mno-crt0 -mrelax *

MTオプション* -mno-crt0 -mbacc -msim -march = * *cpu-type *

PDP-11オプション* -mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 -mbcopy -mbcopy-builtin -mint32 -mno-int16 -mint16 -mno-int32 -mfloat32 -mno-float64 -mfloat64- mno-float32 -mabshi -mno-abshi -mbranch-expensive -mbranch-cheap -msplit -mno-split -munix-asm -mdec-asm *

PowerPCオプション RS/6000およびPowerPCオプションを参照してください。

RS/6000およびPowerPCオプション* -mcpu = * *cpu-type -mtune = * *cpu-type -mpower -mno-power -mpower2 -mno-power2 -mpowerpc -mpowerpc64 -mno-powerpc -maltivec -mno-altivec -mpowerpc-gpopt -mno-powerpc-gpopt -mpowerpc-gfxopt -mno-powerpc-gfxopt -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mfprnd -mno-fprnd -mmfpgpr -mno-mfpgpr -mnew -mnemonics -mold-mnemonics -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc -m64 -m32 -mxl-compat -mno-xl-compat -mpe -malign-power -malign-natural -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 -mlittle -mlittle-endian -mbig -mbig-endian -mdynamic-no-pic -maltivec -mswdiv -mprioritize-restricted-insns = * *priority -msched-costly-dep = * *dependence_type -minsert-sched-nops = * *scheme -mcall-sysv -mcall-netbsd -maix -構造-return -msvr4-struct-return -mabi = * *abi-type -msecure-plt -mbss-plt -misel -mno-isel -misel = yes -misel = no -mspe -mno-spe -mspe = yes -mspe = no -mvrsave -mno-vrsave -mfloat-gprs = yes -mfloat-gprs = no -mfloat-gprs = single -mfloat-gprs = double -mprototype -mno-prototype -msim -mmvme -mads -myellowknife -memb -msdata -msdata = * *opt -mvxworks -mwindiss -G num -pthread *

S/390およびzSeriesオプション* -mtune = * *cpu-type -march = * *cpu-type -mhard-float -msoft-float -mlong-double-64 -mlong-double-128 -mbackchain- mno-backchain -mpacked-stack -mno-packed-stack -msmall-exec -mno-small-exec -mmvcle -mno-mvcle -m64 -m31 -mdebug -mno-debug -mesa -mzarch -mtpf-trace -mno- tpf-trace -mfused-madd -mno-fused-madd -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard *

SHオプション* -m1 -m2 -m2e -m3 -m3e -m4-nofpu -m4-single-only -m4-single -m4 -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al -m5 -64media -m5-64media-nofpu -m5-32media -m5-32media-nofpu -m5-compact -m5-compact-nofpu -mb -ml -mdalign -mrelax -mbigtable -mfmovd -mhitachi -mrenesas -mno-renesas -mnomacsave -mieee -misize -mpadstruct -mspace -mprefergot -musermode -multcost = * *number -mdiv = * *strategy -mdivsi3_libfunc = * *name -madjust-unroll -mindexed-addressing -mgettrcost = * *number -mpt-fixed -minvalid-symbols *

SPARCオプション* -mcpu = * *cpu-type -mtune = * *cpu-type -mcmodel = * *code-model -m32 -m64 -mapp-regs -mno-app-regs -mfaster-構造体-mno-faster-structs -mfpu -mno-fpu -mhard-float -msoft-float -mhard-quad-float -msoft-quad-float -mimpure-text -mno-impure-text -mlittle-endian -mstack-バイアス-mno-stack-bias -munaligned-doubles -mno-unaligned-doubles -mv8plus -mno-v8plus -mvis -mno-vis -threads -pthreads -pthread *

System Vオプション* -Qy -Qn -YP、 paths -Ym、 *dir

TMS320C3x/C4xオプション* -mcpu = * *cpu -mbig -msmall -mregparm -mmemparm -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload -mrpts = * *count -mrptb -mdb- mloop-unsigned -mparallel-insns -mparallel-mpy -mpreserve-float *

V850オプション* -mlong-calls -mno-long-calls -mep -mno-ep -mprolog-function -mno-prolog-function -mspace -mtda = * *n -msda = * *n -mzda = * *n -mapp-regs -mno-app-regs -mdisable-callt -mno-disable-callt -mv850e1 -mv850e -mv850 -mbig-switch *

VAXオプション* -mg -mgnu -munix *

x86-64オプション i386およびx86-64オプションを参照してください。

Xstormy16オプション* -msim *

Xtensaオプション* -mconst16 -mno-const16 -mfused-madd -mno-fused-madd -mtext-section-literals -mno-text-section-literals -mtarget-align -mno-target-align -mlongcalls -mno-longcalls *

zSeriesオプション S/390およびzSeriesオプションを参照してください。

Code Generation Options

出力の種類を制御するオプション

GCC

任意の入力ファイルについて、ファイル名の接尾辞によって、実行されるコンパイルの種類が決まります。

Tag

説明

file **。c * *

前処理が必要なCソースコード。

file* *。i * *

前処理してはならないCソースコード。

file* *。ii * *

前処理してはならないC ++ソースコード。

file* *。m * *

Objective-Cソースコード。 Objective-Cプログラムを機能させるには、_libobjc_ライブラリとリンクする必要があることに注意してください。

file* *。mi * *

前処理してはならないObjective-Cソースコード。

file* *。mm * *

file* *。M * *

Objective-C ソースコード。 Objective-C プログラムを機能させるには、_libobjc_ライブラリとリンクする必要があることに注意してください。* .M *はリテラルの大文字Mを参照することに注意してください。

file **。mii * *

前処理してはならないObjective-C ++ソースコード。

file* *。h * *

プリコンパイル済みヘッダーに変換するC、C 、Objective-CまたはObjective-C ヘッダーファイル。

file* *。cc * *

file* *。cp * *

file* *。cxx * *

file* *。cpp * *

file* *。CPP * *

file* *。c ++ * *

file* *。C * *

前処理が必要なC ++ソースコード。* .cxx では、最後の2文字が両方とも文字通り *x でなければならないことに注意してください。 同様に、*。C *はリテラルの大文字Cを指します。

file **。mm * *

file* *。M * *

前処理が必要なObjective-C ++ソースコード。

file* *。mii * *

前処理してはならないObjective-C ++ソースコード。

file* *。hh * *

file* *。H * *

プリコンパイル済みヘッダーに変換されるC ++ヘッダーファイル。

file* *。f * *

file* *。for * *

file* *。FOR * *

前処理してはならないFortranソースコードを修正しました。

file* *。F * *

file* *。fpp * *

file* *。FPP * *

(従来のプリプロセッサを使用して)前処理する必要がある固定形式のFortranソースコード。

file* *。f90 * *

file* *。f95 * *

前処理してはいけないフリーフォームのFortranソースコード。

file* *。F90 * *

file* *。F95 * *

(従来のプリプロセッサを使用して)前処理する必要がある自由形式のFortranソースコード。

file* *。ads * *

ライブラリユニット宣言(パッケージ、サブプログラム、ジェネリック、またはジェネリックインスタンス化の宣言)、またはライブラリユニットの名前変更宣言(パッケージ、ジェネリック、またはサブプログラムの名前変更宣言)を含むAdaソースコードファイル。 このようなファイルは_specs_とも呼ばれます。

file* *。adb * *

ライブラリユニット本体(サブプログラムまたはパッケージ本体)を含むAdaソースコードファイル。 そのようなファイルは_bodies_とも呼ばれます。

file* *。s * *

アセンブラーコード。

file* 。S *

前処理が必要なアセンブラーコード。

other

リンクに直接送られるオブジェクトファイル。 認識される接尾辞のないファイル名はすべてこの方法で処理されます。

-x

Tag

説明

*-x* _言語_

次の入力ファイルに対して_language_を明示的に指定します(ファイル名の接尾辞に基づいてコンパイラーにデフォルトを選択させるのではなく)。 このオプションは、次の -x オプションまで、後続のすべての入力ファイルに適用されます。 _language_の可能な値は次のとおりです。

++

c c-header c-cpp-output c++ c++-header c++-cpp-output objective-c objective-c-header objective-c-cpp-output objective-c++ objective-c++-header objective-c++-cpp-output assembler assembler-with-cpp ada f95 f95-cpp-input java treelang
  • -xなし*

言語の指定をオフにして、後続のファイルがファイル名のサフィックスに従って処理されるようにします( -x がまったく使用されていない場合)。

*-pass-exit-codes*

通常、 gcc プログラムは、コンパイラーのいずれかのフェーズが失敗した戻りコードを返した場合、コード1で終了します。 -pass-exit-codes を指定すると、 gcc プログラムは、エラー表示を返したフェーズで生成された数値的に最も高いエラーを返します。

*-xgcc-c-S-Egcc-x cpp-output -Egcc*
Tag Description
-c

Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.

デフォルトでは、ソースファイルのオブジェクトファイル名は、サフィックス .c。i *、。s などを *.o に置き換えることで作成されます。

認識されていない入力ファイルは、コンパイルまたはアセンブリを必要とせず、無視されます。

-S

Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for each non-assembler input file specified.

デフォルトでは、ソースファイルのアセンブラファイル名は、サフィックス .c。i *などを *.s に置き換えることで作成されます。

コンパイルを必要としない入力ファイルは無視されます。

-E

Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.

前処理を必要としない入力ファイルは無視されます。

-o file

Place output in file file. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.

  • -o* を指定しない場合、デフォルトでは、実行可能ファイルを_a.out_に、_source.suffix_のオブジェクトファイルを_source.o_に、アセンブラファイルを_source.s_に、プリコンパイル済みヘッダーファイルを_source.suffixに配置します。 .gch_、および標準出力のすべての前処理されたCソース。
-v Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and the compiler proper.
*-# * Like* -v* except the commands are not executed and all command arguments are quoted. This is useful for shell scripts to capture the driver-generated command lines.
-pipe Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has no trouble.
*-combine * If you are compiling multiple source files, this option tells the driver to pass all the source files to the compiler at once (for those languages for which the compiler can handle this). This will allow intermodule analysis (IMA) to be performed by the compiler. Currently the only language for which this is supported is C. If you pass source files for multiple languages to the driver, using this option, the driver will invoke the compiler(s) that support IMA once each, passing each compiler all the source files appropriate for it. For those languages that do not support IMA this option will be ignored, and the compiler will be invoked once for each source file in that language. If you use this option in conjunction with* -save-temps*, the compiler will generate multiple pre-processed files (one for each source file), but only one (combined) .o or .s file.
*--help * Print (on the standard output) a description of the command line options understood by* gcc*. If the -v *option is also specified then --help will also be passed on to the various processes invoked by gcc*, so that they can display the command line options they accept. If the -Wextra option is also specified then command line options which have no documentation associated with them will also be displayed.
--target-help Print (on the standard output) a description of target specific command line options for each tool.
*--version * Display the version number and copyrights of the invoked GCC.

C ++プログラムのコンパイル

  • *。C.cc.cpp.CPP.c 。cp.cxx * * *。hh.H * * 。ii * *GCC ++ gcc *

ただし、C プログラムには、多くの場合、クラスライブラリとC 言語を理解するコンパイラが必要です。また、状況によっては、標準入力からプログラムまたはヘッダーファイルをコンパイルするか、C プログラムとしてフラグを付けるサフィックスを使用しないでください。 。 また、C コンパイルで使用される .h 拡張子を持つCヘッダーファイルをプリコンパイルすることもできます。 g * は、デフォルト言語をC に設定してGCCを呼び出し、C ライブラリに対するリンクを自動的に指定するプログラムです。 多くのシステムでは、 *c という名前で g ++ もインストールされます。

C プログラムをコンパイルする場合、任意の言語でプログラムをコンパイルするために使用するものと同じコマンドラインオプションの多くを指定できます。または、Cおよび関連言語にとって意味のあるコマンドラインオプション。または、C プログラムでのみ意味のあるオプション。

C方言を制御するオプション

Tag Description
-ansi

In C mode, support all ISO C90 programs. In C mode, remove GNU extensions that conflict with ISO C.

これにより、ISO C90(Cコードのコンパイル時)、または標準C (C コードのコンパイル時)と互換性のないGCCの特定の機能( `+ asm `および ` typeof `キーワードなど)、および使用しているシステムのタイプを識別する「 unix 」および「 vax 」。 また、望ましくないめったに使用されないISOトライグラフ機能も有効にします。 Cコンパイラの場合、C ++スタイルの *//* コメントと ` inline +`キーワードの認識を無効にします。

代替キーワード「+ asm 」、「 extension 」、「 inline 」、および「 typeof 」は、*-ansi *にもかかわらず機能し続けます。 もちろん、ISO Cプログラムでそれらを使用したくないでしょうが、*-ansi *で行われたコンパイルに含まれる可能性のあるヘッダーファイルに配置すると便利です。 「 unix 」や「 vax +」などの代替の事前定義マクロも、*-ansi *の有無にかかわらず使用できます。

  • -ansi* オプションを使用しても、ISO以外のプログラムが不当に拒否されることはありません。 そのためには、*-ansi *に加えて *-pedantic* が必要です。 *-ansi* オプションを使用すると、マクロ `+ __ STRICT_ANSI __ +`が事前定義されます。 一部のヘッダーファイルはこのマクロに気づき、特定の関数を宣言したり、ISO規格が要求しない特定のマクロを定義したりすることを控えます。これは、これらの名前を他のものに使用する可能性のあるプログラムとの干渉を避けるためです。

通常は組み込まれるが、ISO Cで定義されたセマンティクスを持たない関数( `+ alloca `や ` ffs +`など)は、*-ansi *が組み込まれた組み込み関数ではありません。

-std= Determine the language standard. This option is currently only supported when compiling C or C++. A value for this option must be provided; possible values are

|Tag |Description |c89 | |iso9899:1990 *|ISO C90 (same as -ansi*). |iso9899:199409 |ISO C90 as modified in amendment 1. |c99 | |c9x | |iso9899:1999 | |iso9899:199x |ISO C99. Note that this standard is not yet fully supported; see <http://gcc.gnu.org/gcc-4.1/c99statusl> for more information. The names c9x *and iso9899:199x* are deprecated. |gnu89 |Default, ISO C90 plus GNU extensions (including some C99 features). |gnu99 | |gnu9x *|ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC, this will become the default. The name gnu9x* is deprecated. |c98* |The 1998 ISO C standard plus amendments. |*gnu98 *|The same as* -std=c98 plus GNU extensions. This is the default for C++ code.

このオプションが指定されていない場合でも、以前のC標準と競合しない限り、新しい標準の機能の一部を使用できます。 たとえば、*-std = c99 *が指定されていない場合でも、 `+ restrict `を使用できます。

ISO Cの一部のバージョンを指定する *-std* オプションは、*-ansi *と同じ効果がありますが、ISO C90にはないが指定されたバージョンにある機能( *//* コメントや ` ISO C99のinline + `キーワードは無効になりません。

*-fgnu89-inline *a

The option* -fgnu89-inline* tells GCC to use the traditional GNU semantics for inline functions when in C99 mode. Using this option is roughly equivalent to adding the gnu_inline function attribute to all inline functions.

このオプションは、GCCバージョン4.1.3以降で受け入れられます。 4.3より前のGCCバージョンでは、C99インラインセマンティクスはサポートされていないため、このオプションは、指定されているかどうかにかかわらず、事実上存在すると見なされます。明示的に指定することの唯一の効果は、C99モードでのインライン関数の使用に関する警告を無効にすることです。 同様に、オプション -fno-gnu89-inline は、4.3より前のGCCのバージョンではサポートされていません。 C99またはgnu99モードではなく、C99またはgnu99モードでのみサポートされます。

プリプロセッサマクロ `+ GNUC_GNU_INLINE `および ` GNUC_STDC_INLINE `を使用して、 ` inline +`関数に有効なセマンティクスを確認できます。

-aux-info filename

Output to the given filename prototyped declarations for all functions declared and/or defined in a translation unit, including those in header files. This option is silently ignored in any language other than C.

ファイルは、宣言のほかに、各宣言のソース(ソースファイルと行)、宣言が暗黙的か、プロトタイプ化されているか、プロトタイプ化されていないか(それぞれ、 IN は古い、 O は古い、行番号とコロンの後の最初の文字)、および宣言または定義(それぞれ、次の文字の C または F )から来たかどうか。 関数定義の場合、コメントの後に宣言の後に続く引数のK&Rスタイルのリストも提供されます。

*-fno-asm *a

Do not recognize asm, inline or typeof as a keyword, so that code can use these words as identifiers. You can use the keywords __asm__, __inline__ and __typeof__ instead.* -ansi implies -fno-asm*.

C +では、このスイッチは「 typeof 」キーワードにのみ影響します。これは、「 asm 」と「 inline 」が標準のキーワードであるためです。 代わりに *-fno-gnu-keywords* フラグを使用すると、同じ効果が得られます。 C99モード( *-std = c99* または *-std = gnu99* )では、このスイッチは ` asm `および ` typeof `キーワードにのみ影響します。これは、 ` inline +`がISO C99の標準キーワードであるためです。

-fno-builtin
-fno-builtin-function

Don’t recognize built-in functions that do not begin with builtin_ as prefix.

GCCは通常、特定の組み込み関数をより効率的に処理するための特別なコードを生成します。たとえば、 + alloca +`の呼び出しはスタックを直接調整する単一の命令になり、 `+ memcpy +`の呼び出しはインラインコピーループになる場合があります。 多くの場合、結果のコードは小さくて高速ですが、関数呼び出しはもはや表示されないため、それらの呼び出しにブレークポイントを設定したり、別のライブラリとリンクして関数の動作を変更することはできません。 さらに、関数が組み込み関数として認識されると、GCCはその関数に関する情報を使用して、その関数の呼び出しに関する問題を警告したり、結果のコードにその関数の呼び出しが含まれている場合でもより効率的なコードを生成したりする場合があります。 たとえば、 `+ printf +`が組み込まれ、 `+ strlen +`がグローバルメモリを変更しないことがわかっている場合、 `+ printf +`への不正な呼び出しに対して -Wformat で警告が与えられます。

-fno-builtin- </emphasis> functionオプションを使用すると、組み込み関数_function_のみが無効になります。 function_は ' builtin' で始まってはなりません。 関数の名前がGCCのこのバージョンに組み込まれていない場合、このオプションは無視されます。 対応する*-fbuiltin- functionオプションはありません。 -fno-builtin または *-ffreestanding を使用するときに組み込み関数を選択的に有効にしたい場合は、次のようなマクロを定義できます。

`++</literal>

[width="100%",cols="100%",]

a|

        #define abs(n)          __builtin_abs ((n))
        #define strcpy(d, s)    __builtin_strcpy ((d), (s))
*-fhosted * Assert that compilation takes place in a hosted environment. This implies* -fbuiltin*. A hosted environment is one in which the entire standard library is available, and in which main has a return type of int. Examples are nearly everything except a kernel. This is equivalent to -fno-freestanding. *-ffreestanding * Assert that compilation takes place in a freestanding environment. This implies* -fno-builtin*. A freestanding environment is one in which the standard library may not exist, and program startup may not necessarily be at main. The most obvious example is an OS kernel. This is equivalent to -fno-hosted. -fms-extensions

Accept some non-standard constructs used in Microsoft header files.

構造体および共用体の名前のないフィールドの一部のケースは、このオプションでのみ受け入れられます。

*-trigraphs * Support ISO C trigraphs. The* -ansi option (and -std options for strict ISO C conformance) implies -trigraphs*. *-no-integrated-cpp *a

Performs a compilation in two passes: preprocessing and compiling. This option allows a user supplied cc1, cc1plus, or cc1obj via the* -B* option. The user supplied compilation step can then add in an additional preprocessing step after normal preprocessing but before compiling. The default is to use the integrated cpp (internal cpp)

cc1、cc1plus、およびcc1objがマージされると、このオプションのセマンティクスが変わります。

-traditional
*-traditional-cpp * Formerly, these options caused GCC to attempt to emulate a pre-standard C compiler. They are now only supported with the* -E* switch. The preprocessor continues to support a pre-standard mode. See the GNU CPP manual for details. -fcond-mismatch Allow conditional expressions with mismatched types in the second and third arguments. The value of such an expression is void. This option is not supported for C++. -funsigned-char

Let the type char be unsigned, like unsigned char.

各種類のマシンには、 `+ char `のデフォルトがあります。 これは、デフォルトで ` unsigned char `のようなものか、デフォルトで ` signed char +`のようなものです。

理想的には、移植可能なプログラムは、オブジェクトの署名の有無に依存する場合、常に `+ signed char `または ` unsigned char `を使用する必要があります。 しかし、多くのプログラムは、プレーンな「 char +」を使用するように作成されており、作成されたマシンに応じて、署名されるか、署名されていないことを期待しています。 このオプションとその逆により、そのようなプログラムを反対のデフォルトで動作させることができます。

型 `+ char `は、常に振る舞いがこれらの2つのいずれかと同じであるにもかかわらず、常に ` signed char `または ` unsigned char +`のそれぞれとは異なる型です。

-fsigned-char

Let the type char be signed, like signed char.

これは、-funsigned-char *の否定形である *-fno-unsigned-char と同等であることに注意してください。 同様に、オプション -fno-signed-char-funsigned-char と同等です。

-fsigned-bitfields -funsigned-bitfields

C ++方言を制御するオプション

++ GNU` + firstClass.C + `

++

g++ -g -frepo -O -c firstClass.C

この例では、*-frepo *のみがC ++プログラム専用のオプションです。 GCCでサポートされている任意の言語で他のオプションを使用できます。

以下は、C ++プログラムをコンパイルするための_only_のオプションのリストです。

Tag

説明

-fabi-version = n

C ABIのバージョン_n_を使用します。 バージョン2は、G 3.4で最初に登場したC ABIのバージョンです。 バージョン1は、G 3.2で最初に登場したC ABIのバージョンです。 バージョン0は、常にC ABI仕様に最も近いバージョンです。 したがって、バージョン0を使用して取得したABIは、ABIのバグが修正されると変更されます。

デフォルトはバージョン2です。

*-fno-access-control*

すべてのアクセスチェックをオフにします。 このスイッチは、主にアクセス制御コードのバグを回避するのに役立ちます。

*-fcheck-new*
割り当てられたストレージを変更する前に、 + operator new +`によって返されるポインターがnullでないことを確認してください。 C ++標準では、* *+ throw()`* *が宣言されている場合にのみ operator new + + 0 + `を返すように指定しているため、このチェックは通常不要です。この場合、コンパイラは常にチェックしますこのオプションがなくても戻り値。 他のすべての場合、 `+ operator new `に空でない例外指定がある場合、 ` std

bad_alloc +`をスローすることでメモリ枯渇が通知されます。 * new(nothrow)*も参照してください。

*-fconserve-space*

Cのように、初期化されていない、またはランタイムで初期化されたグローバル変数を共通セグメントに配置します。 これにより、重複する定義を診断しないという犠牲を払って、実行可能ファイルのスペースを節約できます。 このフラグを使用してコンパイルし、 `+ main()+`が完了した後にプログラムが不意にクラッシュした場合、2つの定義がマージされたためにオブジェクトが2回破棄される可能性があります。

このオプションは、変数を一般化せずにBSSに追加するためのサポートが追加されたため、ほとんどのターゲットで使用できなくなりました。

*-ffriend-injection*

フレンド関数を囲んでいるネームスペースに挿入し、それらが宣言されているクラスのスコープ外で見えるようにします。 フレンド関数は、古い注釈付きC リファレンスマニュアルでこのように機能するように文書化されており、4.1より前のバージョンのG は常にそのように機能していました。 ただし、ISO C ++では、囲みスコープで宣言されていないフレンド関数は、引数依存ルックアップを使用してのみ見つけることができます。 このオプションを使用すると、以前のリリースのように友人が注入されます。

このオプションは互換性のためであり、G ++の将来のリリースで削除される可能性があります。

*-fno-const-strings*

タイプ `+ const char `ではなく、タイプ ` char `の文字列定数を指定します。 デフォルトでは、G ++は標準で必要とされる ` const char +`型を使用します。 -fno-const-strings *を使用しても、実際には文字列定数の値を変更することはできません。

このオプションは、G +の将来のリリースで削除される可能性があります。 移植性を最大限に高めるには、 ` const char * +`型の文字列定数で動作するようにコードを構成する必要があります。

*-fno-elide-constructors*

C 標準では、実装は、同じタイプの別のオブジェクトを初期化するためにのみ使用される一時的なものの作成を省略することができます。 このオプションを指定すると、その最適化が無効になり、G がすべての場合にコピーコンストラクターを強制的に呼び出します。

*-fno-enforce-eh-specs*

実行時に例外仕様の違反をチェックするコードを生成しないでください。 このオプションはC ++標準に違反しますが、 NDEBUG を定義するのと同じように、実動ビルドのコードサイズを削減するのに役立ちます。 これは、例外仕様に違反して例外をスローする許可をユーザーコードに与えるものではありません。コンパイラは引き続き仕様に基づいて最適化するため、予期しない例外をスローすると、未定義の動作が発生します。

*-ffor-scope*
*-fno-for-scope*
*-ffor-scope* が指定されている場合、_for-init-statement_で宣言された変数のスコープは、C ++標準で指定されている *for* ループ自体に制限されます。 *-fno-for-scope* が指定されている場合、_for-init-statement_で宣言された変数のスコープは、G ++の古いバージョンや他の(従来の)実装の場合のように、囲んでいるスコープの最後まで拡張されますC ++。

どちらのフラグも標準に準拠するために指定されていない場合のデフォルトですが、それ以外の場合は無効であるか、または異なる動作をする古いスタイルのコードに対して警告を許可および提供します。

*-fno-gnu-keywords*

コードがこの単語を識別子として使用できるように、「+ typeof 」をキーワードとして認識しないでください。 代わりにキーワード「 typeof +」を使用できます。 -ansi-fno-gnu-keywords を意味します。

*-fno-implicit-templates*

暗黙的にインスタンス化される非インラインテンプレート(つまり、 使用による);明示的なインスタンス化のためにのみコードを出力します。

*-fno-implicit-inline-templates*

インラインテンプレートの暗黙的なインスタンス化のコードも発行しないでください。 デフォルトでは、インラインを異なる方法で処理するため、最適化ありと最適化なしでコンパイルするには、明示的なインスタンス化の同じセットが必要です。

*-fno-implement-inlines*

スペースを節約するために、*#pragma implementation *によって制御されるインライン関数の行外コピーを出力しないでください。 これらの関数が呼び出されるすべての場所でインライン化されていない場合、リンカーエラーが発生します。

*-fms-extensions*

暗黙のintや非標準の構文を介したメンバー関数へのポインターの取得など、MFCで使用される構成体に関するペダンティックな警告を無効にします。

*-fno-nonansi-builtins*

ANSI/ISO Cで義務付けられていない関数の組み込み宣言を無効にします。 これらには、「+ ffs 」、「 alloca 」、「 _ exit 」、「 index 」、「 bzero 」、「 conjf +」、およびその他の関連関数が含まれます。

*-fno-operator-names*

演算子名のキーワード「+ and 」、「 bitand 」、「 bitor 」、「 compl 」、「 not 」、「 or 」、および「 xor +」をキーワードとして同義語として扱わないでください。

*-fno-optional-diags*

コンパイラが発行する必要がないと標準が言っている診断を無効にします。 現在、G ++が発行するこのような診断は、クラス内で複数の意味を持つ名前の診断のみです。

*-fpermissive*

不適合コードに関する診断をエラーから警告に格下げします。 したがって、*-fpermissive *を使用すると、一部の不適合コードをコンパイルできます。

*-frepo*

リンク時にテンプレートの自動インスタンス化を有効にします。 このオプションは、*-fno-implicit-templates *も意味します。

*-fno-rtti*

C ++ランタイム型識別機能( dynamic_cast および typeid )が使用する仮想関数を持つすべてのクラスに関する情報の生成を無効にします。 言語のこれらの部分を使用しない場合は、このフラグを使用してスペースを節約できます。 例外処理では同じ情報が使用されますが、必要に応じて生成されることに注意してください。

*-fstats*

コンパイルの最後にフロントエンド処理に関する統計を出力します。 通常、この情報はG ++開発チームにのみ役立ちます。

-ftemplate-depth- n

テンプレートクラスの最大インスタンス化の深さを_n_に設定します。 テンプレートクラスのインスタンス化中に無限の再帰を検出するには、テンプレートのインスタンス化の深さに制限が必要です。 ANSI/ISO C ++準拠プログラムは、17を超える最大深度に依存してはなりません。

*-fno-threadsafe-statics*

ローカルスタティックのスレッドセーフな初期化にC ABIで指定されたルーチンを使用するための追加コードを発行しないでください。 このオプションを使用すると、スレッドセーフである必要のないコードでコードサイズをわずかに削減できます。

*-fuse-cxa-atexit*

`+ atexit `関数ではなく、 ` cxa_atexit `関数を使用して、静的ストレージ期間を持つオブジェクトのデストラクタを登録します。 このオプションは、静的デストラクタの完全に標準に準拠した処理に必要ですが、Cライブラリが ` cxa_atexit +`をサポートしている場合にのみ機能します。

*-fvisibility-inlines-hidden*

インライン化されたすべてのメソッドに `+ attribute((visibility(" hidden ")))+`のマークを付け、DSOのエクスポートテーブルに表示されず、DSO内で使用されるときにPLTインダイレクションが不要になるようにします。 このオプションを有効にすると、ライブラリがテンプレートを頻繁に使用するときに動的エクスポートテーブルのサイズが大幅に縮小されるため、DSOのロード時間とリンク時間に劇的な影響を与える可能性があります。

メソッドを明示的に可視性があるとマークして、そのメソッドのスイッチの効果を無効にすることができます。 たとえば、特定のインラインメソッドへのポインターを比較する場合、またはメソッドにローカルの静的データがある場合、デフォルトの可視性があるとマークすることができます。

*-fno-weak*

リンカーによって提供される場合でも、弱いシンボルのサポートを使用しないでください。 デフォルトでは、G は利用可能な弱いシンボルを使用します。 このオプションはテスト専用であり、エンドユーザーは使用しないでください。コードの品質が低下し、メリットはありません。 このオプションは、G の将来のリリースで削除される可能性があります。

*-nostdinc ++*

C に固有の標準ディレクトリでヘッダーファイルを検索しないでください。ただし、他の標準ディレクトリは検索します。 (このオプションは、C ライブラリをビルドするときに使用されます。)

Tag

説明

*-fno-default-inline*

クラススコープ内で定義された関数を*インライン*と見なさないでください。 これらの関数には、インライン関数のようなリンケージがあることに注意してください。デフォルトではインライン化されません。

*-Wabi* (C ++のみ)

G が、ベンダーに中立なC ABIと互換性のないコードを生成したときに警告します。 このようなすべてのケースについて警告する努力がなされましたが、G ++が互換性のないコードを生成していても、おそらく警告されないケースがいくつかあります。 生成されたコードに互換性がある場合でも、警告が発行される場合もあります。

G ++で生成されたコードが他のコンパイラーで生成されたコードとバイナリ互換でない可能性があるという懸念がある場合は、これらの警告を避けるためにコードを書き直してください。

この時点で既知の非互換性には以下が含まれます。

Tag Description
*

Incorrect handling of tail-padding for bit-fields. G++ may attempt to pack data into the same byte as a base class. For example:

++

a|

        struct A { virtual void f(); int f1 : 1; };
        struct B : public A { int f2 : 1; };
この場合、G は `+ B :: f2 +`を `+ A :: f1 +`と同じバイトに配置します。他のコンパイラはサポートしません。 この問題を回避するには、明示的に `+ A +`をパディングして、そのサイズがプラットフォームのバイトサイズの倍数になるようにします。これにより、G および他のコンパイラは `+ B +`を同じようにレイアウトします。
*

Incorrect handling of tail-padding for virtual bases. G does not use tail padding when laying out virtual bases. For example:

``

[width="100%",cols="100%",]

a|

        struct A { virtual void f(); char c1; };
        struct B { B(); char c2; };
        struct C : public A, public virtual B {};
この場合、G は `+ A +`のテールパディングに `+ B +`を配置しません。他のコンパイラはそうします。 この問題を回避するには、明示的に `+ A +`をパディングして、サイズがそのアライメントの倍数になるようにします(仮想ベースクラスを無視します)。これにより、G および他のコンパイラは `+ C +`を同じようにレイアウトします。
*

Incorrect handling of bit-fields with declared widths greater than that of their underlying types, when the bit-fields appear in a union. For example:

++

[width="100%",cols="100%",]

a|

        union U { int i : 4096; };
`+ int `が4096ビットを持たないと仮定すると、G ++は ` int +`のビット数分だけユニオンを小さくします。
*

Empty classes can be placed at incorrect offsets. For example:

++

[width="100%",cols="100%",]

a|

        struct A {};

++

[width="100%",cols="100%",]

a|

        struct B {
          A a;
          virtual void f ();
        };

++

[width="100%",cols="100%",]

a|

        struct C : public B, public A {};
G は、「+ C +」の「+ A +」基本クラスをゼロ以外のオフセットに配置します。オフセット0に配置する必要があります。 G は、「+ B 」の「 A +」データメンバーがすでにオフセット0にあると誤って信じています。
*

Names of template functions whose types involve typename or template template parameters can be mangled incorrectly.

++

[width="100%",cols="100%",]

a|

        template <typename Q>
        void f(typename Q::X) {}

++

[width="100%",cols="100%",]

a|

        template <template <typename> class Q>
        void f(typename Q<int>::X) {}
これらのテンプレートのインスタンス化は、誤って破損する可能性があります。
*-Wctor-dtor-privacy* (C ++のみ)

そのクラスのすべてのコンストラクターまたはデストラクターがプライベートであり、フレンドもパブリックスタティックメンバー関数も持たないため、クラスが使用できないように思われる場合に警告します。

*-Wnon-virtual-dtor* (C ++のみ)

クラスがポリモーフィックであるように見えるため、仮想デストラクターが必要であるが、非仮想クラスが宣言されている場合に警告します。 この警告は -Wall によって有効になります。

*-Wreorder* (C ++のみ)

コードで指定されたメンバー初期化子の順序が、実行する必要がある順序と一致しない場合に警告します。 例えば:

++

struct A { int i; int j; A(): j (0), i (1) { } };

コンパイラは、メンバーの宣言順序に一致するように i および j のメンバー初期化子を再配置し、その結果に警告を発行します。 この警告は -Wall によって有効になります。

  • -W …​-壁*
Tag Description
*-Weffc* (C only) Warn about violations of the following style guidelines from Scott Meyers’ Effective C++ book:

|Tag |Description |* |Item 11: Define a copy constructor and an assignment operator for classes with dynamically allocated memory. |* |Item 12: Prefer initialization to assignment in constructors. |* |Item 14: Make destructors virtual in base classes. |* |Item 15: Have operator= return a reference to *this. |* |Item 23: Don’t try to return a reference when you must return an object.

また、Scott Meyersの_More Effective C ++ _ bookの次のスタイルガイドラインへの違反について警告します。

[cols=",",options="header",]

|Tag |Description |* |Item 6: Distinguish between prefix and postfix forms of increment and decrement operators. | *|Item 7: Never overload &&, ||, or ,.

このオプションを選択するときは、標準ライブラリヘッダーがこれらのガイドラインのすべてに従っていないことに注意してください。* grep -v *を使用して、これらの警告を除外します。
-Wno-deprecated (C++ only)
Do not warn about usage of deprecated features.
-Wstrict-null-sentinel (C++ only)
Warn also about the use of an uncasted NULL as sentinel. When compiling only with GCC this is a valid sentinel, as NULL is defined to __null. Although it is a null pointer constant not a null pointer, it is guaranteed to of the same size as a pointer. But this use is not portable across different compilers.
*-Wno-non-template-friend *(C++ only)
Disable warnings when non-templatized friend functions are declared within a template. Since the advent of explicit template specification support in G, if the name of the friend is an unqualified-id (i.e.,* friend foo(int)*), the C language specification demands that the friend declare or define an ordinary, nontemplate function. (Section 14.5.3). Before G implemented explicit specification, unqualified-ids could be interpreted as a particular specialization of a templatized function. Because this non-conforming behavior is no longer the default behavior for G, -Wnon-template-friend *allows the compiler to check existing code for potential trouble spots and is on by default. This new compiler behavior can be turned off with -Wno-non-template-friend* which keeps the conformant compiler code but disables the helpful warning.
-Wold-style-cast (C++ only)
Warn if an old-style (C-style) cast to a non-void type is used within a C++ program. The new-style casts (dynamic_cast, static_cast, reinterpret_cast, and const_cast) are less vulnerable to unintended effects and much easier to search for.
-Woverloaded-virtual (C++ only)

Warn when a function declaration hides virtual functions from a base class. For example, in:

++

[width="100%",cols="100%",]

a|

        struct A {
          virtual void f();
        };

++

[width="100%",cols="100%",]

a|

        struct B: public A {
          void f(int);
        };

+ f +`の `+ A +`クラスバージョンは `+ B +`に隠されており、次のようなコードです。

`++</literal>

[width="100%",cols="100%",]

a|

        B* b;
        b->f();
コンパイルに失敗します。
-Wno-pmf-conversions (C++ only)
Disable the diagnostic for converting a bound pointer to member function to a plain pointer.
-Wsign-promo (C++ only)

Warn when overload resolution chooses a promotion from unsigned or enumerated type to a signed type, over a conversion to an unsigned type of the same size. Previous versions of G would try to preserve unsignedness, but the standard mandates the current behavior.

``

[width="100%",cols="100%",]

a|

        struct A {
          operator int ();
          A& operator = (int);
        };

++

[width="100%",cols="100%",]

a|

        main ()
        {
          A a,b;
          a = b;
        }
この例では、G ++はデフォルトの A&operator =(const A&); を合成しますが、cfrontはユーザー定義の operator = を使用します。

Objective-CおよびObjective-C ++の方言を制御するオプション

NOTE ++

このセクションでは、Objective-CおよびObjective-C +プログラムでのみ意味のあるコマンドラインオプションについて説明しますが、言語に依存しないGNUコンパイラオプションのほとんどを使用することもできます。 たとえば、次のようなファイル ` some_class.m +`をコンパイルできます。

++

gcc -g -fgnu-runtime -O -c some_class.m

この例では、*-fgnu-runtime *は、Objective-CおよびObjective-C ++プログラム専用のオプションです。 GCCでサポートされている任意の言語で他のオプションを使用できます。

Objective-CはC言語の拡張であるため、Objective-CのコンパイルではCフロントエンド固有のオプション( -Wtraditional など)も使用される場合があることに注意してください。 同様に、Objective-C コンパイルでは、C 固有のオプション( -Wabi など)を使用できます。

以下は、Objective-CおよびObjective-C ++プログラムをコンパイルするための_only_のオプションのリストです。

Tag Description
-fconstant-string-class=class-name Use class-name as the name of the class to instantiate for each literal string specified with the syntax @"...". The default class name is NXConstantString if the GNU runtime is being used, and NSConstantString if the NeXT runtime is being used (see below). The -fconstant-cfstrings *option, if also present, will override the -fconstant-string-class* setting and cause @"..." literals to be laid out as constant CoreFoundation strings.
-fgnu-runtime Generate object code compatible with the standard GNU Objective-C runtime. This is the default for most types of systems.
-fnext-runtime Generate output compatible with the NeXT runtime. This is the default for NeXT-based systems, including Darwin and Mac OS X. The macro __NEXT_RUNTIME__ is predefined if (and only if) this option is used.
-fno-nil-receivers Assume that all Objective-C message dispatches (e.g., [receiver message:arg]) in this translation unit ensure that the receiver is not nil. This allows for more efficient entry points in the runtime to be used. Currently, this option is only available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
-fobjc-call-cxx-cdtors

For each Objective-C class, check if any of its instance variables is a C object with a non-trivial default constructor. If so, synthesize a special `+- (id) .cxx_construct+` instance method that will run non-trivial default constructors on any such instance variables, in order, and then return `+self+`. Similarly, check if any instance variable is a C object with a non-trivial destructor, and if so, synthesize a special - (void) .cxx_destruct method that will run all such default destructors, in reverse order.

このように生成された `-(id).cxx_construct +`および/または `-(void).cxx_destruct `メソッドは、現在のObjective-Cクラスで宣言されたインスタンス変数でのみ動作し、スーパークラスから継承されたものでは動作しません。 オブジェクトの継承階層でこのようなすべてのメソッドを呼び出すのは、Objective-Cランタイムの責任です。 `-(id).cxx_construct `メソッドは、新しいオブジェクトインスタンスが割り当てられた直後にランタイムによって呼び出されます。 `-(void).cxx_destruct +`メソッドは、ランタイムがオブジェクトインスタンスの割り当てを解除する直前に呼び出されます。

この記事の執筆時点では、Mac OS X 10.4以降のNeXTランタイムのみが、 `-(id).cxx_construct +`および `-(void).cxx_destruct +`メソッドの呼び出しをサポートしています。

-fobjc-direct-dispatch Allow fast jumps to the message dispatcher. On Darwin this is accomplished via the comm page.
*-fobjc-exceptions *a

Enable syntactic support for structured exception handling in Objective-C, similar to what is offered by C and Java. Currently, this option is only available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.

``

[width="100%",cols="100%",]

a|

          @try {
            ...
               @throw expr;
            ...
          }
          @catch (AnObjCClass* exc) {
            ...
              @throw expr;
            ...
              @throw;
            ...
          }
          @catch (AnotherClass *exc) {
            ...
          }
          @catch (id allOthers) {
            ...
          }
          @finally {
            ...
              @throw expr;
            ...
          }

+ @ throw +`ステートメントは、Objective-CまたはObjective-C プログラムのどこにでも表示できます。 `+ @ catch +`ブロック内で使用すると、 `+ @ throw +`は引数なしで表示される場合があります(上記を参照)。この場合、 `+ @ catch +`でキャッチされたオブジェクトは再スローされます。

このスキームを使用すると、Objective-Cオブジェクト(へのポインタ)のみがスローおよびキャッチされます。 オブジェクトがスローされると、C およびJavaでの `+ catch +`ブロックの動作と同様に、そのタイプのオブジェクトを処理できる最も近い `+ @ catch +`句によってキャッチされます。 前の `+ @ catch +`句(存在する場合)でキャッチされなかったすべてのObjective-C例外をキャッチするために、 `+ @ catch(id …​)+`句(上記参照)を提供することもできます。

`+ @ finally +`句が存在する場合、直前の `+ @ try …​の終了時に実行されます…​ @ catch + `セクション。 これは、「+ @ try …​」内で例外がスロー、キャッチ、または再スローされたかどうかに関係なく発生します。 @ catch + `セクション。Javaの</literal> + finally + `句の動作に似ています。

新しい例外メカニズムを使用するには、いくつかの注意事項があります。

[cols=",",options="header",]

|Tag |Description |* |Although currently designed to be binary compatible with NS_HANDLER-style idioms provided by the NSException class, the new exceptions can only be used on Mac OS X 10.3 (Panther) and later systems, due to additional functionality needed in the (NeXT) Objective-C runtime. |* |As mentioned above, the new exceptions do not support handling types other than Objective-C objects. Furthermore, when used from Objective-C, the Objective-C exception model does not interoperate with C exceptions at this time. This means you cannot @throw an exception from Objective-C and catch it in C+, or vice versa (i.e., `+throw ... @catch`).

-fobjc-exceptions スイッチは、スレッドセーフな実行のための同期ブロックの使用も可能にします。

++

[width="100%",cols="100%",]

a|

          @synchronized (ObjCClass *guard) {
            ...
          }

`+ @ synchronized `ブロックに入ると、実行スレッドは最初に、別のスレッドによって対応する ` guard `オブジェクトにロックがかけられているかどうかをチェックします。 存在する場合、現在のスレッドは、他のスレッドがロックを放棄するまで待機します。 ` guard `が使用可能になると、現在のスレッドは独自のロックを設定し、 ` @ synchronized `ブロックに含まれるコードを実行し、最後にロックを放棄します(これにより、 ` guard `が他のスレッドで使用可能になります)。

Javaとは異なり、Objective-Cでは、メソッド全体を「 @ synchronized 」とマークすることはできません。 ` @ synchronized +`ブロックから例外をスローすることは許可されており、ガードオブジェクトが適切にロック解除されることに注意してください。

-fobjc-gc
Enable garbage collection (GC) in Objective-C and Objective-C++ programs.
*-freplace-objc-classes *
Emit a special marker instructing* 'ld'(1) not to statically link in the resulting object file, and allowdyld(1)* to load it in at run time instead. This is used in conjunction with the Fix-and-Continue debugging mode, where the object file in question may be recompiled and dynamically reloaded in the course of program execution, without the need to restart the program itself. Currently, Fix-and-Continue functionality is only available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
*-fzero-link *
When compiling for the NeXT runtime, the compiler ordinarily replaces calls to objc_getClass("...") (when the name of the class is known at compile time) with static class references that get initialized at load time, which improves run-time performance. Specifying the* -fzero-link* flag suppresses this behavior and causes calls to objc_getClass("...") to be retained. This is useful in Zero-Link debugging mode, since it allows for individual class implementations to be modified during program execution.
-gen-decls
Dump interface declarations for all classes seen in the source file to a file named sourcename.decl.
-Wassign-intercept
Warn whenever an Objective-C assignment is being intercepted by the garbage collector.
*-Wno-protocol *
If a class is declared to implement a protocol, a warning is issued for every method in the protocol that is not implemented by the class. The default behavior is to issue a warning for every method not explicitly implemented in the class, even if a method implementation is inherited from the superclass. If you use the* -Wno-protocol* option, then methods inherited from the superclass are considered to be implemented, and no warning is issued for them.
*-Wselector *
Warn if multiple methods of different types for the same selector are found during compilation. The check is performed on the list of methods in the final stage of compilation. Additionally, a check is performed for each selector appearing in a @selector(...) expression, and a corresponding method for that selector has been found during compilation. Because these checks scan the method table only at the end of compilation, these warnings are not produced if the final stage of compilation is not reached, for example because an error is found during compilation, or because the* -fsyntax-only* option is being used.
-Wstrict-selector-match
Warn if multiple methods with differing argument and/or return types are found for a given selector when attempting to send a message using this selector to a receiver of type id or Class. When this flag is off (which is the default behavior), the compiler will omit such warnings if any differences found are confined to types which share the same size and alignment.
*-Wundeclared-selector *
Warn if a @selector(...) expression referring to an undeclared selector is found. A selector is considered undeclared if no method with that name has been declared before the @selector(...) expression, either explicitly in an @interface or @protocol declaration, or implicitly in an @implementation section. This option always performs its checks as soon as a @selector(...) expression is found, while* -Wselector* only performs its checks in the final stage of compilation. This also enforces the coding style convention that methods and selectors must be declared before being used.
-print-objc-runtime-info
Generate C header describing the largest structure that is passed by value, if any.

診断メッセージのフォーマットを制御するオプション

Tag Description
-fmessage-length=n Try to format error messages so that they fit on lines of about n characters. The default is 72 characters for g++ and 0 for the rest of the front ends supported by GCC. If n is zero, then no line-wrapping will be done; each error message will appear on a single line.
-fdiagnostics-show-location=once Only meaningful in line-wrapping mode. Instructs the diagnostic messages reporter to emit once source location information; that is, in case the message is too long to fit on a single physical line and has to be wrapped, the source location won’t be emitted (as prefix) again, over and over, in subsequent continuation lines. This is the default behavior.
-fdiagnostics-show-location=every-line Only meaningful in line-wrapping mode. Instructs the diagnostic messages reporter to emit the same source location information (as prefix) for physical lines that result from the process of breaking a message which is too long to fit on a single line.
-fdiagnostics-show-options This option instructs the diagnostic machinery to add text to each diagnostic emitted, which indicates which command line option directly controls that diagnostic, when such an option is known to the diagnostic machinery.

警告を要求または抑制するオプション

*-W* で始まるオプションを使用して、多くの特定の警告を要求できます。たとえば、暗黙の宣言に関する警告を要求する *-Wimplicit* です。 これらの特定の警告オプションにはそれぞれ、警告をオフにする *-Wno-* で始まる否定形式もあります。たとえば、*-Wno-implicit *。 このマニュアルでは、2つの形式のうちどちらか一方だけがデフォルトになっています。

次のオプションは、GCCが生成する警告の量と種類を制御します。さらに、言語固有のオプションについては、 C Dialect Options* および *Objective-CおよびObjective-C Dialect Options も参照してください。

Tag

説明

*-fsyntax-only*

コードに構文エラーがないか確認しますが、それ以上は何もしません。

*-pedantic*

厳密なISO CおよびISO C が要求するすべての警告を発行します。禁止されている拡張機能を使用するすべてのプログラム、およびISO CおよびISO C に従わないその他のプログラムをすべて拒否します。 ISO Cの場合、使用される -std オプションで指定されたISO C標準のバージョンに従います。

有効なISO CおよびISO C プログラムは、このオプションを使用して、または使用せずに適切にコンパイルする必要があります(ごくまれに、必要なバージョンのISO Cを指定する *-ansi* または *-std* オプションが必要です)。 ただし、このオプションがないと、特定のGNU拡張機能と従来のCおよびC 機能もサポートされます。 このオプションを使用すると、拒否されます。

*-pedantic* は、名前が *__​​* で始まる代替キーワードの使用に関する警告メッセージを表示しません。 「+ __ extension __ +」の後に続く式では、知識をひけらかす警告も無効になっています。 ただし、システムヘッダーファイルのみがこれらのエスケープルートを使用する必要があります。アプリケーションプログラムはそれらを避けるべきです。

一部のユーザーは、*-pedantic *を使用して、厳密なISO C準拠のプログラムをチェックしようとします。 彼らはすぐに、それが望んでいることをまったく行わないことに気付きます.ISO以外の慣行をいくつか見つけますが、すべてではなく、ISO Cが診断を必要とするもの、および診断が追加された他のものを見つけます。

ISO Cに準拠していないことを報告する機能は、場合によっては便利ですが、かなりの追加作業が必要になり、*-pedantic *とはまったく異なります。 近い将来、このような機能をサポートする予定はありません。

*-std* で指定された標準が *gnu89* や *gnu99* などのCのGNU拡張方言を表す場合、対応する_base standard_、GNU拡張方言のベースとなるISO Cのバージョンがあります。 *-pedantic* からの警告は、基本標準で必要な場合に提供されます。 (定義により、CのGNU方言には、コンパイラが指定されたオプションでサポートするすべての機能が含まれるため、指定されたGNU C方言にない機能に対してのみこのような警告を与えることは意味がありません。 )
*-pedantic-errors*

警告ではなくエラーが生成されることを除いて、*-pedantic *に似ています。

-w

すべての警告メッセージを禁止します。

*-Wno-import*
  • #import *の使用に関する警告メッセージを禁止します。
*-Wchar-subscripts*

配列の添字のタイプが `+ char +`の場合に警告します。 プログラマはこのタイプが一部のマシンで署名されていることを忘れる場合が多いため、これはエラーの一般的な原因です。 この警告は -Wall によって有効になります。

*-Wcomment*

コメント開始シーケンス / が */ コメントに表示されるたび、またはバックスラッシュ改行が *// コメントに表示されるたびに警告します。 この警告は -Wall によって有効になります。

-致命的なエラー

このオプションを使用すると、コンパイラは、エラーメッセージを出力し続けて印刷しようとするのではなく、最初に発生したエラーでコンパイルを中止します。

*-Wformat*

+ printf +`や `+ scanf +`などの呼び出しをチェックして、指定された引数が指定されたフォーマット文字列に適した型を持ち、フォーマット文字列で指定された変換が意味をなすことを確認します。 これには、標準機能、およびフォーマット属性で指定された他の `+ printf ++ scanf ++ strftime +、および + strfmon +(C標準ではないX/Open拡張)ファミリ(またはその他ターゲット固有のファミリー)。 形式属性を指定せずにチェックする関数は、選択した標準バージョンによって異なります。属性を指定しない関数のこのようなチェックは、-ffreestanding *または *-fno-builtin によって無効にされます。

フォーマットは、GNU libcバージョン2.2でサポートされているフォーマット機能に対してチェックされます。 これらには、ISO C90およびC99のすべての機能、ならびにSingle Unix SpecificationおよびBSDおよびGNUの拡張機能からの機能がすべて含まれています。 他のライブラリの実装では、これらのすべての機能をサポートしていない場合があります。 GCCは、特定のライブラリの制限を超える機能に関する警告をサポートしていません。 ただし、-pedantic *を *-Wformat とともに使用すると、選択した標準バージョンにないフォーマット機能について警告が表示されます(ただし、C標準のどのバージョンにもないため、 `+ strfmon +`フォーマットには適用されません) 。

*-Wformat* はいくつかの関数のnull形式の引数もチェックするため、*-Wformat *は *-Wnonnull* も意味します。
*-Wformat* は *-Wall* に含まれています。 形式チェックのいくつかの側面をさらに制御するには、オプション *-Wformat-y2k* 、*-Wno-format-extra-args *、*-Wno-format-zero-length *、*-Wformat-nonliteral *、*- Wformat-security *および *-Wformat = 2* は使用可能ですが、*-Wall *には含まれていません。
*-Wformat-y2k*
*-Wformat* が指定されている場合、2桁の年しか得られない `+ strftime +`フォーマットについても警告します。
*-Wno-format-extra-args*
*-Wformat* が指定されている場合、 `+ printf +`または `+ scanf +`形式関数への過剰な引数について警告しないでください。 C標準では、このような引数は無視されると規定されています。

未使用の引数が $ オペランド番号指定で指定された使用済みの引数の間にある場合、実装は未使用の引数をスキップするために `+ va_arg `に渡すタイプを知ることができないため、通常は警告が引き続き表示されます。 ただし、 ` scanf +`形式の場合、未使用の引数がすべてポインターである場合、このオプションは警告を抑制します。これは、Single Unix仕様がそのような未使用の引数が許可されると述べているためです。

*-Wno-format-zero-length*
*-Wformat* が指定されている場合、長さゼロの形式について警告しません。 C標準では、長さゼロの形式が許可されると規定されています。
*-Wformat-nonliteral*
*-Wformat* が指定されている場合、フォーマット文字列が文字列リテラルではないため、フォーマット関数がそのフォーマット引数を `+ va_list +`として受け取らない限り、チェックできない場合にも警告します。
*-Wformat-security*
*-Wformat* が指定されている場合、考えられるセキュリティ上の問題を表すフォーマット関数の使用についても警告します。 現時点では、これは、フォーマット文字列が文字列リテラルではなく、 `+ printf(foo); +`のようにフォーマット引数がない `+ printf +`および `+ scanf +`関数の呼び出しについて警告します。 フォーマット文字列が信頼できない入力からのもので、*%n *を含む場合、これはセキュリティホールになる可能性があります。 (現在、これは *-Wformat-nonliteral* が警告する内容のサブセットですが、将来、*-Wformat-nonliteral *に含まれない *-Wformat-security* に警告が追加される可能性があります。)
*-Wformat = 2*
*-Wformat* に加えて、*-Wformat *に含まれないフォーマットチェックを有効にします。 現在、*-Wformat -Wformat-nonliteral -Wformat-security -Wformat-y2k *と同等です。
*-Wnonnull*

`+ nonnull +`関数属性によってnull以外の値が必要とマークされた引数にnullポインタを渡すことについて警告します。

*-Wnonnull* は *-Wall* および *-Wformat* に含まれています。 *-Wno-nonnull* オプションで無効にできます。
*-Winit-self* (C、C ++、Objective-CおよびObjective-C ++のみ)

自分自身で初期化される初期化されていない変数について警告します。 このオプションは、-Wuninitialized *オプションでのみ使用できます。-Wuninitialized オプションは、-O1 *以上でのみ機能します。

たとえば、GCCは -Winit-self が指定されている場合にのみ、次のスニペットで「+ i +」が初期化されていないことを警告します。

++

int f() { int i = i; return i; }
*-Wimplicit-int*

宣言でタイプが指定されていない場合に警告します。 この警告は -Wall によって有効になります。

*-Wimplicit-function-declaration*
*-Werror-implicit-function-declaration*

関数が宣言される前に使用されるたびに警告(またはエラー)を出します。 -Wno-error-implicit-function-declaration という形式はサポートされていません。 この警告は、*-Wall *によって有効になります(エラーではなく警告として)。

*-Wimplicit*
*-Wimplicit-int* および *-Wimplicit-function-declaration* と同じです。 この警告は *-Wall* によって有効になります。
*-Wmain*
*main* のタイプが疑わしい場合に警告します。 *main* は、外部リンケージを持つ関数で、intを返し、適切なタイプの引数を2つ、2つ、または3つ取る必要があります。 この警告は *-Wall* によって有効になります。

-ミッシングブレース

集約または共用体の初期化子が完全に括弧で囲まれていない場合に警告します。 次の例では、 a の初期化子は完全に括弧で囲まれていませんが、 b の初期化子は完全に括弧で囲まれています。

++

int a[2][2] = { 0, 1, 2, 3 }; int b[2][2] = { { 0, 1 }, { 2, 3 } };

この警告は -Wall によって有効になります。

*-Wmissing-include-dirs* (C、C ++、Objective-C、Objective-C ++のみ)

ユーザー指定のインクルードディレクトリが存在しない場合に警告します。

-括弧

真理値が期待されるコンテキストに割り当てがある場合、または優先順位が混乱することが多い演算子がネストされている場合など、特定のコンテキストで括弧が省略されている場合に警告します。 C ++のコンパイル時には、真理値として使用される割り当ての警告のみがサポートされます。その他の警告は、Cのコンパイル時にのみサポートされます。

*x <= y <= z* のような比較が表示された場合も警告します。これは*(x <= y? 1:0)<= z *。これは通常の数学表記とは異なる解釈です。

また、 `+ else `ブランチが属する ` if +`ステートメントに混乱が生じる可能性のある構造についても警告します。 そのような場合の例を次に示します。

++

{ if (a) if (b) foo (); else bar (); }

Cでは、すべての `+ else `ブランチは可能な限り最も内側の ` if `ステートメントに属します。この例では、これは ` if(b)`です。 上記の例でプログラマーが選択したインデントで示すように、これは多くの場合プログラマーが期待したものではありません。 この混乱の可能性がある場合、GCCはこのフラグが指定されると警告を発行します。 警告を排除するには、最も内側の ` if `ステートメントの周りに明示的な中括弧を追加して、 ` else `が囲む ` if +`に属することができないようにします。 結果のコードは次のようになります。

++

{ if (a) { if (b) foo (); else bar (); } }

この警告は -Wall によって有効になります。

*-Wsequence-point*

C標準のシーケンスポイントルールの違反により、未定義のセマンティクスを持つ可能性のあるコードについて警告します。

C標準は、Cプログラム内の式が_sequence points_の観点から評価される順序を定義します。これは、プログラムの各部分の実行間の順序を表します。 これらは、完全な式(より大きな式の一部ではない式)の評価後、 + && ++ || ++?の第1オペランドの評価後に発生します。 :+ `または 、 `(コンマ)演算子、関数が呼び出される前(ただし、引数と呼び出された関数を表す式の評価後)、および他の特定の場所。 シーケンスポイント規則で表現されている場合を除き、式の部分式の評価順序は指定されていません。 例えば、2つの関数が1つの式の中でそれらの間にシーケンス・ポイントなしで呼び出される場合、関数が呼び出される順序は指定されていないため、これらすべての規則は全順序ではなく部分順序のみを記述します。 ただし、標準化委員会は、関数呼び出しが重複しないように決定しました。

シーケンスポイント間でオブジェクトの値に対する変更が有効になる場合は指定されていません。 動作がこれに依存するプログラムには、未定義の動作があります。 C標準では、前のシーケンスポイントと次のシーケンスポイントの間で、式の評価によってオブジェクトの格納値が最大で1回変更されることを指定しています。 さらに、保存する値を決定するためにのみ、以前の値が読み取られます。 プログラムがこれらの規則を破った場合、特定の実装に関する結果はまったく予測できません。

未定義の動作を伴うコードの例は、 + a = a ; +`、 `+ a [n] = b [n ] +、および `+ a [i ++] = i; +`です。 いくつかのより複雑なケースはこのオプションによって診断されず、それは時折の誤検知の結果を与えるかもしれませんが、一般的にプログラムの中でこの種の問題を検出するのにかなり効果的であることがわかっています。

このオプションの現在の実装は、Cプログラムでのみ機能します。 将来の実装はC ++プログラムでも機能する可能性があります。

C規格はわかりにくい言葉で記述されているため、微妙な場合のシーケンスポイントルールの正確な意味については議論があります。 正式な定義案を含む問題の議論へのリンクは、<http://gcc.gnu.org/readingsl>のGCCリーディングページにあります。

この警告は -Wall によって有効になります。

-返品タイプ

関数がデフォルトで `+ int `のreturn-typeで定義されている場合に警告します。 また、return-typeが ` void `でない関数で、戻り値のない ` return +`ステートメントについて警告します。

Cの場合、関数の戻り値の型に `+ const `などの型修飾子がある場合にも警告します。 関数によって返される値は左辺値ではないため、このような型修飾子は効果がありません。 ISO Cは、関数定義で修飾された ` void +`戻り値型を禁止しているため、このような戻り値型は、このオプションがなくても常に警告を受け取ります。

C ++では、-Wno-return-type *が指定されている場合でも、戻り値のない関数は常に診断メッセージを生成します。 唯一の例外は、 *main およびシステムヘッダーで定義された関数です。

この警告は -Wall によって有効になります。

*-Wswitch*

`+ switch `ステートメントに列挙型のインデックスがあり、その列挙の名前付きコードの1つ以上の ` case `がない場合に警告します。 ( ` default `ラベルの存在はこの警告を防ぎます。)列挙範囲外の ` case +`ラベルも、このオプションが使用されると警告を引き起こします。 この警告は -Wall によって有効になります。

*-Wswitch-default*

`+ switch `ステートメントに ` default +`ケースがない場合は常に警告します。

*-Wswitch-enum*

`+ switch `ステートメントに列挙型のインデックスがあり、その列挙の名前付きコードの1つ以上の ` case `がない場合に警告します。 列挙範囲外の ` case +`ラベルも、このオプションが使用されると警告を発します。

*-Wtrigraphs*

プログラムの意味を変更する可能性のあるトライグラフが検出された場合は警告します(コメント内のトライグラフは警告されません)。 この警告は -Wall によって有効になります。

*-Wunused-function*

静的関数が宣言されているが定義されていない場合、またはインラインでない静的関数が使用されていない場合は常に警告します。 この警告は -Wall によって有効になります。

-未使用ラベル

ラベルが宣言されているが使用されていない場合は常に警告します。 この警告は -Wall によって有効になります。

この警告を抑制するには、 unused 属性を使用します。

*-Wunused-parameter*

関数パラメーターが宣言以外で使用されていない場合は常に警告します。

この警告を抑制するには、 unused 属性を使用します。

-未使用変数

ローカル変数または非定数の静的変数がその宣言とは別に使用されない場合は常に警告します。 この警告は -Wall によって有効になります。

この警告を抑制するには、 unused 属性を使用します。

-未使用値

ステートメントが明示的に使用されない結果を計算するたびに警告します。 この警告は -Wall によって有効になります。

この警告を抑制するには、式を void にキャストします。

-未使用

上記のすべての -Wunused オプションが組み合わされています。

未使用の関数パラメーターに関する警告を取得するには、-Wextra -Wunused *( *-Wall-Wunused を意味することに注意)を指定するか、*-Wunused-parameter *を個別に指定する必要があります。

*-Wuninitialized*

最初に初期化されずに自動変数が使用された場合、または変数が `+ setjmp +`呼び出しによって上書きされる可能性がある場合に警告します。

これらの警告は、最適化時にのみ計算されるデータフロー情報を必要とするため、最適化コンパイルでのみ可能です。 -O を指定しない場合、これらの警告は表示されません。

独自の初期化子で変数の初期化されていない値を使用するコードについて警告する場合は、*-Winit-self *オプションを使用します。

これらの警告は、構造体、ユニオン、または配列変数の個々の初期化されていない、または上書きされている要素、および全体として初期化されていない、または上書きされる変数に対して発生します。 これらは、 `+ volatile +`として宣言された変数または要素には発生しません。 これらの警告は最適化に依存するため、警告のある正確な変数または要素は、使用するGCCの正確な最適化オプションとバージョンによって異なります。

警告が出力される前にデータフロー分析によってそのような計算が削除される可能性があるため、それ自体は決して使用されない値を計算するためにのみ使用される変数については、警告がない場合があります

GCCは、エラーが発生しているように見えてもコードが正しい可能性があるすべての理由を確認できるほど賢くないため、これらの警告はオプションです。 これがどのように起こるかの一例を以下に示します。

++

{ int x; switch (y) { case 1: x = 1; break; case 2: x = 4; break; case 3: x = 5; } foo (x); }

「+ y 」の値が常に1、2、または3の場合、「 x +」は常に初期化されますが、GCCはこれを認識しません。 別の一般的なケースを次に示します。

++

{ int save_y; if (change_y) save_y = y, y = new_y; ... if (change_y) y = save_y; }

`+ save_y +`は設定されている場合にのみ使用されるため、これにはバグはありません。

このオプションは、不揮発性の自動変数が `+ longjmp +`の呼び出しによって変更される可能性がある場合にも警告します。 これらの警告も、コンパイルの最適化でのみ可能です。

コンパイラは、 `+ setjmp `の呼び出しのみを認識します。 ` longjmp `がどこで呼び出されるかはわかりません。実際、シグナルハンドラーは、コードの任意の時点で呼び出すことができます。 その結果、実際に問題が発生していなくても、問題を引き起こす場所で ` longjmp +`を呼び出すことができないため、警告が表示される場合があります。

`+ noreturn +`として返らない、使用するすべての関数を宣言すると、いくつかの偽の警告を回避できます。

この警告は -Wall によって有効になります。

*-Wunknown-pragmas*

GCCが理解できない#pragmaディレクティブが検出されたときに警告します。 このコマンドラインオプションを使用すると、システムヘッダーファイル内の不明なプラグマに対しても警告が発行されます。 これは、警告が -Wall コマンドラインオプションによってのみ有効にされた場合には当てはまりません。

*-Wno-pragmas*

誤ったパラメーター、無効な構文、プラグマ間の競合など、プラグマの誤用について警告しないでください。 -Wunknown-pragmas も参照してください。

*-Wstrict-aliasing*

このオプションは、-fstrict-aliasing *がアクティブな場合にのみアクティブになります。 コンパイラが最適化に使用している厳密なエイリアシング規則を破る可能性のあるコードについて警告します。 警告はすべてのケースを捕らえるわけではありませんが、より一般的な落とし穴を捕まえようとします。 *-Wall に含まれています。

*-Wstrict-aliasing = 2*

このオプションは、-fstrict-aliasing *がアクティブな場合にのみアクティブになります。 コンパイラが最適化に使用している厳密なエイリアシング規則を破る可能性のあるコードについて警告します。 この警告は、-Wstrict-aliasing *よりも多くのケースをキャッチしますが、安全ないくつかのあいまいなケースについても警告を出します。

-壁

上記のすべての -W オプションが組み合わされています。 これにより、一部のユーザーが疑わしいと考える構成に関するすべての警告が有効になり、マクロと組み合わせても回避(または変更して警告を防ぐ)するのは簡単です。 これにより、 C Dialect Options* および *Objective-CおよびObjective-C Dialect Options で説明されている言語固有の警告も有効になります。

  • -W …​-壁*
Tag Description
*-Wextra *a

(This option used to be called* -W*. The older name is still supported, but the newer name is more descriptive.) Print extra warning messages for these events:

[width="100%",cols="50%,50%",options="header",]

|Tag |Description |* a| A function can return either with or without a value. (Falling off the end of the function body is considered returning without a value.) For example, this function would evoke such a warning:

++

foo (a) { if (a > 0) return a; }

| |An expression-statement or the left-hand side of a comma expression contains no side effects. To suppress the warning, cast the unused expression to void. For example, an expression such as x[i,j] will cause a warning, but x[(void)i,j]* will not. | |An unsigned value is compared against zero with < or >=. | |Storage-class specifiers like static are not the first things in a declaration. According to the C Standard, this usage is obsolescent. | |If -Wall or -Wunused* is also specified, warn about unused arguments. | |A comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. (But don’t warn if -Wno-sign-compare* is also specified.) | |An aggregate has an initializer which does not initialize all members. This warning can be independently controlled by -Wmissing-field-initializers*. |* a| A function parameter is declared without a type specifier in K&R-style functions:

++

void foo(bar) { }

| |An empty body occurs in an if or else* statement. | |A pointer is compared against integer zero with <*, , >, or >=. | |A variable might be changed by longjmp or vfork*. |* |Any of several floating-point events that often indicate errors, such as overflow, underflow, loss of precision, etc. |<(C only)> |An enumerator and a non-enumerator both appear in a conditional expression. |*<(C only)> |A non-static reference or non-static *const member appears in a class without constructors. |<(C only)> |Ambiguous virtual bases. |*<(C only)> |Subscripting an array which has been declared *register. |*<(C only)> |Taking the address of a variable which has been declared *register*. |*<(C only)> |A base class is not initialized in a derived class’ copy constructor.

-Wno-div-by-zero Do not warn about compile-time integer division by zero. Floating point division by zero is not warned about, as it can be a legitimate way of obtaining infinities and NaNs. *-Wsystem-headers * Print warning messages for constructs found in system header files. Warnings from system headers are normally suppressed, on the assumption that they usually do not indicate real problems and would only make the compiler output harder to read. Using this command line option tells GCC to emit warnings from system headers as if they occurred in user code. However, note that using* -Wall in conjunction with this option will not warn about unknown pragmas in system headers---for that, -Wunknown-pragmas* must also be used. -Wfloat-equal

Warn if floating point values are used in equality comparisons.

この背後にある考え方は、浮動小数点値を無限に正確な実数の近似値と見なすことが(プログラマにとって)便利な場合があるということです。 これを行う場合は、計算で生じる最大または可能性のある最大エラーを(コードを分析するなどして)計算し、比較を実行するとき(および出力を生成するときにそれを可能にする必要がありますが、それは別の問題)。 特に、同等性をテストする代わりに、2つの値に重複する範囲があるかどうかを確認します。そして、これは関係演算子で行われるため、等値比較はおそらく間違っています。

|Tag |Description |* |Macro parameters that appear within string literals in the macro body. In traditional C macro replacement takes place within string literals, but does not in ISO C. | |In traditional C, some preprocessor directives did not exist. Traditional preprocessors would only consider a line to be a directive if the # appeared in column 1 on the line. Therefore -Wtraditional warns about directives that traditional C understands but would ignore because the # does not appear as the first character on the line. It also suggests you hide directives like #pragma not understood by traditional C by indenting them. Some traditional implementations would not recognize #elif*, so it suggests avoiding it altogether. |* |A function-like macro that appears without arguments. |* |The unary plus operator. | |The U integer constant suffix, or the F or L floating point constant suffixes. (Traditional C does support the L suffix on integer constants.) Note, these suffixes appear in macros defined in the system headers of most modern systems, e.g. the MIN*/_MAX macros in <limits.h>. Use of these macros in user code might normally lead to spurious warnings, however GCC’s integrated preprocessor has enough context to avoid warning in these cases. |* |A function declared external in one block and then used after the end of the block. |* |A switch statement has an operand of type long. |* |A non-static function declaration follows a static one. This construct is not accepted by some traditional C compilers. |* |The ISO type of an integer constant has a different width or signedness from its traditional type. This warning is only issued if the base of the constant is ten. I.e. hexadecimal or octal values, which typically represent bit patterns, are not warned about. |* |Usage of ISO string concatenation is detected. |* |Initialization of automatic aggregates. |* |Identifier conflicts with labels. Traditional C lacks a separate namespace for labels. |* |Initialization of unions. If the initializer is zero, the warning is omitted. This is done under the assumption that the zero initializer in user code appears conditioned on e.g. __STDC__ to avoid missing initializer warnings and relies on default initialization to zero in the traditional C case. | |Conversions by prototypes between fixed/floating point values and vice versa. The absence of these prototypes when compiling with traditional C would cause serious problems. This is a subset of the possible conversion warnings, for the full set use -Wconversion*. |* |Use of ISO C style function definitions. This warning intentionally is _not issued for prototype declarations or variadic functions because these ISO C features will appear in your code when using libiberty’s traditional C compatibility macros, PARAMS and VPARAMS. This warning is also bypassed for nested functions because that feature is already a GCC extension and thus not relevant to traditional C compatibility.

-Wdeclaration-after-statement (C only) Warn when a declaration is found after a statement in a block. This construct, known from C++, was introduced with ISO C99 and is by default allowed in GCC. It is not supported by ISO C90 and was not supported by GCC versions before GCC 3.0. *-Wundef * Warn if an undefined identifier is evaluated in an* #if* directive. *-Wno-endif-labels * Do not warn whenever an* #else or an #endif* are followed by text. -Wshadow Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed. -Wlarger-than-len Warn whenever an object of larger than len bytes is defined. *-Wunsafe-loop-optimizations * Warn if the loop cannot be optimized because the compiler could not assume anything on the bounds of the loop indices. With* -funsafe-loop-optimizations* warn if the compiler made such assumptions. *-Wpointer-arith * Warn about anything that depends on the size of a function type or of void. GNU C assigns these types a size of 1, for convenience in calculations with +void* + pointers and pointers to functions. *-Wbad-function-cast *(C only) Warn whenever a function call is cast to a non-matching type. For example, warn if int malloc() is cast to +anything* +. *-Wc++-compat * Warn about ISO C constructs that are outside of the common subset of ISO C and ISO C+, e.g. request for implicit conversion from `+void* +` to a pointer to non-`+void` type. *-Wcast-qual * Warn whenever a pointer is cast so as to remove a type qualifier from the target type. For example, warn if a +const char* + is cast to an ordinary char *. *-Wcast-align * Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a +char* + is cast to an int * on machines where integers can only be accessed at two- or four-byte boundaries. *-Wwrite-strings * When compiling C, give string constants the type const char[length] so that copying the address of one into a non-const +char* + pointer will get a warning; when compiling C+, warn about the deprecated conversion from string constants to `+char *. These warnings will help you find at compile time code that can try to write into a string constant, but only if you have been very careful about using `const in declarations and prototypes. Otherwise, it will just be a nuisance; this is why we did not make -Wall request these warnings. -Wconversion

Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of a prototype. This includes conversions of fixed point to floating and vice versa, and conversions changing the width or signedness of a fixed point argument except when the same as the default promotion.

また、負の整数定数式が暗黙的に符号なし型に変換される場合に警告します。 たとえば、「+ x 」が符号なしの場合、割り当て「 x = -1+」について警告します。 しかし、 `+(unsigned)-1 +`のような明示的なキャストについて警告しないでください。

a|

        struct s { int f, g, h; };
        struct s x = { 3, 4 };

このオプションは、指定された初期化子について警告しないため、次の変更は警告をトリガーしません。

++

[width="100%",cols="100%",]

a|

        struct s { int f, g, h; };
        struct s x = { .f = 3, .g = 4 };
この警告は -Wextra に含まれています。 この警告なしで他の -Wextra 警告を取得するには、*-Wextra -Wno-missing-field-initializers *を使用します。
-Wmissing-noreturn
Warn about functions which might be candidates for attribute noreturn. Note these are only possible candidates, not absolute ones. Care should be taken to manually verify functions actually do not ever return before adding the noreturn attribute, otherwise subtle code generation bugs could be introduced. You will not get a warning for main in hosted C environments.
-Wmissing-format-attribute

Warn about function pointers which might be candidates for format attributes. Note these are only possible candidates, not absolute ones. GCC will guess that function pointers with format attributes that are used in assignment, initialization, parameter passing or return statements should have a corresponding format attribute in the resulting type. I.e. the left-hand side of the assignment or initialization, the type of the parameter variable, or the return type of the containing function respectively should also have a format attribute to avoid the warning.

GCCは、 `+ format `属性の候補となる可能性のある関数定義についても警告します。 繰り返しますが、これらは可能な候補にすぎません。 GCCは、「 vprintf 」や「 vscanf 」などの関数を呼び出す関数には「 format +」属性が適切であると推測しますが、常にそうであるとは限りません。適切が検出されない場合があります。

-Wno-multichar
Do not warn if a multicharacter constant (’FOOF’) is used. Usually they indicate a typo in the user’s code, as they have implementation-defined values, and should not be used in portable code.
*-Wnormalized=<none
id
nfc
nfkc>*

In ISO C and ISO C, two identifiers are different if they are different sequences of characters. However, sometimes when characters outside the basic ASCII character set are used, you can have two different character sequences that look the same. To avoid confusion, the ISO 10646 standard sets out some _normalization rules_ which when applied ensure that two sequences that look the same are turned into the same sequence. GCC can warn you if you are using identifiers which have not been normalized; this option controls that warning.

GCCがサポートする警告には4つのレベルがあります。 デフォルトは *-Wnormalized = nfc* で、ISO 10646 C正規化形式_NFC_にない識別子について警告します。 NFCは、ほとんどの用途に推奨される形式です。

残念ながら、ISO CおよびISO C が識別子に許可する文字がいくつかありますが、NFCに変換すると識別子として許可されません。 つまり、これらのシンボルをポータブルISO CまたはC +で使用し、すべての識別子をNFCで使用する方法はありません。 *-Wnormalized = id* は、これらの文字の警告を抑制します。 関係する標準の将来のバージョンでこれが修正されることが望まれるため、このオプションはデフォルトではありません。

  • -Wnormalized = none* と記述することで、すべての文字の警告をオフに切り替えることができます。 これは、他の正規化スキーム(Dなど)を使用している場合にのみ行います。そうしないと、文字通り見ることができないバグを簡単に作成できるためです。

ISO 10646の一部の文字には明確な意味がありますが、一部のフォントまたは表示方法では、特に書式設定が適用されると同一に見えます。 たとえば、「 \ u207F 」のスーパースクリプトラテン小文字Nは、上付き文字に配置された通常の「 n +」のように表示されます。 ISO 10646では_NFKC_正規化スキームが定義されており、これらもすべて標準形式に変換されます。*-Wnormalized = nfkc *を使用すると、コードがNFKCにない場合、GCCが警告します。 この警告は、文字Oを含むすべての識別子に関する警告に匹敵します。これは、数字0と混同される可能性があるため、デフォルトではないが、プログラミング環境を修正できない場合のローカルコーディング規則として役立つ場合があるためです。これらの文字を明確に表示します。

-Wno-deprecated-declarations
Do not warn about uses of functions, variables, and types marked as deprecated by using the deprecated attribute. (@pxref\{Function Attributes}, @pxref\{Variable Attributes}, @pxref\{Type Attributes}.)
-Wpacked

Warn if a structure is given the packed attribute, but the packed attribute has no effect on the layout or size of the structure. Such structures may be mis-aligned for little benefit. For instance, in this code, the variable f.x in struct bar will be misaligned even though struct bar does not itself have the packed attribute:

++

[width="100%",cols="100%",]

a|

        struct foo {
          int x;
          char a, b, c, d;
        } __attribute__((packed));
        struct bar {
          char z;
          struct foo f;
        };
-Wpadded Warn if padding is included in a structure, either to align an element of the structure or to align the whole structure. Sometimes when this happens it is possible to rearrange the fields of the structure to reduce the padding and so make the structure smaller. -Wredundant-decls Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing. -Wnested-externs (C only) Warn if an extern declaration is encountered within a function. -Wunreachable-code

Warn if the compiler detects that code will never be executed.

このオプションは、ある条件が満たされないため、または戻らないプロシージャの後にあるため、少なくともソースコードの行全体が実行されないことをコンパイラが検出した場合に警告することを目的としています。

影響を受ける行の一部を実行できる状況がある場合でも、このオプションは警告を生成する可能性があるため、明らかに到達不能なコードを削除する場合は注意が必要です。

たとえば、関数がインライン化されている場合、警告は関数の1つのインラインコピーでのみ行に到達できないことを意味する場合があります。

このオプションは -Wall の一部ではありません。デバッグバージョンのプログラムには、プログラムの正常な機能をチェックするかなりのコードが存在することが多く、プログラムが機能するために到達できないことが望ましいためです。 到達不能コードの別の一般的な使用法は、コンパイル時に選択可能な動作を提供することです。

-Winline

Warn if a function can not be inlined and it was declared as inline. Even with this option, the compiler will not warn about failures to inline functions declared in system headers.

コンパイラは、さまざまなヒューリスティックを使用して、関数をインライン化するかどうかを決定します。 たとえば、コンパイラーは、インライン化される関数のサイズと、現在の関数で既に行われているインライン化の量を考慮します。 そのため、ソースプログラムで一見些細な変更を行うと、*-Winline *によって生成される警告が表示または非表示になります。

*-Wno-invalid-offsetof *(C++ only)

Suppress warnings from applying the* offsetof macro to a non-POD type. According to the 1998 ISO C standard, applying* offsetof *to a non-POD type is undefined. In existing C implementations, however, offsetof typically gives meaningful results even when applied to certain kinds of non-POD types. (Such as a simple struct* that fails to be a POD type only by virtue of having a constructor.) This flag is for users who are aware that they are writing nonportable code and who have deliberately chosen to ignore the warning about it.

  • offsetof* の制限は、C ++標準の将来のバージョンで緩和される可能性があります。
-Wno-int-to-pointer-cast (C only) Suppress warnings from casts to pointer type of an integer of a different size. -Wno-pointer-to-int-cast (C only) Suppress warnings from casts from a pointer to an integer type of a different size.
-Winvalid-pch Warn if a precompiled header is found in the search path but can’t be used. *-Wlong-long * Warn if* long long type is used. This is default. To inhibit the warning messages, use -Wno-long-long*. Flags -Wlong-long *and -Wno-long-long are taken into account only when -pedantic* flag is used. *-Wvariadic-macros * Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU alternate syntax when in pedantic ISO C99 mode. This is default. To inhibit the warning messages, use* -Wno-variadic-macros*. -Wvolatile-register-var Warn if a register variable is declared volatile. The volatile modifier does not inhibit all optimizations that may eliminate reads and/or writes to register variables.
-Wdisabled-optimization Warn if a requested optimization pass is disabled. This warning does not generally indicate that there is anything wrong with your code; it merely indicates that GCC’s optimizers were unable to handle the code effectively. Often, the problem is that your code is too big or too complex; GCC will refuse to optimize programs when the optimization itself is likely to take inordinate amounts of time. *-Wpointer-sign * Warn for pointer argument passing or assignment with different signedness. This option is only supported for C and Objective-C. It is implied by* -Wall and by -pedantic*, which can be disabled with -Wno-pointer-sign. -Werror Make all warnings into errors. *-Wstack-protector * This option is only active when* -fstack-protector* is active. It warns about functions that will not be protected against stack smashing.

プログラムまたはGCCをデバッグするためのオプション

GCCGCC:

Tag Description
-g

Produce debugging information in the operating system’s native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging information.

スタブ形式を使用するほとんどのシステムでは、-g *を使用すると、GDBのみが使用できる追加のデバッグ情報を使用できます。この追加情報により、GDBでのデバッグ作業が改善されますが、おそらく他のデバッガーがクラッシュしたり、プログラムの読み取りが拒否されたりします。 追加情報を生成するかどうかを確実に制御する場合は、-gstabs + -gstabs -gxcoff + -gxcoff 、または *-gvms を使用します(以下を参照)。

GCCでは、-g *を *-O とともに使用できます。 最適化されたコードが使用する近道はときどき驚くべき結果を生み出すかもしれません。制御の流れは、あなたがそれを期待していなかった場所に一時的に動くかもしれません。いくつかのステートメントは一定の結果を計算するか、それらの値がすでに手元にあるために実行されないかもしれません。一部のステートメントは、ループの外に移動したため、異なる場所で実行される可能性があります。

それでも、最適化された出力をデバッグすることは可能です。 このため、バグがある可能性があるプログラムにはオプティマイザを使用するのが妥当です。

次のオプションは、複数のデバッグ形式の機能を備えたGCCが生成される場合に役立ちます。

-ggdb Produce debugging information for use by GDB. This means to use the most expressive format available (DWARF 2, stabs, or the native format if neither of those are supported), including GDB extensions if at all possible.
-gstabs Produce debugging information in stabs format (if that is supported), without GDB extensions. This is the format used by DBX on most BSD systems. On MIPS, Alpha and System V Release 4 systems this option produces stabs debugging output which is not understood by DBX or SDB. On System V Release 4 systems this option requires the GNU assembler.
-feliminate-unused-debug-symbols Produce debugging information in stabs format (if that is supported), for only symbols that are actually used.
-gstabs+ Produce debugging information in stabs format (if that is supported), using GNU extensions understood only by the GNU debugger (GDB). The use of these extensions is likely to make other debuggers crash or refuse to read the program.
-gcoff Produce debugging information in COFF format (if that is supported). This is the format used by SDB on most System V systems prior to System V Release 4.
-gxcoff Produce debugging information in XCOFF format (if that is supported). This is the format used by the DBX debugger on IBM RS/6000 systems.
-gxcoff+ Produce debugging information in XCOFF format (if that is supported), using GNU extensions understood only by the GNU debugger (GDB). The use of these extensions is likely to make other debuggers crash or refuse to read the program, and may cause assemblers other than the GNU assembler (GAS) to fail with an error.
-gdwarf-2 Produce debugging information in DWARF version 2 format (if that is supported). This is the format used by DBX on IRIX 6. With this option, GCC uses features of DWARF version 3 when they are useful; version 3 is upward compatible with version 2, but may still cause problems for older debuggers.
-gvms Produce debugging information in VMS debug format (if that is supported). This is the format used by DEBUG on VMS systems.
-glevel
-ggdblevel
-gstabslevel
-gcofflevel
-gxcofflevel
-gvmslevel

Request debugging information and also use level to specify how much information. The default level is 2.

レベル1は、デバッグする予定のないプログラムの一部でバックトレースを作成するのに十分な最小限の情報を生成します。 これには、関数と外部変数の説明が含まれますが、ローカル変数に関する情報や行番号は含まれません。

レベル3には、プログラムに存在するすべてのマクロ定義などの追加情報が含まれます。 -g3 を使用すると、一部のデバッガーはマクロ展開をサポートします。

  • -gdwarf-2* は連結されたデバッグレベルを受け入れません。これは、GCCがDWARF形式のバージョン1(バージョン2とは非常に異なる)でデバッグ情報を生成するためのオプション *-gdwarf* をサポートしていたためです。混乱しすぎていたでしょう。 そのデバッグ形式は長い間廃止されていますが、このオプションは現在変更できません。 代わりに、追加の**-g ** __ level__オプションを使用して、DWARF2のデバッグレベルを変更します。
*-feliminate-dwarf2-dups * Compress DWARF2 debugging information by eliminating duplicated information about each symbol. This option only makes sense when generating DWARF2 debugging information with* -gdwarf-2*.
*-p * Generate extra code to write profile information suitable for the analysis program* prof*. You must use this option when compiling the source files you want data about, and you must also use it when linking.
*-pg * Generate extra code to write profile information suitable for the analysis program* gprof*. You must use this option when compiling the source files you want data about, and you must also use it when linking.
-Q Makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes.
-ftime-report Makes the compiler print some statistics about the time consumed by each pass when it finishes.
-fmem-report Makes the compiler print some statistics about permanent memory allocation when it finishes.
-fprofile-arcs Add code so that program flow arcs are instrumented. During execution the program records how many times each branch and call is executed and how many times it is taken or returns. When the compiled program exits it saves this data to a file called auxname.gcda for each source file. The data may be used for profile-directed optimizations (-fbranch-probabilities), or for test coverage analysis (-ftest-coverage). Each object file’s auxname is generated from the name of the output file, if explicitly specified and it is not the final executable, otherwise it is the basename of the source file. In both cases any suffix is removed (e.g. foo.gcda for input file dir/foo.c, or dir/foo.gcda for output file specified as -o dir/foo.o).
*--coverage *a

This option is used to compile and link code instrumented for coverage analysis. The option is a synonym for* -fprofile-arcs* -ftest-coverage *(when compiling) and -lgcov *(when linking). See the documentation for those options for more details.

[cols=",",options="header",]

|Tag |Description |@bullet |Compile the source files with* -fprofile-arcs plus optimization and code generation options. For test coverage analysis, use the additional -ftest-coverage option. You do not need to profile every source file in a program. |@cvmmfu |Link your object files with -lgcov or -fprofile-arcs (the latter implies the former). |@dwnngv |Run the program on a representative workload to generate the arc profile information. This may be repeated any number of times. You can run concurrent instances of your program, and provided that the file system supports locking, the data files will be correctly updated. Also fork calls are detected and correctly handled (double counting will not happen). |@exoohw |For profile-directed optimizations, compile the source files again with the same optimization and code generation options plus -fbranch-probabilities*. |@fyppix |For test coverage analysis, use gcov *to produce human readable information from the .gcno and .gcda files. Refer to the gcov* documentation for further information.

-fprofile-arcs を使用すると、プログラムの各機能についてGCCはプログラムフローグラフを作成し、グラフのスパニングツリーを見つけます。 スパニングツリー上にないアークのみをインストルメント化する必要があります。コンパイラは、これらのアークが実行される回数をカウントするコードを追加します。 アークがブロックの唯一の出口または唯一の入口である場合、計装コードをブロックに追加できます。そうでない場合は、インストルメンテーションコードを保持するために新しい基本ブロックを作成する必要があります。
*-ftest-coverage *
Produce a notes file that the* gcov code-coverage utility can use to show program coverage. Each source file’s note file is called auxname.gcno. Refer to the -fprofile-arcs* option above for a description of auxname and instructions on how to generate test coverage data. Coverage data will match the source files more closely, if you do not optimize.
-dletters
-fdump-rtl-pass

Says to make debugging dumps during compilation at times specified by letters. This is used for debugging the RTL-based passes of the compiler. The file names for most of the dumps are made by appending a pass number and a word to the dumpname. dumpname is generated from the name of the output file, if explicitly specified and it is not an executable, otherwise it is the basename of the source file.

ほとんどのデバッグダンプは、-d *オプションに文字を渡すか、長い *-fdump-rtl スイッチで有効にできます。 _letters_および_pass_で使用できる文字とその意味は次のとおりです。

[cols=",",options="header",]

|Tag |Description |-dA |Annotate the assembler output with miscellaneous debugging information. |-db | |-fdump-rtl-bp |Dump after computing branch probabilities, to file.09.bp. |-dB | |-fdump-rtl-bbro |Dump after block reordering, to file.30.bbro. |-dc | |-fdump-rtl-combine |Dump after instruction combination, to the file file.17.combine. |-dC | |-fdump-rtl-ce1 | |-fdump-rtl-ce2 |-dC *and -fdump-rtl-ce1 enable dumping after the first if conversion, to the file file.11.ce1. -dC and -fdump-rtl-ce2* enable dumping after the second if conversion, to the file file.18.ce2. |-dd | |-fdump-rtl-btl | |-fdump-rtl-dbr |-dd *and -fdump-rtl-btl enable dumping after branch target load optimization, to file.31.btl. -dd and -fdump-rtl-dbr* enable dumping after delayed branch scheduling, to file.36.dbr. |-dD |Dump all macro definitions, at the end of preprocessing, in addition to normal output. |-dE | |-fdump-rtl-ce3 |Dump after the third if conversion, to file.28.ce3. |-df | |-fdump-rtl-cfg | |-fdump-rtl-life |-df *and -fdump-rtl-cfg enable dumping after control and data flow analysis, to file.08.cfg. -df and -fdump-rtl-cfg* enable dumping dump after life analysis, to file.16.life. |-dg | |-fdump-rtl-greg |Dump after global register allocation, to file.23.greg. |-dG | |-fdump-rtl-gcse | |-fdump-rtl-bypass |-dG *and -fdump-rtl-gcse enable dumping after GCSE, to file.05.gcse. -dG and -fdump-rtl-bypass* enable dumping after jump bypassing and control flow optimizations, to file.07.bypass. |-dh | |-fdump-rtl-eh |Dump after finalization of EH handling code, to file.02.eh. |-di | |-fdump-rtl-sibling |Dump after sibling call optimizations, to file.01.sibling. |-dj | |-fdump-rtl-jump |Dump after the first jump optimization, to file.03.jump. |-dk | |-fdump-rtl-stack |Dump after conversion from registers to stack, to file.33.stack. |-dl | |-fdump-rtl-lreg |Dump after local register allocation, to file.22.lreg. |-dL | |-fdump-rtl-loop | |-fdump-rtl-loop2 |-dL *and -fdump-rtl-loop enable dumping after the first loop optimization pass, to file.06.loop. -dL and -fdump-rtl-loop2* enable dumping after the second pass, to file.13.loop2. |-dm | |-fdump-rtl-sms |Dump after modulo scheduling, to file.20.sms. |-dM | |-fdump-rtl-mach |Dump after performing the machine dependent reorganization pass, to file.35.mach. |-dn | |-fdump-rtl-rnreg |Dump after register renumbering, to file.29.rnreg. |-dN | |-fdump-rtl-regmove |Dump after the register move pass, to file.19.regmove. |-do | |-fdump-rtl-postreload |Dump after post-reload optimizations, to file.24.postreload. |-dr | |-fdump-rtl-expand |Dump after RTL generation, to file.00.expand. |-dR | |-fdump-rtl-sched2 |Dump after the second scheduling pass, to file.32.sched2. |-ds | |-fdump-rtl-cse |Dump after CSE (including the jump optimization that sometimes follows CSE), to file.04.cse. |-dS | |-fdump-rtl-sched |Dump after the first scheduling pass, to file.21.sched. |-dt | |-fdump-rtl-cse2 |Dump after the second CSE pass (including the jump optimization that sometimes follows CSE), to file.15.cse2. |-dT | |-fdump-rtl-tracer |Dump after running tracer, to file.12.tracer. |-dV | |-fdump-rtl-vpt | |-fdump-rtl-vartrack |-dV *and -fdump-rtl-vpt enable dumping after the value profile transformations, to file.10.vpt. -dV and -fdump-rtl-vartrack* enable dumping after variable tracking, to file.34.vartrack. |-dw | |-fdump-rtl-flow2 |Dump after the second flow pass, to file.26.flow2. |-dz | |-fdump-rtl-peephole2 |Dump after the peephole pass, to file.27.peephole2. |-dZ | |-fdump-rtl-web |Dump after live range splitting, to file.14.web. |-da | |-fdump-rtl-all |Produce all the dumps listed above. |-dH |Produce a core dump whenever an error occurs. |-dm |Print statistics on memory usage, at the end of the run, to standard error. |-dp |Annotate the assembler output with a comment indicating which pattern and alternative was used. The length of each instruction is also printed. |-dP *|Dump the RTL in the assembler output as a comment before each instruction. Also turns on -dp* annotation. |-dv *|For each of the other indicated dump files (either with -d or -fdump-rtl-*pass), dump a representation of the control flow graph suitable for viewing with VCG to file.pass.vcg. |-dx *|Just generate RTL for a function instead of compiling it. Usually used with r* (-fdump-rtl-expand). |-dy |Dump debugging information during parsing, to standard error.

*-fdump-unnumbered * When doing debugging dumps (see* -d option above), suppress instruction numbers and line number note output. This makes it more feasible to use diff on debugging dumps for compiler invocations with different options, in particular with and without -g*. -fdump-translation-unit (C++ only) -fdump-translation-unit-options * *(C++ only) Dump a representation of the tree structure for the entire translation unit to a file. The file name is made by appending .tu to the source file name. If the* -*options form is used, options controls the details of the dump as described for the -fdump-tree options. -fdump-class-hierarchy (C++ only) -fdump-class-hierarchy-options * *(C++ only) Dump a representation of each class’s hierarchy and virtual function table layout to a file. The file name is made by appending .class to the source file name. If the* -*options form is used, options controls the details of the dump as described for the -fdump-tree options. -fdump-ipa-switch Control the dumping at various stages of inter-procedural analysis language tree to a file. The file name is generated by appending a switch specific suffix to the source file name. The following dumps are possible:

|Tag |Description |all *|Enables all inter-procedural analysis dumps; currently the only produced dump is the cgraph* dump. |cgraph |Dumps information about call-graph optimization, unused function removal, and inlining decisions.

-fdump-tree-switch -fdump-tree-switch-options Control the dumping at various stages of processing the intermediate language tree to a file. The file name is generated by appending a switch specific suffix to the source file name. If the -options form is used, options is a list of - separated options that control the details of the dump. Not all options are applicable to all dumps, those which are not meaningful will be ignored. The following options are available

|Tag |Description |address |Print the address of each node. Usually this is not meaningful as it changes according to the environment and source file. Its primary use is for tying up a dump file with a debug environment. |slim |Inhibit dumping of members of a scope or body of a function merely because that scope has been reached. Only dump such items when they are directly reachable by some other path. When dumping pretty-printed trees, this option inhibits dumping the bodies of control structures. |raw |Print a raw representation of the tree. By default, trees are pretty-printed into a C-like representation. |details |Enable more detailed dumps (not honored by every dump option). |stats |Enable dumping various statistics about the pass (not honored by every dump option). |blocks |Enable showing basic block boundaries (disabled in raw dumps). |vops |Enable showing virtual operands for every statement. |lineno |Enable showing line numbers for statements. |uid |Enable showing the unique ID (DECL_UID) for each variable. |all *|Turn on all options, except raw*, slim *and lineno*.

次のツリーダンプが可能です。

[cols=",",options="header",]

|Tag |Description |original |Dump before any tree based optimization, to file.original. |optimized |Dump after all tree based optimization, to file.optimized. |inlined |Dump after function inlining, to file.inlined. |gimple |Dump each function before and after the gimplification pass to a file. The file name is made by appending .gimple to the source file name. |cfg |Dump the control flow graph of each function to a file. The file name is made by appending .cfg to the source file name. |vcg |Dump the control flow graph of each function to a file in VCG format. The file name is made by appending .vcg to the source file name. Note that if the file contains more than one function, the generated file cannot be used directly by VCG. You will need to cut and paste each function’s graph into its own separate file first. |ch |Dump each function after copying loop headers. The file name is made by appending .ch to the source file name. |ssa |Dump SSA related information to a file. The file name is made by appending .ssa to the source file name. |salias |Dump structure aliasing variable information to a file. This file name is made by appending .salias to the source file name. |alias |Dump aliasing information for each function. The file name is made by appending .alias to the source file name. |ccp |Dump each function after CCP. The file name is made by appending .ccp to the source file name. |storeccp |Dump each function after STORE-CCP. The file name is made by appending .storeccp to the source file name. |pre |Dump trees after partial redundancy elimination. The file name is made by appending .pre to the source file name. |fre |Dump trees after full redundancy elimination. The file name is made by appending .fre to the source file name. |copyprop |Dump trees after copy propagation. The file name is made by appending .copyprop to the source file name. |store_copyprop |Dump trees after store copy-propagation. The file name is made by appending .store_copyprop to the source file name. |dce |Dump each function after dead code elimination. The file name is made by appending .dce to the source file name. |mudflap |Dump each function after adding mudflap instrumentation. The file name is made by appending .mudflap to the source file name. |sra |Dump each function after performing scalar replacement of aggregates. The file name is made by appending .sra to the source file name. |sink |Dump each function after performing code sinking. The file name is made by appending .sink to the source file name. |dom |Dump each function after applying dominator tree optimizations. The file name is made by appending .dom to the source file name. |dse |Dump each function after applying dead store elimination. The file name is made by appending .dse to the source file name. |phiopt |Dump each function after optimizing PHI nodes into straightline code. The file name is made by appending .phiopt to the source file name. |forwprop |Dump each function after forward propagating single use variables. The file name is made by appending .forwprop to the source file name. |copyrename |Dump each function after applying the copy rename optimization. The file name is made by appending .copyrename to the source file name. |nrv |Dump each function after applying the named return value optimization on generic trees. The file name is made by appending .nrv to the source file name. |vect |Dump each function after applying vectorization of loops. The file name is made by appending .vect to the source file name. |vrp |Dump each function after Value Range Propagation (VRP). The file name is made by appending .vrp to the source file name. |all |Enable all the available tree dumps with the flags provided in this option.

-ftree-vectorizer-verbose=n This option controls the amount of debugging output the vectorizer prints. This information is written to standard error, unless -fdump-tree-all *or -fdump-tree-vect* is specified, in which case it is output to the usual dump listing file, .vect. -frandom-seed=string

This option provides a seed that GCC uses when it would otherwise use random numbers. It is used to generate certain symbol names that have to be different in every compiled file. It is also used to place unique stamps in coverage data files and the object files that produce them. You can use the -frandom-seed option to produce reproducibly identical object files.

_string_は、コンパイルするファイルごとに異なる必要があります。

-fsched-verbose=n

On targets that use instruction scheduling, this option controls the amount of debugging output the scheduler prints. This information is written to standard error, unless -dS *or -dR* is specified, in which case it is output to the usual dump listing file, .sched or .sched2 respectively. However for n greater than nine, the output is always printed to standard error.

ゼロより大きい_n_の場合、-fsched-verbose *は *-dRS と同じ情報を出力します。 _n_が1より大きい場合、基本ブロックの確率、詳細な準備完了リスト情報、ユニット/insn情報も出力します。 2より大きい_n_の場合、アボートポイントでのRTL、制御フロー、および領域情報が含まれます。 また、_n_が4を超える場合、*-fsched-verbose *にも依存情報が含まれます。

*-save-temps *a

Store the usual temporary intermediate files permanently; place them in the current directory and name them based on the source file. Thus, compiling foo.c with* -c -save-temps* would produce files foo.i and foo.s, as well as foo.o. This creates a preprocessed foo.i output file even though the compiler now normally uses an integrated preprocessor.

-x コマンドラインオプションと組み合わせて使用​​する場合、-save-temps *は、中間ファイルと同じ拡張子を持つ入力ソースファイルの上書きを避けるのに十分賢明です。 対応する中間ファイルは、-save-temps *を使用する前にソースファイルの名前を変更することで取得できます。

a|

    # cc1 0.12 0.01
    # as 0.00 0.01
各行の最初の数値はユーザー時間、つまりプログラム自体の実行に費やされた時間です。 2番目の数値はシステム時間、つまりプログラムに代わってオペレーティングシステムルーチンの実行に費やした時間です。 両方の数値は秒単位です。
-fvar-tracking

Run variable tracking pass. It computes where variables are stored at each position in code. Better debugging information is then generated (if the debugging information format supports this information).

最適化( -Os-O *、-O2 、…​)、デバッグ情報( *-g )、およびデバッグ情報形式でサポートされている場合、デフォルトで有効になっています。

-print-file-name=library
Print the full absolute name of the library file library that would be used when linking---and don’t do anything else. With this option, GCC does not compile or link anything; it just prints the file name.
*-print-multi-directory *
Print the directory name corresponding to the multilib selected by any other switches present in the command line. This directory is supposed to exist in* GCC_EXEC_PREFIX*.
*-print-multi-lib *
Print the mapping from multilib directory names to compiler switches that enable them. The directory name is separated from the switches by* ;*, and each switch starts with an @} instead of the @samp\{-, without spaces between multiple switches. This is supposed to ease shell-processing.
-print-prog-name=program
Like -print-file-name, but searches for a program such as cpp.
*-print-libgcc-file-name *a

Same as* -print-file-name=libgcc.a*.

これは、-nostdlib *または *-nodefaultlibs を使用しているが、_libgcc.a_とリンクする場合に便利です。 できるよ

++

[width="100%",cols="100%",]

a|

    gcc -nostdlib <files>... ‘
    gcc -print-libgcc-file-name‘
*-print-search-dirs *a

Print the name of the configured installation directory and a list of program and library directories* gcc* will search---and don’t do anything else.

これは、 gcc がエラーメッセージ installation problemを出力し、cpp0:No such file or directory を実行できない場合に役立ちます。 これを解決するには、_cpp0_およびその他のコンパイラコンポーネントを gcc が検出する場所に配置するか、環境変数 GCC_EXEC_PREFIX をインストールしたディレクトリに設定する必要があります。 末尾の / を忘れないでください。

*-dumpmachine * Print the compiler’s target machine (for example,* i686-pc-linux-gnu*)---and don’t do anything else.
*-dumpversion * Print the compiler version (for example,* 3.0*)---and don’t do anything else.
-dumpspecs Print the compiler’s built-in specs---and don’t do anything else. (This is used when GCC itself is being built.)
-feliminate-unused-debug-types Normally, when producing DWARF2 output, GCC will emit debugging information for all types declared in a compilation unit, regardless of whether or not they are actually used in that compilation unit. Sometimes this is useful, such as if, in the debugger, you want to cast a value to a type that is not actually used in your program (but is declared). More often, however, this results in a significant amount of wasted space. With this option, GCC will avoid producing debug symbol output for types that are nowhere used in the source file being compiled.

最適化を制御するオプション

最適化オプションがない場合、コンパイラの目標は、コンパイルのコストを削減し、デバッグで期待どおりの結果が得られるようにすることです。 ステートメントは独立しています。ステートメント間のブレークポイントでプログラムを停止すると、変数に新しい値を割り当てるか、プログラムカウンターを関数内の他のステートメントに変更して、ソースコードから期待する結果を正確に取得できます。

最適化フラグをオンにすると、コンパイラーは、コンパイル時間と場合によってはプログラムをデバッグする能力を犠牲にして、パフォーマンスやコードサイズの改善を試みます。

コンパイラは、プログラムに関する知識に基づいて最適化を実行します。 最適化レベル -O 以上では、特に、_unit-at-a-time_モードが有効になります。これにより、コンパイラーは、関数のコンパイル時にファイル内の後続の関数から取得した情報を考慮することができます。 _unit-at-a-time-モードで複数のファイルを一度に1つの出力ファイルにコンパイルすると、コンパイラーは、各ファイルをコンパイルするときにすべてのファイルから取得した情報を使用できます。

すべての最適化がフラグによって直接制御されるわけではありません。 フラグがある最適化のみがリストされます。

Tag

説明

-O

*-O1*

最適化します。 コンパイルを最適化するには多少時間がかかり、大きな関数にはもっと多くのメモリが必要です。

*-O* を使用すると、コンパイラは、コンパイル時間を大幅に費やす最適化を実行せずに、コードサイズと実行時間を削減しようとします。
*-O* は、次の最適化フラグをオンにします。 *-fdefer-pop -fdelayed-branch -fguess-branch-probability -fcprop-registers -floop-optimize -fif-conversion -fif-conversion2 -ftree-ccp -ftree-cc -ftree-dominator-opts -ftree-dse -ftree-ter -ftree-lrs -ftree-sra -ftree-copyrename -ftree-fre -ftree-ch -funit-at-a-time -fmerge-constants*
*-O* は、デバッグを妨げないマシンでも *-fomit-frame-pointer* をオンにします。
*-O* は、Adaコンパイラの *-ftree-sra* をオンにしません。 このオプションは、Adaコンパイラで有効にするにはコマンドラインで明示的に指定する必要があります。
*-O2*

さらに最適化してください。 GCCは、スペースとスピードのトレードオフを伴わない、サポートされているほぼすべての最適化を実行します。 -O2 を指定すると、コンパイラーはループの展開または関数のインライン化を実行しません。 -O と比較すると、このオプションはコンパイル時間と生成コードのパフォーマンスの両方を向上させます。

*-O2* は、*-O *で指定されたすべての最適化フラグをオンにします。 また、次の最適化フラグをオンにします。 -cse-after-loop -frerun-loop-opt -fcaller-saves -fpeephole2 -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fregmove -fstrict-aliasing -fdelete-null-pointer-checks -freorder -blocks -freorder-functions -falign-functions -falign-jumps -falign-loops -falign-labels -ftree-vrp -ftree-pre *

計算gotoを使用するプログラムで -O2 を呼び出すことに関する -fgcse の下の警告に注意してください。

*-O3*

さらに最適化する。 -O3 は、-O2 *で指定されたすべての最適化をオンにし、-finline-functions -funswitch-loops 、および *-fgcse-after-reload オプションもオンにします。

*-O0*

最適化しないでください。 これがデフォルトです。

*-Os*

サイズを最適化します。 -Os は、通常コードサイズを増加させないすべての -O2 最適化を有効にします。 また、コードサイズを縮小するように設計されたさらなる最適化も実行します。

*-Os* は、次の最適化フラグを無効にします。ループバージョン*

レベル番号の有無にかかわらず、複数の -O オプションを使用する場合、最後のオプションは有効なオプションです。

*-f * *flag -ffoo-fno-foono- *

次のオプションは、特定の最適化を制御します。 それらは、*-O *オプションによってアクティブ化されるか、または関連するオプションに関連付けられます。 まれに、実行する最適化の微調整が必​​要な場合に、次のフラグを使用できます。

Tag

説明

*-fno-default-inline*

クラススコープ内で定義されているという理由だけで、デフォルトでメンバー関数をインラインにしないでください(C ++のみ)。 それ以外の場合、*-O *を指定すると、クラススコープ内で定義されたメンバー関数はデフォルトでインラインでコンパイルされます。つまり、メンバー関数名の前に*インライン*を追加する必要はありません。

*-fno-defer-pop*

その関数が戻るとすぐに、各関数呼び出しへの引数を常にポップします。 関数呼び出し後に引数をポップする必要があるマシンの場合、コンパイラーは通常、いくつかの関数呼び出しのためにスタックに引数を蓄積させ、それらを一度にポップします。

レベル -O-O2 *、-O3 -Os *で無効になります。

*-fforce-mem*

演算を行う前に、メモリオペランドを強制的にレジスタにコピーします。 これにより、すべてのメモリ参照に潜在的な共通部分式が作成されるため、より優れたコードが生成されます。 共通の部分式ではない場合、命令の組み合わせにより、個別のレジスタロードを排除する必要があります。 このオプションは現在nopであり、4.2で削除されます。

*-fforce-addr*

メモリアドレス定数を演算する前に、レジスタに強制的にコピーします。

*-fomit-frame-pointer*

フレームポインターを必要としない関数のレジスタに保持しないでください。 これにより、フレームポインターの保存、設定、復元の指示が回避されます。また、多くの機能で追加のレジスタを使用できます。 また、一部のマシンではデバッグが不可能になります。

VAXなどの一部のマシンでは、標準の呼び出しシーケンスがフレームポインターを自動的に処理し、存在しないふりをして何も保存されないため、このフラグは効果がありません。 マシン記述マクロ `+ FRAME_POINTER_REQUIRED +`は、ターゲットマシンがこのフラグをサポートするかどうかを制御します。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-foptimize-sibling-calls*

兄弟と末尾の再帰呼び出しを最適化します。

レベル -O2-O3 *、-Os *で有効になります。

*-fno-inline*

「+ inline +」キーワードに注意しないでください。 通常、このオプションは、コンパイラーが関数をインライン展開しないようにするために使用されます。 最適化していない場合、インラインで関数を拡張できないことに注意してください。

*-finline-functions*

すべての単純な関数を呼び出し元に統合します。 コンパイラは、この方法で統合する価値があるほど単純な関数を発見的に決定します。

特定の関数へのすべての呼び出しが統合され、関数が「+ static +」と宣言されている場合、その関数は通常、アセンブラーコードとして出力されません。

レベル -O3 で有効になります。

*-finline-functions-called-once*

`+ inline `とマークされていなくても、呼び出し元にインライン化するために一度呼び出されるすべての ` static +`関数を考えてください。 特定の関数の呼び出しが統合されている場合、その関数はそれ自体ではアセンブラーコードとして出力されません。

*-funit-at-a-time* が有効な場合に有効になります。
*-fearly-inlining*

`+ always_inline +`でマークされたインライン関数、および -fprofile-generate インストルメンテーションと実際のインラインパスを実行する前の早い段階で、関数呼び出しのオーバーヘッドよりも小さいと思われる関数を持つ関数。 そうすることで、プロファイリングが大幅に安価になり、ネストされたラッパー関数の大規模なチェーンを持つプログラムでのインライン化が通常より速くなります。

デフォルトで有効になっています。

-finline-limit = n

デフォルトでは、GCCはインライン化できる関数のサイズを制限します。 このフラグにより​​、インラインとして明示的にマークされている(つまり、インラインキーワードでマークされているか、c のクラス定義内で定義されている)関数のこの制限を制御できます。 _n_は、疑似命令の数でインライン化できる関数のサイズです(パラメーター処理はカウントしません)。 _n_のデフォルト値は600です。 この値を増やすと、コンパイル時間とメモリ消費を犠牲にしてコードがインライン化される可能性があります。 通常、この値を小さくすると、コンパイルが高速になり、インライン化されるコードが少なくなります(これはおそらくプログラムの速度低下を意味します)。 このオプションは、C での再帰的なテンプレートに基づくものなど、インライン化を多用するプログラムに特に役立ちます。

インライン化は、実際にはいくつかのパラメーターによって制御されます。パラメーターは、-param *name = _ value_を使用して個別に指定できます。 -finline-limit = * nオプションは、これらのパラメーターの一部を次のように設定します。

Tag Description
max-inline-insns-single ++

a|

 is set to I<n>/2.
max-inline-insns-auto ++

a|

 is set to I<n>/2.
min-inline-insns ++

a|

 is set to 130 or I<n>/4, whichever is smaller.
max-inline-insns-rtl ++

a|

 is set to I<n>.

インライン化を制御する個々のパラメーターのドキュメントについては、以下を参照してください。

_注:_疑似命令は、この特定のコンテキストでは、関数のサイズの抽象的な測定値を表します。 アセンブリ命令の数を表すものではありません。そのため、その正確な意味はリリースごとに変わる可能性があります。

*-fkeep-inline-functions*

Cでは、関数がすべての呼び出し元にインライン化されている場合でも、オブジェクトファイルに「+ inline 」と宣言された「 static 」関数を発行します。 このスイッチは、GNU Cで ` extern inline +`拡張を使用している関数には影響しません。 C ++では、すべてのインライン関数をオブジェクトファイルに出力します。

*-fkeep-static-consts*

変数が参照されていなくても、最適化がオンになっていない場合は、「+ static const +」と宣言された変数を生成します。

GCCはデフォルトでこのオプションを有効にします。 最適化がオンになっているかどうかに関係なく、コンパイラーに変数が参照されたかどうかを強制的に確認させたい場合は、*-fno-keep-static-consts *オプションを使用します。

*-fmerge-constants*

コンパイル単位間で同一の定数(文字列定数と浮動小数点定数)をマージしようとします。

このオプションは、アセンブラーとリンカーがサポートしている場合の最適化されたコンパイルのデフォルトです。 -fno-merge-constants を使用して、この動作を抑制します。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-fmerge-all-constants*

同一の定数と同一の変数をマージしてみてください。

このオプションは、-fmerge-constants *を意味します。 *-fmerge-constants に加えて、これは例えば 定数または浮動小数点型の定数初期化配列または初期化定数変数ですら。 CやC ++などの言語では、非自動変数ごとに個別の場所が必要であるため、このオプションを使用すると動作が不適合になります。

*-fmodulo-sched*

最初のスケジューリングパスの直前に、スイングモジュロスケジューリングを実行します。 このパスは、最も内側のループを調べ、異なる反復を重複させることにより命令を並べ替えます。

*-fno-branch-count-reg*

カウントレジスタでデクリメントおよび分岐命令を使用しないでください。代わりに、レジスタをデクリメントし、ゼロと比較し、結果に基づいて分岐する一連の命令を生成します。 このオプションは、x86、PowerPC、IA-64、S/390などの命令をサポートするアーキテクチャでのみ意味があります。

デフォルトは -fbranch-count-reg で、*-fstrength-reduce *が有効な場合に有効になります。

*-fno-function-cse*

レジスタに関数アドレスを入れないでください。定数関数を呼び出す各命令に関数のアドレスが明示的に含まれるようにします。

このオプションはコードの効率を低下させますが、アセンブラーの出力を変更するいくつかの奇妙なハックは、このオプションを使用しない場合に実行される最適化によって混乱する可能性があります。

デフォルトは -ffunction-cse です

*-fno-zero-initialized-in-bss*

ターゲットがBSSセクションをサポートする場合、GCCはデフォルトでゼロに初期化された変数をBSSに入れます。 これにより、結果のコードのスペースを節約できます。

一部のプログラムはデータセクションに行く変数に明示的に依存しているため、このオプションはこの動作をオフにします。 たとえば、結果の実行可能ファイルがそのセクションの先頭を見つけたり、それに基づいて仮定を立てたりできるようにします。

デフォルトは -fzero-initialized-in-bss です。

*-fmudflap -fmudflapth -fmudflapir*

それをサポートするフロントエンド(CおよびC +)の場合、すべての危険なポインター/配列の間接参照操作、一部の標準ライブラリ文字列/ヒープ関数、および範囲/有効性テストに関連するその他の構成要素をインスツルメントします。 そのようにインスツルメントされたモジュールは、バッファオーバーフロー、無効なヒープ使用、およびその他のC/Cプログラミングエラーのクラスに対して耐性があるはずです。 インストルメンテーションは、リンク時に *-fmudflap* が指定された場合にプログラムにリンクされる別個のランタイムライブラリ(_libmudflap_)に依存します。 インストルメント済みプログラムの実行時の動作は、 *MUDFLAP_OPTIONS* 環境変数によって制御されます。 オプションについては、「 env MUDFLAP_OPTIONS = -help a.out +」を参照してください。

プログラムがマルチスレッドの場合、コンパイルおよびリンクするには、-fmudflap *ではなく *-fmudflapth を使用します。 インストルメンテーションがポインター読み取りを無視する必要がある場合は、-fmudflap *または *-fmudflapth に加えて、*-fmudflapir *を使用します。 これにより、インストルメンテーションが少なくなり(したがって、実行が速くなります)、書き込みを破損する完全なメモリに対する保護が提供されますが、誤って読み取られたデータがプログラム内で伝播することができます。

*-fstrength-reduce*

ループ強度の削減と反復変数の除去の最適化を実行します。

レベル -O2-O3 *、-Os *で有効になります。

*-fthread-jumps*

最適化を実行して、最初に含まれる別の比較が見つかった場所にジャンプが分岐するかどうかを確認します。 その場合、条件がtrueまたはfalseであることがわかっているかどうかに応じて、最初のブランチは2番目のブランチの宛先またはその直後のポイントにリダイレクトされます。

レベル -O2-O3 *、-Os *で有効になります。

*-fcse-follow-jumps*

一般的な部分式の削除では、他のパスがジャンプのターゲットに到達しない場合に、ジャンプ命令をスキャンします。 たとえば、CSEが `+ else `句を持つ ` if +`ステートメントに遭遇すると、CSEはテストされた条件がfalseの場合にジャンプに従います。

レベル -O2-O3 *、-Os *で有効になります。

*-fcse-skip-blocks*

これは -fcse-follow-jumps と似ていますが、CSEは条件付きでブロックをスキップするジャンプを追跡します。 CSEがelse節のない単純な `+ if `ステートメントを検出すると、*-fcse-skip-blocks *により、CSEは ` if +`の本文のジャンプに追従します。

レベル -O2-O3 *、-Os *で有効になります。

*-frerun-cse-after-loop*

ループの最適化が実行された後、共通部分式の除去を再実行します。

レベル -O2-O3 *、-Os *で有効になります。

*-frerun-loop-opt*

ループオプティマイザーを2回実行します。

レベル -O2-O3 *、-Os *で有効になります。

*-fgcse*

グローバル共通部分式除去パスを実行します。 このパスは、グローバル定数とコピーの伝播も実行します。

注: GCC拡張機能である計算gotoを使用してプログラムをコンパイルする場合、コマンドラインに -fno-gcse を追加してグローバル共通部分式削除パスを無効にすると、実行時のパフォーマンスが向上する場合があります。

レベル -O2-O3 *、-Os *で有効になります。

*-fgcse-lm*
*-fgcse-lm* が有効になっている場合、グローバル共通部分式の除去は、ストアによってのみ強制終了されるロードをそれ自体に移動しようとします。 これにより、ロード/ストアシーケンスを含むループをループ外のロード、およびループ内のコピー/ストアに変更できます。

gcseが有効な場合、デフォルトで有効になります。

*-fgcse-sm*
*-fgcse-sm* が有効な場合、グローバル共通部分式の除去後にストアモーションパスが実行されます。 このパスは、ストアをループ外に移動しようとします。 *-fgcse-lm* と組み合わせて使用​​すると、ロード/ストアシーケンスを含むループをループ前のロードとループ後のストアに変更できます。

どの最適化レベルでも有効になりません。

*-fgcse-las*
*-fgcse-las* が有効になっている場合、グローバル共通部分式除去パスは、同じメモリー位置へのストアの後に来る冗長ロード(部分冗長と完全冗長の両方)を削除します。

どの最適化レベルでも有効になりません。

*-fgcse-after-reload*
*-fgcse-after-reload* が有効な場合、リロード後に冗長な負荷除去パスが実行されます。 このパスの目的は、冗長な流出をクリーンアップすることです。
*-floop-optimize*

ループの最適化を実行します。定数式をループ外に移動し、終了テスト条件を簡素化し、オプションで強度の削減も行います。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-floop-optimize2*

新しいループオプティマイザーを使用してループ最適化を実行します。 最適化(ループの展開、剥離と切り替え、ループ不変モーション)は、個別のフラグによって有効になります。

*-funsafe-loop-optimizations*

指定された場合、ループオプティマイザーは、ループインデックスがオーバーフローしないこと、および非自明な終了条件を持つループが無限ではないと想定します。 これにより、ループオプティマイザー自体がこれらの仮定が有効であることを証明できない場合でも、より広い範囲のループ最適化が可能になります。 -Wunsafe-loop-optimizations を使用すると、コンパイラはこの種のループを検出すると警告を表示します。

*-fcrossjumping*

クロスジャンプ変換を実行します。 この変換により、同等のコードが統合され、コードサイズが節約されます。 結果のコードは、クロスジャンプを使用しない場合よりもパフォーマンスが向上する場合としない場合があります。

レベル -O2-O3 *、-Os *で有効になります。

*-fif-conversion*

条件付きジャンプをブランチレスの同等物に変換しようとします。 これには、条件付き移動、最小、最大、フラグおよびabs命令の設定の使用、および標準的な算術で実行可能ないくつかのトリックが含まれます。 利用可能なチップでの条件付き実行の使用は、「+ if-conversion2 +」によって制御されます。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-fif-conversion2*

条件付き実行(使用可能な場合)を使用して、条件付きジャンプをブランチレスの同等物に変換します。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-fdelete-null-pointer-checks*

グローバルデータフロー分析を使用して、nullポインターの無駄なチェックを特定し、排除します。 コンパイラは、nullポインターを逆参照するとプログラムが停止すると想定しています。 既に間接参照された後にポインターをチェックする場合、nullにすることはできません。

環境によっては、この仮定が正しくないため、プログラムはnullポインターを安全に逆参照できます。 -fno-delete-null-pointer-checks を使用して、その動作に依存するプログラムのこの最適化を無効にします。

レベル -O2-O3 *、-Os *で有効になります。

*-fexpensive-optimizations*

比較的高価ないくつかのマイナーな最適化を実行します。

レベル -O2-O3 *、-Os *で有効になります。

*-foptimize-register-move*
*-fregmove*

移動命令で、および他の単純な命令のオペランドとしてレジスタ番号を再割り当てして、レジスタの結合の量を最大化することを試みます。 これは、2つのオペランドの命令があるマシンで特に役立ちます。

-fregmove-foptimize-register-move は同じ最適化です。

レベル -O2-O3 *、-Os *で有効になります。

*-fdelayed-branch*

ターゲットマシンでサポートされている場合は、命令を並べ替えて、遅延分岐命令の後に使用可能な命令スロットを活用します。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-fschedule-insns*

ターゲットマシンでサポートされている場合は、必要なデータが利用できないために実行が停止するのを防ぐために、命令を並べ替えてみてください。 これにより、ロードまたは浮動小数点命令の結果が必要になるまで他の命令を発行できるため、浮動小数点またはメモリのロード命令が遅いマシンに役立ちます。

レベル -O2-O3 *、-Os *で有効になります。

*-fschedule-insns2*
*-fschedule-insns* に似ていますが、レジスタの割り当てが完了した後に命令スケジューリングの追加パスを要求します。 これは、レジスタの数が比較的少なく、メモリのロード命令に1サイクル以上かかるマシンで特に役立ちます。

レベル -O2-O3 *、-Os *で有効になります。

*-fno-sched-interblock*

基本的なブロックにまたがって指示をスケジュールしないでください。 これは通常、レジスター割り当ての前にスケジューリングするときにデフォルトで有効になります。 -fschedule-insns または -O2 以上で。

*-fno-sched-spec*

非ロード命令の投機的な動作を許可しないでください。 これは通常、レジスター割り当ての前にスケジューリングするときにデフォルトで有効になります。 -fschedule-insns または -O2 以上で。

*-fsched-spec-load*

いくつかのロード命令の投機的な動作を許可します。 これは、レジスタ割り当ての前にスケジューリングする場合にのみ意味があります。 -fschedule-insns または -O2 以上で。

*-fsched-spec-load-dangerous*

より多くのロード命令の投機的動作を許可します。 これは、レジスタ割り当ての前にスケジューリングする場合にのみ意味があります。 -fschedule-insns または -O2 以上で。

*-fsched-stalled-insns*
    • -fsched-stalled-insns = * *n

2番目のスケジューリングパス中に、失速したinsnのキューからレディリストに早まって移動できるinsnの数(ある場合)を定義します。* -fno-fsched-stalled-insns と *-fsched-stalled-insns = 0 は同等であり、早期にinsnsが移動されないことを意味します。 _n_が指定されていない場合、キューに入れられたinsnを早まって移動できる数に制限はありません。

*-fsched-stalled-insns-dep*

-fsched-stalled-insns-dep = n

ストールされたインスのキューからの早期削除の候補であるストールされたインへの依存関係について検査されるイングループ(サイクル)の数を定義します。 これは、2回目のスケジューリングパスでのみ効果があり、*-fsched-stalled-insns *が使用されており、その値がゼロでない場合のみです。 + -fno-sched-stalled-insns-depは+ -fsched-stalled-insns-dep = 0と同等です。 値なしの+ -fsched-stalled-insns-depは、+ -fsched-stalled-insns-dep = 1と同等です。

*-fsched2-use-superblocks*

レジスタ割り当て後にスケジューリングする場合は、スーパーブロックスケジューリングアルゴリズムを使用してください。 スーパーブロックスケジューリングにより、基本的なブロック境界を越えた動きが可能になり、結果としてより高速なスケジュールが実現します。 このオプションは実験的なものです。GCCが使用するすべてのマシン記述が、アルゴリズムの信頼できない結果を回避するのに十分なほどCPUを厳密にモデル化するわけではないためです。

これは、レジスタ割り当て後にスケジューリングする場合にのみ意味があります。 -fschedule-insns2 または -O2 以上で。

*-fsched2-use-traces*

レジスタ割り当て後のスケジューリング時に -fsched2-use-superblocks アルゴリズムを使用し、さらにトレーサパスを使用してスーパーブロックのサイズを増やすためにコード複製を実行します。 トレース形成の詳細については、*-ftracer *を参照してください。

このモードでは、より高速ですが、かなり長いプログラムが生成されます。 また、-fbranch-probabilities *がないと、構築されたトレースが現実と一致せず、パフォーマンスが低下する可能性があります。 これは、レジスタ割り当て後にスケジューリングする場合にのみ意味があります。 *-fschedule-insns2 または -O2 以上で。

*-freschedule-modulo-scheduled-loops*

モジュロスケジューリングは、従来のスケジューリングよりも前に行われます。ループがモジュロスケジューリングされた場合、後のスケジューリングパスでスケジュールが変更されないようにするには、このオプションを使用して制御します。

*-fcaller-saves*

このような呼び出しの周りのレジスタを保存および復元するための追加の命令を発行することにより、関数呼び出しによって上書きされるレジスタに割り当てられる値を有効にします。 このような割り当ては、他の方法で生成されるよりも優れたコードが得られると思われる場合にのみ行われます。

このオプションは、特定のマシン、通常は代わりに使用するコール保存レジスタを持たないマシンでデフォルトで常に有効になっています。

レベル -O2-O3 *、-Os *で有効になります。

*-ftree-pre*

木で部分冗長除去(PRE)を実行します。 このフラグは、-O2 *および *-O3 でデフォルトで有効になっています。

*-ftree-fre*

木で完全冗長除去(FRE)を実行します。 FREとPREの違いは、FREは冗長な計算に至るすべてのパスで計算された式のみを考慮することです。 この分析はPREよりも高速ですが、冗長性は少なくなります。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-copy-prop*

ツリーでコピー伝播を実行します。 このパスにより、不必要なコピー操作がなくなります。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-store-copy-prop*

メモリのロードとストアのコピー伝播を実行します。 このパスにより、メモリ参照(構造、グローバル変数、配列など)の不要なコピー操作が排除されます。 このフラグは、デフォルトで -O2 以上で有効になっています。

*-ftree-salias*

ツリーの構造エイリアス分析を実行します。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-sink*

ツリーで前方ストアモーションを実行します。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-ccp*

ツリーでスパース条件付き定数伝播(CCP)を実行します。 このパスはローカルスカラー変数でのみ動作し、デフォルトで -O 以上で有効になっています。

*-ftree-store-ccp*

ツリーでスパース条件付き定数伝播(CCP)を実行します。 このパスは、ローカルスカラー変数とメモリストアおよびロード(グローバル変数、構造体、配列など)の両方で動作します。 このフラグは、デフォルトで -O2 以上で有効になっています。

*-ftree-dce*

ツリーでデッドコード除去(DCE)を実行します。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-dominator-opts*

ドミネーターツリートラバーサルに基づいて、さまざまな単純なスカラークリーンアップ(定数/コピーの伝播、冗長性の除去、範囲の伝播、および式の単純化)を実行します。 これにより、ジャンプスレッドも実行されます(ジャンプをジャンプに減らすため)。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-ch*

ツリーでループヘッダーのコピーを実行します。 これは、コードモーション最適化の効果を高めるため、有益です。 また、ジャンプを1回節約します。 このフラグは、デフォルトで -O 以上で有効になっています。 通常はコードサイズが増加するため、*-Os *には対応していません。

*-ftree-loop-optimize*

ツリーでループ最適化を実行します。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-loop-linear*

ツリーで線形ループ変換を実行します。 このフラグにより​​、キャッシュのパフォーマンスが向上し、ループのさらなる最適化が可能になります。

*-ftree-loop-im*

木に対してループ不変モーションを実行します。 このパスは、RTLレベル(関数呼び出し、insnの非自明なシーケンスに展開される操作)で処理するのが難しい不変条件のみを移動します。 -funswitch-loops を使用すると、不変の条件のオペランドもループ外に移動するため、ループの非切り替えで単純な不変分析のみを使用できます。 パスには、ストアモーションも含まれます。

*-ftree-loop-ivcanon*

ループ内の反復回数の正規カウンターを作成します。反復回数の決定には複雑な分析が必要です。 その後、その後の最適化で簡単に数を決定できます。 特に展開に関連して有用です。

*-fivopts*

ツリーで誘導変数の最適化(強度の削減、誘導変数のマージ、および誘導変数の削除)を実行します。

*-ftree-sra*

集計のスカラー置換を実行します。 このパスは、構造参照をスカラーに置き換えて、構造をメモリにコミットするのが早すぎることを防ぎます。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-copyrename*

ツリーでコピーの名前変更を実行します。 このパスは、コンパイラの一時名をコピー場所の他の変数に変更しようとするため、通常は元の変数により近い変数名になります。 このフラグは、デフォルトで -O 以上で有効になっています。

*-ftree-ter*

SSA→通常フェーズ中に一時的な式の置換を実行します。 単一使用/単一定義の一時ファイルは、使用場所で定義式で置き換えられます。 これにより、非GIMPLEコードが生成されますが、エクスパンダーがより複雑なツリーを処理できるようになり、RTL生成が向上します。 これは、デフォルトで -O 以上で有効になっています。

*-ftree-lrs*

SSA→通常フェーズ中にライブ範囲分割を実行します。 変数の個別のライブ範囲は一意の変数に分割されるため、後で最適化することができます。 これは、デフォルトで -O 以上で有効になっています。

*-ftree-vectorize*

ツリーでループベクトル化を実行します。

*-ftree-vect-loop-version*

ツリーでループベクトル化を行うときに、ループのバージョン管理を実行します。 ループがベクトル化可能であるように見える場合、コンパイル時にデータのアライメントまたはデータの依存関係を判別できない場合、ループのベクトル化バージョンおよび非ベクトル化バージョンが生成されます。 このオプションは、無効になっているレベル -Os を除き、デフォルトで有効になっています。

*-ftree-vrp*

ツリーで値の範囲の伝播を実行します。 これは定数伝搬パスに似ていますが、値の代わりに値の範囲が伝搬されます。 これにより、オプティマイザーは配列バインドチェックやNULLポインターチェックなどの不要な範囲チェックを削除できます。 これは、デフォルトで -O2 以上で有効になっています。 ヌルポインターチェックの削除は、*-fdelete-null-pointer-checks *が有効になっている場合にのみ行われます。

*-ftracer*

テール複製を実行して、スーパーブロックサイズを拡大します。 この変換により、関数の制御フローが単純化され、他の最適化でより良い仕事ができるようになります。

*-funroll-loops*

コンパイル時またはループに入るときに反復回数を決定できるループを展開します。 -funroll-loops は、-fstrength-reduce *と *-frerun-cse-after-loop の両方を意味します。 このオプションを使用すると、コードが大きくなり、実行速度が速くなったり遅くなったりする場合があります。

*-funroll-all-loops*

ループに入ったときに反復回数が不確実であっても、すべてのループを展開します。 これにより、通常、プログラムの実行が遅くなります。 -funroll-all-loops は、*-funroll-loops *と同じオプションを意味します。

*-fsplit-ivs-in-unroller*

最初の反復の値を使用して、展開されたループの後続の反復で誘導変数の値の表現を有効にします。 これにより、長い依存関係チェーンが切断され、スケジューリングパスの効率が向上します。

同じ効果を得るには、多くの場合、*-fweb *とCSEの組み合わせで十分です。 ただし、ループ本体が単一の基本ブロックよりも複雑な場合、これは信頼できません。 また、CSEパスの制限により、一部のアーキテクチャではまったく機能しません。

この最適化はデフォルトで有効になっています。

*-fvariable-expansion-in-unroller*

このオプションを使用すると、コンパイラーは、ループを展開するときにいくつかのローカル変数の複数のコピーを作成し、優れたコードを作成できます。

*-fprefetch-loop-arrays*

ターゲットマシンでサポートされている場合は、メモリをプリフェッチする命令を生成して、大きな配列にアクセスするループのパフォーマンスを向上させます。

これらのオプションは、より良いコードまたはより悪いコードを生成する場合があります。結果は、ソースコード内のループの構造に大きく依存します。

*-fno-peephole*
*-fno-peephole2*

マシン固有ののぞき穴の最適化を無効にします。 -fno-peephole-fno-peephole2 の違いは、コンパイラーでの実装方法です。一部のターゲットは一方を使用し、一部は他方を使用し、一部は両方を使用します。

*-fpeephole* はデフォルトで有効になっています。 *-fpeephole2* はレベル *-O2* 、*-O3 *、*-Os *で有効になります。
*-fno-guess-branch-probability*

ヒューリスティックを使用して分岐確率を推測しないでください。

GCCは、プロファイリングフィードバック( -fprofile-arcs )によって提供されない場合、ヒューリスティックを使用して分岐確率を推測します。 これらのヒューリスティックは、制御フローグラフに基づいています。 一部の分岐確率が ​​ builtin_expect で指定されている場合、ヒューリスティックを使用して、 ' builtin_expect 情報を考慮に入れて、制御フローグラフの残りの部分の分岐確率を推測します。 ヒューリスティックと builtin_expect の相互作用は複雑になる可能性があり、場合によっては、ヒューリスティックを無効にして ' builtin_expect の効果を理解しやすくすることが役立つ場合があります。

デフォルトは、レベル -O-O2 *、-O3 -Os での *-fguess-branch-probability です。

*-freorder-blocks*

分岐の数を減らし、コードの局所性を向上させるために、コンパイルされた関数の基本ブロックを並べ替えます。

レベル -O2 、*-O3 *で有効になります。

*-freorder-blocks-and-partition*

コンパイルされた関数の基本ブロックを並べ替えるだけでなく、分岐の数を減らすために、ホットおよびコールドの基本ブロックをアセンブリおよび.oファイルの個別のセクションに分割し、ページングとキャッシュの局所性のパフォーマンスを向上させます。

この最適化は、例外処理の存在、linkonceセクション、ユーザー定義セクション属性を持つ関数、および名前付きセクションをサポートしないアーキテクチャーでは自動的にオフになります。

*-freorder-functions*

コードの局所性を改善するために、オブジェクトファイル内の関数を並べ替えます。 これは、最も頻繁に実行される関数には特殊なサブセクション `+ .text.hot `を使用し、まれに実行される関数には ` .text.unlikely +`を使用して実装されます。 並べ替えはリンカによって行われるため、オブジェクトファイル形式は名前付きセクションをサポートし、リンカはそれらを適切な方法で配置する必要があります。

また、このオプションを有効にするには、プロファイルフィードバックを利用できる必要があります。 詳細については、*-fprofile-arcs *を参照してください。

レベル -O2-O3 *、-Os *で有効になります。

*-fstrict-aliasing*

コンパイラーは、コンパイルされている言語に適用可能な最も厳密な別名規則を想定できます。 C(およびC +)の場合、これは式のタイプに基づいて最適化をアクティブにします。 特に、1つのタイプのオブジェクトは、タイプがほぼ同じでない限り、異なるタイプのオブジェクトと同じアドレスに常駐することはありません。 たとえば、「 unsigned int 」は「 int 」をエイリアスできますが、「 void *」または「 double +」はエイリアスできません。 文字タイプは、他のタイプをエイリアスする場合があります。

このようなコードには特に注意してください。

++

union a_union { int i; double d; };

++

int f() { a_union t; t.d = 3.0; return t.i; }

直近に書き込まれたものとは別のユニオンメンバー(タイプパニングと呼ばれる)からの読み取りの慣行は一般的です。* -fstrict-aliasing *を使用しても、共用体型を介してメモリにアクセスする場合、型のパンニングが許可されます。 したがって、上記のコードは期待どおりに機能します。 ただし、このコードでは次のことはできません。

++

int f() { a_union t; int *ip; t.d = 3.0; ip = &t.i; return* ip; }

言語固有のエイリアス分析を実行したいすべての言語は、 `+ tree `ノードが与えられた場合、ノードのエイリアスセットを計算する関数を定義する必要があります。 異なるエイリアスセットのノードは、エイリアスを作成できません。 例については、Cフロントエンド関数 ` c_get_alias_set +`を参照してください。

レベル -O2-O3 *、-Os *で有効になります。

*-falign-functions*

-falign-functions = n

関数の開始を_n_より大きい次の2のべき乗に合わせて、_n_バイトまでスキップします。 たとえば、-falign-functions = 32 *は関数を次の32バイト境界に揃えますが、-falign-functions = 24 *は次の32バイト境界に合わせます。これは、23バイトをスキップするか、もっと少なく。

*-fno-align-functions* と *-falign-functions = 1* は同等であり、関数が整列されないことを意味します。

一部のアセンブラは、_n_が2の累乗の場合にのみこのフラグをサポートします。その場合、切り上げられます。

_n_が指定されていないかゼロの場合、マシン依存のデフォルトを使用します。

レベル -O2 、*-O3 *で有効になります。

*-falign-labels*

-falign-labels = n

*-falign-functions* のように_n_バイトまでスキップして、すべてのブランチターゲットを2のべき乗の境界に合わせます。 このオプションは、通常のコードフローでブランチターゲットに到達したときにダミー操作を挿入する必要があるため、コードを簡単に遅くすることができます。
*-fno-align-labels* と *-falign-labels = 1* は同等であり、ラベルが整列されないことを意味します。
*-falign-loops* または *-falign-jumps* が適用可能であり、この値より大きい場合、代わりにそれらの値が使用されます。

_n_が指定されていないかゼロの場合、マシンに依存するデフォルトを使用してください。

レベル -O2 、*-O3 *で有効になります。

*-falign-loops*

-falign-loops = n

*-falign-functions* のように_n_バイトまでスキップして、ループを2のべき乗の境界に揃えます。 ループが何度も実行され、ダミー操作の実行を補うことが期待されます。
*-fno-align-loops* と *-falign-loops = 1* は同等であり、ループが整列されないことを意味します。

_n_が指定されていないかゼロの場合、マシン依存のデフォルトを使用します。

レベル -O2 、*-O3 *で有効になります。

*-falign-jumps*

-falign-jumps = n

*-falign-functions* のように_n_バイトまでスキップしてジャンプすることによってのみター​​ゲットに到達できるブランチターゲットの場合、ブランチターゲットを2のべき乗の境界に揃えます。 この場合、ダミー操作を実行する必要はありません。
*-fno-align-jumps* と *-falign-jumps = 1* は同等であり、ループが整列されないことを意味します。

_n_が指定されていないかゼロの場合、マシン依存のデフォルトを使用します。

レベル -O2 、*-O3 *で有効になります。

-一度に

コードの生成を開始する前に、コンパイル単位全体を解析します。 これにより、いくつかの追加の最適化を実行できますが、より多くのメモリを消費します(一般的に)。 _unit-at-at-time_モードにはいくつかの互換性の問題があります。

Tag Description
* enabling unit-at-a-time mode may change the order in which functions, variables, and top-level asm statements are emitted, and will likely break code relying on some particular ordering. The majority of such top-level asm statements, though, can be replaced by section attributes.
* unit-at-a-time mode removes unreferenced static variables and functions. This may result in undefined references when an asm statement refers directly to variables or functions that are otherwise unused. In that case either the variable/function shall be listed as an operand of the asm statement operand or, in the case of top-level asm statements the attribute used shall be used on the declaration.
* Static functions now can use non-standard passing conventions that may break asm statements calling functions directly. Again, attribute used will prevent this behavior.

一時的な回避策として、*-fno-unit-at-a-time *を使用できますが、このスキームはGCCの将来のリリースではサポートされない可能性があります。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-fweb*

レジスタ割り当ての目的で一般的に使用されるようにWebを構築し、各Webに個別の擬似レジスタを割り当てます。 これにより、レジスタ割り当てパスは疑似で直接操作できるようになりますが、CSE、ループオプティマイザー、自明なデッドコード除去など、いくつかの他の最適化パスも強化されます。 ただし、変数がホームレジスタに留まらないため、デバッグが不可能になる可能性があります。

*-funroll-loops* でデフォルトで有効になっています。
*-fwhole-program*

現在のコンパイル単位がコンパイル中のプログラム全体を表していると仮定します。 `+ main `と属性 ` externally_visible `によってマージされたものを除くすべてのパブリック関数と変数は静的関数になり、実際には手続き間オプティマイザーによってより積極的に最適化されます。 このオプションは、単一ファイルで構成されるプログラムでの「 static +」キーワードの適切な使用と同等ですが、オプション*-combine *と組み合わせて、このフラグを使用して、関数と変数がローカルになるため、小規模のCプログラムのほとんどをコンパイルできます単一のソースファイル自体ではなく、結合されたコンパイルユニット全体に対して。

*-fcprop-registers*

レジスタ割り当てとレジスタ後割り当て命令の分割後、コピー伝播パスを実行して、スケジューリングの依存関係を減らし、コピーを削除することを試みます。

レベル -O-O2 *、-O3 -Os *で有効になります。

*-fprofile-generate*

プロファイルフィードバックベースの最適化による後の再コンパイルに役立つプロファイルを生成するために、アプリケーションのインスツルメントに通常使用されるオプションを有効にします。 コンパイル時とプログラムのリンク時の両方で -fprofile-generate を使用する必要があります。

次のオプションが有効になります: + -fprofile-arcs ++ -fprofile-values ++ -fvpt +

*-fprofile-use*

プロファイルフィードバックによる最適化を有効にします。一般的に、プロファイルフィードバックが利用可能な場合にのみ最適化が有効になります。

次のオプションが有効になります: + -fbranch-probabilities ++ -fvpt ++ -funroll-loops ++ -fpeel-loops ++ -ftracer +、 `+ -fno-loop-optimize + `。

Tag

説明

*-ffloat-store*

浮動小数点変数をレジスタに格納しないでください。また、浮動小数点値がレジスタまたはメモリのどちらから取られるかを変更する可能性のある他のオプションを禁止します。

このオプションは、(68881の)浮動レジスタが `+ double +`が持つはずの精度よりも高い精度を維持する68000などのマシンでの望ましくない過剰な精度を防ぎます。 x86アーキテクチャの場合も同様です。 ほとんどのプログラムでは、過剰な精度は良いことしかしませんが、少数のプログラムはIEEE浮動小数点の正確な定義に依存しています。 すべての関連する中間計算を変数に保存するように修正した後、そのようなプログラムには -ffloat-store を使用します。

*-ffast-math*
*-fno-math-errno* 、*-funsafe-math-optimizations *、*-fno-trapping-math *、*-ffinite-math-only *、*-fno-rounding-math *、*-fno-を設定しますsignalling-nans *および *fcx-limited-range* 。

このオプションにより、プリプロセッサマクロ `+ FAST_MATH +`が定義されます。

このオプションは、*-O *オプションによってオンにしないでください。これは、数学関数のIEEEまたはISOルール/仕様の正確な実装に依存するプログラムの出力が正しくない可能性があるためです。

*-fno-math-errno*

sqrtなどの単一の命令で実行される数学関数を呼び出した後、ERRNOを設定しないでください。 算術エラー処理のためにIEEE例外に依存するプログラムでは、IEEE算術の互換性を維持しながら速度を上げるためにこのフラグを使用できます。

このオプションは、*-O *オプションによってオンにしないでください。これは、数学関数のIEEEまたはISOルール/仕様の正確な実装に依存するプログラムの出力が正しくない可能性があるためです。

デフォルトは -fmath-errno です。

Darwinシステムでは、数学ライブラリは決して `+ errno +`を設定しません。 したがって、コンパイラーがその可能性を考慮する理由はなく、*-fno-math-errno *がデフォルトです。

*-funsafe-math-optimizations*

(a)引数と結果が有効であると仮定し、(b)IEEEまたはANSI標準に違反する可能性がある浮動小数点演算の最適化を許可します。 リンク時に使用される場合、デフォルトのFPU制御ワードまたは他の同様の最適化を変更するライブラリまたは起動ファイルが含まれる場合があります。

このオプションは、*-O *オプションによってオンにしないでください。これは、数学関数のIEEEまたはISOルール/仕様の正確な実装に依存するプログラムの出力が正しくない可能性があるためです。

デフォルトは -fno-unsafe-math-optimizations です。

*-ffinite-math-only*

引数と結果がNaNまたは+ -Infsではないと想定する浮動小数点演算の最適化を許可します。

IEEEまたはISOの規則/仕様の正確な実装に依存するプログラムの出力が正しくない可能性があるため、このオプションを -O オプションでオンにしないでください。

デフォルトは -fno-finite-math-only です。

*-fno-trapping-math*

浮動小数点演算がユーザーに見えるトラップを生成できないと仮定して、コードをコンパイルします。 これらのトラップには、ゼロ除算、オーバーフロー、アンダーフロー、不正確な結果、無効な操作が含まれます。 このオプションは、*-fno-signaling-nans *を意味します。 このオプションを設定すると、たとえば、ノンストップIEEE算術に依存している場合、コードの高速化が可能になります。

このオプションは、*-O *オプションによってオンにしないでください。これは、数学関数のIEEEまたはISOルール/仕様の正確な実装に依存するプログラムの出力が正しくない可能性があるためです。

デフォルトは -ftrapping-math です。

*-frounding-math*

デフォルトの浮動小数点丸め動作を想定した変換と最適化を無効にします。 これは、すべての浮動小数点から整数への変換ではゼロに丸められ、他のすべての算術切り捨てでは最も近い値に丸められます。 このオプションは、FP丸めモードを動的に変更するプログラム、またはデフォルト以外の丸めモードで実行されるプログラムに指定する必要があります。 このオプションは、コンパイル時の浮動小数点式の定数折りたたみ(丸めモードの影響を受ける可能性があります)および符号依存の丸めモードが存在する場合に安全でない算術変換を無効にします。

デフォルトは -fno-rounding-math です。

このオプションは実験的なものであり、現在、丸めモードの影響を受けるすべてのGCC最適化を無効にすることを保証していません。 GCCの将来のバージョンでは、C99の `+ FENV_ACCESS `プラグマを使用して、この設定をより細かく制御できるようになる可能性があります。 このコマンドラインオプションは、 ` FENV_ACCESS +`のデフォルト状態を指定するために使用されます。

*-fsignaling-nans*

IEEEシグナルNaNが浮動小数点演算中にユーザーに見えるトラップを生成する可能性があると仮定して、コードをコンパイルします。 このオプションを設定すると、シグナルNaNで表示される例外の数を変更する可能性がある最適化が無効になります。 このオプションは、*-ftrapping-math *を意味します。

このオプションにより、プリプロセッサマクロ `+ SUPPORT_SNAN +`が定義されます。

デフォルトは -fno-signaling-nans です。

このオプションは実験的なものであり、現在、NaNのシグナリング動作に影響するすべてのGCC最適化を無効にすることを保証していません。

*-fsingle-precision-constant*

浮動小数点定数を暗黙的に倍精度定数に変換するのではなく、単精度定数として扱います。

*-fcx-limited-range*

有効にすると、このオプションは、複雑な除算を実行するときに範囲縮小ステップが不要であることを示します。 デフォルトは -fno-cx-limited-range ですが、*-ffast-math *によって有効になります。

このオプションは、ISO C99 `+ CX_LIMITED_RANGE +`プラグマのデフォルト設定を制御します。 それでも、このオプションはすべての言語に適用されます。

-O

Tag Description
*-fbranch-probabilities *a

After running a program compiled with* -fprofile-arcs*, you can compile it a second time using -fbranch-probabilities, to improve optimizations based on the number of times each branch was taken. When the program compiled with -fprofile-arcs exits it saves arc execution counts to a file called sourcename.gcda for each source file The information in this data file is very dependent on the structure of the generated code, so you must use the same source code and the same optimization options for both compilations.

-fbranch-probabilities を使用すると、GCCは各 JUMP_INSN および CALL_INSNREG_BR_PROB メモを付けます。 これらは最適化を改善するために使用できます。 現在、これらは1つの場所でのみ使用されています。_reorg.c_では、ブランチが主に使用するパスを推測する代わりに、 REG_BR_PROB 値を使用して、どのパスを使用するかを正確に決定します。

*-fprofile-values *a

If combined with* -fprofile-arcs*, it adds code so that some data about values of expressions in the program is gathered.

-fbranch-probabilities を使用すると、式のプロファイリング値から収集されたデータを読み戻し、後の最適化で使用するための指示に REG_VALUE_PROFILE ノートを追加します。

-fprofile-generate および -fprofile-use を使用して有効にします。

*-fvpt *a

If combined with* -fprofile-arcs*, it instructs the compiler to add a code to gather information about values of expressions.

-fbranch-probabilities を使用すると、収集されたデータを読み取り、実際にそれらに基づいて最適化を実行します。 現在、最適化には、分母の値に関する知識を使用した除算演算の専門化が含まれています。

-frename-registers

Attempt to avoid false dependencies in scheduled code by making use of registers left over after register allocation. This optimization will most benefit processors with lots of registers. Depending on the debug information format adopted by the target, however, it can make debugging impossible, since variables will no longer stay in a home register.

  • -funroll-loops* でデフォルトで有効になっています。
-ftracer

Perform tail duplication to enlarge superblock size. This transformation simplifies the control flow of the function allowing other optimizations to do better job.

  • -fprofile-use* で有効にします。
*-funroll-loops *a

Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop.* -funroll-loops implies -frerun-cse-after-loop*, -fweb *and -frename-registers*. It also turns on complete loop peeling (i.e. complete removal of loops with small constant number of iterations). This option makes code larger, and may or may not make it run faster.

-fprofile-use で有効にします。

*-funroll-all-loops * Unroll all loops, even if their number of iterations is uncertain when the loop is entered. This usually makes programs run more slowly.* -funroll-all-loops implies the same options as -funroll-loops*.
-fpeel-loops

Peels the loops for that there is enough information that they do not roll much (from profile feedback). It also turns on complete loop peeling (i.e. complete removal of loops with small constant number of iterations).

  • -fprofile-use* で有効にします。
*-fmove-loop-invariants * Enables the loop invariant motion pass in the new loop optimizer. Enabled at level* -O1*
-funswitch-loops Move branches with loop invariant conditions out of the loop, with duplicates of the loop on both branches (modified according to result of the condition).
-fprefetch-loop-arrays

If supported by the target machine, generate instructions to prefetch memory to improve the performance of loops that access large arrays.

レベル -Os では無効です。

-ffunction-sections
-fdata-sections

Place each function or data item into its own section in the output file if the target supports arbitrary sections. The name of the function or the name of the data item determines the section’s name in the output file.

これらのオプションは、リンカが最適化を実行して、命令空間での参照の局所性を改善できるシステムで使用します。 ELFオブジェクト形式とSolaris 2を実行するSPARCプロセッサを使用するほとんどのシステムには、このような最適化を備えたリンカーがあります。 AIXでは、将来これらの最適化が行われる可能性があります。

これらのオプションを使用する重要な利点がある場合にのみ使用してください。 これらのオプションを指定すると、アセンブラーとリンカーはより大きなオブジェクトと実行可能ファイルを作成し、速度も低下します。 このオプションを指定すると、すべてのシステムで「+ gprof +」を使用できなくなり、このオプションと -g の両方を指定すると、デバッグで問題が発生する可能性があります。

-fbranch-target-load-optimize Perform branch target register load optimization before prologue/epilogue threading. The use of target registers can typically be exposed only during reload, thus hoisting loads out of loops and doing inter-block scheduling needs a separate optimization pass.
-fbranch-target-load-optimize2 Perform branch target register load optimization after prologue/epilogue threading.
-fbtr-bb-exclusive When performing branch target register load optimization, don’t reuse branch target registers in within any basic block.
-fstack-protector Emit extra code to check for buffer overflows, such as stack smashing attacks. This is done by adding a guard variable to functions with vulnerable objects. This includes functions that call alloca, and functions with buffers larger than 8 bytes. The guards are initialized when a function is entered and then checked when the function exits. If a guard check fails, an error message is printed and the program exits.
*-fstack-protector-all * Like* -fstack-protector* except that all functions are protected.
--param name=value

In some places, GCC uses various constants to control the amount of optimization that is done. For example, GCC will not inline functions that contain more that a certain number of instructions. You can control some of these constants on the command-line using the --param option.

特定のパラメーターの名前と値の意味は、コンパイラーの内部に関連付けられており、将来のリリースでは予告なく変更される場合があります。

いずれの場合も、_value_は整数です。 次の表に、_name_の選択可能な選択肢を示します。

|Tag |Description |salias-max-implicit-fields |The maximum number of fields in a variable without direct structure accesses for which structure aliasing will consider trying to track each field. The default is 5 |sra-max-structure-size |The maximum structure size, in bytes, at which the scalar replacement of aggregates (SRA) optimization will perform block copies. The default value, 0, implies that GCC will select the most appropriate size itself. |sra-field-structure-ratio |The threshold ratio (as a percentage) between instantiated fields and the complete structure size. We say that if the ratio of the number of bytes in instantiated fields to the number of bytes in the complete structure exceeds this parameter, then block copies are not used. The default is 75. |max-crossjump-edges *|The maximum number of incoming edges to consider for crossjumping. The algorithm used by -fcrossjumping* is O(N^2) in the number of edges incoming to each block. Increasing values mean more aggressive optimization, making the compile time increase with probably small improvement in executable size. |min-crossjump-insns |The minimum number of instructions which must be matched at the end of two blocks before crossjumping will be performed on them. This value is ignored in the case where all instructions in the block being crossjumped from are matched. The default value is 5. |max-grow-copy-bb-insns |The maximum code size expansion factor when copying basic blocks instead of jumping. The expansion is relative to a jump instruction. The default value is 8. |max-goto-duplication-insns |The maximum number of instructions to duplicate to a block that jumps to a computed goto. To avoid O(N^2) behavior in a number of passes, GCC factors computed gotos early in the compilation process, and unfactors them as late as possible. Only computed jumps at the end of a basic blocks with no more than max-goto-duplication-insns are unfactored. The default value is 8. |max-delay-slot-insn-search |The maximum number of instructions to consider when looking for an instruction to fill a delay slot. If more than this arbitrary number of instructions is searched, the time savings from filling the delay slot will be minimal so stop searching. Increasing values mean more aggressive optimization, making the compile time increase with probably small improvement in executable run time. |max-delay-slot-live-search |When trying to fill delay slots, the maximum number of instructions to consider when searching for a block with valid live register information. Increasing this arbitrarily chosen value means more aggressive optimization, increasing the compile time. This parameter should be removed when the delay slot code is rewritten to maintain the control-flow graph. |max-gcse-memory |The approximate maximum amount of memory that will be allocated in order to perform the global common subexpression elimination optimization. If more memory than specified is required, the optimization will not be done. |max-gcse-passes |The maximum number of passes of GCSE to run. The default is 1. |max-pending-list-length |The maximum number of pending dependencies scheduling will allow before flushing the current state and starting over. Large functions with few branches or calls can create excessively large lists which needlessly consume memory and resources. |max-inline-insns-single |Several parameters control the tree inliner used in gcc. This number sets the maximum number of instructions (counted in GCC’s internal representation) in a single function that the tree inliner will consider for inlining. This only affects functions declared inline and methods implemented in a class declaration (C++). The default value is 450. |max-inline-insns-auto *|When you use -finline-functions (included in -O3*), a lot of functions that would otherwise not be considered for inlining by the compiler will be investigated. To those functions, a different (more restrictive) limit compared to functions declared inline can be applied. The default value is 90. |large-function-insns *|The limit specifying really large functions. For functions larger than this limit after inlining inlining is constrained by --param large-function-growth*. This parameter is useful primarily to avoid extreme compilation time caused by non-linear algorithms used by the backend. This parameter is ignored when -funit-at-a-time is not used. The default value is 2700. |large-function-growth *|Specifies maximal growth of large function caused by inlining in percents. This parameter is ignored when -funit-at-a-time* is not used. The default value is 100 which limits large function growth to 2.0 times the original size. |large-unit-insns *|The limit specifying large translation unit. Growth caused by inlining of units larger than this limit is limited by --param inline-unit-growth*. For small units this might be too tight (consider unit consisting of function A that is inline and B that just calls A three time. If B is small relative to A, the growth of unit is 300\% and yet such inlining is very sane. For very large units consisting of small inlininable functions however the overall unit growth limit is needed to avoid exponential explosion of code size. Thus for smaller units, the size is increased to --param large-unit-insns *before aplying --param inline-unit-growth*. The default is 10000 |inline-unit-growth *|Specifies maximal overall growth of the compilation unit caused by inlining. This parameter is ignored when -funit-at-a-time* is not used. The default value is 50 which limits unit growth to 1.5 times the original size. |max-inline-insns-recursive | |*max-inline-insns-recursive-auto *a| Specifies maximum number of instructions out-of-line copy of self recursive inline function can grow into by performing recursive inlining.

インラインで宣言された関数の場合、-param max-inline-insns-recursive* が考慮されます。 インラインで宣言されていない関数の場合、-finline-functions *( *-O3 に含まれる)が有効で、*-param max-inline-insns-recursive-auto *が使用されている場合にのみ、再帰的インライン化が行われます。 デフォルト値は450です。

|max-inline-recursive-depth | |*max-inline-recursive-depth-auto *a| Specifies maximum recursion depth used by the recursive inlining.

インラインで宣言された関数については、-param max-inline-recursive-depth* が考慮されます。 インラインで宣言されていない関数の場合、-finline-functions *( *-O3 に含まれる)が有効で、*-param max-inline-recursive-depth-auto *が使用されている場合にのみ、再帰的インライン化が行われます。 デフォルト値は450です。

|min-inline-recursive-probability a| Recursive inlining is profitable only for function having deep recursion in average and can hurt for function having little recursion depth by increasing the prologue size or complexity of function body to other optimizers.

プロファイルフィードバックが利用可能な場合( -fprofile-generate を参照)、実際の再帰の深さは、指定された呼び出し式を介して関数が再帰する確率から推測できます。 このパラメーターは、指定されたしきい値(パーセント単位)を超える確率を持つ呼び出し式にのみインライン化を制限します。 デフォルト値は10です。

|inline-call-cost |Specify cost of call instruction relative to simple arithmetics operations (having cost of 1). Increasing this cost disqualifies inlining of non-leaf functions and at the same time increases size of leaf function that is believed to reduce function size by being inlined. In effect it increases amount of inlining for code having large abstraction penalty (many functions that just pass the arguments to other functions) and decrease inlining for code with low abstraction penalty. The default value is 16. |max-unrolled-insns |The maximum number of instructions that a loop should have if that loop is unrolled, and if the loop is unrolled, it determines how many times the loop code is unrolled. |max-average-unrolled-insns |The maximum number of instructions biased by probabilities of their execution that a loop should have if that loop is unrolled, and if the loop is unrolled, it determines how many times the loop code is unrolled. |max-unroll-times |The maximum number of unrollings of a single loop. |max-peeled-insns |The maximum number of instructions that a loop should have if that loop is peeled, and if the loop is peeled, it determines how many times the loop code is peeled. |max-peel-times |The maximum number of peelings of a single loop. |max-completely-peeled-insns |The maximum number of insns of a completely peeled loop. |max-completely-peel-times |The maximum number of iterations of a loop to be suitable for complete peeling. |max-unswitch-insns |The maximum number of insns of an unswitched loop. |max-unswitch-level |The maximum number of branches unswitched in a single loop. |lim-expensive |The minimum cost of an expensive expression in the loop invariant motion. |iv-consider-all-candidates-bound |Bound on number of candidates for induction variables below that all candidates are considered for each use in induction variable optimizations. Only the most relevant candidates are considered if there are more candidates, to avoid quadratic time complexity. |iv-max-considered-uses |The induction variable optimizations give up on loops that contain more induction variable uses. |iv-always-prune-cand-set-bound |If number of candidates in the set is smaller than this value, we always try to remove unnecessary ivs from the set during its optimization when a new iv is added to the set. |scev-max-expr-size |Bound on size of expressions used in the scalar evolutions analyzer. Large expressions slow the analyzer. |vect-max-version-checks |The maximum number of runtime checks that can be performed when doing loop versioning in the vectorizer. See option ftree-vect-loop-version for more information. |max-iterations-to-track |The maximum number of iterations of a loop the brute force algorithm for analysis of # of iterations of the loop tries to evaluate. |hot-bb-count-fraction |Select fraction of the maximal count of repetitions of basic block in program given basic block needs to have to be considered hot. |hot-bb-frequency-fraction |Select fraction of the maximal frequency of executions of basic block in function given basic block needs to have to be considered hot |max-predicted-iterations |The maximum number of loop iterations we predict statically. This is useful in cases where function contain single loop with known bound and other loop with unknown. We predict the known number of iterations correctly, while the unknown number of iterations average to roughly 10. This means that the loop without bounds would appear artificially cold relative to the other one. |tracer-dynamic-coverage | |tracer-dynamic-coverage-feedback a| This value is used to limit superblock formation once the given percentage of executed instructions is covered. This limits unnecessary code size expansion.

*tracer-dynamic-coverage-feedback* は、プロファイルフィードバックが利用可能な場合にのみ使用されます。 (静的に推定されたプロファイルとは対照的に)実際のプロファイルはバランスが非常に悪く、しきい値を大きくすることができます。

|tracer-max-code-growth |Stop tail duplication once code growth has reached given percentage. This is rather hokey argument, as most of the duplicates will be eliminated later in cross jumping, so it may be set to much higher values than is the desired code growth. |tracer-min-branch-ratio |Stop reverse growth when the reverse probability of best edge is less than this threshold (in percent). |tracer-min-branch-ratio | |tracer-min-branch-ratio-feedback a| Stop forward growth if the best edge do have probability lower than this threshold.

*tracer-dynamic-coverage* と同様に、プロファイルフィードバック用のコンパイル用とコンパイルなしのコンパイル用の2つの値が存在します。 プロファイルフィードバックを使用したコンパイルの値は、トレーサーを効果的にするために、より保守的(高い)にする必要があります。

|max-cse-path-length |Maximum number of basic blocks on path that cse considers. The default is 10. |max-cse-insns |The maximum instructions CSE process before flushing. The default is 1000. |global-var-threshold *|Counts the number of function calls (n) and the number of call-clobbered variables (v). If nx_v_ is larger than this limit, a single artificial variable will be created to represent all the call-clobbered variables at function call sites. This artificial variable will then be made to alias every call-clobbered variable. (done as int* size_t on the host machine; beware overflow). |*max-aliased-vops |Maximum number of virtual operands allowed to represent aliases before triggering the alias grouping heuristic. Alias grouping reduces compile times and memory consumption needed for aliasing at the expense of precision loss in alias information. |ggc-min-expand a| GCC uses a garbage collector to manage its own memory allocation. This parameter specifies the minimum percentage by which the garbage collector’s heap should be allowed to expand between collections. Tuning this may improve compilation speed; it has no effect on code generation.

デフォルトは30%+ 70%(RAM/1GB)で、RAM> = 1GBの場合の上限は100%です。 `+ getrlimit `が利用可能な場合、RAMの概念は実際のRAMと ` RLIMIT_DATA `または ` RLIMIT_AS +`の最小値です。 GCCが特定のプラットフォームでRAMを計算できない場合、30%の下限が使用されます。 このパラメーターと *ggc-min-heapsize をゼロに設定すると、すべての機会に完全なコレクションが発生します。 これは非常に遅いですが、デバッグには役立ちます。

|ggc-min-heapsize *a| Minimum size of the garbage collector’s heap before it begins bothering to collect garbage. The first collection occurs after the heap expands by ggc-min-expand*% beyond ggc-min-heapsize. Again, tuning this may improve compilation speed, and has no effect on code generation.

デフォルトは、RAM/8、RLIMIT_RSSのうち小さい方、またはRLIMIT_DATAまたはRLIMIT_ASを超えないようにする制限ですが、下限は4096(4メガバイト)、上限は131072(128メガバイト)です。 GCCが特定のプラットフォームでRAMを計算できない場合、下限が使用されます。 このパラメーターを非常に大きく設定すると、ガベージコレクションが事実上無効になります。 このパラメーターと ggc-min-expand をゼロに設定すると、すべての機会に完全なコレクションが発生します。

|max-reload-search-insns |The maximum number of instruction reload should look backward for equivalent register. Increasing values mean more aggressive optimization, making the compile time increase with probably slightly better performance. The default value is 100. |max-cselib-memory-location |The maximum number of memory locations cselib should take into account. Increasing values mean more aggressive optimization, making the compile time increase with probably slightly better performance. The default value is 500. |max-flow-memory-location *|Similar as max-cselib-memory-location* but for dataflow liveness. The default value is 100. |reorder-blocks-duplicate | |reorder-blocks-duplicate-feedback a| Used by basic block reordering pass to decide whether to use unconditional branch or duplicate the code on its destination. Code is duplicated when its estimated size is smaller than this value multiplied by the estimated size of unconditional jump in the hot spots of the program.

*reorder-block-duplicate-feedback* は、プロファイルフィードバックが利用可能な場合にのみ使用され、ホットスポットに関する情報がより正確であるため、 *reorder-block-duplicate* よりも高い値に設定できます。

|max-sched-ready-insns |The maximum number of instructions ready to be issued the scheduler should consider at any given time during the first scheduling pass. Increasing values mean more thorough searches, making the compilation time increase with probably little benefit. The default value is 100. |max-sched-region-blocks |The maximum number of blocks in a region to be considered for interblock scheduling. The default value is 10. |max-sched-region-insns |The maximum number of insns in a region to be considered for interblock scheduling. The default value is 100. |min-sched-prob |The minimum probability of reaching a source block for interblock speculative scheduling. The default value is 40. |max-last-value-rtl |The maximum size measured as number of RTLs that can be recorded in an expression in combiner for a pseudo register as last known value of that register. The default is 10000. |integer-share-limit |Small integer constants can use a shared data structure, reducing the compiler’s memory usage and increasing its speed. This sets the maximum value of a shared integer constant’s. The default value is 256. |min-virtual-mappings |Specifies the minimum number of virtual mappings in the incremental SSA updater that should be registered to trigger the virtual mappings heuristic defined by virtual-mappings-ratio. The default value is 100. |virtual-mappings-ratio |If the number of virtual mappings is virtual-mappings-ratio bigger than the number of virtual symbols to be updated, then the incremental SSA updater switches to a full update for those symbols. The default ratio is 3. |ssp-buffer-size *|The minimum size of buffers (i.e. arrays) that will receive stack smashing protection when -fstack-protection* is used. |max-jump-thread-duplication-stmts |Maximum number of statements allowed in a block that needs to be duplicated when threading jumps. |max-fields-for-field-sensitive |Maximum number of fields in a structure we will treat in a field sensitive manner during pointer analysis.

プリプロセッサを制御するオプション

*-E* オプションを使用すると、前処理以外は何も行われません。 これらのオプションの一部は、*-E *と組み合わせた場合にのみ意味があります。これは、プリプロセッサの出力が実際のコンパイルに不適切になるためです。

-Wp、 optionを使用して、コンパイラドライバーをバイパスし、_option_を直接プリプロセッサに渡すことができます。 _option_にコンマが含まれている場合、コンマで複数のオプションに分割されます。 ただし、多くのオプションは、プリプロセッサに渡される前にコンパイラドライバによって変更、変換、または解釈され、-Wp *はこのフェーズを強制的にバイパスします。 プリプロセッサーの直接インターフェースは文書化されておらず、変更される可能性があるため、可能な限り *-Wp の使用を避け、代わりにドライバーにオプションを処理させる必要があります。

Tag Description
-Xpreprocessor option

Pass option as an option to the preprocessor. You can use this to supply system-specific preprocessor options which GCC does not know how to recognize.

引数を取るオプションを渡す場合は、オプションに1回、引数に1回、*-Xpreprocessor *を2回使用する必要があります。

-D name Predefine name as a macro, with definition 1.
-D name=definition

The contents of definition are tokenized and processed as if they appeared during translation phase three in a *#define *directive. In particular, the definition will be truncated by embedded newline characters.

シェルまたはシェルのようなプログラムからプリプロセッサを呼び出す場合は、シェルの引用構文を使用して、シェル構文で意味を持つスペースなどの文字を保護する必要があります。

コマンドラインで関数のようなマクロを定義する場合は、等号の前にかっこを付けて引数リストを記述します(存在する場合)。 括弧はほとんどのシェルにとって意味があるため、オプションを引用する必要があります。* sh および *csh では、*-D ’ name args …​ )= * *definition ’ *が機能します。

  • -D* および *-U* オプションは、コマンドラインで指定された順序で処理されます。 すべての *-imacros* _file_および *-include* _file_オプションは、すべての *-D* および *-U* オプションの後に処理されます。
*-U *name Cancel any previous definition of name, either built in or provided with a* -D* option.
-undef Do not predefine any system-specific or GCC-specific macros. The standard predefined macros remain defined.
*-I *dir Add the directory dir to the list of directories to be searched for header files. Directories named by* -I* are searched before the standard system include directories. If the directory dir is a standard system include directory, the option is ignored to ensure that the default search order for system directories and the special treatment of system headers are not defeated .
*-o *file Write output to file. This is the same as specifying file as the second non-option argument to* cpp*. gcc *has a different interpretation of a second non-option argument, so you must use -o* to specify the output file.
*-Wall * Turns on all optional warnings which are desirable for normal code. At present this is* -Wcomment*, -Wtrigraphs, -Wmultichar and a warning about integer promotion causing a change of sign in #if expressions. Note that many of the preprocessor’s warnings are on by default and have no options to control them.
-Wcomment
*-Wcomments * Warn whenever a comment-start sequence*/* appears in a/* comment, or whenever a backslash-newline appears in a//* comment. (Both forms have the same effect.)
-Wtrigraphs

Most trigraphs in comments cannot affect the meaning of the program. However, a trigraph that would form an escaped newline (??/ at the end of a line) can, by changing where the comment begins or ends. Therefore, only trigraphs that would form escaped newlines produce warnings inside a comment.

このオプションは、-Wall *によって暗示されています。 *-Wall が指定されていない場合、トライグラフが有効になっていない限り、このオプションは有効のままです。 警告なしでトライグラフ変換を取得し、他の -Wall 警告を取得するには、*-trigraphs -Wall -Wno-trigraphs *を使用します。

-Wtraditional Warn about certain constructs that behave differently in traditional and ISO C. Also warn about ISO C constructs that have no traditional C equivalent, and problematic constructs which should be avoided.
*-Wimport * Warn the first time* #import* is used.
*-Wundef * Warn whenever an identifier which is not a macro is encountered in an* #if directive, outside of defined*. Such identifiers are replaced with zero.
-Wunused-macros

Warn about macros defined in the main file that are unused. A macro is used if it is expanded or tested for existence at least once. The preprocessor will also warn if the macro has not been used at the time it is redefined or undefined.

組み込みマクロ、コマンドラインで定義されたマクロ、およびインクルードファイルで定義されたマクロは警告されません。

_注:_マクロが実際に使用され、スキップされた条件ブロックでのみ使用されている場合、CPPはそれを未使用として報告します。 このような場合の警告を回避するには、たとえば最初にスキップしたブロックにマクロを移動することにより、マクロの定義の範囲を改善することができます。 または、次のようなダミーの使用を提供できます。

++

a|

    #if defined the_macro_causing_the_warning
    #endif
*-Wendif-labels *a

Warn whenever an* #else or an #endif* are followed by text. This usually happens in code of the form

++

[width="100%",cols="100%",]

a|

    #if FOO
    ...
    #else FOO
    ...
    #endif FOO
    #if FOO
    ...
    #else FOO
    ...
    #endif FOO
2番目と3番目の `+ FOO +`はコメントに含める必要がありますが、多くの場合、古いプログラムにはありません。 この警告はデフォルトでオンになっています。
-Werror
Make all warnings into hard errors. Source code which triggers warnings will be rejected.
-Wsystem-headers
Issue warnings for code in system headers. These are normally unhelpful in finding bugs in your own code, therefore suppressed. If you are responsible for the system library, you may want to see them.
-w
Suppress all warnings, including those which GNU CPP issues by default.
-pedantic
Issue all the mandatory diagnostics listed in the C standard. Some of them are left out by default, since they trigger frequently on harmless code.
*-pedantic-errors *
Issue all the mandatory diagnostics, and make all mandatory diagnostics into errors. This includes mandatory diagnostics that GCC issues without* -pedantic* but treats as warnings.
*-M *a

Instead of outputting the result of preprocessing, output a rule suitable for* make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros* command line options.

-MT または -MQ で)明示的に指定されていない限り、オブジェクトファイル名は、ソースファイルのベース名から構成され、サフィックスはオブジェクトファイルのサフィックスに置き換えられます。 含まれるファイルが多数ある場合、ルールは \ -newlineを使用して複数の行に分割されます。 ルールにはコマンドがありません。

このオプションは、-dM *などのプリプロセッサのデバッグ出力を抑制しません。 そのようなデバッグ出力が依存関係ルールと混ざらないようにするには、依存関係出力ファイルを *-MF で明示的に指定するか、 DEPENDENCIES_OUTPUT などの環境変数を使用する必要があります。 通常どおり、デバッグ出力は通常の出力ストリームに送信されます。

-M をドライバーに渡すと、-E *が暗黙的に指定され、暗黙の *-w で警告が抑制されます。

*-MM *a

Like* -M* but do not mention header files that are found in system header directories, nor header files that are included, directly or indirectly, from such a header.

これは、#include *ディレクティブでの山括弧または二重引用符の選択自体が、ヘッダーが​​ -MM *依存関係出力に表示されるかどうかを決定しないことを意味します。 これは、GCCバージョン3.0以前からのセマンティクスのわずかな変更です。

*-MF *file

When used with* -M or -MM*, specifies a file to write the dependencies to. If no -MF switch is given the preprocessor sends the rules to the same place it would have sent preprocessed output.

ドライバオプション -MD または -MMD を使用すると、*-MF *はデフォルトの依存関係出力ファイルを上書きします。

*-MG *a

In conjunction with an option such as* -M requesting dependency generation, -MG assumes missing header files are generated files and adds them to the dependency list without raising an error. The dependency filename is taken directly from the #include directive without prepending any path. -MG* also suppresses preprocessed output, as a missing header file renders this useless.

この機能は、メイクファイルの自動更新で使用されます。

*-MP *a

This option instructs CPP to add a phony target for each dependency other than the main file, causing each to depend on nothing. These dummy rules work around errors* make* gives if you remove header files without updating the Makefile to match.

これは典型的な出力です:

++

[width="100%",cols="100%",]

a|

    test.o: test.c test.h

++

[width="100%",cols="100%",]

a|

    test.h:
*-MT *target

Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, including any path, deletes any file suffix such as* .c*, and appends the platform’s usual object suffix. The result is the target.

  • -MT* オプションは、ターゲットを指定した文字列に正確に設定します。 複数のターゲットが必要な場合は、それらを *-MT* の単一の引数として指定するか、複数の *-MT* オプションを使用できます。

たとえば、*-MT ’$(objpfx)foo.o’ *は、

++

a|

    $(objpfx)foo.o: foo.c
*-MQ *target

Same as* -MT*, but it quotes any characters which are special to Make. -MQ ’$(objpfx)foo.o’ gives

++

a|

    $$(objpfx)foo.o: foo.c
デフォルトのターゲットは、*-MQ *で指定されたかのように、自動的に引用されます。
*-MD *a
  • -MD is equivalent to -M -MF file, except that -E is not implied. The driver determines file based on whether an -o* option is given. If it is, the driver uses its argument but with a suffix of .d, otherwise it take the basename of the input file and applies a .d suffix.

-MD-E と組み合わせて使用​​すると、-o *スイッチは依存関係出力ファイルを指定するものと解釈されます(ただし、 + @ pxref + \ {dashMF ,,-MF})。ただし、 *-E 、各 -o はターゲットオブジェクトファイルを指定すると理解されます。

-E は暗黙指定されないため、コンパイルプロセスの副作用として、*-MD *を使用して依存関係出力ファイルを生成できます。

*-MMD *
Like* -MD* except mention only user header files, not system header files.
-fpch-deps
When using precompiled headers, this flag will cause the dependency-output flags to also list the files from the precompiled header’s dependencies. If not specified only the precompiled header would be listed and not the files that were used to create it because those files are not consulted when a precompiled header is used.
*-fpch-preprocess *a

This option allows use of a precompiled header together with* -E*. It inserts a special #pragma, #pragma GCC pch_preprocess "<filename>" in the output to mark the place where the precompiled header was found, and its filename. When -fpreprocessed *is in use, GCC recognizes this #pragma and loads the PCH.

結果の前処理済み出力は、GCCへの入力としてのみ本当に適しているため、このオプションはデフォルトではオフになっています。</emphasis> -save-temps *によってオンになります。

この `+#pragma +`を独自のコードで記述するべきではありませんが、PCHファイルが別の場所にある場合はファイル名を編集しても安全です。 ファイル名は絶対的なものでも、GCCの現在のディレクトリに相対的なものでもかまいません。

-x c
-x c++
-x objective-c
*-x assembler-with-cpp *a

Specify the source language: C, C, Objective-C, or assembly. This has nothing to do with standards conformance or extensions; it merely selects which base syntax to expect. If you give none of these options, cpp will deduce the language from the extension of the source file:* .c*, *.cc*, *.m*, or *.S*. Some other common extensions for C and assembly are also recognized. If cpp does not recognize the extension, it will treat the file as C; this is the most generic mode.

注: cppの以前のバージョンは、言語と標準適合レベルの両方を選択する -lang オプションを受け入れました。 このオプションは -l オプションと競合するため、削除されました。

-std=standard
*-ansi *a

Specify the standard to which the code should conform. Currently CPP knows about C and C++ standards; others may be added in the future.

_standard_は次のいずれかです。

[width="100%",cols="50%,50%",options="header",]

|Tag |Description |iso9899:1990 | |c89 a| The ISO C standard from 1990.* c89* is the customary shorthand for this version of the standard.

*-ansi* オプションは *-std = c89* と同等です。

|iso9899:199409 |The 1990 C standard, as amended in 1994. |iso9899:1999 | |c99 | |iso9899:199x | |c9x |The revised ISO C standard, published in December 1999. Before publication, this was known as C9X. |gnu89 |The 1990 C standard plus GNU extensions. This is the default. |gnu99 | |gnu9x |The 1999 C standard plus GNU extensions. |+c98+` |The 1998 ISO C standard plus amendments. |+gnu98+` |The same as *-std=c98* plus GNU extensions. This is the default for C++ code.

*-I- *a

Split the include path. Any directories specified with* -I options before -I- are searched only for headers requested with #include "file"; they are not searched for #include <file>. If additional directories are specified with -I options after the -I-, those directories are searched for all *#include directives.

さらに、*-I- *は、現在のファイルディレクトリのディレクトリを、 `+#include" + + file + + "+`の最初の検索ディレクトリとして使用することを禁止します。 このオプションは廃止されました。

*-nostdinc * Do not search the standard system directories for header files. Only the directories you have specified with* -I* options (and the directory of the current file, if appropriate) are searched.
-nostdinc++ Do not search for header files in the C-specific standard directories, but do still search the other standard directories. (This option is used when building the C library.)
-include file

Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor’s working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.

複数の -include オプションが指定されている場合、ファイルはコマンドラインに表示される順序で含まれます。

*-imacros *file

Exactly like* -include*, except that any output produced by scanning file is thrown away. Macros it defines remain defined. This allows you to acquire all the macros from a header without also processing its declarations.

  • -imacros* で指定されたすべてのファイルは、*-include *で指定されたすべてのファイルの前に処理されます。
*-idirafter *dir Search dir for header files, but do it after all directories specified with* -I* and the standard system directories have been exhausted. dir is treated as a system include directory.
*-iprefix *prefix Specify prefix as the prefix for subsequent* -iwithprefix options. If the prefix represents a directory, you should include the final/*.
-iwithprefix dir
*-iwithprefixbefore *dir Append dir to the prefix specified previously with* -iprefix*, and add the resulting directory to the include search path. -iwithprefixbefore *puts it in the same place -I would; -iwithprefix puts it where -idirafter* would.
*-isysroot *dir This option is like the* --sysroot option, but applies only to header files. See the --sysroot* option for more information.
*-isystem *dir Search dir for header files, after all directories specified by* -I* but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories.
*-iquote *dir Search dir only for header files requested with #include "file"; they are not searched for #include <file>, before all directories specified by* -I* and before the standard system directories.
*-fdollars-in-identifiers * Accept* $* in identifiers.
-fextended-identifiers Accept universal character names in identifiers. This option is experimental; in a future version of GCC, it will be enabled by default for C99 and C++.
*-fpreprocessed *a

Indicate to the preprocessor that the input file has already been preprocessed. This suppresses things like macro expansion, trigraph conversion, escaped newline splicing, and processing of most directives. The preprocessor still recognizes and removes comments, so that you can pass a file preprocessed with* -C* to the compiler without problems. In this mode the integrated preprocessor is little more than a tokenizer for the front ends.

入力ファイルに拡張子 .i。ii *、または *.mi のいずれかがある場合、-fpreprocessed *は暗黙的です。 これらは、-save-temps *によって作成された前処理済みファイルにGCCが使用する拡張子です。

-ftabstop=width Set the distance between tab stops. This helps the preprocessor report correct column numbers in warnings or errors, even if tabs appear on the line. If the value is less than 1 or greater than 100, the option is ignored. The default is 8.
-fexec-charset=charset Set the execution character set, used for string and character constants. The default is UTF-8. charset can be any encoding supported by the system’s iconv library routine.
-fwide-exec-charset=charset Set the wide execution character set, used for wide string and character constants. The default is UTF-32 or UTF-16, whichever corresponds to the width of wchar_t. As with -fexec-charset, charset can be any encoding supported by the system’s iconv library routine; however, you will have problems with encodings that do not fit exactly in wchar_t.
-finput-charset=charset Set the input character set, used for translation from the character set of the input file to the source character set used by GCC. If the locale does not specify, or GCC cannot get this information from the locale, the default is UTF-8. This can be overridden by either the locale or this command line option. Currently the command line option takes precedence if there’s a conflict. charset can be any encoding supported by the system’s iconv library routine.
*-fworking-directory * Enable generation of linemarkers in the preprocessor output that will let the compiler know the current working directory at the time of preprocessing. When this option is enabled, the preprocessor will emit, after the initial linemarker, a second linemarker with the current working directory followed by two slashes. GCC will use this directory, when it’s present in the preprocessed input, as the directory emitted as the current working directory in some debugging information formats. This option is implicitly enabled if debugging information is enabled, but this can be inhibited with the negated form* -fno-working-directory*. If the -P flag is present in the command line, this option has no effect, since no #line directives are emitted whatsoever.
*-fno-show-column * Do not print column numbers in diagnostics. This may be necessary if diagnostics are being scanned by a program that does not understand the column numbers, such as* dejagnu*.
-A predicate=answer Make an assertion with the predicate predicate and answer answer. This form is preferred to the older form -A predicate(answer), which is still supported, because it does not use shell special characters.
-A -predicate=answer Cancel an assertion with the predicate predicate and answer answer.
-dCHARS CHARS is a sequence of one or more of the following characters, and must not be preceded by a space. Other characters are interpreted by the compiler proper, or reserved for future versions of GCC, and so are silently ignored. If you specify characters whose behavior conflicts, the result is undefined.

|Tag |Description |M *a| Instead of the normal output, generate a list of #define* directives for all the macros defined during the execution of the preprocessor, including predefined macros. This gives you a way of finding out what is predefined in your version of the preprocessor. Assuming you have no file foo.h, the command

++

touch foo.h; cpp -dM foo.h

すべての定義済みマクロが表示されます。

|D *|Like M except in two respects: it does not include the predefined macros, and it outputs both the #define* directives and the result of preprocessing. Both kinds of output go to the standard output file. |N *|Like D*, but emit only the macro names, not their expansions. |I *|Output #include* directives in addition to the result of preprocessing.

-P Inhibit generation of linemarkers in the output from the preprocessor. This might be useful when running the preprocessor on something that is not C code, and will be sent to a program which might be confused by the linemarkers. -C

Do not discard comments. All comments are passed through to the output file, except for comments in processed directives, which are deleted along with the directive.

  • -C* を使用する場合、副作用に備える必要があります。プリプロセッサは、コメントを独自のトークンとして処理します。 たとえば、ディレクティブ行となるものの先頭に表示されるコメントは、行の最初のトークンが*#*でなくなるため、その行を通常のソース行に変換する効果があります。
*-CC *a

Do not discard comments, including during macro expansion. This is like* -C*, except that comments contained within macros are also passed through to the output file where the macro is expanded.

-C オプションの副作用に加えて、-CC *オプションを使用すると、マクロ内のすべてのC ++スタイルのコメントがCスタイルのコメントに変換されます。 これは、そのマクロを後で使用して、ソース行の残りの部分を誤ってコメントアウトしないようにするためです。

  • -CC</emphasis> オプションは、一般的にlintコメントをサポートするために使用されます。
-traditional-cpp Try to imitate the behavior of old-fashioned C preprocessors, as opposed to ISO C preprocessors.

a|

Trigraph:   ??(  ??)  ??<  ??>  ??=  ??/ ??’  ??!  ??-
Replacement:  [    ]    {    }    #    \    ^    |    ~
-remap Enable special code to work around file systems which only permit very short file names, such as MS-DOS. --help --target-help Print text describing all the command line options instead of preprocessing anything. -v Verbose mode. Print out GNU CPP’s version number at the beginning of execution, and report the final form of the include path. *-H * Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the* #include stack it is. Precompiled header files are also printed, even if they are found to be invalid; an invalid precompiled header file is printed with …​x and a valid one with …​!* . -version --version Print out GNU CPP’s version number. With one dash, proceed to preprocess as normal. With two dashes, exit immediately.

アセンブラーにオプションを渡す

Tag Description
-Wa,option Pass option as an option to the assembler. If option contains commas, it is split into multiple options at the commas.
-Xassembler option

Pass option as an option to the assembler. You can use this to supply system-specific assembler options which GCC does not know how to recognize.

引数を取るオプションを渡したい場合は、オプションに1回、引数に1回、*-Xassembler *を2回使用する必要があります。

リンクのオプション

Tag Description
object-file-name A file name that does not end in a special recognized suffix is considered to name an object file or library. (Object files are distinguished from libraries by the linker according to the file contents.) If linking is done, these object files are used as input to the linker.
-c
-S
-E If any of these options is used, then the linker is not run, and object file names should not be used as arguments.
-llibrary
-l library

Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)

コマンドでこのオプションを記述する場所に違いが生じます。リンカーは、指定された順序でライブラリとオブジェクトファイルを検索して処理します。 したがって、 foo.o -lz bar.o は、ファイル_foo.o_の後、_bar.o_の前にライブラリ z を検索します。 _bar.o_が z の関数を参照している場合、それらの関数はロードされない可能性があります。

リンカーは、ライブラリのディレクトリの標準リストを検索します。ライブラリは、実際には_liblibrary.a_という名前のファイルです。 リンカーは、このファイルを名前で正確に指定されているかのように使用します。

検索されるディレクトリには、いくつかの標準システムディレクトリと -L で指定したディレクトリが含まれます。

通常、この方法で見つかったファイルはライブラリファイルです。アーカイブファイルのメンバーはオブジェクトファイルです。 リンカは、これまでに参照されたが定義されていないシンボルを定義するメンバーをスキャンしてアーカイブファイルを処理します。 ただし、見つかったファイルが通常のオブジェクトファイルである場合、通常の方法でリンクされます。 -l オプションの使用とファイル名の指定の唯一の違いは、-l *が_library_を *lib および .a で囲み、いくつかのディレクトリを検索することです。

*-lobjc * You need this special case of the* -l* option in order to link an Objective-C or Objective-C++ program.
*-nostartfiles * Do not use the standard system startup files when linking. The standard system libraries are used normally, unless* -nostdlib or -nodefaultlibs* is used.
*-nodefaultlibs * Do not use the standard system libraries when linking. Only the libraries you specify will be passed to the linker. The standard startup files are used normally, unless* -nostartfiles* is used. The compiler may generate calls to memcmp, memset, memcpy and memmove. These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified.
-nostdlib

Do not use the standard system startup files or libraries when linking. No startup files and only the libraries you specify will be passed to the linker. The compiler may generate calls to memcmp, memset, memcpy and memmove. These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified.

  • -nostdlib* および *-nodefaultlibs* によってバイパスされる標準ライブラリの1つは、_libgcc.a_です。これは、GCCが特定のマシンの欠点や一部の言語の特別なニーズを克服するために使用する内部サブルーチンのライブラリです。

ほとんどの場合、他の標準ライブラリを避けたい場合でも、libgcc.a_が必要です。 つまり、-nostdlib *または *-nodefaultlibs を指定するときは、通常 -lgcc も指定する必要があります。 これにより、内部GCCライブラリサブルーチンへの未解決の参照がなくなります。 (たとえば、C ++コンストラクターが呼び出されるようにするために使用される _ main 。)

-pie Produce a position independent executable on targets which support it. For predictable results, you must also specify the same set of options that were used to generate code (-fpie, -fPIE, or model suboptions) when you specify this option.
*-rdynamic * Pass the flag* -export-dynamic* to the ELF linker, on targets that support it. This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. This option is needed for some uses of dlopen or to allow obtaining backtraces from within a program.
-s Remove all symbol table and relocation information from the executable.
-static On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.
-shared Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options that were used to generate code (-fpic, -fPIC, or model suboptions) when you specify this option.[1]
-shared-libgcc
-static-libgcc

On systems that provide libgcc as a shared library, these options force the use of either the shared or static version respectively. If no shared version of libgcc was built when the compiler was configured, these options have no effect.

アプリケーションが静的バージョンの代わりに共有_libgcc_を使用する必要がある状況がいくつかあります。 これらの最も一般的なのは、アプリケーションが異なる共有ライブラリ全体で例外をスローおよびキャッチしたい場合です。 その場合、各ライブラリとアプリケーション自体は共有_libgcc_を使用する必要があります。

そのため、C およびJavaプログラムは通常例外を使用するため、共有ライブラリまたはメイン実行可能ファイルをビルドするたびに、G およびGCJドライバーは -shared-libgcc を自動的に追加します。これは正しいことです。

代わりに、GCCドライバーを使用して共有ライブラリーを作成する場合、それらが常に共有_libgcc_とリンクされないことがあります。 GCCは、設定時に、非GNUリンカーまたはオプション*-eh-frame-hdr *をサポートしないGNUリンカーがあることを検出すると、デフォルトで_libgcc_の共有バージョンを共有ライブラリにリンクします。 それ以外の場合は、リンカーを利用して、_libgcc_の共有バージョンとのリンクを最適化し、デフォルトでlibgccの静的バージョンとリンクします。 これにより、ライブラリのロード時に再配置コストを発生させることなく、そのような共有ライブラリを通じて例外を伝播できます。

ただし、ライブラリまたはメインの実行可能ファイルが例外をスローまたはキャッチすることになっている場合は、プログラムで使用される言語に応じてG ++またはGCJドライバーを使用するか、オプション -shared-libgcc を使用してリンクする必要があります。共有の_libgcc_とリンクされています。

*-symbolic * Bind references to global symbols when building a shared object. Warn about any unresolved references (unless overridden by the link editor option* -Xlinker -z -Xlinker defs*). Only a few systems support this option.
-Xlinker option

Pass option as an option to the linker. You can use this to supply system-specific linker options which GCC does not know how to recognize.

引数を取るオプションを渡したい場合は、オプションに1回、引数に1回、-Xlinker *を2回使用する必要があります。 たとえば、-assert definition を渡すには、-Xlinker -assert -Xlinker definition と記述する必要があります。 *-Xlinker -assert definition を記述することは機能しません。これは、文字列全体を単一の引数として渡すためです。これは、リンカが予期するものではありません。

-Wl,option Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas.
*-u *symbol Pretend the symbol symbol is undefined, to force linking of library modules to define it. You can use* -u* multiple times with different symbols to force loading of additional library modules.

ディレクトリ検索のオプション

Tag Description
-Idir

Add the directory dir to the head of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. However, you should not use this option to add directories that contain vendor-supplied system header files (use -isystem *for that). If you use more than one -I* option, the directories are scanned in left-to-right order; the standard system directories come after.

標準システムインクルードディレクトリ、または -isystem で指定されたディレクトリが -I でも指定されている場合、-I *オプションは無視されます。 ディレクトリは引き続き検索されますが、システムインクルードチェーンの通常の位置にあるシステムディレクトリとして。 これは、バグのあるシステムヘッダーを修正するGCCの手順とinclude_nextディレクティブの順序が誤って変更されないようにするためです。 システムディレクトリの検索順序を本当に変更する必要がある場合は、-nostdinc および/または *-isystem オプションを使用します。

-iquotedir Add the directory dir to the head of the list of directories to be searched for header files only for the case of #include "file*"; they are not searched for #include <file>*, otherwise just like -I.
-Ldir Add directory dir to the list of directories to be searched for -l.
-Bprefix

This option specifies where to find the executables, libraries, include files, and data files of the compiler itself.

コンパイラドライバプログラムは、1つ以上のサブプログラム_cpp cc1 as_、および_ld_を実行します。 machine * / version / *の有無にかかわらず、実行しようとする各プログラムのプレフィックスとして_prefix_を試行します。

実行するサブプログラムごとに、コンパイラドライバーは最初に -B プレフィックスを試します。 その名前が見つからない場合、または -B が指定されていない場合、ドライバーは_/usr/lib/gcc//usr/local/lib/gcc/_の2つの標準プレフィックスを試行します。 これらのどちらでもファイル名が見つからない場合、 PATH 環境変数で指定されたディレクトリを使用して、変更されていないプログラム名が検索されます。

コンパイラは、*-B *が提供するパスがディレクトリを参照しているかどうかを確認し、必要に応じてパスの末尾にディレクトリ区切り文字を追加します。

コンパイラがこれらのオプションをリンカーの -L オプションに変換するため、ディレクトリ名を効果的に指定する -B プレフィックスはリンカーのライブラリにも適用されます。 コンパイラはこれらのオプションをプリプロセッサの -isystem オプションに変換するため、プリプロセッサのインクルードファイルにも適用されます。 この場合、コンパイラはプレフィックスに include を追加します。

必要に応じて、*-B *プレフィックスを使用して、ランタイムサポートファイル_libgcc.a_を検索することもできます。 そこで見つからない場合は、上記の2つの標準プレフィックスが試されますが、それだけです。 これらの方法で見つからない場合、ファイルはリンクから除外されます。

  • -B* プレフィックスのようにプレフィックスを指定する別の方法は、環境変数 *GCC_EXEC_PREFIX* を使用することです。

特別な工夫として、*-B *によって提供されるパスが_ [dir/] stageN/である場合、_N_は0〜9の範囲の数値であり、 [dir/] include_に置き換えられます。 これは、コンパイラのブートストラップを支援するためです。

-specs=file Process file after the compiler reads in the standard specs file, in order to override the defaults that the gcc driver program uses when determining what switches to pass to cc1, cc1plus, as, ld, etc. More than one -specs=file can be specified on the command line, and they are processed in order, from left to right.
--sysroot=dir

Use dir as the logical root directory for headers and libraries. For example, if the compiler would normally search for headers in /usr/include and libraries in /usr/lib, it will instead search dir/usr/include and dir/usr/lib.

このオプションと -isysroot オプションの両方を使用する場合、-sysroot *オプションはライブラリに適用されますが、-isysroot *オプションはヘッダーファイルに適用されます。

GNUリンカー(バージョン2.16以降)は、このオプションに必要なサポートを提供しています。 リンカーがこのオプションをサポートしていない場合、*-sysroot *のヘッダーファイルの側面は引き続き機能しますが、ライブラリの側面は機能しません。

*-I- *a

This option has been deprecated. Please use* -iquote instead for -I directories before the -I- and remove the -I-. Any directories you specify with *-I *options before the -I- option are searched only for the case of #include "file"; they are not searched for#include <file>*.

-I- の後に -I オプションを使用して追加のディレクトリを指定すると、これらのディレクトリですべての*#include ディレクティブが検索されます。 (通常、この方法で_all_ *-I ディレクトリが使用されます。)

さらに、-I- *オプションは、#include "</emphasis> file " の最初の検索ディレクトリとして、現在のディレクトリ(現在の入力ファイルの取得元)の使用を禁止します。 *-I- のこの効果を無効にする方法はありません。 * -I。を使用すると、コンパイラが呼び出されたときに最新であったディレクトリを検索するように指定できます。 これは、プリプロセッサがデフォルトで行うこととまったく同じではありませんが、多くの場合満足のいくものです。

  • -I-</emphasis> は、ヘッダーファイル用の標準​​システムディレクトリの使用を禁止しません。 したがって、-I- *と *-nostdinc は独立しています。

ターゲットマシンとコンパイラバージョンの指定

GCCgcc <マシン> -gcc <マシン> -gcc- <バージョン> GCC

Tag

説明

*-b* _machine_

引数_machine_は、コンパイルのターゲットマシンを指定します。

_machine_に使用する値は、GCCをクロスコンパイラとして構成するときにマシンタイプとして指定されたものと同じです。 たとえば、クロスコンパイラが configure arm-elf で構成されている場合、つまりelfバイナリを備えたarmプロセッサ用にコンパイルする場合、-b arm-elf *を指定してそのクロスコンパイラを実行します。 *-b で始まる他のオプションがあるため、構成にはハイフンを含める必要があります。

*-V* _version_

引数_version_は、実行するGCCのバージョンを指定します。 これは、複数のバージョンがインストールされている場合に便利です。 たとえば、_version_は 4.0 で、GCCバージョン4.0を実行することを意味します。

-V-b <マシン> -gcc- <バージョン>

ハードウェアモデルと構成

-b VAX

さらに、これらのターゲットマシンタイプにはそれぞれ、*-m *で始まる独自の特別なオプションがあり、さまざまなハードウェアモデルまたは構成から選択できます。たとえば、68010 vs 68020、フローティングコプロセッサー、なしなどです。 指定されたオプションに従って、単一のインストール済みバージョンのコンパイラーは、任意のモデルまたは構成用にコンパイルできます。

コンパイラの一部の構成では、通常、同じプラットフォーム上の他のコンパイラとの互換性のために、追加の特別なオプションもサポートしています。

ARCオプション

ARC

Tag Description
-EL Compile code for little endian mode. This is the default.
-EB Compile code for big endian mode.
-mmangle-cpu Prepend the name of the cpu to all public symbol names. In multiple-processor systems, there are many ARC variants with different instruction and register set characteristics. This flag prevents code compiled for one cpu to be linked with code compiled for another. No facility exists for handling variants that are almost identical. This is an all or nothing option.
-mcpu=cpu Compile code for ARC variant cpu. Which variants are supported depend on the configuration. All variants support -mcpu=base, this is the default.
-mtext=text-section
-mdata=data-section
-mrodata=readonly-data-section Put functions, data, and readonly data in text-section, data-section, and readonly-data-section respectively by default. This can be overridden with the section attribute.

ARMオプション

-m RISCARM

Tag Description
-mabi=name Generate code for the specified ABI. Permissible values are: apcs-gnu, atpcs, aapcs, aapcs-linux *and iwmmxt*.
*-mapcs-frame * Generate a stack frame that is compliant with the ARM Procedure Call Standard for all functions, even if this is not strictly necessary for correct execution of the code. Specifying* -fomit-frame-pointer with this option will cause the stack frames not to be generated for leaf functions. The default is -mno-apcs-frame*.
*-mapcs * This is a synonym for* -mapcs-frame*.
*-mthumb-interwork * Generate code which supports calling between the ARM and Thumb instruction sets. Without this option the two instruction sets cannot be reliably used inside one program. The default is* -mno-thumb-interwork*, since slightly larger code is generated when -mthumb-interwork is specified.
*-mno-sched-prolog * Prevent the reordering of instructions in the function prolog, or the merging of those instruction with the instructions in the function’s body. This means that all functions will start with a recognizable set of instructions (or in fact one of a choice from a small set of different function prologues), and this information can be used to locate the start if functions inside an executable piece of code. The default is* -msched-prolog*.
-mhard-float Generate output containing floating point instructions. This is the default.
*-msoft-float *a

Generate output containing library calls for floating point.* Warning:* the requisite libraries are not available for all ARM targets. Normally the facilities of the machine’s usual C compiler are used, but this cannot be done directly in cross-compilation. You must make your own arrangements to provide suitable library functions for cross-compilation.

-msoft-float は、出力ファイルの呼び出し規則を変更します。したがって、このオプションを使用してプログラムのすべてをコンパイルする場合にのみ役立ちます。 特に、これが機能するためには、GCCに付属のライブラリである_libgcc.a_を -msoft-float でコンパイルする必要があります。

-mfloat-abi=name

Specifies which ABI to use for floating point values. Permissible values are: soft, softfp *and hard*.

  • soft* および *hard* は、それぞれ *-msoft-float* および *-mhard-float* と同等です。 *softfp* は、浮動小数点命令の生成を許可しますが、それでもソフトフロート呼び出し規約を使用します。
-mlittle-endian Generate code for a processor running in little-endian mode. This is the default for all standard configurations.
-mbig-endian Generate code for a processor running in big-endian mode; the default is to compile code for a little-endian processor.
*-mwords-little-endian * This option only applies when generating code for big-endian processors. Generate code for a little-endian word order but a big-endian byte order. That is, a byte order of the form* 32107654*. Note: this option should only be used if you require compatibility with code for big-endian ARM processors generated by versions of the compiler prior to 2.8.
-mcpu=name This specifies the name of the target ARM processor. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. Permissible names are: arm2, arm250, arm3, arm6, arm60, arm600, arm610, arm620, arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700, arm700i, arm710, arm710c, arm7100, arm7500, arm7500fe, arm7tdmi, arm7tdmi-s, arm8, strongarm, strongarm110, strongarm1100, arm8, arm810, arm9, arm9e, arm920, arm920t, arm922t, arm946e-s, arm966e-s, arm968e-s, arm926ej-s, arm940t, arm9tdmi, arm10tdmi, arm1020t, arm1026ej-s, arm10e, arm1020e, arm1022e, arm1136j-s, arm1136jf-s, mpcore, mpcorenovfp, arm1176jz-s, arm1176jzf-s, xscale, iwmmxt, ep9312.
-mtune=name This option is very similar to the -mcpu= *option, except that instead of specifying the actual target processor type, and hence restricting which instructions can be used, it specifies that GCC should tune the performance of the code as if the target were of the type specified in this option, but still choosing the instructions that it will generate based on the cpu specified by a -mcpu=* option. For some ARM implementations better performance can be obtained by using this option.
-march=name This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. This option can be used in conjunction with or instead of the -mcpu= *option. Permissible names are: armv2*, armv2a, armv3, armv3m, armv4, armv4t, armv5, armv5t, armv5te, armv6, armv6j, iwmmxt, ep9312.
-mfpu=name
-mfpe=number
-mfp=number

This specifies what floating point hardware (or hardware emulation) is available on the target. Permissible names are: fpa, fpe2, fpe3, maverick, vfp. -mfp *and -mfpe are synonyms for -mfpu=fpe*number, for compatibility with older versions of GCC.

  • -msoft-float* が指定されている場合、これは浮動小数点値の形式を指定します。
-mstructure-size-boundary=n

The size of all structures and unions will be rounded up to a multiple of the number of bits set by this option. Permissible values are 8, 32 and 64. The default value varies for different toolchains. For the COFF targeted toolchain the default value is 8. A value of 64 is only allowed if the underlying ABI supports it.

大きい数値を指定すると、より高速で効率的なコードが生成されますが、プログラムのサイズが大きくなる可能性もあります。 異なる値は潜在的に互換性がありません。 ある値でコンパイルされたコードは、構造体または共用体を使用して情報を交換する場合、別の値でコンパイルされたコードまたはライブラリで動作すると必ずしも期待できません。

-mabort-on-noreturn Generate a call to the function abort at the end of a noreturn function. It will be executed if the function tries to return.
-mlong-calls
-mno-long-calls

Tells the compiler to perform function calls by first loading the address of the function into a register and then performing a subroutine call on this register. This switch is needed if the target function will lie outside of the 64 megabyte addressing range of the offset based version of subroutine call instruction.

このスイッチを有効にしても、すべての関数呼び出しが長い呼び出しに変わるわけではありません。 ヒューリスティックは、静的関数、 short-call 属性を持つ関数、#pragma no_long_calls *ディレクティブのスコープ内にある関数、および現在のコンパイルユニット内で既に定義がコンパイルされている関数は有効にならないことです。長い通話に。 この規則の例外は、弱い関数定義、 *long-call 属性または section 属性を持つ関数、および*#pragma long_calls *ディレクティブのスコープ内にある関数は、常に長い呼び出しに変換されることです。

この機能はデフォルトでは有効になっていません。 -mno-long-calls を指定すると、デフォルトの動作が復元され、関数呼び出しが*#pragma long_calls_off *ディレクティブのスコープ内に配置されます。 これらのスイッチは、コンパイラが関数ポインタを介して関数呼び出しを処理するコードを生成する方法に影響を与えないことに注意してください。

-mnop-fun-dllimport Disable support for the dllimport attribute.
-msingle-pic-base Treat the register used for PIC addressing as read-only, rather than loading it in the prologue for each function. The run-time system is responsible for initializing this register with an appropriate value before execution begins.
-mpic-register=reg Specify the register to be used for PIC addressing. The default is R10 unless stack-checking is enabled, when R9 is used.
*-mcirrus-fix-invalid-insns * Insert NOPs into the instruction stream to in order to work around problems with invalid Maverick instruction combinations. This option is only valid if the* -mcpu=ep9312 option has been used to enable generation of instructions for the Cirrus Maverick floating point co-processor. This option is not enabled by default, since the problem is only present in older Maverick implementations. The default can be re-enabled by use of the -mno-cirrus-fix-invalid-insns* switch.
-mpoke-function-name

Write the name of each function into the text section, directly preceding the function prologue. The generated code is similar to this:

++

a|

             t0
                 .ascii "arm_poke_function_name", 0
                 .align
             t1
                 .word 0xff000000 + (t1 - t0)
             arm_poke_function_name
                 mov     ip, sp
                 stmfd   sp!, {fp, ip, lr, pc}
                 sub     fp, ip, #4
スタックバックトレースを実行するとき、コードは、「+ fp + 0+」に格納されている「+ pc 」の値を検査できます。 次に、トレース関数が位置「 pc-12+」を見て、上位8ビットが設定されている場合、この位置の直前に埋め込まれた関数名があり、長さが「((pc [-3])」 &0xff000000) `。
-mthumb
Generate code for the 16-bit Thumb instruction set. The default is to use the 32-bit ARM instruction set.
*-mtpcs-frame *
Generate a stack frame that is compliant with the Thumb Procedure Call Standard for all non-leaf functions. (A leaf function is one that does not call any other functions.) The default is* -mno-tpcs-frame*.
*-mtpcs-leaf-frame *
Generate a stack frame that is compliant with the Thumb Procedure Call Standard for all leaf functions. (A leaf function is one that does not call any other functions.) The default is* -mno-apcs-leaf-frame*.
-mcallee-super-interworking
Gives all externally visible functions in the file being compiled an ARM instruction set header which switches to Thumb mode before executing the rest of the function. This allows these functions to be called from non-interworking code.
-mcaller-super-interworking
Allows calls via function pointers (including virtual functions) to execute correctly regardless of whether the target code has been compiled for interworking or not. There is a small overhead in the cost of executing a function pointer if this option is enabled.
-mtp=name
Specify the access model for the thread local storage pointer. The valid models are soft, which generates calls to __aeabi_read_tp, cp15, which fetches the thread pointer from cp15 directly (supported in the arm6k architecture), and auto, which uses the best available method for the selected processor. The default setting is auto.

AVRオプション

AVR

Tag Description
-mmcu=mcu

Specify ATMEL AVR instruction set or MCU type.

命令セットavr1は、最小のAVRコア用であり、Cコンパイラではサポートされていません。アセンブラープログラム(MCUタイプ:at90s1200、attiny10、attiny11、attiny12、attiny15、attiny28)専用です。

命令セットavr2(デフォルト)は、最大8Kプログラムメモリスペース(MCUタイプ:at90s2313、at90s2323、attiny22、at90s2333、at90s2343、at90s4414、at90s4433、at90s4434、at90s8515、at90c8534、at90s8535)を備えたクラシックAVRコア用です。

命令セットavr3は、最大128Kのプログラムメモリ空間を持つ従来のAVRコア用です(MCUタイプ:atmega103、atmega603、at43usb320、at76c711)。

命令セットavr4は、最大8Kのプログラムメモリ空間(MCUタイプ:atmega8、atmega83、atmega85)を備えた拡張AVRコア用です。

命令セットavr5は、最大128Kのプログラムメモリ空間を持つ拡張AVRコア用です(MCUタイプ:atmega16、atmega161、atmega163、atmega32、atmega323、atmega64、atmega128、at43usb355、at94k)。

-msize Output instruction sizes to the asm file.
-minit-stack=N Specify the initial stack address, which may be a symbol or numeric value, __stack is the default.
-mno-interrupts Generated code is not compatible with hardware interrupts. Code size will be smaller.
-mcall-prologues Functions prologues/epilogues expanded as call to appropriate subroutines. Code size will be smaller.
-mno-tablejump Do not generate tablejump insns which sometimes increase code size.
-mtiny-stack Change only the low 8 bits of the stack pointer.
-mint8 Assume int to be 8 bit integer. This affects the sizes of all types: A char will be 1 byte, an int will be 1 byte, an long will be 2 bytes and long long will be 4 bytes. Please note that this option does not comply to the C standards, but it will provide you with smaller code size.

Blackfinオプション

Tag Description
*-momit-leaf-frame-pointer * Don’t keep the frame pointer in a register for leaf functions. This avoids the instructions to save, set up and restore frame pointers and makes an extra register available in leaf functions. The option* -fomit-frame-pointer* removes the frame pointer for all functions which might make debugging harder.
-mspecld-anomaly When enabled, the compiler will ensure that the generated code does not contain speculative loads after jump instructions. This option is enabled by default.
-mno-specld-anomaly Don’t generate extra code to prevent speculative loads from occurring.
-mcsync-anomaly When enabled, the compiler will ensure that the generated code does not contain CSYNC or SSYNC instructions too soon after conditional branches. This option is enabled by default.
-mno-csync-anomaly Don’t generate extra code to prevent CSYNC or SSYNC instructions from occurring too soon after a conditional branch.
-mlow-64k When enabled, the compiler is free to take advantage of the knowledge that the entire program fits into the low 64k of memory.
-mno-low-64k Assume that the program is arbitrarily large. This is the default.
*-mid-shared-library * Generate code that supports shared libraries via the library ID method. This allows for execute in place and shared libraries in an environment without virtual memory management. This option implies* -fPIC*.
-mno-id-shared-library Generate code that doesn’t assume ID based shared libraries are being used. This is the default.
-mshared-library-id=n Specified the identification number of the ID based shared library being compiled. Specifying a value of 0 will generate more compact code, specifying other values will force the allocation of that number to the current library but is no more space or time efficient than omitting this option.
-mlong-calls
*-mno-long-calls *a

Tells the compiler to perform function calls by first loading the address of the function into a register and then performing a subroutine call on this register. This switch is needed if the target function will lie outside of the 24 bit addressing range of the offset based version of subroutine call instruction.

この機能はデフォルトでは有効になっていません。* -mno-long-calls *を指定すると、デフォルトの動作に戻ります。 これらのスイッチは、コンパイラが関数ポインタを介して関数呼び出しを処理するコードを生成する方法に影響を与えないことに注意してください。

CRISオプション

CRIS

Tag Description
-march=architecture-type
-mcpu=architecture-type Generate code for the specified architecture. The choices for architecture-type are v3, v8 *and v10 for respectively ETRAX 4, ETRAX 100, and ETRAX 100 LX. Default is v0 except for cris-axis-linux-gnu, where the default is v10*.
-mtune=architecture-type Tune to architecture-type everything applicable about the generated code, except for the ABI and the set of available instructions. The choices for architecture-type are the same as for -march=architecture-type.
-mmax-stack-frame=n Warn when the stack frame of a function exceeds n bytes.
-melinux-stacksize=n Only available with the cris-axis-aout target. Arranges for indications in the program to the kernel loader that the stack of the program should be set to n bytes.
-metrax4
*-metrax100 * The options* -metrax4 and -metrax100 are synonyms for -march=v3 and -march=v8* respectively.
-mmul-bug-workaround
-mno-mul-bug-workaround Work around a bug in the muls and mulu instructions for CPU models where it applies. This option is active by default.
*-mpdebug * Enable CRIS-specific verbose debug-related information in the assembly code. This option also has the effect to turn off the* #NO_APP* formatted-code indicator to the assembler at the beginning of the assembly file.
-mcc-init Do not use condition-code results from previous instruction; always emit compare and test instructions before use of condition codes.
-mno-side-effects Do not emit instructions with side-effects in addressing modes other than post-increment.
-mstack-align
-mno-stack-align
-mdata-align
-mno-data-align
-mconst-align
-mno-const-align These options (no-options) arranges (eliminate arrangements) for the stack-frame, individual data and constants to be aligned for the maximum single data access size for the chosen CPU model. The default is to arrange for 32-bit alignment. ABI details such as structure layout are not affected by these options.
-m32-bit
-m16-bit
-m8-bit Similar to the stack- data- and const-align options above, these options arrange for stack-frame, writable data and constants to all be 32-bit, 16-bit or 8-bit aligned. The default is 32-bit alignment.
-mno-prologue-epilogue
*-mprologue-epilogue * With* -mno-prologue-epilogue*, the normal function prologue and epilogue that sets up the stack-frame are omitted and no return instructions or return sequences are generated in the code. Use this option only together with visual inspection of the compiled code: no warnings or errors are generated when call-saved registers must be saved, or storage for local variable needs to be allocated.
-mno-gotplt
*-mgotplt * With* -fpic and -fPIC*, don’t generate (do generate) instruction sequences that load addresses for functions from the PLT part of the GOT rather than (traditional on other architectures) calls to the PLT. The default is -mgotplt.
-maout Legacy no-op option only recognized with the cris-axis-aout target.
-melf Legacy no-op option only recognized with the cris-axis-elf and cris-axis-linux-gnu targets.
*-melinux * Only recognized with the cris-axis-aout target, where it selects a GNU/linux-like multilib, include files and instruction set for* -march=v8*.
-mlinux Legacy no-op option only recognized with the cris-axis-linux-gnu target.
-sim This option, recognized for the cris-axis-aout and cris-axis-elf arranges to link with input-output functions from a simulator library. Code, initialized data and zero-initialized data are allocated consecutively.
*-sim2 * Like* -sim*, but pass linker options to locate initialized data at 0x40000000 and zero-initialized data at 0x80000000.

CRXオプション

CRX

Tag Description
-mmac Enable the use of multiply-accumulate instructions. Disabled by default.
-mpush-args Push instructions will be used to pass outgoing arguments when functions are called. Enabled by default.

ダーウィンオプション

DarwinのFSF GCCは、脂肪オブジェクトファイルを作成しません。ターゲットとしてビルドされた単一のアーキテクチャ用のオブジェクトファイルを作成します。 複数の -arch オプションが使用されている場合、AppleのDarwin上のGCCはファットファイルを作成します。これは、コンパイラーまたはリンカーを複数回実行し、_lipo_で結果を結合することにより行われます。

作成されるファイルのサブタイプ( ppc7400ppc970 、または i686 など)は、-mcpu *または *-march など、GCCが対象としているISAを指定するフラグによって決定されます。 -force_cpusubtype_ALL オプションを使用して、これをオーバーライドできます。

Darwinのツールは、ISAの不一致を示すと動作が異なります。 アセンブラ_as_は、生成するファイルのサブタイプに有効な命令のみを使用できるようにするため、64ビット命令を ppc750 オブジェクトファイルに入れることはできません。 共有ライブラリのリンカ_/usr/bin/libtool_は、入力ファイルよりも制限の少ないサブタイプで共有ライブラリを作成するように要求されると失敗し、エラーを出力します(たとえば、 ppc970 オブジェクトファイルを ppc7400 ライブラリ)。 実行可能ファイルのリンカー_ld_は、実行可能ファイルに、その入力ファイルの最も制限的なサブタイプを静かに与えます。

Tag Description
-Fdir

Add the framework directory dir to the head of the list of directories to be searched for header files. These directories are interleaved with those specified by -I options and are scanned in a left-to-right order.

フレームワークディレクトリは、フレームワークが含まれるディレクトリです。 フレームワークは、。framework *で終わる *HeadersPrivateHeaders ディレクトリが直接含まれるディレクトリです。 フレームワークの名前は、。framework *を除くこのディレクトリの名前です。 フレームワークに関連付けられているヘッダーは、これら2つのディレクトリのいずれかで見つかり、 *Headers が最初に検索されます。 サブフレームワークは、フレームワークの Frameworks ディレクトリにあるフレームワークディレクトリです。 サブフレームワークヘッダーのインクルードは、サブフレームワークを含むフレームワークのヘッダー、または兄弟サブフレームワークヘッダーにのみ表示できます。 2つのサブフレームワークは、同じフレームワークで発生する場合、兄弟です。 サブフレームワークにはフレームワークと同じ名前を付けないでください。これに違反すると、警告が発行されます。 現在、サブフレームワークにサブフレームワークを含めることはできません。将来的には、これをサポートするためにメカニズムが拡張される可能性があります。 標準フレームワークは、 /System/Library/Frameworks および /Library/Frameworks にあります。 インクルードの例は、 `+#include <Framework/header.h> +`のようになります。 Framework はフレームワークの名前を示し、header.hは PrivateHeaders または Headers ディレクトリにあります。

*-gused * Emit debugging information for symbols that are used. For STABS debugging format, this enables* -feliminate-unused-debug-symbols*. This is by default ON.
-gfull Emit debugging information for all symbols and types.
-mmacosx-version-min=version

The earliest version of MacOS X that this executable will run on is version. Typical values of version include 10.1, 10.2, and 10.3.9.

このオプションのデフォルトでは、最も有用と思われる選択が行われます。

*-mone-byte-bool *a

Override the defaults for* bool so that sizeof(bool)==1*. By default sizeof(bool) *is 4 when compiling for Darwin/PowerPC and 1* when compiling for Darwin/x86, so this option has no effect on x86.

警告: -mone-byte-bool スイッチを使用すると、GCCはそのスイッチなしで生成されたコードとバイナリ互換性のないコードを生成します。 このスイッチを使用するには、システムライブラリを含むプログラム内の他のすべてのモジュールを再コンパイルする必要があります。 このスイッチを使用して、デフォルト以外のデータモデルに準拠します。

-mfix-and-continue
-ffix-and-continue
*-findirect-data * Generate code suitable for fast turn around development. Needed to enable gdb to dynamically load .o files into already running programs.* -findirect-data and -ffix-and-continue* are provided for backwards compatibility.
-all_load Loads all members of static archive libraries. See man ld(1) for more information.
-arch_errors_fatal Cause the errors having to do with files that have the wrong architecture to be fatal.
-bind_at_load Causes the output file to be marked such that the dynamic linker will bind all undefined references when the file is loaded or launched.
-bundle Produce a Mach-o bundle format file. See man ld(1) for more information.
-bundle_loader executable This option specifies the executable that will be loading the build output file being linked. See man ld(1) for more information.
-dynamiclib When passed this option, GCC will produce a dynamic library instead of an executable when linking, using the Darwin libtool command.
*-force_cpusubtype_ALL * This causes GCC’s output file to have the ALL subtype, instead of one controlled by the* -mcpu or -march* option.
-allowable_client client_name
-client_name
-compatibility_version
-current_version
-dead_strip
-dependency-file
-dylib_file
-dylinker_install_name
-dynamic
-exported_symbols_list
-filelist
-flat_namespace
-force_flat_namespace
-headerpad_max_install_names
-image_base
-init
-install_name
-keep_private_externs
-multi_module
-multiply_defined
-multiply_defined_unused
-noall_load
-no_dead_strip_inits_and_terms
-nofixprebinding
-nomultidefs
-noprebind
-noseglinkedit
-pagezero_size
-prebind
-prebind_all_twolevel_modules
-private_bundle
-read_only_relocs
-sectalign
-sectobjectsymbols
-whyload
-seg1addr
-sectcreate
-sectobjectsymbols
-sectorder
-segaddr
-segs_read_only_addr
-segs_read_write_addr
-seg_addr_table
-seg_addr_table_filename
-seglinkedit
-segprot
-segs_read_only_addr
-segs_read_write_addr
-single_module
-static
-sub_library
-sub_umbrella
-twolevel_namespace
-umbrella
-undefined
-unexported_symbols_list
-weak_reference_mismatches
-whatsloaded These options are passed to the Darwin linker. The Darwin linker man page describes them in detail.

DEC Alphaオプション

-m DEC

Tag Description
-mno-soft-float
*-msoft-float *a

Use (do not use) the hardware floating-point instructions for floating-point operations. When* -msoft-float* is specified, functions in libgcc.a will be used to perform floating-point operations. Unless they are replaced by routines that emulate the floating-point operations, or compiled in such a way as to call such emulations routines, these routines will issue floating-point operations. If you are compiling for an Alpha without floating-point operations, you must ensure that the library is built so as not to call them.

浮動小数点演算を行わないAlpha実装には、浮動小数点レジスタが必要です。

-mfp-reg
*-mno-fp-regs *a

Generate code that uses (does not use) the floating-point register set.* -mno-fp-regs implies -msoft-float*. If the floating-point register set is not used, floating point operands are passed in integer registers as if they were integers and floating-point results are passed in $0 instead of $f0. This is a non-standard calling sequence, so any function with a floating-point argument or return value called by code compiled with -mno-fp-regs must also be compiled with that option.

このオプションの一般的な使用法は、浮動小数点レジスタを使用せず、したがって保存および復元する必要のないカーネルを構築することです。

*-mieee * The Alpha architecture implements floating-point hardware optimized for maximum performance. It is mostly compliant with the IEEE floating point standard. However, for full compliance, software assistance is required. This option generates code fully IEEE compliant code except that the inexact-flag is not maintained (see below). If this option is turned on, the preprocessor macro _IEEE_FP is defined during compilation. The resulting code is less efficient but is able to correctly support denormalized numbers and exceptional IEEE values such as not-a-number and plus/minus infinity. Other Alpha compilers call this option* -ieee_with_no_inexact*.
*-mieee-with-inexact * This is like* -mieee except the generated code also maintains the IEEE inexact-flag. Turning on this option causes the generated code to implement fully-compliant IEEE math. In addition to _IEEE_FP, _IEEE_FP_EXACT is defined as a preprocessor macro. On some Alpha implementations the resulting code may execute significantly slower than the code generated by default. Since there is very little code that depends on the inexact-flag, you should normally not specify this option. Other Alpha compilers call this option -ieee_with_inexact*.
-mfp-trap-mode=trap-mode This option controls what floating-point related traps are enabled. Other Alpha compilers call this option -fptm trap-mode. The trap mode can be set to one of four values:

|Tag |Description |n |This is the default (normal) setting. The only traps that are enabled are the ones that cannot be disabled in software (e.g., division by zero trap). |u *|In addition to the traps enabled by n*, underflow traps are enabled as well. |su *|Like su*, but the instructions are marked to be safe for software completion (see Alpha architecture manual for details). |sui *|Like su*, but inexact traps are enabled as well.

-mfp-rounding-mode=rounding-mode Selects the IEEE rounding mode. Other Alpha compilers call this option -fprm rounding-mode. The rounding-mode can be one of:

|Tag |Description |n |Normal IEEE rounding mode. Floating point numbers are rounded towards the nearest machine number or towards the even machine number in case of a tie. |m |Round towards minus infinity. |c |Chopped rounding mode. Floating point numbers are rounded towards zero. |d *|Dynamic rounding mode. A field in the floating point control register (fpcr, see Alpha architecture reference manual) controls the rounding mode in effect. The C library initializes this register for rounding towards plus infinity. Thus, unless your program modifies the fpcr, d* corresponds to round towards plus infinity.

-mtrap-precision=trap-precision In the Alpha architecture, floating point traps are imprecise. This means without software assistance it is impossible to recover from a floating trap and program execution normally needs to be terminated. GCC can generate code that can assist operating system trap handlers in determining the exact location that caused a floating point trap. Depending on the requirements of an application, different levels of precisions can be selected:

|Tag |Description |p |Program precision. This option is the default and means a trap handler can only identify which program caused a floating point exception. |f |Function precision. The trap handler can determine the function that caused a floating point exception. |i |Instruction precision. The trap handler can determine the exact instruction that caused a floating point exception.

他のAlphaコンパイラは、-scope_safe *および *-resumption_safe と呼ばれる同等のオプションを提供します。
*-mieee-conformant *
This option marks the generated code as IEEE conformant. You must not use this option unless you also specify* -mtrap-precision=i and either -mfp-trap-mode=su or -mfp-trap-mode=sui*. Its only effect is to emit the line .eflag 48 in the function prologue of the generated assembly file. Under DEC Unix, this has the effect that IEEE-conformant math library routines will be linked in.
-mbuild-constants

Normally GCC examines a 32- or 64-bit integer constant to see if it can construct it from smaller constants in two or three instructions. If it cannot, it will output the constant as a literal and generate code to load it from the data segment at runtime.

このオプションを使用すると、GCCがコードを使用して_all_整数定数を構成するように要求します(さらに多くの命令(最大6つ)が必要な場合でも)。

通常、このオプションを使用して、共有ライブラリの動的ローダーを構築します。 それ自体が共有ライブラリであり、自身のデータセグメントで変数と定数を見つける前に、メモリ内で自身を再配置する必要があります。

-malpha-as
-mgas
Select whether to generate code to be assembled by the vendor-supplied assembler (-malpha-as) or by the GNU assembler -mgas.
-mbwx
-mno-bwx
-mcix
-mno-cix
-mfix
-mno-fix
-mmax
*-mno-max *
Indicate whether GCC should generate code to use the optional BWX, CIX, FIX and MAX instruction sets. The default is to use the instruction sets supported by the CPU type specified via* -mcpu=* option or that of the CPU on which GCC was built if none was specified.
-mfloat-vax
-mfloat-ieee
Generate code that uses (does not use) VAX F and G floating point arithmetic instead of IEEE single and double precision.
-mexplicit-relocs
-mno-explicit-relocs
Older Alpha assemblers provided no way to generate symbol relocations except via assembler macros. Use of these macros does not allow optimal instruction scheduling. GNU binutils as of version 2.12 supports a new syntax that allows the compiler to explicitly mark which relocations should apply to which instructions. This option is mostly useful for debugging, as GCC detects the capabilities of the assembler when it is built and sets the default accordingly.
-msmall-data
*-mlarge-data *a

When* -mexplicit-relocs is in effect, static data is accessed via gp-relative relocations. When -msmall-data* is used, objects 8 bytes long or smaller are placed in a small data area (the .sdata and .sbss sections) and are accessed via 16-bit relocations off of the $gp register. This limits the size of the small data area to 64KB, but allows the variables to be directly accessed via a single instruction.

デフォルトは -mlarge-data です。 このオプションを使用すると、データ領域は2GB未満に制限されます。 2GBを超えるデータを必要とするプログラムは、プログラムのデータセグメントではなく、ヒープにデータを割り当てるために `+ malloc `または ` mmap +`を使用する必要があります。

共有ライブラリのコードを生成する場合、-fpic *は *-msmall-data を意味し、-fPIC *は *-mlarge-data を意味します。

-msmall-text
*-mlarge-text *a

When* -msmall-text is used, the compiler assumes that the code of the entire program (or shared library) fits in 4MB, and is thus reachable with a branch instruction. When -msmall-data* is used, the compiler can assume that all local symbols share the same $gp value, and thus reduce the number of instructions required for a function call from 4 to 1.

デフォルトは -mlarge-text です。

-mcpu=cpu_type

Set the instruction set and instruction scheduling parameters for machine type cpu_type. You can specify either the EV style name or the corresponding chip number. GCC supports scheduling parameters for the EV4, EV5 and EV6 family of processors and will choose the default values for the instruction set from the processor you specify. If you do not specify a processor type, GCC will default to the processor on which the compiler was built.

_cpu_type_のサポートされている値は次のとおりです。

[cols=",",options="header",]

|Tag |Description |ev4 | |ev45 | |21064 |Schedules as an EV4 and has no instruction set extensions. |ev5 | |21164 |Schedules as an EV5 and has no instruction set extensions. |ev56 | |21164a |Schedules as an EV5 and supports the BWX extension. |pca56 | |21164pc | |21164PC |Schedules as an EV5 and supports the BWX and MAX extensions. |ev6 | |21264 |Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. |ev67 | |21264a |Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.

-mtune=cpu_type Set only the instruction scheduling parameters for machine type cpu_type. The instruction set is not changed. -mmemory-latency=time

Sets the latency the scheduler should assume for typical memory references as seen by the application. This number is highly dependent on the memory access patterns used by the application and the size of the external cache on the machine.

_time_の有効なオプションは

|Tag |Description |number |A decimal number representing clock cycles. |L1 | |L2 | |L3 | |main |The compiler contains estimates of the number of clock cycles for typical EV4 & EV5 hardware for the Level 1, 2 & 3 caches (also called Dcache, Scache, and Bcache), as well as to main memory. Note that L3 is only valid for EV5.

DEC Alpha/VMSオプション

-m DEC

Tag Description
-mvms-return-codes Return VMS condition codes from main. The default is to return POSIX style condition (e.g. error) codes.

FRVオプション

Tag Description
-mgpr-32 Only use the first 32 general purpose registers.
-mgpr-64 Use all 64 general purpose registers.
-mfpr-32 Use only the first 32 floating point registers.
-mfpr-64 Use all 64 floating point registers
-mhard-float Use hardware instructions for floating point operations.
-msoft-float Use library routines for floating point operations.
-malloc-cc Dynamically allocate condition code registers.
-mfixed-cc Do not try to dynamically allocate condition code registers, only use icc0 and fcc0.
-mdword Change ABI to use double word insns.
-mno-dword Do not use double word instructions.
-mdouble Use floating point double instructions.
-mno-double Do not use floating point double instructions.
-mmedia Use media instructions.
-mno-media Do not use media instructions.
-mmuladd Use multiply and add/subtract instructions.
-mno-muladd Do not use multiply and add/subtract instructions.
*-mfdpic * Select the FDPIC ABI, that uses function descriptors to represent pointers to functions. Without any PIC/PIE-related options, it implies* -fPIE*. With -fpic *or -fpie*, it assumes GOT entries and small data are within a 12-bit range from the GOT base address; with -fPIC *or -fPIE*, GOT offsets are computed with 32 bits.
*-minline-plt * Enable inlining of PLT entries in function calls to functions that are not known to bind locally. It has no effect without* -mfdpic*. It’s enabled by default if optimizing for speed and compiling for shared libraries (i.e., -fPIC *or -fpic*), or when an optimization option such as -O3 or above is present in the command line.
-mTLS Assume a large TLS segment when generating thread-local code.
-mtls Do not assume a large TLS segment when generating thread-local code.
*-mgprel-ro * Enable the use of GPREL relocations in the FDPIC ABI for data that is known to be in read-only sections. It’s enabled by default, except for* -fpic or -fpie*: even though it may help make the global offset table smaller, it trades 1 instruction for 4. With -fPIC *or -fPIE*, it trades 3 instructions for 4, one of which may be shared by multiple symbols, and it avoids the need for a GOT entry for the referenced symbol, so it’s more likely to be a win. If it is not, -mno-gprel-ro can be used to disable it.
*-multilib-library-pic * Link with the (library, not FD) pic libraries. It’s implied by* -mlibrary-pic*, as well as by -fPIC *and -fpic without -mfdpic*. You should never have to use it explicitly.
*-mlinked-fp * Follow the EABI requirement of always creating a frame pointer whenever a stack frame is allocated. This option is enabled by default and can be disabled with* -mno-linked-fp*.
-mlong-calls Use indirect addressing to call functions outside the current compilation unit. This allows the functions to be placed anywhere within the 32-bit address space.
-malign-labels Try to align labels to an 8-byte boundary by inserting nops into the previous packet. This option only has an effect when VLIW packing is enabled. It doesn’t create new packets; it merely adds nops to existing ones.
-mlibrary-pic Generate position-independent EABI code.
-macc-4 Use only the first four media accumulator registers.
-macc-8 Use all eight media accumulator registers.
-mpack Pack VLIW instructions.
-mno-pack Do not pack VLIW instructions.
-mno-eflags Do not mark ABI switches in e_flags.
-mcond-move

Enable the use of conditional-move instructions (default).

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mno-cond-move

Disable the use of conditional-move instructions.

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mscc

Enable the use of conditional set instructions (default).

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mno-scc

Disable the use of conditional set instructions.

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mcond-exec

Enable the use of conditional execution (default).

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mno-cond-exec

Disable the use of conditional execution.

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mvliw-branch

Run a pass to pack branches into VLIW instructions (default).

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mno-vliw-branch

Do not run a pass to pack branches into VLIW instructions.

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mmulti-cond-exec Enable optimization of && and `+

+` in conditional execution (default).

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mno-multi-cond-exec Disable optimization of && and `+

+` in conditional execution.

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mnested-cond-exec

Enable nested conditional execution optimizations (default).

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-mno-nested-cond-exec

Disable nested conditional execution optimizations.

このスイッチは、主にコンパイラのデバッグ用であり、将来のバージョンでは削除される可能性があります。

-moptimize-membar This switch removes redundant membar instructions from the compiler generated code. It is enabled by default.
-mno-optimize-membar This switch disables the automatic removal of redundant membar instructions from the generated code.
-mtomcat-stats Cause gas to print out tomcat statistics.
-mcpu=cpu Select the processor type for which to generate code. Possible values are frv, fr550, tomcat, fr500, fr450, fr405, fr400, fr300 *and simple*.

H8/300オプション

-m

Tag Description
*-mrelax * Shorten some address references at link time, when possible; uses the linker option* -relax*.
-mh Generate code for the H8/300H.
-ms Generate code for the H8S.
*-mn * Generate code for the H8S and H8/300H in the normal mode. This switch must be used either with* -mh or -ms*.
*-ms2600 * Generate code for the H8S/2600. This switch must be used with* -ms*.
-mint32 Make int data 32 bits by default.
*-malign-300 * On the H8/300H and H8S, use the same alignment rules as for the H8/300. The default for the H8/300H and H8S is to align longs and floats on 4 byte boundaries.* -malign-300* causes them to be aligned on 2 byte boundaries. This option has no effect on the H8/300.

HPPAオプション

-m HPPA

Tag Description
-march=architecture-type Generate code for the specified architecture. The choices for architecture-type are 1.0 *for PA 1.0, 1.1 for PA 1.1, and 2.0* for PA 2.0 processors. Refer to /usr/lib/sched.models on an HP-UX system to determine the proper architecture option for your machine. Code compiled for lower numbered architectures will run on higher numbered architectures, but not the other way around.
-mpa-risc-1-0
-mpa-risc-1-1
*-mpa-risc-2-0 * Synonyms for* -march=1.0*, -march=1.1, and -march=2.0 respectively.
-mbig-switch Generate code suitable for big switch tables. Use this option only if the assembler/linker complain about out of range branches within a switch table.
-mjump-in-delay Fill delay slots of function calls with unconditional jump instructions by modifying the return pointer for the function call to be the target of the conditional jump.
-mdisable-fpregs Prevent floating point registers from being used in any manner. This is necessary for compiling kernels which perform lazy context switching of floating point registers. If you use this option and attempt to perform floating point operations, the compiler will abort.
-mdisable-indexing Prevent the compiler from using indexing address modes. This avoids some rather obscure problems when compiling MIG generated code under MACH.
-mno-space-regs

Generate code that assumes the target has no space registers. This allows GCC to generate faster indirect calls and use unscaled index address modes.

このようなコードは、レベル0 PAシステムおよびカーネルに適しています。

-mfast-indirect-calls

Generate code that assumes calls never cross space boundaries. This allows GCC to emit code which performs faster indirect calls.

このオプションは、共有ライブラリまたはネストされた関数が存在する場合は機能しません。

-mfixed-range=register-range Generate code treating the given register range as fixed registers. A fixed register is one that the register allocator can not use. This is useful when compiling kernel code. A register range is specified as two registers separated by a dash. Multiple register ranges can be specified separated by a comma.
*-mlong-load-store * Generate 3-instruction load and store sequences as sometimes required by the HP-UX 10 linker. This is equivalent to the* +k* option to the HP compilers.
-mportable-runtime Use the portable calling conventions proposed by HP for ELF systems.
-mgas Enable the use of assembler directives only GAS understands.
-mschedule=cpu-type Schedule code according to the constraints for the machine type cpu-type. The choices for cpu-type are 700 7100, 7100LC, 7200, 7300 *and 8000*. Refer to /usr/lib/sched.models on an HP-UX system to determine the proper scheduling option for your machine. The default scheduling is 8000.
-mlinker-opt Enable the optimization pass in the HP-UX linker. Note this makes symbolic debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 linkers in which they give bogus error messages when linking some programs.
*-msoft-float *a

Generate output containing library calls for floating point.* Warning: the requisite libraries are not available for all HPPA targets. Normally the facilities of the machine’s usual C compiler are used, but this cannot be done directly in cross-compilation. You must make your own arrangements to provide suitable library functions for cross-compilation. The embedded target hppa1.1--pro does provide software floating point support.

-msoft-float は、出力ファイルの呼び出し規則を変更します。したがって、このオプションを使用してプログラムのすべてをコンパイルする場合にのみ役立ちます。 特に、これが機能するためには、GCCに付属のライブラリである_libgcc.a_を -msoft-float でコンパイルする必要があります。

*-msio * Generate the predefine, _SIO, for server IO. The default is* -mwsio*. This generates the predefines, __hp9000s700, __hp9000s700__ and _WSIO, for workstation IO. These options are available under HP-UX and HI-UX.
*-mgnu-ld * Use GNU ld specific options. This passes* -shared to ld when building a shared library. It is the default when GCC is configured, explicitly or implicitly, with the GNU linker. This option does not have any affect on which ld is called, it only changes what parameters are passed to that ld. The ld that is called is determined by the --with-ld configure option, GCC’s program search path, and finally by the user’s PATH*. The linker used by GCC can be printed using which ‘gcc -print-prog-name=ld‘. This option is only available on the 64 bit HP-UX GCC, i.e. configured with hppa*64--hpux*.
*-mhp-ld * Use HP ld specific options. This passes* -b to ld when building a shared library and passes +Accept TypeMismatch to ld on all links. It is the default when GCC is configured, explicitly or implicitly, with the HP linker. This option does not have any affect on which ld is called, it only changes what parameters are passed to that ld. The ld that is called is determined by the --with-ld configure option, GCC’s program search path, and finally by the user’s PATH*. The linker used by GCC can be printed using which ‘gcc -print-prog-name=ld‘. This option is only available on the 64 bit HP-UX GCC, i.e. configured with hppa*64--hpux*.
-mlong-calls

Generate code that uses long call sequences. This ensures that a call is always able to reach linker generated stubs. The default is to generate long calls only when the distance from the call site to the beginning of the function or translation unit, as the case may be, exceeds a predefined limit set by the branch type being used. The limits for normal calls are 7,600,000 and 240,000 bytes, respectively for the PA 2.0 and PA 1.X architectures. Sibcalls are always limited at 240,000 bytes.

  • -ffunction-sections* オプションを使用する場合、またはHP-UXでSOMリンカーを使用して *-mgas* および *-mno-portable-runtime* オプションを一緒に使用する場合、距離は関数の先頭から測定されます。

このオプションを使用すると、パフォーマンスが低下するため、通常は望ましくありません。 ただし、特に部分的なリンクを使用してアプリケーションを構築する場合、大規模なアプリケーションで役立ちます。

使用される長い呼び出しの種類は、アセンブラとリンカの機能、および生成されるコードの種類によって異なります。 長い絶対呼び出し、および長いpicシンボル差分呼び出しまたはpc相対呼び出しをサポートするシステムへの影響は比較的小さいはずです。 ただし、間接呼び出しはpicコードで32ビットELFシステムで使用され、非常に長いです。

-munix=unix-std

Generate compiler predefines and select a startfile for the specified UNIX standard. The choices for unix-std are 93, 95 *and 98*. 93 *is supported on all HP-UX versions. 95 is available on HP-UX 10.10 and later. 98 is available on HP-UX 11.11 and later. The default values are 93 for HP-UX 10.00, 95 for HP-UX 10.10 though to 11.00, and 98* for HP-UX 11.11 and later.

  • -munix = 93* は、GCC 3.3および3.4​​と同じ事前定義を提供します。 *-munix = 95* は、 `+ XOPEN_UNIX +`と `+ _XOPEN_SOURCE_EXTENDED +`、および開始ファイル_unix95.o_の追加の事前定義を提供します。 *-munix = 98* は、 `+ _XOPEN_UNIX +`、 `+ _XOPEN_SOURCE_EXTENDED +`、 `+ _INCLUDE__STDC_A1_SOURCE +`および `+ _INCLUDE_XOPEN_SOURCE_500 +`、および開始ファイル_unix98.o_の追加の事前定義を提供します。

このオプションは、さまざまなライブラリルーチンのインターフェイスを変更することに注意してください。 また、Cライブラリの動作動作にも影響します。 したがって、このオプションを使用するには、_extreme_の注意が必要です。

複数のUNIX標準で動作することを目的としたライブラリコードは、必要に応じて変数___xpg4_extended_mask_をテスト、設定、および復元する必要があります。 ほとんどのGNUソフトウェアはこの機能を提供していません。

*-nolibdld * Suppress the generation of link options to search libdld.sl when the* -static* option is specified on HP-UX 10 and later.
*-static *a

The HP-UX implementation of setlocale in libc has a dependency on libdld.sl. There isn’t an archive version of libdld.sl. Thus, when the* -static* option is specified, special link options are needed to resolve this dependency.

HP-UX 10以降では、-static *オプションが指定されている場合、GCCドライバーはlibdld.slとリンクするために必要なオプションを追加します。 これにより、結果のバイナリが動的になります。 64ビットポートでは、リンカーはデフォルトで動的バイナリを生成します。 *-nolibdld オプションを使用して、GCCドライバーがこれらのリンクオプションを追加しないようにすることができます。

-threads Add support for multithreading with the dce thread library under HP-UX. This option sets flags for both the preprocessor and linker.

Intel 386およびAMD x86-64オプション

-m

Tag

説明

    • -mtune = * *cpu-type

生成されたコードについて適用可能なすべての_cpu-type_に調整します。ただし、ABIと使用可能な命令セットは除きます。 _cpu-type_の選択肢は次のとおりです。

Tag Description
generic

Produce code optimized for the most common IA32/AMD64/EM64T processors. If you know the CPU on which your code will run, then you should use the corresponding* -mtune option instead of -mtune=generic*. But, if you do not know exactly what CPU users of your application will have, then you should use this option.

新しいプロセッサが市場に導入されると、このオプションの動作が変わります。 したがって、GCCの新しいバージョンにアップグレードすると、コード生成オプションが変更され、そのバージョンのGCCがリリースされたときに最も一般的なプロセッサが反映されます。

  • -march* はコンパイラが使用できる命令セットを示すため、*-march = generic *オプションはありません。また、すべてのプロセッサに適用できる汎用命令セットはありません。 対照的に、*-mtune *は、コードが最適化されているプロセッサ(または、この場合はプロセッサのコレクション)を示します。
i386 Original Intel’s i386 CPU.
i486 Intel’s i486 CPU. (No scheduling is implemented for this chip.)
i586, pentium Intel Pentium CPU with no MMX support.
pentium-mmx Intel PentiumMMX CPU based on Pentium core with MMX instruction set support.
pentiumpro Intel PentiumPro CPU.
i686 Same as generic, but when used as march option, PentiumPro instruction set will be used, so the code will run on all i686 familly chips.
pentium2 Intel Pentium2 CPU based on PentiumPro core with MMX instruction set support.
pentium3, pentium3m Intel Pentium3 CPU based on PentiumPro core with MMX and SSE instruction set support.
pentium-m Low power version of Intel Pentium3 CPU with MMX, SSE and SSE2 instruction set support. Used by Centrino notebooks.
pentium4, pentium4m Intel Pentium4 CPU with MMX, SSE and SSE2 instruction set support.
prescott Improved version of Intel Pentium4 CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
nocona Improved version of Intel Pentium4 CPU with 64-bit extensions, MMX, SSE, SSE2 and SSE3 instruction set support.
core2 Intel Core2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3 and SSSE3 instruction set support.
k6 AMD K6 CPU with MMX instruction set support.
k6-2, k6-3 Improved versions of AMD K6 CPU with MMX and 3dNOW! instruction set support.
athlon, athlon-tbird AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and SSE prefetch instructions support.
athlon-4, athlon-xp, athlon-mp Improved AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and full SSE instruction set support.
k8, opteron, athlon64, athlon-fx AMD K8 core based CPUs with x86-64 instruction set support. (This supersets MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)
amdfam10 AMD Family 10 core based CPUs with x86-64 instruction set support. (This supersets MMX, SSE, SSE2, SSE3, SSE4A, SSE5, 3dNOW!, enhanced 3dNOW!, ABM and 64-bit instruction set extensions.)
winchip-c6 IDT Winchip C6 CPU, dealt in same way as i486 with additional MMX instruction set support.
winchip2 IDT Winchip2 CPU, dealt in same way as i486 with additional MMX and 3dNOW! instruction set support.
c3 Via C3 CPU with MMX and 3dNOW! instruction set support. (No scheduling is implemented for this chip.)
c3-2 Via C3-2 CPU with MMX and SSE instruction set support. (No scheduling is implemented for this chip.)

特定の_cpu-type_を選択すると、その特定のチップに対して適切にスケジュールされますが、コンパイラは-march = _ cpu-typeオプションを使用しないとi386で実行されないコードを生成しません。

-march = cpu-type

マシンタイプ_cpu-type_の指示を生成します。 _cpu-type_の選択は、*-mtune *と同じです。 さらに、-march = cpu-typeを指定すると、-mtune = cpu-typeが暗黙的に指定されます。

-mcpu = cpu-type

*-mtune* の非推奨の同義語。
*-m386*
*-m486*
*-mpentium*
*-mpentiumpro*

これらのオプションは、それぞれ -mtune = i386-mtune = i486 *、-mtune = pentium 、および *-mtune = pentiumpro の同義語です。 これらの同義語は非推奨です。

-mfpmath = unit

選択したユニット_unit_の浮動小数点演算を生成します。 _unit_の選択肢は次のとおりです。

Tag Description
*387 *a

Use the standard 387 floating point coprocessor present majority of chips and emulated otherwise. Code compiled with this option will run almost everywhere. The temporary results are computed in 80bit precision instead of precision specified by the type resulting in slightly different results compared to most of other chips. See* -ffloat-store* for more detailed description.

これは、i386コンパイラのデフォルトの選択です。

sse

Use scalar floating point instructions present in the SSE instruction set. This instruction set is supported by Pentium3 and newer chips, in the AMD line by Athlon-4, Athlon-xp and Athlon-mp chips. The earlier version of SSE instruction set supports only single precision arithmetics, thus the double and extended precision arithmetics is still done using 387. Later version, present only in Pentium4 and the future AMD x86-64 chips supports double precision arithmetics too.

i386コンパイラの場合、SSE拡張機能を有効にしてこのオプションを有効にするには、-march = cpu-type-msse *、または *-msse2 スイッチを使用する必要があります。 x86-64コンパイラの場合、これらの拡張機能はデフォルトで有効になっています。

結果として得られるコードは、ほとんどの場合かなり高速になり、387コードの数値的な不安定性の問題を回避しますが、一時ビットが80ビットであると予測する既存のコードが破損する場合があります。

これは、x86-64コンパイラのデフォルトの選択です。

sse,387 Attempt to utilize both instruction sets at once. This effectively double the amount of available registers and on chips with separate execution units for 387 and SSE the execution resources too. Use this option with care, as it is still experimental, because the GCC register allocator does not model separate functional units well resulting in instable performance.

-masm = dialect

選択した_dialect_を使用してasm命令を出力します。 サポートされる選択肢は intel または att (デフォルト)です。 Darwinは intel をサポートしていません。

*-mieee-fp*
*-mno-ieee-fp*

コンパイラーがIEEE浮動小数点比較を使用するかどうかを制御します。 これらは、比較の結果が順序付けられていない場合を正しく処理します。

*-msoft-float*

浮動小数点のライブラリー呼び出しを含む出力を生成します。 *警告:*必要なライブラリはGCCの一部ではありません。 通常、マシンの通常のCコンパイラの機能が使用されますが、これをクロスコンパイルで直接行うことはできません。 クロスコンパイルに適したライブラリ関数を提供するには、独自の手配をする必要があります。

関数が浮動小数点の結果を80387レジスタスタックで返すマシンでは、*-msoft-float *が使用されていても、一部の浮動小数点オペコードが出力される場合があります。

*-mno-fp-ret-in-387*

関数の戻り値にFPUレジスタを使用しないでください。

通常の呼び出し規約には、FPUがない場合でも、FPUレジスタで `+ float `および ` double +`型の値を返す関数があります。 その考えは、オペレーティングシステムがFPUをエミュレートするということです。

オプション -mno-fp-ret-in-387 を使用すると、そのような値が通常のCPUレジスタに返されます。

*-mno-fancy-math-387*

一部の387エミュレーターは、387の + sin ++ cos +、および `+ sqrt +`命令をサポートしていません。 これらの命令の生成を回避するには、このオプションを指定します。 このオプションは、FreeBSD、OpenBSD、およびNetBSDのデフォルトです。 このオプションは、-march *がターゲットCPUに常にFPUがあり、命令にエミュレーションが不要であることを示す場合にオーバーライドされます。 リビジョン2.6.1以降、-funsafe-math-optimizations *スイッチも使用しない限り、これらの命令は生成されません。

*-malign-double*
*-mno-align-double*

GCCが2ワード境界または1ワード境界で + double ++ long double +、および `+ long long `変数を整列させるかどうかを制御します。 2ワード境界で「 double +」変数を整列させると、 Pentium でより高速に実行されるコードが生成されますが、メモリが増えます。

x86-64では、デフォルトで -malign-double が有効になっています。

警告: -malign-double スイッチを使用する場合、上記の型を含む構造体は、386用に公開されているアプリケーションバイナリインターフェイス仕様とは異なる方法で配置され、そのスイッチなしでコンパイルされたコードの構造体とバイナリ互換性がありません。

*-m96bit-long-double*
*-m128bit-long-double*

これらのスイッチは、「+ long double +」タイプのサイズを制御します。 i386アプリケーションバイナリインターフェイスはサイズを96ビットに指定しているため、32ビットモードでは -m96bit-long-double がデフォルトです。

最新のアーキテクチャ(Pentium以降)では、8バイトまたは16バイトの境界に整列するために `+ long double `を好むでしょう。 ABIに準拠した配列または構造体では、これは不可能です。 そのため、*-m128bit-long-double *を指定すると、 ` long double `に32ビットのゼロを追加することで、 ` long double +`を16バイト境界に揃えます。

x86-64コンパイラーでは、*-m128bit-long-double *がデフォルトの選択肢です。これは、ABIが `+ long double +`を16バイト境界に揃えることを指定しているためです。

これらのオプションはどちらも、 `+ long double +`の80ビットのx87標準を超える精度を有効にしないことに注意してください。

  • 警告:*ターゲットABIのデフォルト値をオーバーライドすると、 `+ long double `変数を含む構造体と配列のサイズが変更され、 ` long double +`をとる関数の関数呼び出し規約が変更されます。 したがって、それらは、そのスイッチなしでコンパイルされたコード内の配列または構造とバイナリ互換ではありません。

-mmlarge-data-threshold = number

*-mcmodel = medium* を指定すると、_threshold_より大きいデータがラージデータセクションに配置されます。 この値は、バイナリにリンクされているすべてのオブジェクトで同じである必要があり、デフォルトは65535です。
*-msvr3-shlib*
*-mno-svr3-shlib*

GCCが初期化されていないローカル変数を `+ bss `または ` data `セグメントに配置するかどうかを制御します。 *-msvr3-shlib* はそれらを ` bss +`に配置します。 これらのオプションは、System Vリリース3でのみ意味があります。

*-mrtd*

別の関数呼び出し規則を使用します。この規則では、固定数の引数を取る関数は、戻り時に引数をポップする + ret + _num_命令で戻ります。 引数をポップする必要がないので、これにより呼び出し元で1つの命令が保存されます。

関数属性 stdcall を使用して、この呼び出しシーケンスで個々の関数が呼び出されるように指定できます。 関数属性 cdecl を使用して、*-mrtd *オプションをオーバーライドすることもできます。

  • 警告:*この呼び出し規約は、Unixで通常使用されるものと互換性がないため、Unixコンパイラーでコンパイルされたライブラリーを呼び出す必要がある場合は使用できません。

また、可変数の引数( `+ printf +`を含む)をとるすべての関数の関数プロトタイプを提供する必要があります。そうしないと、これらの関数の呼び出しに対して誤ったコードが生成されます。

さらに、引数が多すぎる関数を呼び出すと、深刻な不正コードが発生します。 (通常、余分な引数は無害に無視されます。)

-mregparm = num

整数の引数を渡すために使用されるレジスタの数を制御します。 デフォルトでは、引数を渡すためにレジスタは使用されず、最大3つのレジスタを使用できます。 関数属性 regparm を使用して、特定の関数のこの動作を制御できます。

  • 警告:*このスイッチを使用し、_num_がゼロ以外の場合、ライブラリを含め、同じ値を持つすべてのモジュールをビルドする必要があります。 これには、システムライブラリと起動モジュールが含まれます。
*-msseregparm*

floatおよびdoubleの引数と戻り値の規則を渡すSSEレジスタを使用します。 関数属性 sseregparm を使用して、特定の関数のこの動作を制御できます。

  • 警告:*このスイッチを使用する場合、ライブラリを含む同じ値を持つすべてのモジュールをビルドする必要があります。 これには、システムライブラリと起動モジュールが含まれます。
    • -mpreferred-stack-boundary = * *num

スタック境界を2から_num_バイト境界に揃えて保持しようとします。* -mpreferred-stack-boundary *が指定されていない場合、デフォルトは4(16バイトまたは128ビット)です。

PentiumおよびPentiumProでは、「+ double 」および「 long double 」の値を8バイト境界に揃える( *-malign-double* を参照)か、実行時のパフォーマンスが大幅に低下します。 Pentium IIIでは、ストリーミングSIMD拡張機能(SSE)データ型 ` __ m128 +`は、16バイトにアライメントされていない場合、適切に動作しない場合があります。

スタック上でこの値を正しく整列させるには、スタックの境界を、スタックに格納されている値に必要な境界と同じ位置に配置する必要があります。 さらに、すべての関数は、スタックを整列させ続けるように生成されなければなりません。 したがって、優先順位の低いスタック境界を使用してコンパイルされた関数から優先順位の高いスタック境界を使用してコンパイルされた関数を呼び出すと、スタックが誤って整列される可能性があります。 コールバックを使用するライブラリは常にデフォルト設定を使用することをお勧めします。

この余分なアライメントは余分なスタックスペースを消費し、一般にコードサイズを増加させます。 組み込みシステムやオペレーティングシステムカーネルなど、スタックスペースの使用に敏感なコードでは、優先アライメントを -mpreferred-stack-boundary = 2 に減らしたい場合があります。

*-mmmx*
*-mno-mmx*
*-msse*
*-mno-sse*
*-msse2*
*-mno-sse2*
*-msse3*
*-mno-sse3*
*-mssse3*
*-mno-ssse3*
*-msse4a*
*-mno-sse4a*
*-msse5*
*-mno-sse5*
*-m3dnow*
*-mno-3dnow*
*-mpopcnt*
*-mno-popcnt*
*-mabm*
*-mno-abm*

これらのスイッチは、MMX、SSE、SSE2、3DNow!の命令の使用を有効または無効にします。 拡張命令セット。 これらの拡張機能は、組み込み関数としても使用できます。これらのスイッチによって有効または無効にされる機能の詳細については、* X86組み込み関数*を参照してください。

(387命令ではなく)浮動小数点コードからSSE/SSE2命令を自動的に生成するには、*-mfpmath = sse *を参照してください。

これらのオプションにより、GCCは、*-mfpmath = sse *がなくても、生成されたコードでこれらの拡張命令を使用できます。 ランタイムCPU検出を実行するアプリケーションは、適切なフラグを使用して、サポートされているアーキテクチャごとに個別のファイルをコンパイルする必要があります。 特に、CPU検出コードを含むファイルは、これらのオプションなしでコンパイルする必要があります。

*-mpush-args*
*-mno-push-args*

PUSH操作を使用して、発信パラメーターを保存します。 この方法は短く、通常はSUB/MOV操作を使用する方法と同じくらい高速で、デフォルトで有効になっています。 場合によっては、スケジュールを改善し、依存関係を減らすため、これを無効にするとパフォーマンスが向上する場合があります。

*-maccumulate-outgoing-args*

有効にした場合、発信引数に必要なスペースの最大量が関数プロローグで計算されます。 これは、優先スタック境界が2に等しくない場合の依存関係の削減、スケジューリングの改善、スタック使用量の削減により、ほとんどの最新のCPUで高速です。 欠点は、コードサイズの著しい増加です。 このスイッチは -mno-push-args を意味します。

*-mthreads*
*Mingw32* でスレッドセーフな例外処理をサポートします。 スレッドセーフな例外処理に依存するコードは、すべてのコードをコンパイルし、*-mthreads *オプションでリンクする必要があります。 コンパイル時に、*-mthreads *は *-D_MT* を定義します。リンクするとき、特別なスレッドヘルパーライブラリ *-lmingwthrd* にリンクします。このライブラリは、スレッドごとに例外処理データをクリーンアップします。
*-mno-align-stringops*

インライン文字列操作の宛先を整列しません。 このスイッチは、コードサイズを縮小し、宛先が既に整列している場合にパフォーマンスを向上させますが、GCCはそれを認識しません。

*-minline-all-stringops*

デフォルトでは、GCCは、宛先が少なくとも4バイト境界に位置合わせされていることがわかっている場合にのみ、文字列操作をインライン化します。 これにより、インライン化が増加し、コードサイズが増加しますが、短い長さの高速なmemcpy、strlen、memsetに依存するコードのパフォーマンスが向上する場合があります。

*-momit-leaf-frame-pointer*

リーフ関数のレジスタにフレームポインターを保持しないでください。 これにより、フレームポインターの保存、設定、復元の指示が回避され、リーフ関数で追加のレジスタが使用可能になります。 オプション -fomit-frame-pointer は、デバッグを困難にする可能性のあるすべての関数のフレームポインターを削除します。

*-mtls-direct-seg-refs*
*-mno-tls-direct-seg-refs*

TLSセグメントレジスタからのオフセットでTLS変数にアクセスできるかどうか(32ビットの場合は +%gs +、64ビットの場合は +%fs +)、またはスレッドベースポインターを追加する必要があるかどうかを制御します。 これが合法かどうかは、オペレーティングシステムと、TLSエリア全体をカバーするようにセグメントをマップするかどうかによって異なります。

GNU libcを使用するシステムの場合、デフォルトはオンです。

-m AMD

Tag Description
-m32
-m64 Generate code for a 32-bit or 64-bit environment. The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any i386 system. The 64-bit environment sets int to 32 bits and long and pointer to 64 bits and generates code for AMD’s x86-64 architecture.
*-mno-red-zone * Do not use a so called red zone for x86-64 code. The red zone is mandated by the x86-64 ABI, it is a 128-byte area beyond the location of the stack pointer that will not be modified by signal or interrupt handlers and therefore can be used for temporary data without adjusting the stack pointer. The flag* -mno-red-zone* disables this red zone.
-mcmodel=small Generate code for the small code model: the program and its symbols must be linked in the lower 2 GB of the address space. Pointers are 64 bits. Programs can be statically or dynamically linked. This is the default code model.
-mcmodel=kernel Generate code for the kernel code model. The kernel runs in the negative 2 GB of the address space. This model has to be used for Linux kernel code.
-mcmodel=medium Generate code for the medium model: The program is linked in the lower 2 GB of the address space but symbols can be located anywhere in the address space. Programs can be statically or dynamically linked, but building of shared libraries are not supported with the medium model.
-mcmodel=large Generate code for the large model: This model makes no assumptions about addresses and sizes of sections. Currently GCC does not implement this model.
-mfused-madd
-mno-fused-madd Enable automatic generation of fused floating point multiply-add instructions if the ISA supports such instructions. The -mfused-madd option is on by default.

IA-64オプション

-m IA-64

Tag Description
-mbig-endian Generate code for a big endian target. This is the default for HP-UX.
-mlittle-endian Generate code for a little endian target. This is the default for AIX5 and GNU/Linux.
-mgnu-as
-mno-gnu-as Generate (or don’t) code for the GNU assembler. This is the default.
-mgnu-ld
-mno-gnu-ld Generate (or don’t) code for the GNU linker. This is the default.
-mno-pic Generate code that does not use a global pointer register. The result is not position independent code, and violates the IA-64 ABI.
-mvolatile-asm-stop
-mno-volatile-asm-stop Generate (or don’t) a stop bit immediately before and after volatile asm statements.
-mregister-names
*-mno-register-names * Generate (or don’t)* in*, loc, and out register names for the stacked registers. This may make assembler output more readable.
-mno-sdata
-msdata Disable (or enable) optimizations that use the small data section. This may be useful for working around optimizer bugs.
-mconstant-gp Generate code that uses a single constant global pointer value. This is useful when compiling kernel code.
*-mauto-pic * Generate code that is self-relocatable. This implies* -mconstant-gp*. This is useful when compiling firmware code.
-minline-float-divide-min-latency Generate code for inline divides of floating point values using the minimum latency algorithm.
-minline-float-divide-max-throughput Generate code for inline divides of floating point values using the maximum throughput algorithm.
-minline-int-divide-min-latency Generate code for inline divides of integer values using the minimum latency algorithm.
-minline-int-divide-max-throughput Generate code for inline divides of integer values using the maximum throughput algorithm.
-minline-sqrt-min-latency Generate code for inline square roots using the minimum latency algorithm.
-minline-sqrt-max-throughput Generate code for inline square roots using the maximum throughput algorithm.
-mno-dwarf2-asm
-mdwarf2-asm Don’t (or do) generate assembler code for the DWARF2 line number debugging info. This may be useful when not using the GNU assembler.
-mearly-stop-bits
-mno-early-stop-bits Allow stop bits to be placed earlier than immediately preceding the instruction that triggered the stop bit. This can improve instruction scheduling, but does not always do so.
-mfixed-range=register-range Generate code treating the given register range as fixed registers. A fixed register is one that the register allocator can not use. This is useful when compiling kernel code. A register range is specified as two registers separated by a dash. Multiple register ranges can be specified separated by a comma.
-mtls-size=tls-size Specify bit size of immediate TLS offsets. Valid values are 14, 22, and 64.
-mtune=cpu-type Tune the instruction scheduling for a particular CPU, Valid values are itanium, itanium1, merced, itanium2, and mckinley.
-mt
-pthread Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. It does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it. These are HP-UX specific flags.
-milp32
-mlp64 Generate code for a 32-bit or 64-bit environment. The 32-bit environment sets int, long and pointer to 32 bits. The 64-bit environment sets int to 32 bits and long and pointer to 64 bits. These are HP-UX specific flags.

M32Cオプション

Tag Description
-mcpu=name Select the CPU for which code is generated. name may be one of r8c *for the R8C/Tiny series, m16c for the M16C (up to/60) series, m32cm for the M16C/80 series, or m32c* for the M32C/80 series.
-msim Specifies that the program will be run on the simulator. This causes an alternate runtime library to be linked in which supports, for example, file I/O. You must not use this option when generating programs that will run on real hardware; you must provide your own runtime library for whatever I/O functions are needed.
-memregs=number Specifies the number of memory-based pseudo-registers GCC will use during code generation. These pseudo-registers will be used like real registers, so there is a tradeoff between GCC’s ability to fit the code into available registers, and the performance penalty of using memory instead of registers. Note that all modules in a program must be compiled with the same value for this option. Because of that, you must not use this option with the default runtime libraries gcc builds.

M32R/Dオプション

-m

Tag Description
-m32r2 Generate code for the M32R/2.
-m32rx Generate code for the M32R/X.
-m32r Generate code for the M32R. This is the default.
-mmodel=small

Assume all objects live in the lower 16MB of memory (so that their addresses can be loaded with the ld24 instruction), and assume all subroutines are reachable with the bl instruction. This is the default.

特定のオブジェクトのアドレス可能度は、 `+ model +`属性で設定できます。

-mmodel=medium Assume objects may be anywhere in the 32-bit address space (the compiler will generate seth/add3 instructions to load their addresses), and assume all subroutines are reachable with the bl instruction.
-mmodel=large Assume objects may be anywhere in the 32-bit address space (the compiler will generate seth/add3 instructions to load their addresses), and assume subroutines may not be reachable with the bl instruction (the compiler will generate the much slower seth/add3/jl instruction sequence).
*-msdata=none *a

Disable use of the small data area. Variables will be put into one of* .data*, bss, or .rodata (unless the section attribute has been specified). This is the default.

小さなデータ領域は、。sdata *および *.sbss セクションで構成されています。 オブジェクトは、これらのセクションのいずれかを使用して、 `+ section +`属性で小さなデータ領域に明示的に配置できます。

-msdata=sdata Put small global and static data in the small data area, but do not generate special code to reference them.
-msdata=use Put small global and static data in the small data area, and generate special instructions to reference them.
*-G *num

Put global and static objects less than or equal to num bytes into the small data or bss sections instead of the normal data or bss sections. The default value of num is 8. The* -msdata option must be set to one of sdata or use* for this option to have any effect.

すべてのモジュールは、同じ -G _num_値でコンパイルする必要があります。 _num_の異なる値でコンパイルすると、動作する場合と動作しない場合があります。そうでない場合、リンカーはエラーメッセージを表示します---誤ったコードは生成されません。

-mdebug Makes the M32R specific code in the compiler display some statistics that might help in debugging programs.
-malign-loops Align all loops to a 32-byte boundary.
-mno-align-loops Do not enforce a 32-byte alignment for loops. This is the default.
-missue-rate=number Issue number instructions per cycle. number can only be 1 or 2.
-mbranch-cost=number number can only be 1 or 2. If it is 1 then branches will be preferred over conditional code, if it is 2, then the opposite will apply.
-mflush-trap=number Specifies the trap number to use to flush the cache. The default is 12. Valid numbers are between 0 and 15 inclusive.
-mno-flush-trap Specifies that the cache cannot be flushed by using a trap.
-mflush-func=name Specifies the name of the operating system function to call to flush the cache. The default is _flush_cache, but a function call will only be used if a trap is not available.
-mno-flush-func Indicates that there is no OS function for flushing the cache.

M680x0オプション

-m

Tag Description
-m68000
-mc68000

Generate output for a 68000. This is the default when the compiler is configured for 68000-based systems.

68008、68302、68306、68307、68322、68328、および68356を含む、68000またはEC000コアを備えたマイクロコントローラーにこのオプションを使用します。

-m68020
-mc68020 Generate output for a 68020. This is the default when the compiler is configured for 68020-based systems.
*-m68881 * Generate output containing 68881 instructions for floating point. This is the default for most 68020 systems unless* --nfp* was specified when the compiler was configured.
-m68030 Generate output for a 68030. This is the default when the compiler is configured for 68030-based systems.
-m68040

Generate output for a 68040. This is the default when the compiler is configured for 68040-based systems.

このオプションは、68040上のソフトウェアによってエミュレートされる必要がある68881/68882命令の使用を禁止します。 68040にこれらの命令をエミュレートするコードがない場合は、このオプションを使用します。

-m68060

Generate output for a 68060. This is the default when the compiler is configured for 68060-based systems.

このオプションは、68060上のソフトウェアによってエミュレートされる必要がある68020および68881/68882命令の使用を禁止します。 68060にこれらの命令をエミュレートするコードがない場合は、このオプションを使用します。

-mcpu32

Generate output for a CPU32. This is the default when the compiler is configured for CPU32-based systems.

このオプションは、68330、68331、68332、68333、68334、68336、68340、68341、68349、および68360を含む、CPU32またはCPU32 +コアを備えたマイクロコントローラーに使用します。

-m5200

Generate output for a 520X coldfire family cpu. This is the default when the compiler is configured for 520X-based systems.

MCF5202、MCF5203、MCF5204、MCF5202など、5200コアのマイクロコントローラーでこのオプションを使用します。

-m68020-40 Generate output for a 68040, without using any of the new instructions. This results in code which can run relatively efficiently on either a 68020/68881 or a 68030 or a 68040. The generated code does use the 68881 instructions that are emulated on the 68040.
-m68020-60 Generate output for a 68060, without using any of the new instructions. This results in code which can run relatively efficiently on either a 68020/68881 or a 68030 or a 68040. The generated code does use the 68881 instructions that are emulated on the 68060.
*-msoft-float * Generate output containing library calls for floating point.* Warning: the requisite libraries are not available for all m68k targets. Normally the facilities of the machine’s usual C compiler are used, but this can’t be done directly in cross-compilation. You must make your own arrangements to provide suitable library functions for cross-compilation. The embedded targets m68k--aout *and m68k--coff do provide software floating point support.
-mshort Consider type int to be 16 bits wide, like short int. Additionally, parameters passed on the stack are also aligned to a 16-bit boundary even on targets whose API mandates promotion to 32-bit.
*-mnobitfield * Do not use the bit-field instructions. The* -m68000*, -mcpu32 *and -m5200 options imply -mnobitfield*.
*-mbitfield * Do use the bit-field instructions. The* -m68020 option implies -mbitfield*. This is the default if you use a configuration designed for a 68020.
-mrtd

Use a different function-calling convention, in which functions that take a fixed number of arguments return with the rtd instruction, which pops their arguments while returning. This saves one instruction in the caller since there is no need to pop the arguments there.

この呼び出し規則は、Unixで通常使用されるものと互換性がないため、Unixコンパイラでコンパイルされたライブラリを呼び出す必要がある場合は使用できません。

また、可変数の引数( `+ printf +`を含む)をとるすべての関数の関数プロトタイプを提供する必要があります。そうしないと、これらの関数の呼び出しに対して誤ったコードが生成されます。

さらに、引数が多すぎる関数を呼び出すと、深刻な不正コードが発生します。 (通常、余分な引数は無害に無視されます。)

「+ rtd +」命令は、68010、68020、68030、68040、68060、およびCPU32プロセッサでサポートされていますが、68000または5200ではサポートされていません。

-malign-int
-mno-align-int

Control whether GCC aligns int, long, long long, float, double, and long double variables on a 32-bit boundary (-malign-int) or a 16-bit boundary (-mno-align-int). Aligning variables on 32-bit boundaries produces code that runs somewhat faster on processors with 32-bit busses at the expense of more memory.

警告: -malign-int スイッチを使用すると、GCCは上記のタイプを含む構造を、m68kのほとんどの公開アプリケーションバイナリインターフェイス仕様とは異なる方法で整列します。

*-mpcrel * Use the pc-relative addressing mode of the 68000 directly, instead of using a global offset table. At present, this option implies* -fpic*, allowing at most a 16-bit offset for pc-relative addressing. -fPIC *is not presently supported with -mpcrel*, though this could be supported for 68020 and higher processors.
-mno-strict-align
-mstrict-align Do not (do) assume that unaligned memory references will be handled by the system.
*-msep-data * Generate code that allows the data segment to be located in a different area of memory from the text segment. This allows for execute in place in an environment without virtual memory management. This option implies* -fPIC*.
-mno-sep-data Generate code that assumes that the data segment follows the text segment. This is the default.
*-mid-shared-library * Generate code that supports shared libraries via the library ID method. This allows for execute in place and shared libraries in an environment without virtual memory management. This option implies* -fPIC*.
-mno-id-shared-library Generate code that doesn’t assume ID based shared libraries are being used. This is the default.
-mshared-library-id=n Specified the identification number of the ID based shared library being compiled. Specifying a value of 0 will generate more compact code, specifying other values will force the allocation of that number to the current library but is no more space or time efficient than omitting this option.

M68hc1xオプション

-m

Tag Description
-m6811
-m68hc11 Generate output for a 68HC11. This is the default when the compiler is configured for 68HC11-based systems.
-m6812
-m68hc12 Generate output for a 68HC12. This is the default when the compiler is configured for 68HC12-based systems.
-m68S12
-m68hcs12 Generate output for a 68HCS12.
-mauto-incdec Enable the use of 68HC12 pre and post auto-increment and auto-decrement addressing modes.
-minmax
-nominmax Enable the use of 68HC12 min and max instructions.
-mlong-calls
-mno-long-calls Treat all calls as being far away (near). If calls are assumed to be far away, the compiler will use the call instruction to call a function and the rtc instruction for returning.
-mshort Consider type int to be 16 bits wide, like short int.
-msoft-reg-count=count Specify the number of pseudo-soft registers which are used for the code generation. The maximum number is 32. Using more pseudo-soft register may or may not result in better code depending on the program. The default is 4 for 68HC11 and 2 for 68HC12.

MCoreオプション

-m

Tag Description
-mhardlit
-mno-hardlit Inline constants into the code stream if it can be done in two instructions or less.
-mdiv
-mno-div Use the divide instruction. (Enabled by default).
-mrelax-immediate
-mno-relax-immediate Allow arbitrary sized immediates in bit operations.
-mwide-bitfields
-mno-wide-bitfields Always treat bit-fields as int-sized.
-m4byte-functions
-mno-4byte-functions Force all functions to be aligned to a four byte boundary.
-mcallgraph-data
-mno-callgraph-data Emit callgraph information.
-mslow-bytes
-mno-slow-bytes Prefer word access when reading byte quantities.
-mlittle-endian
-mbig-endian Generate code for a little endian target.
-m210
-m340 Generate code for the 210 processor.

MIPSオプション

Tag Description
-EB Generate big-endian code.
*-EL * Generate little-endian code. This is the default for* mips*el--* configurations.
-march=arch

Generate code that will run on arch, which can be the name of a generic MIPS ISA, or the name of a particular processor. The ISA names are: mips1, mips2, mips3, mips4, mips32, mips32r2, and mips64. The processor names are: 4kc, 4km, 4kp, 5kc, 5kf, 20kc, 24k, 24kc, 24kf, 24kx, m4k, orion, r2000, r3000, r3900, r4000, r4400, r4600, r4650, r6000, r8000, rm7000, rm9000, sb1, sr71000, vr4100, vr4111, vr4120, vr4130, vr4300, vr5000, vr5400 *and vr5500*. The special value from-abi *selects the most compatible architecture for the selected ABI (that is, mips1 for 32-bit ABIs and mips3* for 64-bit ABIs).

プロセッサ名では、最後の 000k と省略できます(たとえば、-march = r2k *)。 プレフィックスはオプションであり、 *vrr と書くことができます。

GCCは、このオプションの値に基づいて2つのマクロを定義します。 1つ目は MIPS_ARCH で、ターゲットアーキテクチャの名前を文字列として提供します。 2番目の形式は* ' MIPS_ARCH _' * fooの形式で、_foo_は _MIPS_ARCH の大文字の値です。 たとえば、-march = r2000 *は *_MIPS_ARCHr2000 に設定し、マクロ _MIPS_ARCH_R2000 を定義します。

  • _MIPS_ARCH* マクロは上記のプロセッサ名を使用することに注意してください。 言い換えると、完全なプレフィックスを持ち、 *000* を *k* に短縮しません。 *from-abi* の場合、マクロは解決されたアーキテクチャ( *mips1* または *mips3* のいずれか)に名前を付けます。 *-march* オプションが指定されていない場合、デフォルトのアーキテクチャを指定します。
-mtune=arch

Optimize for arch. Among other things, this option controls the way instructions are scheduled, and the perceived cost of arithmetic operations. The list of arch values is the same as for -march.

このオプションを使用しない場合、GCCは -march で指定されたプロセッサー用に最適化します。 -march-mtune を一緒に使用することで、プロセッサフ​​ァミリで実行されるコードを生成できますが、そのファミリの特定のメンバーのコードを最適化できます。

  • -mtune* は、マクロ *_MIPS_TUNE* および* *_ MIPS_TUNE _* * __ foo__を定義します。これらは上記の *-march* と同じように機能します。
*-mips1 * Equivalent to* -march=mips1*.
*-mips2 * Equivalent to* -march=mips2*.
*-mips3 * Equivalent to* -march=mips3*.
*-mips4 * Equivalent to* -march=mips4*.
*-mips32 * Equivalent to* -march=mips32*.
*-mips32r2 * Equivalent to* -march=mips32r2*.
*-mips64 * Equivalent to* -march=mips64*.
-mips16
-mno-mips16 Generate (do not generate) MIPS16 code. If GCC is targetting a MIPS32 or MIPS64 architecture, it will make use of the MIPS16e ASE.
-mabi=32
-mabi=o64
-mabi=n32
-mabi=64
-mabi=eabi

Generate code for the given ABI.

EABIには32ビットと64ビットのバリアントがあることに注意してください。 GCCは通常、64ビットアーキテクチャを選択すると64ビットコードを生成しますが、代わりに -mgp32 を使用して32ビットコードを取得できます。

O64 ABIの詳細については、<http://gcc.gnu.org/projects/mipso64-abil>を参照してください。

-mabicalls
*-mno-abicalls * Generate (do not generate) SVR4-style position-independent code.* -mabicalls* is the default for SVR4-based systems.
-mxgot
-mno-xgot

Lift (do not lift) the usual restrictions on the size of the global offset table.

GCCは通常、単一の命令を使用してGOTから値をロードします。 これは比較的効率的ですが、GOTが約64kより小さい場合にのみ機能します。 これより大きな値を設定すると、リンカーは次のようなエラーを報告します。

++

a|

        relocation truncated to fit: R_MIPS_GOT16 foobar

この場合は、-mxgot *を使用してコードを再コンパイルする必要があります。 その後、非常に大きなGOTで動作しますが、グローバルシンボルの値を取得するには3つの命令が必要になるため、効率が低下します。

一部のリンカーは複数のGOTを作成できることに注意してください。 このようなリンカがある場合、1つのオブジェクトファイルが64k相当のGOTエントリにアクセスする場合にのみ、</emphasis>-mxgot *を使用する必要があります。 非常に少ないです。

GCCが位置に依存しないコードを生成していない限り、これらのオプションは効果がありません。

-mgp32
Assume that general-purpose registers are 32 bits wide.
-mgp64
Assume that general-purpose registers are 64 bits wide.
-mfp32
Assume that floating-point registers are 32 bits wide.
-mfp64
Assume that floating-point registers are 64 bits wide.
-mhard-float
Use floating-point coprocessor instructions.
-msoft-float
Do not use floating-point coprocessor instructions. Implement floating-point calculations using library calls instead.
-msingle-float
Assume that the floating-point coprocessor only supports single-precision operations.
-mdouble-float
Assume that the floating-point coprocessor supports double-precision operations. This is the default.
-mdsp
-mno-dsp
Use (do not use) the MIPS DSP ASE.
-mpaired-single
-mno-paired-single
Use (do not use) paired-single floating-point instructions. This option can only be used when generating 64-bit code and requires hardware floating-point support to be enabled.
-mips3d
*-mno-mips3d *
Use (do not use) the MIPS-3D ASE. The option* -mips3d implies -mpaired-single*.
*-mlong64 *
Force long types to be 64 bits wide. See* -mlong32* for an explanation of the default and the way that the pointer size is determined.
-mlong32

Force long, int, and pointer types to be 32 bits wide.

+ int + s、 + long + s、およびポインターのデフォルトサイズは、ABIによって異なります。 サポートされているすべてのABIは32ビットの「+ int 」を使用します。 n64 ABIは、64ビットEABIと同様に、64ビットの「 long 」を使用します。その他は32ビットの「 long 」を使用します。 ポインタは、 ` long +` sと同じサイズ、または整数レジスタと同じサイズのいずれか小さい方です。

-msym32
*-mno-sym32 *
Assume (do not assume) that all symbols have 32-bit values, regardless of the selected ABI. This option is useful in combination with* -mabi=64 and -mno-abicalls* because it allows GCC to generate shorter and faster references to symbolic addresses.
-G num

Put global and static items less than or equal to num bytes into the small data or bss section instead of the normal data or bss section. This allows the data to be accessed using a single instruction.

すべてのモジュールは、同じ -G _num_値でコンパイルする必要があります。

-membedded-data
-mno-embedded-data
Allocate variables to the read-only data section first if possible, then next in the small data section if possible, otherwise in data. This gives slightly slower code than the default, but reduces the amount of RAM required when executing, and thus may be preferred for some embedded systems.
-muninit-const-in-rodata
*-mno-uninit-const-in-rodata *
Put uninitialized const variables in the read-only data section. This option is only meaningful in conjunction with* -membedded-data*.
-msplit-addresses
*-mno-split-addresses *
Enable (disable) use of the %hi() and %lo() assembler relocation operators. This option has been superseded by* -mexplicit-relocs* but is retained for backwards compatibility.
-mexplicit-relocs
*-mno-explicit-relocs *a

Use (do not use) assembler relocation operators when dealing with symbolic addresses. The alternative, selected by* -mno-explicit-relocs*, is to use assembler macros instead.

-mexplicit-relocs は、GCCが再配置演算子をサポートするアセンブラーを使用するように構成されている場合のデフォルトです。

-mcheck-zero-division
*-mno-check-zero-division *
Trap (do not trap) on integer division by zero. The default is* -mcheck-zero-division*.
-mdivide-traps
*-mdivide-breaks *a

MIPS systems check for division by zero by generating either a conditional trap or a break instruction. Using traps results in smaller code, but is only supported on MIPS II and later. Also, some versions of the Linux kernel have a bug that prevents trap from generating the proper signal (SIGFPE). Use* -mdivide-traps to allow conditional traps on architectures that support them and -mdivide-breaks* to force the use of breaks.

デフォルトは通常 -mdivide-traps ですが、これは設定時に*-with-divide = breaks を使用して上書きできます。 *-mno-check-zero-division を使用すると、ゼロ除算チェックを完全に無効にできます。

-mmemcpy
*-mno-memcpy *
Force (do not force) the use of memcpy() for non-trivial block moves. The default is* -mno-memcpy*, which allows GCC to inline most constant-sized copies.
-mlong-calls
-mno-long-calls

Disable (do not disable) use of the jal instruction. Calling functions using jal is more efficient but requires the caller and callee to be in the same 256 megabyte segment.

このオプションはabicallsコードには影響しません。 デフォルトは -mno-long-calls です。

-mmad
-mno-mad
Enable (disable) use of the mad, madu and mul instructions, as provided by the R4650 ISA.
-mfused-madd
*-mno-fused-madd *a

Enable (disable) use of the floating point multiply-accumulate instructions, when they are available. The default is* -mfused-madd*.

積和命令を使用する場合、中間積は無限の精度で計算され、FCSRゼロへのフラッシュビットの影響を受けません。 これは状況によっては望ましくない場合があります。

*-nocpp *
Tell the MIPS assembler to not run its preprocessor over user assembler files (with a* .s* suffix) when assembling them.
-mfix-r4000
-mno-fix-r4000

Work around certain R4000 CPU errata:

[cols=",",options="header",]

|Tag |Description |- |A double-word or a variable shift may give an incorrect result if executed immediately after starting an integer division. |- |A double-word or a variable shift may give an incorrect result if executed while an integer multiplication is in progress. |- |An integer division may give an incorrect result if started in a delay slot of a taken branch or a jump.

-mfix-r4400 -mno-fix-r4400 Work around certain R4400 CPU errata:

|Tag |Description |- |A double-word or a variable shift may give an incorrect result if executed immediately after starting an integer division.

-mfix-vr4120 *-mno-fix-vr4120 *a

Work around certain VR4120 errata:

[cols=",",options="header",]

|Tag |Description |- |dmultu does not always produce the correct result. |- |div and ddiv do not always produce the correct result if one of the operands is negative.

部門の正誤表の回避策は、_libgcc.a_の特別な機能に依存しています。 現在、これらの機能は `+ mips64vr* -elf +`設定によってのみ提供されています。

他のVR4120エラッタでは、特定の命令ペアの間にnopを挿入する必要があります。 これらのエラッタは、GCC自体ではなく、アセンブラによって処理されます。

-mfix-vr4130
Work around the VR4130 mflo/mfhi errata. The workarounds are implemented by the assembler rather than by GCC, although GCC will avoid using mflo and mfhi if the VR4130 macc, macchi, dmacc and dmacchi instructions are available instead.
-mfix-sb1
-mno-fix-sb1
Work around certain SB-1 CPU core errata. (This flag currently works around the SB-1 revision 2 F1 and F2 floating point errata.)
-mflush-func=func
*-mno-flush-func *
Specifies the function to call to flush the I and D caches, or to not call any such function. If called, the function must take the same arguments as the common _flush_func(), that is, the address of the memory range for which the cache is being flushed, the size of the memory range, and the number 3 (to flush both caches). The default depends on the target GCC was configured for, but commonly is either* _flush_func or __cpu_flush*.
-mbranch-likely
-mno-branch-likely
Enable or disable use of Branch Likely instructions, regardless of the default for the selected architecture. By default, Branch Likely instructions may be generated if they are supported by the selected architecture. An exception is for the MIPS32 and MIPS64 architectures and processors which implement those architectures; for those, Branch Likely instructions will not be generated by default because the MIPS32 and MIPS64 architectures specifically deprecate their use.
-mfp-exceptions
-mno-fp-exceptions

Specifies whether FP exceptions are enabled. This affects how we schedule FP instructions for some processors. The default is that FP exceptions are enabled.

たとえば、SB-1では、FP例外が無効になっており、64ビットコードを出力している場合、両方のFPパイプを使用できます。 それ以外の場合、FPパイプは1つしか使用できません。

-mvr4130-align
-mno-vr4130-align

The VR4130 pipeline is two-way superscalar, but can only issue two instructions together if the first one is 8-byte aligned. When this option is enabled, GCC will align pairs of instructions that it thinks should execute in parallel.

このオプションは、VR4130用に最適化する場合にのみ効果があります。 通常、コードは高速になりますが、コードが大きくなります。 デフォルトでは、最適化レベル -O3 で有効になっています。

MMIXオプション

MMIX:

Tag Description
-mlibfuncs
-mno-libfuncs Specify that intrinsic library functions are being compiled, passing all values in registers, no matter the size.
-mepsilon
-mno-epsilon Generate floating-point comparison instructions that compare with respect to the rE epsilon register.
-mabi=mmixware
-mabi=gnu Generate code that passes function parameters and return values that (in the called function) are seen as registers $0 and up, as opposed to the GNU ABI which uses global registers $231 and up.
-mzero-extend
-mno-zero-extend When reading data from memory in sizes shorter than 64 bits, use (do not use) zero-extending load instructions by default, rather than sign-extending ones.
-mknuthdiv
*-mno-knuthdiv * Make the result of a division yielding a remainder have the same sign as the divisor. With the default,* -mno-knuthdiv*, the sign of the remainder follows the sign of the dividend. Both methods are arithmetically valid, the latter being almost exclusively used.
-mtoplevel-symbols
*-mno-toplevel-symbols * Prepend (do not prepend) a* :* to all global symbols, so the assembly code can be used with the PREFIX assembly directive.
*-melf * Generate an executable in the ELF format, rather than the default* mmo format used by the mmix* simulator.
-mbranch-predict
-mno-branch-predict Use (do not use) the probable-branch instructions, when static branch prediction indicates a probable branch.
-mbase-addresses
*-mno-base-addresses * Generate (do not generate) code that uses base addresses. Using a base address automatically generates a request (handled by the assembler and the linker) for a constant to be set up in a global register. The register is used for one or more base address requests within the range 0 to 255 from the value held in the register. The generally leads to short and fast code, but the number of different data items that can be addressed is limited. This means that a program that uses lots of static data may require* -mno-base-addresses*.
-msingle-exit
-mno-single-exit Force (do not force) generated code to have a single exit point in each function.

MN10300オプション

-m MN10300

Tag Description
-mmult-bug Generate code to avoid bugs in the multiply instructions for the MN10300 processors. This is the default.
-mno-mult-bug Do not generate code to avoid bugs in the multiply instructions for the MN10300 processors.
-mam33 Generate code which uses features specific to the AM33 processor.
-mno-am33 Do not generate code which uses features specific to the AM33 processor. This is the default.
*-mreturn-pointer-on-d0 * When generating a function which returns a pointer, return the pointer in both a0 and d0. Otherwise, the pointer is returned only in a0, and attempts to call such functions without a prototype would result in errors. Note that this option is on by default; use* -mno-return-pointer-on-d0* to disable it.
-mno-crt0 Do not link in the C run-time initialization object file.
-mrelax

Indicate to the linker that it should perform a relaxation optimization pass to shorten branches, calls and absolute memory addresses. This option only has an effect when used on the command line for the final link step.

このオプションは、シンボリックデバッグを不可能にします。

MTオプション

-m MT

Tag Description
-march=cpu-type

Generate code that will run on cpu-type, which is the name of a system representing a certain processor type. Possible values for cpu-type are ms1-64-001, ms1-16-002, ms1-16-003 *and ms2*.

このオプションを使用しない場合、デフォルトは -march = ms1-16-002 です。

-mbacc Use byte loads and stores when generating code.
-mno-bacc Do not use byte loads and stores when generating code.
-msim Use simulator runtime
-mno-crt0 Do not link in the C run-time initialization object file crti.o. Other run-time initialization and termination files such as startup.o and exit.o are still included on the linker command line.

PDP-11オプション

PDP-11:

Tag Description
-mfpu Use hardware FPP floating point. This is the default. (FIS floating point on the PDP-11/40 is not supported.)
-msoft-float Do not use hardware floating point.
-mac0 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
-mno-ac0 Return floating-point results in memory. This is the default.
-m40 Generate code for a PDP-11/40.
-m45 Generate code for a PDP-11/45. This is the default.
-m10 Generate code for a PDP-11/10.
-mbcopy-builtin Use inline movmemhi patterns for copying memory. This is the default.
-mbcopy Do not use inline movmemhi patterns for copying memory.
-mint16
-mno-int32 Use 16-bit int. This is the default.
-mint32
-mno-int16 Use 32-bit int.
-mfloat64
-mno-float32 Use 64-bit float. This is the default.
-mfloat32
-mno-float64 Use 32-bit float.
-mabshi Use abshi2 pattern. This is the default.
-mno-abshi Do not use abshi2 pattern.
-mbranch-expensive Pretend that branches are expensive. This is for experimenting with code generation only.
-mbranch-cheap Do not pretend that branches are expensive. This is the default.
-msplit Generate code for a system with split I&D.
-mno-split Generate code for a system without split I&D. This is the default.
*-munix-asm * Use Unix assembler syntax. This is the default when configured for* pdp11--bsd.
*-mdec-asm * Use DEC assembler syntax. This is the default when configured for any PDP-11 target other than* pdp11--bsd.

PowerPCオプション

IBM RS/6000およびPowerPCオプション

-m IBMRS/6000

Tag Description
-mpower
-mno-power
-mpower2
-mno-power2
-mpowerpc
-mno-powerpc
-mpowerpc-gpopt
-mno-powerpc-gpopt
-mpowerpc-gfxopt
-mno-powerpc-gfxopt
-mpowerpc64
-mno-powerpc64
-mmfcrf
-mno-mfcrf
-mpopcntb
-mno-popcntb
-mfprnd
-mno-fprnd
-mmfpgpr
*-mno-mfpgpr *a

GCC supports two related instruction set architectures for the RS/6000 and PowerPC. The POWER instruction set are those instructions supported by the* rios chip set used in the original RS/6000 systems and the PowerPC instruction set is the architecture of the Freescale MPC5xx, MPC6xx, MPC8xx microprocessors, and the IBM 4xx, 6xx, and follow-on microprocessors.

どちらのアーキテクチャも他のアーキテクチャのサブセットではありません。 ただし、両方でサポートされる命令の大きな共通サブセットがあります。 MQレジスターは、POWERアーキテクチャーをサポートするプロセッサーに含まれています。

これらのオプションを使用して、使用しているプロセッサで使用可能な命令を指定します。 これらのオプションのデフォルト値は、GCCを構成するときに決定されます。</emphasis> -mcpu = cpu_typeを指定すると、これらのオプションの指定がオーバーライドされます。 上記のオプションではなく、-mcpu = * cpu_typeオプションを使用することをお勧めします。

-mpower オプションを使用すると、GCCはPOWERアーキテクチャでのみ見つかる命令を生成し、MQレジスタを使用できます。 -mpower2 を指定すると、-power *が暗黙的に指定され、GCCがPOWER2アーキテクチャには存在するが元のPOWERアーキテクチャには存在しない命令を生成することもできます。

  • -mpowerpc</emphasis> オプションを使用すると、GCCはPowerPCアーキテクチャの32ビットサブセットでのみ見つかる命令を生成できます。 -mpowerpc-gpopt を指定すると、-mpowerpc *が暗黙指定され、GCCは浮動小数点平方根を含む汎用グループのオプションのPowerPCアーキテクチャ命令を使用できます。 *-mpowerpc-gfxopt を指定すると、-mpowerpc *が暗黙指定され、GCCが浮動小数点選択を含むグラフィックスグループのオプションのPowerPCアーキテクチャ命令を使用できるようになります。
  • -mmfcrf</emphasis> オプションにより、GCCは、POWER4プロセッサーおよびPowerPC V2.01アーキテクチャーをサポートする他のプロセッサーに実装された条件レジスターからの移動フィールド命令を生成できます。 -mpopcntb オプションを使用すると、GCCは、POWER5プロセッサーおよびPowerPC V2.02アーキテクチャーをサポートする他のプロセッサーに実装されたポップカウントおよび倍精度FP相互推定命令を生成できます。 -mfprnd オプションにより、GCCは、POWER5 +プロセッサーおよびPowerPC V2.03アーキテクチャーをサポートする他のプロセッサーに実装されたFPを整数に丸める命令を生成できます。 -mmfpgpr オプションを使用すると、GCCはPOWER6Xプロセッサーおよび拡張PowerPC V2.05アーキテクチャーをサポートする他のプロセッサーに実装された汎用レジスター命令間のFP移動を生成できます。

-mpowerpc64 オプションを使用すると、GCCは完全なPowerPC64アーキテクチャにある追加の64ビット命令を生成し、GPRを64ビットのダブルワード量として処理できます。 GCCのデフォルトは -mno-powerpc64 です。

-mno-power-mno-powerpc の両方を指定すると、GCCは両方のアーキテクチャの共通サブセットに加えていくつかの特別なAIXコモンモードコールの命令のみを使用し、MQレジスタは使用しません。 -mpower-mpowerpc の両方を指定すると、GCCはいずれかのアーキテクチャの任意の命令を使用でき、MQレジスタを使用できます。これをMotorola MPC601に指定します。

-mnew-mnemonics
*-mold-mnemonics *a

Select which mnemonics to use in the generated assembler code. With* -mnew-mnemonics*, GCC uses the assembler mnemonics defined for the PowerPC architecture. With -mold-mnemonics *it uses the assembler mnemonics defined for the POWER architecture. Instructions defined in only one architecture have only one mnemonic; GCC uses that mnemonic irrespective of which of these options is specified.

GCCは、使用中のアーキテクチャに適したニーモニックにデフォルト設定されます。</emphasis> -mcpu = * cpu_typeを指定すると、これらのオプションの値がオーバーライドされる場合があります。 クロスコンパイラを構築している場合を除き、通常は -mnew-mnemonics または -mold-mnemonics を指定しないでください。代わりにデフォルトを受け入れる必要があります。

-mcpu=cpu_type

Set architecture type, register usage, choice of mnemonics, and instruction scheduling parameters for machine type cpu_type. Supported values for cpu_type are 401, 403, 405, 405fp, 440, 440fp, 505, 601, 602, 603, 603e, 604, 604e, 620, 630, 740, 7400, 7450, 750, 801, 821, 823, 860, 970, 8540, ec603e, G3, G4, G5, power, power2, power3, power4, power5, power5+, power6, power6x, common, powerpc, powerpc64, rios, rios1, rios2, rsc, and rs64.

  • -mcpu = common* は、完全に汎用的なプロセッサーを選択します。 このオプションで生成されたコードは、POWERまたはPowerPCプロセッサーで実行されます。 GCCは両方のアーキテクチャの共通サブセットの命令のみを使用し、MQレジスタは使用しません。 GCCは、スケジューリングの目的で汎用プロセッサモデルを想定しています。 *-mcpu = power* 、*-mcpu = power2 *、*-mcpu = powerpc *、および *-mcpu = powerpc64* は、汎用POWER、POWER2、純粋な32ビットPowerPC(つまり、MPC601ではない)、および64ビットを指定しますPowerPCアーキテクチャのマシンの種類。適切な汎用プロセッサモデルがスケジューリングのために想定されています。

他のオプションは特定のプロセッサーを指定します。 これらのオプションで生成されたコードは、そのプロセッサで最適に実行され、他のプロセッサではまったく実行されない場合があります。

  • -mcpu* オプションは、次のオプションを自動的に有効または無効にします: *-maltivec* 、*-mfprnd *、*-mhard-float *、*-mmfcrf *、*-mmultiple *、*-mnew-mnemonics *、*- mpopcntb *、*-mpower *、*-mpower2 *、*-mpowerpc64 *、*-mpowerpc-gpopt *、*-mpowerpc-gfxopt *、*-mstring *、*-mmfpgpr *。 特定のCPUに設定された特定のオプションは、そのCPUに最適なコードを生成する設定に応じて、コンパイラのバージョンによって異なります。実際のハードウェアの機能を必ずしも反映しているわけではありません。 個々のオプションを特定の値に設定したい場合は、*-mcpu = 970 -mno-altivec *のように *-mcpu* オプションの後に指定できます。

AIXでは、-maltivec *および *-mpowerpc64 オプションは、*-mcpu *オプションによって現在有効または無効にされていません。これは、AIXがこれらのオプションを完全にサポートしていないためです。 ご使用の環境で確実に機能する場合は、個別に有効または無効にすることができます。

-mtune=cpu_type Set the instruction scheduling parameters for machine type cpu_type, but do not set the architecture type, register usage, or choice of mnemonics, as -mcpu=cpu_type would. The same values for cpu_type are used for -mtune *as for -mcpu*. If both are specified, the code generated will use the architecture, registers, and mnemonics set by -mcpu, but the scheduling parameters set by -mtune.
-mswdiv
-mno-swdiv Generate code to compute division as reciprocal estimate and iterative refinement, creating opportunities for increased throughput. This feature requires: optional PowerPC Graphics instruction set for single precision and FRE instruction for double precision, assuming divides cannot generate user-visible traps, and the domain values not include Infinities, denormals or zero denominator.
-maltivec
*-mno-altivec * Generate code that uses (does not use) AltiVec instructions, and also enable the use of built-in functions that allow more direct access to the AltiVec instruction set. You may also need to set* -mabi=altivec* to adjust the current ABI with AltiVec ABI enhancements.
-mvrsave
-mno-vrsave Generate VRSAVE instructions when generating AltiVec code.
-msecure-plt Generate code that allows ld and ld.so to build executables and shared libraries with non-exec .plt and .got sections. This is a PowerPC 32-bit SYSV ABI option.
-mbss-plt Generate code that uses a BSS .plt section that ld.so fills in, and requires .plt and .got sections that are both writable and executable. This is a PowerPC 32-bit SYSV ABI option.
-misel
-mno-isel This switch enables or disables the generation of ISEL instructions.
-misel=yes/no This switch has been deprecated. Use -misel *and -mno-isel* instead.
-mspe
-mno-isel This switch enables or disables the generation of SPE simd instructions.
-mspe=yes/no This option has been deprecated. Use -mspe *and -mno-spe* instead.
-mfloat-gprs=yes/single/double/no
-mfloat-gprs

This switch enables or disables the generation of floating point operations on the general purpose registers for architectures that support it.

引数_yes_または_single_は、単精度浮動小数点演算の使用を有効にします。

引数_double_は、単精度および倍精度の浮動小数点演算の使用を有効にします。

引数_no_は、汎用レジスターの浮動小数点演算を無効にします。

現在、このオプションはMPC854xでのみ使用可能です。

-m32
*-m64 * Generate code for 32-bit or 64-bit environments of Darwin and SVR4 targets (including GNU/Linux). The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any PowerPC variant. The 64-bit environment sets int to 32 bits and long and pointer to 64 bits, and generates code for PowerPC64, as for* -mpowerpc64*.
-mfull-toc
-mno-fp-in-toc
-mno-sum-in-toc
*-mminimal-toc *a

Modify generation of the TOC (Table Of Contents), which is created for every executable file. The* -mfull-toc* option is selected by default. In that case, GCC will allocate at least one TOC entry for each unique non-automatic variable reference in your program. GCC will also place floating-point constants in the TOC. However, only 16,384 entries are available in the TOC.

使用可能なTOCスペースがオーバーフローしたというリンカエラーメッセージを受け取った場合は、-mno-fp-in-toc *および *-mno-sum-in-toc オプションで使用されるTOCスペースの量を減らすことができます。 -mno-fp-in-toc は、GCCがTOCに浮動小数点定数を設定するのを防ぎ、-mno-sum-in-toc *は、実行時にアドレスと定数の合計を計算するコードをGCCに生成させます。その合計を目次に入れる代わりに時間を費やします。 これらのオプションの一方または両方を指定できます。 それぞれ、GCCはTOCスペースの節約を犠牲にして、非常にわずかに低速で大きなコードを生成します。

これらのオプションの両方を指定してもTOCのスペースが不足する場合は、代わりに *-mminimal-toc</emphasis> を指定してください。 このオプションにより、GCCはすべてのファイルに対して1つのTOCエントリのみを作成します。 このオプションを指定すると、GCCはより低速でより大きなコードを生成しますが、使用するTOCスペースはごくわずかです。 このオプションは、実行頻度の低いコードを含むファイルでのみ使用できます。

-maix64
*-maix32 * Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit long type, and the infrastructure needed to support them. Specifying* -maix64 implies -mpowerpc64 and -mpowerpc*, while -maix32 *disables the 64-bit ABI and implies -mno-powerpc64*. GCC defaults to -maix32.
-mxl-compat
-mno-xl-compat

Produce code that conforms more closely to IBM XL compiler semantics when using AIX-compatible ABI. Pass floating-point arguments to prototyped functions beyond the register save area (RSA) on the stack in addition to argument FPRs. Do not assume that most significant double in 128-bit long double value is properly rounded when comparing values and converting to double. Use XL symbol names for long double support routines.

AIX呼び出し規約は拡張されましたが、最初は、宣言されたよりも少ない引数で引数のアドレスを取得する関数を呼び出す不明瞭なK&R Cのケースを処理するために文書化されていません。 IBM XLコンパイラーは、サブルーチンを最適化せずにコンパイルすると、スタックからRSAに収まらない浮動小数点引数にアクセスします。 常に浮動小数点引数をスタックに保存するのは非効率的で、ほとんど必要ないため、このオプションはデフォルトでは有効にならず、最適化なしでIBM XLコンパイラーによってコンパイルされたサブルーチンを呼び出す場合にのみ必要です。

*-mpe * Support IBM RS/6000 SP Parallel Environment (PE). Link an application written to use message passing with special startup code to enable the application to run. The system must have PE installed in the standard location (/usr/lpp/ppe.poe/), or the specs file must be overridden with the* -specs= option to specify the appropriate directory location. The Parallel Environment does not support threads, so the -mpe option and the -pthread* option are incompatible.
-malign-natural
*-malign-power *a

On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option* -malign-natural overrides the ABI-defined alignment of larger types, such as floating-point doubles, on their natural size-based boundary. The option -malign-power* instructs GCC to follow the ABI-specified alignment rules. GCC defaults to the standard alignment defined in the ABI.

64ビットDarwinでは、自然なアライメントがデフォルトであり、*-malign-power *はサポートされていません。

-msoft-float
*-mhard-float * Generate code that does not use (uses) the floating-point register set. Software floating point emulation is provided if you use the* -msoft-float* option, and pass the option to GCC when linking.
-mmultiple
*-mno-multiple * Generate code that uses (does not use) the load multiple word instructions and the store multiple word instructions. These instructions are generated by default on POWER systems, and not generated on PowerPC systems. Do not use* -mmultiple* on little endian PowerPC systems, since those instructions do not work when the processor is in little endian mode. The exceptions are PPC740 and PPC750 which permit the instructions usage in little endian mode.
-mstring
*-mno-string * Generate code that uses (does not use) the load string instructions and the store string word instructions to save multiple registers and do small block moves. These instructions are generated by default on POWER systems, and not generated on PowerPC systems. Do not use* -mstring* on little endian PowerPC systems, since those instructions do not work when the processor is in little endian mode. The exceptions are PPC740 and PPC750 which permit the instructions usage in little endian mode.
-mupdate
*-mno-update * Generate code that uses (does not use) the load or store instructions that update the base register to the address of the calculated memory location. These instructions are generated by default. If you use* -mno-update*, there is a small window between the time that the stack pointer is updated and the address of the previous frame is stored, which means code that walks the stack frame across interrupts or signals may get corrupted data.
-mfused-madd
-mno-fused-madd Generate code that uses (does not use) the floating point multiply and accumulate instructions. These instructions are generated by default if hardware floating is used.
-mno-bit-align
*-mbit-align *a

On System V.4 and embedded PowerPC systems do not (do) force structures and unions that contain bit-fields to be aligned to the base type of the bit-field.

たとえば、デフォルトでは、長さ1の8つの `+ unsigned +`ビットフィールドのみを含む構造体は、4バイト境界に揃えられ、サイズは4バイトになります。* -mno-bit-align *を使用すると、構造は1バイト境界に揃えられ、サイズは1バイトになります。

-mno-strict-align
-mstrict-align On System V.4 and embedded PowerPC systems do not (do) assume that unaligned memory references will be handled by the system.
-mrelocatable
*-mno-relocatable * On embedded PowerPC systems generate code that allows (does not allow) the program to be relocated to a different address at runtime. If you use* -mrelocatable on any module, all objects linked together must be compiled with -mrelocatable or -mrelocatable-lib*.
-mrelocatable-lib
*-mno-relocatable-lib * On embedded PowerPC systems generate code that allows (does not allow) the program to be relocated to a different address at runtime. Modules compiled with* -mrelocatable-lib can be linked with either modules compiled without -mrelocatable and -mrelocatable-lib or with modules compiled with the -mrelocatable* options.
-mno-toc
-mtoc On System V.4 and embedded PowerPC systems do not (do) assume that register 2 contains a pointer to a global area pointing to the addresses used in the program.
-mlittle
*-mlittle-endian * On System V.4 and embedded PowerPC systems compile code for the processor in little endian mode. The* -mlittle-endian option is the same as -mlittle*.
-mbig
*-mbig-endian * On System V.4 and embedded PowerPC systems compile code for the processor in big endian mode. The* -mbig-endian option is the same as -mbig*.
-mdynamic-no-pic On Darwin and Mac OS X systems, compile code so that it is not relocatable, but that its external references are relocatable. The resulting code is suitable for applications, but not shared libraries.
-mprioritize-restricted-insns=priority This option controls the priority that is assigned to dispatch-slot restricted instructions during the second scheduling pass. The argument priority takes the value 0/1/2 to assign no/highest/second-highest priority to dispatch slot restricted instructions.
-msched-costly-dep=dependence_type This option controls which dependences are considered costly by the target during instruction scheduling. The argument dependence_type takes one of the following values: no: no dependence is costly, all: all dependences are costly, true_store_to_load: a true dependence from store to load is costly, store_to_load: any dependence from store to load is costly, number: any dependence which latency >= number is costly.
-minsert-sched-nops=scheme This option controls which nop insertion scheme will be used during the second scheduling pass. The argument scheme takes one of the following values: no: Don’t insert nops. pad: Pad with nops any dispatch group which has vacant issue slots, according to the scheduler’s grouping. regroup_exact: Insert nops to force costly dependent insns into separate groups. Insert exactly as many nops as needed to force an insn to a new group, according to the estimated processor grouping. number: Insert nops to force costly dependent insns into separate groups. Insert number nops to force an insn to a new group.
*-mcall-sysv * On System V.4 and embedded PowerPC systems compile code using calling conventions that adheres to the March 1995 draft of the System V Application Binary Interface, PowerPC processor supplement. This is the default unless you configured GCC using* powerpc--eabiaix.
*-mcall-sysv-eabi * Specify both* -mcall-sysv and -meabi* options.
*-mcall-sysv-noeabi * Specify both* -mcall-sysv and -mno-eabi* options.
-mcall-solaris On System V.4 and embedded PowerPC systems compile code for the Solaris operating system.
-mcall-linux On System V.4 and embedded PowerPC systems compile code for the Linux-based GNU system.
-mcall-gnu On System V.4 and embedded PowerPC systems compile code for the Hurd-based GNU system.
-mcall-netbsd On System V.4 and embedded PowerPC systems compile code for the NetBSD operating system.
-maix-struct-return Return all structures in memory (as specified by the AIX ABI).
-msvr4-struct-return Return structures smaller than 8 bytes in registers (as specified by the SVR4 ABI).
-mabi=abi-type Extend the current ABI with a particular extension, or remove such extension. Valid values are altivec, no-altivec, spe, no-spe, ibmlongdouble, ieeelongdouble.
-mabi=spe Extend the current ABI with SPE ABI extensions. This does not change the default ABI, instead it adds the SPE ABI extensions to the current ABI.
-mabi=no-spe Disable Booke SPE ABI extensions for the current ABI.
-mabi=ibmlongdouble Change the current ABI to use IBM extended precision long double. This is a PowerPC 32-bit SYSV ABI option.
-mabi=ieeelongdouble Change the current ABI to use IEEE extended precision long double. This is a PowerPC 32-bit Linux ABI option.
-mprototype
*-mno-prototype * On System V.4 and embedded PowerPC systems assume that all calls to variable argument functions are properly prototyped. Otherwise, the compiler must insert an instruction before every non prototyped call to set or clear bit 6 of the condition code register (CR) to indicate whether floating point values were passed in the floating point registers in case the function takes a variable arguments. With* -mprototype*, only calls to prototyped variable argument functions will set or clear the bit.
*-msim * On embedded PowerPC systems, assume that the startup module is called sim-crt0.o and that the standard C libraries are libsim.a and libc.a. This is the default for* powerpc--eabisim. configurations.
-mmvme On embedded PowerPC systems, assume that the startup module is called crt0.o and the standard C libraries are libmvme.a and libc.a.
-mads On embedded PowerPC systems, assume that the startup module is called crt0.o and the standard C libraries are libads.a and libc.a.
-myellowknife On embedded PowerPC systems, assume that the startup module is called crt0.o and the standard C libraries are libyk.a and libc.a.
-mvxworks On System V.4 and embedded PowerPC systems, specify that you are compiling for a VxWorks system.
-mwindiss Specify that you are compiling for the WindISS simulation environment.
*-memb * On embedded PowerPC systems, set the PPC_EMB bit in the ELF flags header to indicate that* eabi* extended relocations are used.
-meabi
*-mno-eabi * On System V.4 and embedded PowerPC systems do (do not) adhere to the Embedded Applications Binary Interface (eabi) which is a set of modifications to the System V.4 specifications. Selecting* -meabi means that the stack is aligned to an 8 byte boundary, a function __eabi is called to from main to set up the eabi environment, and the -msdata option can use both r2 and r13 to point to two separate small data areas. Selecting -mno-eabi means that the stack is aligned to a 16 byte boundary, do not call an initialization function from main, and the -msdata option will only use r13 to point to a single small data area. The -meabi option is on by default if you configured GCC using one of the powerpc*--eabi* options.
*-msdata=eabi * On System V.4 and embedded PowerPC systems, put small initialized const global and static data in the* .sdata2 section, which is pointed to by register r2. Put small initialized non-const global and static data in the .sdata section, which is pointed to by register r13. Put small uninitialized global and static data in the .sbss section, which is adjacent to the .sdata section. The -msdata=eabi option is incompatible with the -mrelocatable option. The -msdata=eabi option also sets the -memb* option.
*-msdata=sysv * On System V.4 and embedded PowerPC systems, put small global and static data in the* .sdata section, which is pointed to by register r13. Put small uninitialized global and static data in the .sbss section, which is adjacent to the .sdata section. The -msdata=sysv option is incompatible with the -mrelocatable* option.
-msdata=default
*-msdata * On System V.4 and embedded PowerPC systems, if* -meabi is used, compile code the same as -msdata=eabi*, otherwise compile code the same as -msdata=sysv.
*-msdata-data * On System V.4 and embedded PowerPC systems, put small global and static data in the* .sdata section. Put small uninitialized global and static data in the .sbss section. Do not use register r13 to address small data however. This is the default behavior unless other -msdata* options are used.
-msdata=none
*-mno-sdata * On embedded PowerPC systems, put all initialized global and static data in the* .data section, and all uninitialized data in the .bss* section.
*-G *num On embedded PowerPC systems, put global and static items less than or equal to num bytes into the small data or bss sections instead of the normal data or bss section. By default, num is 8. The* -G num switch is also passed to the linker. All modules should be compiled with the same -G* num value.
-mregnames
-mno-regnames On System V.4 and embedded PowerPC systems do (do not) emit register names in the assembly language output using symbolic forms.
-mlongcall
-mno-longcall

Default to making all function calls indirectly, using a register, so that functions which reside further than 32 megabytes (33,554,432 bytes) from the current location can be called. This setting can be overridden by the shortcall function attribute, or by #pragma longcall(0).

一部のリンカーは、範囲外の呼び出しを検出し、その場でグルーコードを生成できます。 これらのシステムでは、長い呼び出しは不要であり、より遅いコードを生成します。 これを書いている時点で、AIXリンカーはこれを行うことができ、PowerPC/64用のGNUリンカーも同様です。 32ビットPowerPCシステムのGNUリンカーにもこの機能を追加する予定です。

Darwin/PPCシステムでは、 `+#pragma longcall +`はjbsrの呼び出し先であるL42とブランチアイランド(グルーコード)を生成します。 2つのターゲットアドレスは、呼び出し先とブランチアイランドを表します。 Darwin/PPCリンカーは、PPC bl命令が呼び出し先に直接到達する場合、最初のアドレスを優先し、bl呼び出し先を生成します。そうでない場合、リンカーはbl L42を生成してブランチアイランドを呼び出します。 ブランチアイランドは、呼び出し関数の本体に追加されます。呼び出し先の完全な32ビットアドレスを計算し、そこにジャンプします。

Mach-O(Darwin)システムでは、このオプションはコンパイラーが直接呼び出しごとにグルーに出力するよう指示し、Darwinリンカーはそれを使用するか破棄するかを決定します。

将来、リンカがグルーを生成することがわかっている場合、GCCはすべてのロングコール仕様を無視する可能性があります。

-pthread Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.

S/390およびzSeriesオプション

-m

Tag Description
-mhard-float
*-msoft-float * Use (do not use) the hardware floating-point instructions and registers for floating-point operations. When* -msoft-float is specified, functions in libgcc.a will be used to perform floating-point operations. When -mhard-float* is specified, the compiler generates IEEE floating-point instructions. This is the default.
-mlong-double-64
-mlong-double-128 These switches control the size of long double type. A size of 64bit makes the long double type equivalent to the double type. This is the default.
-mbackchain
*-mno-backchain *a

Store (do not store) the address of the caller’s frame as backchain pointer into the callee’s stack frame. A backchain may be needed to allow debugging using tools that do not understand DWARF-2 call frame information. When* -mno-packed-stack is in effect, the backchain pointer is stored at the bottom of the stack frame; when -mpacked-stack* is in effect, the backchain is placed into the topmost word of the 96/160 byte register save area.

一般に、-mbackchain *でコンパイルされたコードは、-mmo-backchain でコンパイルされたコードと呼び出し互換です。ただし、デバッグ目的でバックチェーンを使用するには、通常、バイナリ全体を *-mbackchain でビルドする必要があります。 -mbackchain-mpacked-stack *、および *-mhard-float の組み合わせはサポートされていないことに注意してください。 Linuxカーネルを構築するには、*-msoft-float *を使用します。

デフォルトでは、バックチェーンは維持されません。

-mpacked-stack
*-mno-packed-stack *a

Use (do not use) the packed stack layout. When* -mno-packed-stack is specified, the compiler uses the all fields of the 96/160 byte register save area only for their default purpose; unused fields still take up stack space. When -mpacked-stack is specified, register save slots are densely packed at the top of the register save area; unused space is reused for other purposes, allowing for more efficient use of the available stack space. However, when -mbackchain* is also in effect, the topmost word of the save area is always used to store the backchain, and the return address register is always saved two words below the backchain.

スタックフレームバックチェーンが使用されていない限り、-mpacked-stack *で生成されたコードは、-mno-packed-stack で生成されたコードと呼び出し互換です。 S/390またはzSeries用のGCC 2.95の非FSFリリースは、デバッグ目的だけでなく、実行時にスタックフレームバックチェーンを使用するコードを生成したことに注意してください。 このようなコードは、-mpacked-stack でコンパイルされたコードと呼び出し互換性がありません。 また、-mbackchain -mpacked-stack 、および *-mhard-float の組み合わせはサポートされていないことに注意してください。 Linuxカーネルを構築するには、*-msoft-float *を使用します。

デフォルトでは、パックスタックレイアウトは使用されません。

-msmall-exec
-mno-small-exec Generate (or do not generate) code using the bras instruction to do subroutine calls. This only works reliably if the total executable size does not exceed 64k. The default is to use the basr instruction instead, which does not have this limitation.
-m64
*-m31 * When* -m31 is specified, generate code compliant to the GNU/Linux for S/390 ABI. When -m64 is specified, generate code compliant to the GNU/Linux for zSeries ABI. This allows GCC in particular to generate 64-bit instructions. For the s390 targets, the default is -m31*, while the s390x *targets default to -m64*.
-mzarch
*-mesa * When* -mzarch is specified, generate code using the instructions available on z/Architecture. When -mesa is specified, generate code using the instructions available on ESA/390. Note that -mesa is not possible with -m64*. When generating code compliant to the GNU/Linux for S/390 ABI, the default is -mesa. When generating code compliant to the GNU/Linux for zSeries ABI, the default is -mzarch.
-mmvcle
*-mno-mvcle * Generate (or do not generate) code using the mvcle instruction to perform block moves. When* -mno-mvcle* is specified, use a mvc loop instead. This is the default unless optimizing for size.
-mdebug
-mno-debug Print (or do not print) additional debug information when compiling. The default is to not print debug information.
-march=cpu-type Generate code that will run on cpu-type, which is the name of a system representing a certain processor type. Possible values for cpu-type are g5, g6, z900, and z990. When generating code using the instructions available on z/Architecture, the default is -march=z900. Otherwise, the default is -march=g5.
-mtune=cpu-type Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions. The list of cpu-type values is the same as for -march. The default is the value used for -march.
-mtpf-trace
-mno-tpf-trace Generate code that adds (does not add) in TPF OS specific branches to trace routines in the operating system. This option is off by default, even when compiling for the TPF OS.
-mfused-madd
-mno-fused-madd Generate code that uses (does not use) the floating point multiply and accumulate instructions. These instructions are generated by default if hardware floating point is used.
-mwarn-framesize=framesize Emit a warning if the current function exceeds the given frame size. Because this is a compile time check it doesn’t need to be a real problem when the program runs. It is intended to identify functions which most probably cause a stack overflow. It is useful to be used in an environment with limited stack size e.g. the linux kernel.
-mwarn-dynamicstack Emit a warning if the function calls alloca or uses dynamically sized arrays. This is generally a bad idea with a limited stack size.
-mstack-guard=stack-guard
-mstack-size=stack-size These arguments always have to be used in conjunction. If they are present the s390 back end emits additional instructions in the function prologue which trigger a trap if the stack size is stack-guard bytes above the stack-size (remember that the stack on s390 grows downward). These options are intended to be used to help debugging stack overflow problems. The additionally emitted code causes only little overhead and hence can also be used in production like systems without greater performance degradation. The given values have to be exact powers of 2 and stack-size has to be greater than stack-guard without exceeding 64k. In order to be efficient the extra code makes the assumption that the stack starts at an address aligned to the value given by stack-size.

SHオプション

-m SH

Tag Description
-m1 Generate code for the SH1.
-m2 Generate code for the SH2.
-m2e Generate code for the SH2e.
-m3 Generate code for the SH3.
-m3e Generate code for the SH3e.
-m4-nofpu Generate code for the SH4 without a floating-point unit.
-m4-single-only Generate code for the SH4 with a floating-point unit that only supports single-precision arithmetic.
-m4-single Generate code for the SH4 assuming the floating-point unit is in single-precision mode by default.
-m4 Generate code for the SH4.
-m4a-nofpu Generate code for the SH4al-dsp, or for a SH4a in such a way that the floating-point unit is not used.
-m4a-single-only Generate code for the SH4a, in such a way that no double-precision floating point operations are used.
-m4a-single Generate code for the SH4a assuming the floating-point unit is in single-precision mode by default.
-m4a Generate code for the SH4a.
*-m4al * Same as* -m4a-nofpu*, except that it implicitly passes -dsp to the assembler. GCC doesn’t generate any DSP instructions at the moment.
-mb Compile code for the processor in big endian mode.
-ml Compile code for the processor in little endian mode.
*-mdalign * Align doubles at 64-bit boundaries. Note that this changes the calling conventions, and thus some functions from the standard C library will not work unless you recompile it first with* -mdalign*.
*-mrelax * Shorten some address references at link time, when possible; uses the linker option* -relax*.
-mbigtable Use 32-bit offsets in switch tables. The default is to use 16-bit offsets.
-mfmovd Enable the use of the instruction fmovd.
-mhitachi Comply with the calling conventions defined by Renesas.
-mrenesas Comply with the calling conventions defined by Renesas.
*-mno-renesas * Comply with the calling conventions defined for GCC before the Renesas conventions were available. This option is the default for all targets of the SH toolchain except for* sh-symbianelf*.
*-mnomacsave * Mark the MAC register as call-clobbered, even if* -mhitachi* is given.
*-mieee * Increase IEEE-compliance of floating-point code. At the moment, this is equivalent to* -fno-finite-math-only*. When generating 16 bit SH opcodes, getting IEEE-conforming results for comparisons of NANs/infinities incurs extra overhead in every floating point comparison, therefore the default is set to -ffinite-math-only.
-misize Dump instruction size and location in the assembly code.
-mpadstruct This option is deprecated. It pads structures to multiple of 4 bytes, which is incompatible with the SH ABI.
*-mspace * Optimize for space instead of speed. Implied by* -Os*.
-mprefergot When generating position-independent code, emit function calls using the Global Offset Table instead of the Procedure Linkage Table.
-musermode Generate a library function call to invalidate instruction cache entries, after fixing up a trampoline. This library function call doesn’t assume it can write to the whole memory address space. This is the default when the target is sh-*-linux*.
-multcost=number Set the cost to assume for a multiply insn.
-mdiv=strategy Set the division strategy to use for SHmedia code. strategy must be one of: call, call2, fp, inv, inv:minlat, inv20u, inv20l, inv:call, inv:call2, inv:fp . fp performs the operation in floating point. This has a very high latency, but needs only a few instructions, so it might be a good choice if your code has enough easily exploitable ILP to allow the compiler to schedule the floating point instructions together with other instructions. Division by zero causes a floating point exception. inv uses integer operations to calculate the inverse of the divisor, and then multiplies the dividend with the inverse. This strategy allows cse and hoisting of the inverse calculation. Division by zero calculates an unspecified result, but does not trap. inv:minlat is a variant of inv where if no cse/hoisting opportunities have been found, or if the entire operation has been hoisted to the same place, the last stages of the inverse calculation are intertwined with the final multiply to reduce the overall latency, at the expense of using a few more instructions, and thus offering fewer scheduling opportunities with other code. call calls a library function that usually implements the inv:minlat strategy. This gives high code density for m5-*media-nofpu compilations. call2 uses a different entry point of the same library function, where it assumes that a pointer to a lookup table has already been set up, which exposes the pointer load to cse/code hoisting optimizations. inv:call, inv:call2 and inv:fp all use the inv algorithm for initial code generation, but if the code stays unoptimized, revert to the call, call2, or fp strategies, respectively. Note that the potentially-trapping side effect of division by zero is carried by a separate instruction, so it is possible that all the integer instructions are hoisted out, but the marker for the side effect stays where it is. A recombination to fp operations or a call is not possible in that case. inv20u and inv20l are variants of the inv:minlat strategy. In the case that the inverse calculation was nor separated from the multiply, they speed up division where the dividend fits into 20 bits (plus sign where applicable), by inserting a test to skip a number of operations in this case; this test slows down the case of larger dividends. inv20u assumes the case of a such a small dividend to be unlikely, and inv20l assumes it to be likely.
-mdivsi3_libfunc=name Set the name of the library function used for 32 bit signed division to name. This only affect the name used in the call and inv:call division strategies, and the compiler will still expect the same sets of input/output/clobbered registers as if this option was not present.
-madjust-unroll Throttle unrolling to avoid thrashing target registers. This option only has an effect if the gcc code base supports the TARGET_ADJUST_UNROLL_MAX target hook.
-mindexed-addressing Enable the use of the indexed addressing mode for SHmedia32/SHcompact. This is only safe if the hardware and/or OS implement 32 bit wrap-around semantics for the indexed addressing mode. The architecture allows the implementation of processors with 64 bit MMU, which the OS could use to get 32 bit addressing, but since no current hardware implementation supports this or any other way to make the indexed addressing mode safe to use in the 32 bit ABI, the default is -mno-indexed-addressing.
-mgettrcost=number Set the cost assumed for the gettr instruction to number. The default is 2 if -mpt-fixed is in effect, 100 otherwise.
-mpt-fixed Assume pt instructions won’t trap. This will generally generate better scheduled code, but is unsafe on current hardware. The current architecture definition says that ptabs and ptrel trap when the target anded with 3 is 3. This has the unintentional effect of making it unsafe to schedule ptabs/ptrel before a branch, or hoist it out of a loop. For example, __do_global_ctors, a part of libgcc that runs constructors at program startup, calls functions in a list which is delimited by -1. With the -mpt-fixed option, the ptabs will be done before testing against -1. That means that all the constructors will be run a bit quicker, but when the loop comes to the end of the list, the program crashes because ptabs loads -1 into a target register. Since this option is unsafe for any hardware implementing the current architecture specification, the default is -mno-pt-fixed. Unless the user specifies a specific cost with -mgettrcost*, -mno-pt-fixed also implies -mgettrcost=100; this deters register allocation using target registers for storing ordinary integers.
*-minvalid-symbols * Assume symbols might be invalid. Ordinary function symbols generated by the compiler will always be valid to load with movi/shori/ptabs or movi/shori/ptrel, but with assembler and/or linker tricks it is possible to generate symbols that will cause ptabs/ptrel to trap. This option is only meaningful when* -mno-pt-fixed is in effect. It will then prevent cross-basic-block cse, hoisting and most scheduling of symbol loads. The default is -mno-invalid-symbols*.

SPARCオプション

-m SPARC:

Tag

説明

*-mno-app-regs*
*-mapp-regs*
*-mapp-regs* を指定して、SPARC SVR4 ABIがアプリケーション用に予約するグローバルレジスタ2〜4を使用して出力を生成します。 これがデフォルトです。

パフォーマンスをいくらか犠牲にしてSVR4 ABIに完全に準拠するには、*-mno-app-regs *を指定します。 このオプションを使用してライブラリとシステムソフトウェアをコンパイルする必要があります。

*-mfpu*
*-mhard-float*

浮動小数点命令を含む出力を生成します。 これがデフォルトです。

*-mno-fpu*
*-msoft-float*

浮動小数点のライブラリー呼び出しを含む出力を生成します。 警告:*必要なライブラリはすべてのSPARCターゲットで利用できるわけではありません。 通常、マシンの通常のCコンパイラの機能が使用されますが、これをクロスコンパイルで直接行うことはできません。 クロスコンパイルに適したライブラリ関数を提供するには、独自の手配をする必要があります。 組み込みターゲット sparc--aout *および sparclite--*は、ソフトウェアの浮動小数点サポートを提供します。

*-msoft-float* は、出力ファイルの呼び出し規則を変更します。したがって、このオプションを使用してプログラムのすべてをコンパイルする場合にのみ役立ちます。 特に、これが機能するためには、GCCに付属のライブラリである_libgcc.a_を *-msoft-float* でコンパイルする必要があります。
*-mhard-quad-float*

クアッドワード(long double)浮動小数点命令を含む出力を生成します。

*-msoft-quad-float*

クアッドワード(ロングダブル)浮動小数点命令のライブラリ呼び出しを含む出力を生成します。 呼び出される関数は、SPARC ABIで指定されている関数です。 これがデフォルトです。

このドキュメントの執筆時点では、クアッドワード浮動小数点命令をハードウェアでサポートするSPARC実装はありません。 これらはすべて、これらの命令の1つに対してトラップハンドラーを呼び出し、トラップハンドラーは命令の効果をエミュレートします。 トラップハンドラのオーバーヘッドのため、これはABIライブラリルーチンを呼び出すよりもはるかに遅くなります。 したがって、*-msoft-quad-float *オプションがデフォルトです。

*-mno-unaligned-doubles*
*-munaligned-doubles*

doubleには8バイトのアライメントがあると仮定します。 これがデフォルトです。

*-munaligned-doubles* を使用すると、GCCは、doubleが別の型に含まれている場合、または絶対アドレスを持つ場合にのみ、doubleが8バイトのアライメントを持つと想定します。 それ以外の場合、4バイトのアライメントがあると見なされます。 このオプションを指定すると、他のコンパイラーによって生成されたコードとのまれな互換性の問題が回避されます。 特に浮動小数点コードの場合、パフォーマンスが低下するため、デフォルトではありません。
*-mno-faster-structs*
*-mfaster-structs*
*-mfaster-structs* を使用すると、コンパイラーは、構造体が8バイトのアライメントを持つ必要があると想定します。 これにより、2倍の `+ ld +`と `+ st +`のペアの代わりに、構造割り当てのコピーに `+ ldd +`と `+ std +`命令のペアを使用できます。 ただし、この変更されたアライメントの使用は、SPARC ABIに直接違反します。 したがって、結果のコードがABIのルールに直接一致しないことを開発者が認めるターゲットでの使用のみを目的としています。
*-mimpure-text*
*-mimpure-text* は、*-shared *に加えて使用され、共有オブジェクトのリンク時に *-z text* をリンカーに渡さないようコンパイラーに指示します。 このオプションを使用すると、位置依存コードを共有オブジェクトにリンクできます。
*-mimpure-text* は、割り当て可能だが書き込み不可能なセクションのリンカーエラーメッセージに対する再配置を抑制します。 ただし、必要な再配置はコピーオンライトをトリガーし、共有オブジェクトは実際にはプロセス間で共有されません。 *-mimpure-text* を使用する代わりに、*-fpic *または *-fPIC* を使用してすべてのソースコードをコンパイルする必要があります。

このオプションは、SunOSおよびSolarisでのみ使用可能です。

-mcpu = cpu_type

マシンタイプ_cpu_type_の命令セット、レジスタセット、および命令スケジューリングパラメータを設定します。 _cpu_type_でサポートされる値は、 v7cypressv8supersparcsparclitef930f934hypersparcsparclite86xsparclettsc701v9ultrasparcultrasparc3 、および niagara

デフォルトの命令スケジューリングパラメータは、実装ではなくアーキテクチャを選択する値に使用されます。 これらは v7v8sparclitesparcletv9 です。

サポートされている各アーキテクチャとサポートされている実装のリストを次に示します。

++

v7: cypress v8: supersparc, hypersparc sparclite: f930, f934, sparclite86x sparclet: tsc701 v9: ultrasparc, ultrasparc3, niagara

デフォルトでは(特に設定されていない限り)、GCCはSPARCアーキテクチャのV7バリアントのコードを生成します。 -mcpu = cypress を使用すると、SPARCStation/SPARCServer 3xxシリーズで使用されているように、コンパイラはCypress CY7C602チップ用にさらに最適化します。 これは、古いSPARCStation 1、2、IPXなどにも適しています。

*-mcpu = v8* を使用すると、GCCはSPARCアーキテクチャのV8バリアントのコードを生成します。 V7コードとの唯一の違いは、コンパイラがSPARC-V8には存在するがSPARC-V7には存在しない整数乗算および整数除算命令を発行することです。 *-mcpu = supersparc* を使用すると、コンパイラは、SPARCStation 10、1000、および2000シリーズで使用されているSuperSPARCチップ用にさらに最適化します。
*-mcpu = sparclite* を使用すると、GCCはSPARCアーキテクチャのSPARCliteバリアントのコードを生成します。 これにより、SPARCliteには存在するがSPARC-V7には存在しない整数乗算、整数除算ステップ、およびスキャン( `+ ffs +`)命令が追加されます。 *-mcpu = f930* を使用すると、コンパイラーはさらに、FPUのない元のSPARCliteであるFujitsu MB86930チップ用に最適化します。 *-mcpu = f934* を使用すると、コンパイラーはさらに、FPUを備えた最新のSPARCliteであるFujitsu MB86934チップ用に最適化します。
*-mcpu = sparclet* を使用すると、GCCはSPARCアーキテクチャのSPARCletバリアントのコードを生成します。 これにより、SPARCletには存在するがSPARC-V7には存在しない整数乗算、乗算/累算、整数除算ステップおよびスキャン( `+ ffs +`)命令が追加されます。 *-mcpu = tsc701* を使用すると、コンパイラはさらにTEMIC SPARCletチップ用に最適化します。
*-mcpu = v9* を使用すると、GCCはSPARCアーキテクチャのV9バリアントのコードを生成します。 これにより、64ビット整数および浮動小数点移動命令、3つの浮動小数点条件コードレジスタ、条件付き移動命令が追加されます。 *-mcpu = ultrasparc* を使用すると、コンパイラはSun UltraSPARC I/II/IIiチップ用にさらに最適化します。 *-mcpu = ultrasparc3* を使用すると、コンパイラはさらにSun UltraSPARC III/III +/IIIi/IIIi +/IV/IV +チップ用に最適化します。 *-mcpu = niagara* を使用すると、コンパイラはさらにSun UltraSPARC T1チップ用に最適化します。

-mtune = cpu_type

マシンタイプ_cpu_type_の命令スケジューリングパラメータを設定しますが、オプション-mcpu = _ cpu_typeのように命令セットまたはレジスタセットを設定しないでください。

-mctune = cpu_typeの同じ値を-mtune = cpu_typeに使用できますが、唯一の有用な値は特定のCPU実装を選択する値です。 それらは cypresssupersparchypersparcf930f934sparclite86xtsc701ultrasparcultrasparc3 、および niagara です。

*-mv8plus*
*-mno-v8plus*
*-mv8plus* を使用すると、GCCはSPARC-V8 + ABIのコードを生成します。 V8 ABIとの違いは、グローバルおよび出力レジスタが64ビット幅と見なされることです。 これは、すべてのSPARC-V9プロセッサの32ビットモードのSolarisでデフォルトで有効になっています。
*-mvis*
*-mno-vis*
*-mvis* を使用すると、GCCはUltraSPARC Visual Instruction Set拡張機能を利用するコードを生成します。 デフォルトは *-mno-vis* です。

-m SPARC-V9

Tag

説明

*-mlittle-endian*

リトルエンディアンモードで実行されているプロセッサのコードを生成します。 いくつかの構成でのみ使用でき、特にSolarisおよびLinuxでは使用できません。

*-m32*
*-m64*

32ビットまたは64ビット環境のコードを生成します。 32ビット環境では、int、long、およびポインタを32ビットに設定します。 64ビット環境では、intを32ビットに、longを64ビットに設定します。

*-mcmodel = medlow*

中/低​​コードモデルのコードを生成する:64ビットアドレス、プログラムはメモリの低32ビットでリンクする必要があります。 プログラムは静的または動的にリンクできます。

*-mcmodel = medmid*

中/中コードモデルのコードを生成します。64ビットアドレス、プログラムはメモリの下位44ビットにリンクする必要があり、テキストおよびデータセグメントのサイズは2GB未満で、データセグメントは2GB以内に配置する必要がありますテキストセグメント。

*-mcmodel = medany*

Medium/Anywhereコードモデルのコードを生成します。64ビットアドレス、プログラムはメモリ内の任意の場所にリンクできます。テキストおよびデータセグメントのサイズは2GB未満で、データセグメントはテキストセグメントの2GB以内に配置する必要があります。

*-mcmodel = embmedany*

組み込みシステムのMedium/Anywhereコードモデルのコードを生成します。64ビットアドレス、テキストおよびデータセグメントのサイズは2GB未満である必要があります。どちらもメモリ内のどこからでも(リンク時に決定) グローバルレジスタ `+%g4 +`は、データセグメントのベースを指します。 プログラムは静的にリンクされており、PICはサポートされていません。

*-mstack-bias*
*-mno-stack-bias*
*-mstack-bias* を使用すると、GCCはスタックポインターとフレームポインター(存在する場合)が-2047だけオフセットされていると想定します。 これは64ビットモードのデフォルトです。 それ以外の場合、そのようなオフセットは存在しないと想定します。
Tag Description
-threads Add support for multithreading using the Solaris threads library. This option sets flags for both the preprocessor and linker. This option does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it.
-pthreads Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. This option does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it.
*-pthread * This is a synonym for* -pthreads*.

System Vのオプション

Tag Description
*-G * Create a shared object. It is recommended that* -symbolic or -shared* be used instead.
-Qy Identify the versions of each tool used by the compiler, in a .ident assembler directive in the output.
-Qn Refrain from adding .ident directives to the output file (this is the default).
-YP,dirs Search the directories dirs, and no others, for libraries specified with -l.
-Ym,dir Look in the directory dir to find the M4 preprocessor. The assembler uses this option.

TMS320C3x/C4xオプション

-m

Tag Description
-mcpu=cpu_type Set the instruction set, register set, and instruction scheduling parameters for machine type cpu_type. Supported values for cpu_type are c30, c31, c32, c40, and c44. The default is c40 to generate code for the TMS320C40.
-mbig-memory
-mbig
-msmall-memory
-msmall Generates code for the big or small memory model. The small memory model assumed that all data fits into one 64K word page. At run-time the data page (DP) register must be set to point to the 64K page containing the .bss and .data program sections. The big memory model is the default and requires reloading of the DP register for every direct memory access.
-mbk
-mno-bk Allow (disallow) allocation of general integer operands into the block count register BK.
-mdb
-mno-db Enable (disable) generation of code using decrement and branch, DBcond(D), instructions. This is enabled by default for the C4x. To be on the safe side, this is disabled for the C3x, since the maximum iteration count on the C3x is 2^\{23 + 1} (but who iterates loops more than 2^{23} times on the C3x?). Note that GCC will try to reverse a loop so that it can utilize the decrement and branch instruction, but will give up if there is more than one memory reference in the loop. Thus a loop where the loop counter is decremented can generate slightly more efficient code, in cases where the RPTB instruction cannot be utilized.
-mdp-isr-reload
-mparanoid Force the DP register to be saved on entry to an interrupt service routine (ISR), reloaded to point to the data section, and restored on exit from the ISR. This should not be required unless someone has violated the small memory model by modifying the DP register, say within an object library.
-mmpyi
*-mno-mpyi * For the C3x use the 24-bit MPYI instruction for integer multiplies instead of a library call to guarantee 32-bit results. Note that if one of the operands is a constant, then the multiplication will be performed using shifts and adds. If the* -mmpyi* option is not specified for the C3x, then squaring operations are performed inline instead of a library call.
-mfast-fix
-mno-fast-fix The C3x/C4x FIX instruction to convert a floating point value to an integer value chooses the nearest integer less than or equal to the floating point value rather than to the nearest integer. Thus if the floating point number is negative, the result will be incorrectly truncated an additional code is necessary to detect and correct this case. This option can be used to disable generation of the additional code required to correct the result.
-mrptb
*-mno-rptb * Enable (disable) generation of repeat block sequences using the RPTB instruction for zero overhead looping. The RPTB construct is only used for innermost loops that do not call functions or jump across the loop boundaries. There is no advantage having nested RPTB loops due to the overhead required to save and restore the RC, RS, and RE registers. This is enabled by default with* -O2*.
-mrpts=count
-mno-rpts Enable (disable) the use of the single instruction repeat instruction RPTS. If a repeat block contains a single instruction, and the loop count can be guaranteed to be less than the value count, GCC will emit a RPTS instruction instead of a RPTB. If no value is specified, then a RPTS will be emitted even if the loop count cannot be determined at compile time. Note that the repeated instruction following RPTS does not have to be reloaded from memory each iteration, thus freeing up the CPU buses for operands. However, since interrupts are blocked by this instruction, it is disabled by default.
-mloop-unsigned
-mno-loop-unsigned The maximum iteration count when using RPTS and RPTB (and DB on the C40) is 2^\{31 + 1} since these instructions test if the iteration count is negative to terminate the loop. If the iteration count is unsigned there is a possibility than the 2^\{31 + 1} maximum iteration count may be exceeded. This switch allows an unsigned iteration count.
-mti Try to emit an assembler syntax that the TI assembler (asm30) is happy with. This also enforces compatibility with the API employed by the TI C3x C compiler. For example, long doubles are passed as structures rather than in floating point registers.
-mregparm
-mmemparm Generate code that uses registers (stack) for passing arguments to functions. By default, arguments are passed in registers where possible rather than by pushing arguments on to the stack.
-mparallel-insns
*-mno-parallel-insns * Allow the generation of parallel instructions. This is enabled by default with* -O2*.
-mparallel-mpy
*-mno-parallel-mpy * Allow the generation of MPY
ADD and MPY
SUB parallel instructions, provided* -mparallel-insns* is also specified. These instructions have tight register constraints which can pessimize the code generation of large functions.

V850オプション

-m

Tag Description
-mlong-calls
-mno-long-calls Treat all calls as being far away (near). If calls are assumed to be far away, the compiler will always load the functions address up into a register, and call indirect through the pointer.
-mno-ep
*-mep * Do not optimize (do optimize) basic blocks that use the same index pointer 4 or more times to copy pointer into the ep register, and use the shorter sld and sst instructions. The* -mep* option is on by default if you optimize.
-mno-prolog-function
*-mprolog-function * Do not use (do use) external functions to save and restore registers at the prologue and epilogue of a function. The external functions are slower, but use less code space if more than one function saves the same number of registers. The* -mprolog-function* option is on by default if you optimize.
*-mspace * Try to make the code as small as possible. At present, this just turns on the* -mep and -mprolog-function* options.
-mtda=n Put static or global variables whose size is n bytes or less into the tiny data area that register ep points to. The tiny data area can hold up to 256 bytes in total (128 bytes for byte references).
-msda=n Put static or global variables whose size is n bytes or less into the small data area that register gp points to. The small data area can hold up to 64 kilobytes.
-mzda=n Put static or global variables whose size is n bytes or less into the first 32 kilobytes of memory.
-mv850 Specify that the target processor is the V850.
-mbig-switch Generate code suitable for big switch tables. Use this option only if the assembler/linker complain about out of range branches within a switch table.
-mapp-regs This option will cause r2 and r5 to be used in the code generated by the compiler. This setting is the default.
-mno-app-regs This option will cause r2 and r5 to be treated as fixed registers.
*-mv850e1 * Specify that the target processor is the V850E1. The preprocessor constants* v850e1 and v850e* will be defined if this option is used.
*-mv850e *a

Specify that the target processor is the V850E. The preprocessor constant* v850e* will be defined if this option is used.

-mv850-mv850e-mv850e1 も定義されていない場合、デフォルトのターゲットプロセッサが選択され、関連する v850 プリプロセッサ定数が定義されます。

プリプロセッサ定数 *v850 および ' v851 __</emphasis> は、どのプロセッサバリアントがターゲットであるかに関係なく、常に定義されます。

*-mdisable-callt * This option will suppress generation of the CALLT instruction for the v850e and v850e1 flavors of the v850 architecture. The default is* -mno-disable-callt* which allows the CALLT instruction to be used.

VAXオプション

-m VAX:

Tag Description
-munix Do not output certain jump instructions (aobleq and so on) that the Unix assembler for the VAX cannot handle across long ranges.
-mgnu Do output those jump instructions, on the assumption that you will assemble with the GNU assembler.
-mg Output code for g-format floating point numbers instead of d-format.

x86-64オプション

Xstormy16オプション

Tag Description
-msim Choose startup files and linker script suitable for the simulator.

Xtensaオプション

Tag Description
-mconst16
-mno-const16 Enable or disable use of CONST16 instructions for loading constant values. The CONST16 instruction is currently not a standard option from Tensilica. When enabled, CONST16 instructions are always used in place of the standard L32R instructions. The use of CONST16 is enabled by default only if the L32R instruction is not available.
-mfused-madd
-mno-fused-madd Enable or disable use of fused multiply/add and multiply/subtract instructions in the floating-point option. This has no effect if the floating-point option is not also enabled. Disabling fused multiply/add and multiply/subtract instructions forces the compiler to use separate instructions for the multiply and add/subtract operations. This may be desirable in some cases where strict IEEE 754-compliant results are required: the fused multiply add/subtract instructions do not round the intermediate result, thereby producing results with more bits of precision than specified by the IEEE standard. Disabling fused multiply add/subtract instructions also ensures that the program output is not sensitive to the compiler’s ability to combine multiply and add/subtract operations.
-mtext-section-literals
*-mno-text-section-literals * Control the treatment of literal pools. The default is* -mno-text-section-literals*, which places literals in a separate section in the output file. This allows the literal pool to be placed in a data RAM/ROM, and it also allows the linker to combine literal pools from separate object files to remove redundant literals and improve code size. With -mtext-section-literals, the literals are interspersed in the text section in order to keep them as close as possible to their references. This may be necessary for large assembly files.
-mtarget-align
*-mno-target-align * When this option is enabled, GCC instructs the assembler to automatically align instructions to reduce branch penalties at the expense of some code density. The assembler attempts to widen density instructions to align branch targets and the instructions following call instructions. If there are not enough preceding safe density instructions to align a target, no widening will be performed. The default is* -mtarget-align*. These options do not affect the treatment of auto-aligned instructions like LOOP, which the assembler will always align, either by widening density instructions or by inserting no-op instructions.
-mlongcalls
*-mno-longcalls * When this option is enabled, GCC instructs the assembler to translate direct calls to indirect calls unless it can determine that the target of a direct call is in the range allowed by the call instruction. This translation typically occurs for calls to functions in other source files. Specifically, the assembler translates a direct CALL instruction into an L32R followed by a CALLX instruction. The default is* -mno-longcalls*. This option should be used in programs where the call target can potentially be out of range. This option is implemented in the assembler, not the compiler, so the assembly code generated by GCC will still show direct call instructions---look at the disassembled object code to see the actual instructions. Note that the assembler will use an indirect call for every cross-file call, not just those that really will be out of range.

zSeriesオプション

コード生成規則のオプション

それらのほとんどには、正と負の両方の形式があります。 -ffoo の否定形は -fno-foo になります。 次の表では、フォームの1つだけがリストされています。これはデフォルトではありません。 no- を削除するか追加することで、他のフォームを把握できます。

Tag Description
-fbounds-check For front-ends that support it, generate additional code to check that indices used to access arrays are within the declared range. This is currently only supported by the Java and Fortran front-ends, where this option defaults to true and false respectively.
-ftrapv This option generates traps for signed overflow on addition, subtraction, multiplication operations.
-fwrapv This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. This flag enables some optimizations and disables others. This option is enabled by default for the Java front-end, as required by the Java language specification.
-fexceptions Enable exception handling. Generates extra code needed to propagate exceptions. For some targets, this implies GCC will generate frame unwind information for all functions, which can produce significant data size overhead, although it does not affect execution. If you do not specify this option, GCC will enable it by default for languages like C which normally require exception handling, and disable it for languages like C that do not normally require it. However, you may need to enable this option when compiling C code that needs to interoperate properly with exception handlers written in C. You may also wish to disable this option if you are compiling older C++ programs that don’t use exception handling.
-fnon-call-exceptions Generate code that allows trapping instructions to throw exceptions. Note that this requires platform-specific runtime support that does not exist everywhere. Moreover, it only allows trapping instructions to throw exceptions, i.e. memory references or floating point instructions. It does not allow exceptions to be thrown from arbitrary signal handlers such as SIGALRM.
*-funwind-tables * Similar to* -fexceptions*, except that it will just generate any needed static data, but will not affect the generated code in any other way. You will normally not enable this option; instead, a language processor that needs this handling would enable it on your behalf.
-fasynchronous-unwind-tables Generate unwind table in dwarf2 format, if supported by target machine. The table is exact at each instruction boundary, so it can be used for stack unwinding from asynchronous events (such as debugger or garbage collector).
-fpcc-struct-return

Return short struct and union values in memory like longer ones, rather than in registers. This convention is less efficient, but it has the advantage of allowing intercallability between GCC-compiled files and files compiled with other compilers, particularly the Portable C Compiler (pcc).

メモリ内の構造を返すための正確な規則は、ターゲット構成マクロによって異なります。

短い構造体と共用体とは、サイズとアライメントが整数型のものと一致するものです。

警告: *-fpcc-struct-return スイッチでコンパイルされたコードは、*-freg-struct-return *スイッチでコンパイルされたコードとバイナリ互換ではありません。 デフォルト以外のアプリケーションバイナリインタフェースに準拠するために使用します。

*-freg-struct-return *a

Return struct and union values in registers when possible. This is more efficient for small structures than* -fpcc-struct-return*.

-fpcc-struct-return-freg-struct-return のいずれも指定しない場合、GCCはデフォルトでターゲットの標準の規則を使用します。 標準的な規則がない場合、GCCはデフォルトの -fpcc-struct-return になりますが、GCCが主要なコンパイラーであるターゲットを除きます。 そのような場合、標準を選択でき、より効率的なレジスタリターンの代替を選択しました。

警告: -freg-struct-return スイッチでコンパイルされたコードは、*-fpcc-struct-return *スイッチでコンパイルされたコードとバイナリ互換ではありません。 デフォルト以外のアプリケーションバイナリインタフェースに準拠するために使用します。

-fshort-enums

Allocate to an enum type only as many bytes as it needs for the declared range of possible values. Specifically, the enum type will be equivalent to the smallest integer type which has enough room.

警告: -fshort-enums スイッチにより、GCCはそのスイッチなしで生成されたコードとバイナリ互換性のないコードを生成します。 デフォルト以外のアプリケーションバイナリインタフェースに準拠するために使用します。

-fshort-double

Use the same size for double as for float.

警告: -fshort-double スイッチを使用すると、GCCはそのスイッチなしで生成されたコードとバイナリ互換性のないコードを生成します。 デフォルト以外のアプリケーションバイナリインタフェースに準拠するために使用します。

*-fshort-wchar *a

Override the underlying type for* wchar_t to be short unsigned int* instead of the default for the target. This option is useful for building programs to run under WINE.

警告: -fshort-wchar スイッチを使用すると、GCCはそのスイッチなしで生成されたコードとバイナリ互換性のないコードを生成します。 デフォルト以外のアプリケーションバイナリインタフェースに準拠するために使用します。

-fshared-data Requests that the data and non-const variables of this compilation be shared data rather than private data. The distinction makes sense only on certain operating systems, where shared data is shared between processes running the same program, while private data exists in one copy per process.
-fno-common In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern) in two different compilations, you will get an error when you link them. The only reason this might be useful is if you wish to verify that the program will work on other systems which always work this way.
*-fno-ident * Ignore the* #ident* directive.
-finhibit-size-directive Don’t output a .size assembler directive, or anything else that would cause trouble if the function is split in the middle, and the two halves are placed at locations far apart in memory. This option is used when compiling crtstuff.c; you should not need to use it for anything else.
-fverbose-asm

Put extra commentary information in the generated assembly code to make it more readable. This option is generally only of use to those who actually need to read the generated assembly code (perhaps while debugging the compiler itself).

  • -fno-verbose-asm* (デフォルト)を使用すると、追加情報が省略され、2つのアセンブラーファイルを比較するときに役立ちます。
*-fpic *a

Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system). If the GOT size for the linked executable exceeds a machine-specific maximum size, you get an error message from the linker indicating that* -fpic does not work; in that case, recompile with -fPIC* instead. (These maximums are 8k on the SPARC and 32k on the m68k and RS/6000. The 386 has no such limit.)

位置に依存しないコードは特別なサポートを必要とするため、特定のマシンでしか機能しません。 386の場合、GCCはSystem VのPICをサポートしますが、Sun 386iのPICはサポートしません。 IBM RS/6000用に生成されたコードは常に位置に依存しません。

-fPIC

If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC.

位置に依存しないコードは特別なサポートを必要とするため、特定のマシンでしか機能しません。

-fpie
*-fPIE * These options are similar to* -fpic and -fPIC*, but generated position independent code can be only linked into executables. Usually these options are used when -pie GCC option will be used during linking.
*-fno-jump-tables * Do not use jump tables for switch statements even where it would be more efficient than other code generation strategies. This option is of use in conjunction with* -fpic or -fPIC* for building code which forms part of a dynamic linker and cannot reference the address of a jump table. On some targets, jump tables do not require a GOT and this option is not needed.
-ffixed-reg

Treat the register named reg as a fixed register; generated code should never refer to it (except perhaps as a stack pointer, frame pointer or in some other fixed role).

_reg_はレジスタの名前でなければなりません。 受け入れられるレジスタ名はマシン固有であり、マシン記述マクロファイルの `+ REGISTER_NAMES +`マクロで定義されます。

このフラグは、3者間選択を指定するため、否定形を持ちません。

-fcall-used-reg

Treat the register named reg as an allocable register that is clobbered by function calls. It may be allocated for temporaries or variables that do not live across a call. Functions compiled this way will not save and restore the register reg.

このフラグをフレームポインターまたはスタックポインターと共に使用するとエラーになります。 マシンの実行モデルで広く普及している役割を持つ他のレジスタにこのフラグを使用すると、悲惨な結果が生じます。

このフラグは、3者間選択を指定するため、否定形を持ちません。

-fcall-saved-reg

Treat the register named reg as an allocable register saved by functions. It may be allocated even for temporaries or variables that live across a call. Functions compiled this way will save and restore the register reg if they use it.

このフラグをフレームポインターまたはスタックポインターと共に使用するとエラーになります。 マシンの実行モデルで広く普及している役割を持つ他のレジスタにこのフラグを使用すると、悲惨な結果が生じます。

関数値が返される可能性のあるレジスタにこのフラグを使用すると、別の種類の災害が発生します。

このフラグは、3者間選択を指定するため、否定形を持ちません。

-fpack-struct[=n*]*

Without a value specified, pack all structure members together without holes. When a value is specified (which must be a small power of two), pack structure members according to this value, representing the maximum alignment (that is, objects with default alignment requirements larger than this will be output potentially unaligned at the next fitting location.

警告: -fpack-struct スイッチにより、GCCはそのスイッチなしで生成されたコードとバイナリ互換性のないコードを生成します。 さらに、コードが次善になります。 デフォルト以外のアプリケーションバイナリインタフェースに準拠するために使用します。

*-finstrument-functions *a

Generate instrumentation calls for entry and exit to functions. Just after function entry and just before function exit, the following profiling functions will be called with the address of the current function and its call site. (On some platforms, __builtin_return_address does not work beyond the current function, so the call site information may not be available to the profiling functions otherwise.)

++

[width="100%",cols="100%",]

a|

void __cyg_profile_func_enter (void* this_fn,
               void *call_site);
void __cyg_profile_func_exit  (void *this_fn,
               void *call_site);

最初の引数は、現在の関数の開始アドレスであり、シンボルテーブルで正確に検索できます。

この計測は、他の関数でインライン展開された関数に対しても行われます。 プロファイリング呼び出しは、概念的には、インライン関数が開始および終了する場所を示します。 これは、そのような関数のアドレス可能なバージョンが利用可能でなければならないことを意味します。 関数のすべての使用がインラインで展開される場合、これはコードサイズの追加の展開を意味する場合があります。 Cコードで extern inline を使用する場合、そのような関数のアドレス指定可能なバージョンを提供する必要があります。 (とにかくこれは通常のケースですが、運が良ければ、オプティマイザーが常に関数をインラインで展開する場合、静的コピーを提供せずに消えてしまったかもしれません。)

関数には属性 `+ no_instrument_function +`を与えることができます。その場合、このインストルメンテーションは行われません。 これは、たとえば、上記のプロファイリング関数、高優先度の割り込みルーチン、およびプロファイリング関数を安全に呼び出すことができない関数に使用できます(プロファイリングルーチンが出力を生成するか、メモリを割り当てる場合は、おそらくシグナルハンドラー)。

-fstack-check

Generate code to verify that you do not go beyond the boundary of the stack. You should specify this flag if you are running in an environment with multiple threads, but only rarely need to specify it in a single-threaded environment since stack overflow is automatically detected on nearly all systems if there is only one stack.

この切り替えによって実際にチェックが行われるわけではないことに注意してください。オペレーティングシステムがそれを行う必要があります。 このスイッチによりコードが生成され、オペレーティングシステムがスタックが拡張されていることを確認します。

-fstack-limit-register=reg
-fstack-limit-symbol=sym
-fno-stack-limit

Generate code to ensure that the stack does not grow beyond a certain value, either the value of a register or the address of a symbol. If the stack would grow beyond the value, a signal is raised. For most targets, the signal is raised before the stack overruns the boundary, so it is possible to catch the signal without taking special precautions.

たとえば、スタックが絶対アドレス 0x80000000 から始まり、下方に大きくなる場合、フラグ -fstack-limit-symbol = stack_limit および -Wl、-defsym、 stack_limit = 0x7ffe0000 を使用してスタック制限を実施できます128KB。 これはGNUリンカでのみ機能することに注意してください。

-fargument-alias
-fargument-noalias
-fargument-noalias-global

Specify the possible relationships among parameters and between parameters and global data.

-fargument-alias は、引数(パラメーター)が互いにエイリアスし、グローバルストレージをエイリアスすることを指定します。-fargument-noalias *は、引数が互いにエイリアスしないが、グローバルストレージをエイリアスすることを指定します。-fargument-noalias-global *引数が相互にエイリアスせず、グローバルストレージをエイリアスしないことを指定します。

各言語は、言語標準で必要なオプションを自動的に使用します。 これらのオプションを自分で使用する必要はありません。

*-fleading-underscore *a

This option and its counterpart,* -fno-leading-underscore*, forcibly change the way C symbols are represented in the object file. One use is to help link with legacy assembly code.

警告: -fleading-underscore スイッチにより、GCCはそのスイッチなしで生成されたコードとバイナリ互換性のないコードを生成します。 デフォルト以外のアプリケーションバイナリインタフェースに準拠するために使用します。 すべてのターゲットがこのスイッチを完全にサポートしているわけではありません。

-ftls-model=model

Alter the thread-local storage model to be used. The model argument should be one of global-dynamic, local-dynamic, initial-exec or local-exec.

-fpic なしのデフォルトは `+ initial-exec `です。 *-fpic* では、デフォルトは ` global-dynamic +`です。

*-fvisibility= *_default
internal
hidden
protected_

Set the default ELF image symbol visibility to the specified option---all symbols will be marked with this unless overridden within the code. Using this feature can very substantially improve linking and load times of shared object libraries, produce more optimized code, provide near-perfect API export and prevent symbol clashes. It is* strongly recommended that you use this in any shared objects you distribute.

命名法にもかかわらず、 `+ default `は常にパブリックを意味します。共有オブジェクトの外部からリンクすることができます。 ` protected `と ` internal `は実際の使用ではほとんど役に立たないので、他の一般的に使用されるオプションは ` hidden `だけです。* -fvisibility *が指定されていない場合のデフォルトは、「 default 」です。つまり、すべてのシンボルをパブリックにします。これにより、GCCの以前のバージョンと同じ動作が発生します。

ELFシンボルが適切に表示されるようにすることで得られる利点の良い説明は、Ulrich Drepperによる共有ライブラリの書き方(<** http://people.redhat.com/~drepper/**にあります) >)---ただし、デフォルトが公開の場合に非表示にするこのオプションによって可能になった優れたソリューションは、デフォルトを非表示にして公開することです。 これはWindows上のDLLの標準であり、*-fvisibility = hidden *および ` attribute((visibility(" default "))`ではなく、 ` __ declspec(dllexport)+`を使用すると、同じ構文でほぼ同じセマンティクスを取得できます。 。 これは、クロスプラットフォームプロジェクトで作業する人にとって大きな恩恵です。

既存のコードに可視性サポートを追加する場合は、</emphasis>#pragma GCC visibility * of useを見つけることができます。 これは、(たとえば)#pragma GCC visibility push(hidden)*および#pragma GCC visibility pop で可視性を設定する宣言を囲むことで機能します。 シンボルの可視性は APIインターフェイスコントラクトの一部として*表示される必要があるため、すべての新しいコードはデフォルトでない場合は常に可視性を指定する必要があることに注意してください。ローカルDSO内でのみ使用される宣言は、PLT間接オーバーヘッドを回避するために、常に明示的に非表示としてマークする必要があります---これを十分に明確にすることは、コードの可読性と自己文書化にも役立ちます。 ISO C の仕様要件により、operator newおよびoperator deleteは常にデフォルトの可視性でなければならないことに注意してください。

  • extern* 宣言は *-fvisibility* の影響を受けないため、多くのコードを *-fvisibility = hidden* に変更せずに再コンパイルできます。 ただし、これは、明示的な可視性のない *extern* 関数の呼び出しがPLTを使用することを意味するため、* __ attribute((visibility))*および/または*#pragma GCC visibility *を使用して、どの *extern* 宣言は非表示として扱われるべきです。
  • -fvisibility* は、C のあいまいなリンケージエンティティに影響することに注意してください。 これは、たとえば、DSO間でスローされる例外クラスを明示的にデフォルトの可視性でマークし、 type_info ノードがDSO間で統合されるようにする必要があることを意味します。

これらの手法の概要、その利点、およびそれらの使用方法は、<http://gcc.gnu.org/wiki/Visibility>にあります。

*-fopenmp *
Enable handling of OpenMP directives #pragma omp in C/C++ and !$omp in Fortran. When* -fopenmp* is specified, the compiler generates parallel code according to the OpenMP Application Program Interface v2.5 <http://www.openmp.org/>.

環境

GCC

*-B* 、*-I *、*-L *などのオプションを使用して、検索する場所を指定することもできます。 これらは、環境変数を使用して指定された場所より優先され、GCCの構成で指定された場所よりも優先されます。

Tag

説明

*LANG*
*LC_CTYPE*
*LC_MESSAGES*
*LC_ALL*

これらの環境変数は、GCCがさまざまな国の慣習に従って機能することを可能にするローカライズ情報をGCCが使用する方法を制御します。 GCCは、ロケールカテゴリ LC_CTYPE および LC_MESSAGES を検査します(そのように構成されている場合)。 これらのロケールカテゴリは、ご使用のシステムでサポートされている任意の値に設定できます。 典型的な値は、UTF-8でエンコードされた英国の英語の en_GB.UTF-8 です。

*LC_CTYPE* 環境変数は、文字の分類を指定します。 GCCはそれを使って文字列中の文字境界を決定します。これは、それ以外の場合は文字列の末尾またはエスケープとして解釈される、引用符およびエスケープ文字を含むマルチバイトエンコーディングに必要です。
*LC_MESSAGES* 環境変数は、診断メッセージで使用する言語を指定します。
*LC_ALL* 環境変数が設定されている場合、 *LC_CTYPE* および *LC_MESSAGES* の値をオーバーライドします。それ以外の場合、 *LC_CTYPE* および *LC_MESSAGES* は、デフォルトで *LANG* 環境変数の値になります。 これらの変数のどれも設定されていない場合、GCCはデフォルトの伝統的なC英語の振る舞いをします。
*TMPDIR*
*TMPDIR* が設定されている場合、一時ファイルに使用するディレクトリを指定します。 GCCは一時ファイルを使用して、次のステージへの入力として使用されるコンパイルの1つのステージの出力を保持します。たとえば、プリプロセッサの出力は、適切なコンパイラへの入力です。
*GCC_EXEC_PREFIX*
*GCC_EXEC_PREFIX* が設定されている場合、コンパイラーによって実行されるサブプログラムの名前で使用するプレフィックスを指定します。 このプレフィックスをサブプログラムの名前と組み合わせた場合、スラッシュは追加されませんが、必要に応じてスラッシュで終わるプレフィックスを指定できます。
*GCC_EXEC_PREFIX* が設定されていない場合、GCCは、呼び出されたパス名に基づいて、使用する適切なプレフィックスを見つけようとします。

GCCは、指定されたプレフィックスを使用してサブプログラムを見つけることができない場合、サブプログラムの通常の場所を検索しようとします。

*GCC_EXEC_PREFIX* のデフォルト値は_prefix/lib/gcc/_です。ここで、_prefix_は_configure_スクリプトを実行したときの `+ prefix +`の値です。
*-B* で指定された他のプレフィックスは、このプレフィックスよりも優先されます。

このプレフィックスは、リンクに使用される_crt0.o_などのファイルの検索にも使用されます。

さらに、プレフィックスは、ヘッダーファイルを検索するディレクトリを見つける際に通常とは異なる方法で使用されます。 名前が通常 /usr/local/lib/gcc (より正確には GCC_INCLUDE_DIR の値)で始まる標準ディレクトリのそれぞれについて、GCCは、指定されたプレフィックスでその先頭を置き換えて代替ディレクトリ名を生成しようとします。 したがって、*-Bfoo/*を使用すると、GCCは通常_/usr/local/lib/bar_を検索する_foo/bar_を検索します。 これらの代替ディレクトリが最初に検索されます。次に標準ディレクトリが来ます。

*COMPILER_PATH*
*COMPILER_PATH* の値は、 *PATH* によく似た、コロンで区切られたディレクトリのリストです。 GCCは、 *GCC_EXEC_PREFIX* を使用してサブプログラムを見つけられない場合、サブプログラムの検索時にこのように指定されたディレクトリを試行します。
*LIBRARY_PATH*
*LIBRARY_PATH* の値は、 *PATH* によく似た、コロンで区切られたディレクトリのリストです。 ネイティブコンパイラとして設定されている場合、GCCは、 *GCC_EXEC_PREFIX* を使用して見つからない場合、特別なリンカーファイルを検索するときに指定されたディレクトリを試行します。 GCCを使用したリンクでは、*-l *オプションで通常のライブラリを検索するときにこれらのディレクトリも使用します(ただし、*-L *で指定されたディレクトリが最初に来ます)。
*LANG*

この変数は、ロケール情報をコンパイラに渡すために使用されます。 この情報を使用する1つの方法は、CおよびC ++で文字リテラル、文字列リテラル、およびコメントを解析するときに使用する文字セットを決定することです。 コンパイラがマルチバイト文字を許可するように構成されている場合、 LANG の次の値が認識されます。

Tag Description
C-JIS Recognize JIS characters.
C-SJIS Recognize SJIS characters.
C-EUCJP Recognize EUCJP characters.
*LANG* が定義されていない場合、または他の値がある場合、コンパイラはデフォルトのロケールで定義されているmblenおよびmbtowcを使用して、マルチバイト文字を認識および変換します。
Tag Description
CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
*OBJC_INCLUDE_PATH *a

Each variable’s value is a list of directories separated by a special character, much like* PATH*, in which to look for header files. The special character, PATH_SEPARATOR, is target-dependent and determined at GCC build time. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets it is a colon.

CPATH は、-I *で指定された場合と同様に、コマンドラインで *-I オプションで指定されたパスの後に検索するディレクトリのリストを指定します。 この環境変数は、どの言語が前処理されているかに関係なく使用されます。

残りの環境変数は、指定された特定の言語を前処理する場合にのみ適用されます。 それぞれは、-isystem *で指定された場合と同様に、コマンドラインで *-isystem オプションで指定されたパスの後に検索するディレクトリのリストを指定します。

これらすべての変数で、空の要素はコンパイラに現在の作業ディレクトリを検索するよう指示します。 空の要素は、パスの最初または最後に表示できます。 たとえば、 CPATH の値が `+:/special/include +`の場合、*-Iと同じ効果があります。 -I/special/include *。

DEPENDENCIES_OUTPUT

If this variable is set, its value specifies how to output dependencies for Make based on the non-system header files processed by the compiler. System header files are ignored in the dependency output.

  • DEPENDENCIES_OUTPUT* の値は単なるファイル名にすることができます。この場合、Makeルールはそのファイルに書き込まれ、ソースファイル名からターゲット名を推測します。 または、値は_file_ ** _target_の形式を持つことができます。この場合、ルールは_target_をターゲット名として使用してファイル_file_に書き込まれます。

つまり、この環境変数は、オプション -MM および -MF をオプションの -MT スイッチと組み合わせることと同等です。

*SUNPRO_DEPENDENCIES * This variable is the same as* DEPENDENCIES_OUTPUT (see above), except that system header files are not ignored, so it implies -M rather than -MM*. However, the dependence on the main input file is omitted.

基本的な使い方

  • 1. 以下のコマンドは、.cppファイルをコンパイルし、デフォルト名_a.out_ *の実行可能ファイルを生成します
$ gcc HelloWorld.cpp
$ ls
a.out HelloWorld.cpp

2. _-o_オプションを指定した以下のコマンドは、指定された名前の実行可能ファイルを生成します。

$ gcc -o HelloWorld HelloWorld.cpp
$ ls
HelloWorld HelloWorld.cpp

3. _-c_オプションを指定した以下のコマンドは、オブジェクトファイルのみを生成し、実行可能ファイルは生成しません。

$ gcc -c -o demo.o demo.cpp
$ ls
demo.o demo.cpp

デバッグオプション

  • 必要なデバッグ情報がないため、デバッグオプションなしでコンパイルされたプログラムはデバッグできません。 オプション_-g_を使用すると、gdb *などのデバッガーを使用してデバッグできる実行可能ファイルが生成されます
$ gcc -g HelloWorld HelloWorld.cpp
With -g option
$ ls -l
-rwxr-xr-x 1 root root 38613 Jan 23 11:33 HelloWorld
-rw-r--r-- 1 root root    91 Jan 23 11:32 HelloWorld.cpp
Without -g option
$ ls -l
-rwxr-xr-x 1 root root 6589 Jan 23 11:34 HelloWorld
-rw-r--r-- 1 root root   91 Jan 23 11:32 HelloWorld.cpp

静的ライブラリの作成と使用

ステップ1-ソースファイルからオブジェクトファイルを作成します

$ gcc -c -o my.o my.cpp
$ gcc -c -o your.o your.cpp

ステップ2-_ar_コマンドを使用してライブラリを作成

$ ar rcs libdemo.a my.o your.o

ステップ3-ライブラリをリンクし、最終的な実行可能ファイルを作成します

$ gcc -static -L. -ldemo -o HelloWorld HelloWorld.cpp

共有ライブラリの作成と使用

ステップ1-ソースファイルからオブジェクトファイルを作成します

$ gcc -c -o my.o my.cpp
$ gcc -c -o your.o your.cpp

ステップ2-ライブラリの作成

$ gcc -shared -Wl,-soname,libdemo.so.1 -o libdemo.so.1.0 my.o your.o

ステップ3-ライブラリへのシンボリックリンクの作成

$ ln -sf libdemo.so.1.0 libdemo.so.1
$ ln -sf libdemo.so.1 libdemo.so

ステップ4-ライブラリをリンクし、最終的な実行可能ファイルを作成します

$ gcc -L. -ldemo -o HelloWorld HelloWorld.cpp