Clang 编译器

yushang

贡献于2015-07-02

字数:0 关键词:

架构 图一,工具链管理 图二,clang 和 llvm 图三,clang 编译器内部结构 Driver Compilation CompilerInstance CompilerInvocation FrontendAction ToolChain options Tool Parser Sema JobAction Job clang IR ARM X86 … IRBuilder clang 名字空间 名字空间 说明 clang clang::driver clang::driver::cc1asoptions clang::driver::cc1options clang::driver::options clang/Driver/Options.h clang::driver::toolchains clang::driver::tools clang::driver::tools::gcc clang::driver::tools::hexagon clang::driver::tools::darwin clang::driver::tools::openbsd clang::driver::tools::freebsd clang::driver::tools::netbsd clang::driver::tools::linuxtools clang::driver::tools::minix clang::driver::tools::solaris clang::driver::tools::auroraux clang::driver::tools::dragonfly clang::driver::tools::visualstudio clang 类 说明 clang PragmaHandler Scope DeclGroupRef DiagnosticBuilder Parser PragmaUnusedHandler ColonProtectionRAIIObject InMessageExpressionRAIIObject PoisonSEHIdentifiersRAIIObject VersionTuple CodeGenOptions AnalyzerOptions clang::driver 类 说明 Action Arg ArgList Command Compilation DerivedArgList Driver InputArgList InputInfo Job JobAction OptTable Tool ToolChain clang::driver::cc1options 类 说明 AuroraUX clang::driver::toolchains 类 说明 AuroraUX Darwin DarwinClang Darwin_Generic_GCC DragonFly FreeBSD Generic_ELF Generic_GCC Hexagon_TC Linux Minix NetBSD OpenBSD Solaris TCEToolChain Windows clang::driver::tools 类 说明 Clang ClangAs clang::driver::tools::Darwin 类 说明 DarwinTool CC1 Preprocess Compile Assemble Link Lipo Dsymutil VerifyDebug clang::driver::tools::auroraux 类 说明 Assemble Link clang::driver::tools::dragonfly 类 说明 Assemble Link clang::driver::tools::freebsd 类 说明 Assemble Link clang::driver::tools::gcc 类 说明 Common Preprocess Precompile Compile Assemble Link clang::driver::tools::hexagon 类 说明 Assemble Link clang::driver::tools::linuxtools 类 说明 Assemble Link clang::driver::tools::minix 类 说明 Assemble Link clang::driver::tools::netbsd 类 说明 Assemble Link clang::driver::tools::openbsd 类 说明 Assemble Link clang::driver::tools::solaris 类 说明 Assemble Link llvm clang::driver::tools::visualstudio 类 说明 Link FrontendAction 动作 消费者 说明 FrontendAction ASTFrontendAction PrecompilePreambleAction PrecompilePreambleConsumer TopLevelDeclTrackerAction TopLevelDeclTrackerConsumer ARCMTMacroTrackerAction ASTConsumer PluginASTAction PrintFunctionNamesAction PrintFunctionsConsumer CodeGenAction EmitAssemblyAction EmitBCAction EmitLLVMOnlyAction EmitCodeGenOnlyAction EmitObjAction BackendConsumer ASTPrintAction ASTPrinter ASTDumpAction ASTDumpXMLAction ASTDumpXML ASTViewAction ASTViewer DeclContextPrintAction DeclContextPrinter GeneratePCHAction GenerateModuleAction PCHGenerator SyntaxOnlyAction ASTConsumer ASTMergeAction PrintPreambleAction NULL IndexingFrontendAction IndexingConsumer HTMLPrintAction HTMLPrinter FixItAction ASTConsumer RewriteObjCAction RewriteModernObjC RewriteObjCFragileABI NULL PreprocessorFrontendAction DumpRawTokensAction DumpTokensAction GeneratePTHAction PreprocessOnlyAction PrintPreprocessedAction RewriteMacrosAction RewriteTestAction ERROR InitOnlyAction ASTConsumer 命令行 命令行 说明 llc llvm 系统编译器,接受 bc 文件作为输入,编译为目标平台汇编文件 lli llvm 解析器和动态编译器,接受 bc 文件作为输入 llvm-ar LLVM Archiver llvm-as llvm 汇编器,接受 ll 文件作为输入,编译为 bc 文件 llvm-bcanalyzer Bc 文件分析器 llvm-cov llvm cov llvm-diff llvm-dis llvm 反编译器,接受 bc 文件作为输入,反汇编为 ll 文件 llvm-dwarfdump dwarf 信息导出 llvm-extract llvm extractor llvm-ld llvm 链接器 llvm-link llvm 链接器 llvm-mc llvm machine code playground llvm-nm llvm symbol table dumper llvm-objdump llvm object file dumper llvm-prof llvm profile dump decoder llvm-ranlib LLVM Archive Index Generator llvm-readobj LLVM Object Reader llvm-rtdyld llvm MC-JIT tool llvm-size llvm object size dumper llvm-stress llvm codegen stress-tester llvm-stub llvm-tblgen macho-dump llvm Mach-O dumping tool modulemaker not opt llvm 优化器,接受 bc 文件作为输入 yaml-bench clang C/C++/ObjectC 编译器 Driver 选项 Driver 选项由 Driver 处理,这里面有些选项是和 Clang 编译器选项重叠的,例如,预处理 输出选项。 注:下面标红的选项在源代码中确认出现过 长选项 下面这些长选项大多数是别名,标注为绿色 选项 说明 -### Print the commands to run for this compilation --CLASSPATH -fclasspath=别名 --CLASSPATH= -fclasspath=别名 --all-warnings -Wall 别名 --analyze Run the static analyzer 这是 driver 到 clang 静态分析器的开关 --analyze-auto --analyzer-no-default-checks --analyzer-output 参见 Analyzer 的-analyzer-output 参数 --ansi -ansi 别名 --assemble -S 别名 --assert -A 别名 --assert= -A 别名 --bootclasspath -fbootclasspath=别名 --bootclasspath= -fbootclasspath=别名 --classpath -fclasspath=别名 --classpath= -fclasspath=别名 --combine -combine 别名 --comments -C 别名 --comments-in-macros -CC 别名 --compile -c 别名 --constant-cfstrings --coverage -coverage 别名 --debug -g 别名 --debug= -g 别名 --define-macro -D 别名 --define-macro= -D 别名 --dependencies -M 别名 --encoding -fencoding=别名 --encoding= -fencoding=别名 --entry -e 别名 --extdirs -fextdirs=别名 --extdirs= -fextdirs=别名 --extra-warnings -W 别名 --for-linker -Xlinker 别名 --for-linker= -Xlinker 别名 --force-link -u 别名 --force-link= -u 别名 --help Display available options --help-hidden --imacros -imacros 别名 --imacros= -imacros 别名 --include -include 别名 --include-barrier -I-别名 --include-directory -I 别名 --include-directory-after -idirafter 别名 --include-directory-after= -idirafter 别名 --include-directory= -I 别名 --include-prefix -iprefix 别名 --include-prefix= -iprefix 别名 --include-with-prefix -iwithprefix 别名 --include-with-prefix-after -iwithprefix 别名 --include-with-prefix-after= -iwithprefix 别名 --include-with-prefix-before -iwithprefixbefore 别名 --include-with-prefix-before= -iwithprefixbefore 别名 --include-with-prefix= -iwithprefix 别名 --include= -include=别名 --language -x 别名 --language= -x 别名 --library-directory -L 别名 --library-directory= -L 别名 --machine -m 别名 --machine- -m 别名 --machine-= -m 别名 --machine= -m 别名 --migrate Run the migrator --no-integrated-cpp --no-line-commands -P 别名 --no-standard-includes -nostdinc 别名 --no-standard-libraries -nostdlib 别名 --no-undefined --no-warnings -w 别名 --optimize -O 别名 --optimize= -O 别名 --output -o 别名 --output-class-directory -foutput-class-dir=别名 --output-class-directory= -foutput-class-dir=别名 --output= -o 别名 --param --param= --param 别名 --pass-exit-codes -pass-exit-codes 别名 --pedantic -pedantic 别名 --pedantic-errors -pedantic-errors 别名 --pipe -pipe 别名 --prefix -B 别名 --prefix= -B 别名 --preprocess -E 别名 --print-diagnostic-categories --print-file-name -print-file-name=别名 --print-file-name= -print-file-name=别名 --print-libgcc-file-name -print-libgcc-file-name 别名 --print-missing-file-dependencies -MG 别名 --print-multi-directory -print-multi-directory 别名 --print-multi-lib -print-multi-lib 别名 --print-multi-os-directory -print-multi-os-directory 别名 --print-prog-name -print-prog-name=别名 --print-prog-name= -print-prog-name=别名 --print-search-dirs -print-search-dirs 别名 --profile -p 别名 --profile-blocks -a 别名 --relocatable-pch Build a relocatable precompiled header --resource --resource=别名 --resource= --rtlib --rtlib=别名 --rtlib= --save-temps -save-temps 别名 --serialize-diagnostics Serialize compiler diagnostics to a file --shared -shared 别名 --signed-char -fsigned-char 别名 --specs -specs=别名 --specs= -specs=别名 --static -static 别名 --std -std=别名 --std= -std=别名 --stdlib -stdlib=别名 --stdlib= -stdlib=别名 --sysroot --sysroot=别名 --sysroot= --target-help --trace-includes -H 别名 --traditional -traditional 别名 --traditional-cpp -traditional-cpp 别名 --trigraphs -trigraphs 别名 --undefine-macro -U 别名 --undefine-macro= -U 别名 --unsigned-char -funsigned-char 别名 --user-dependencies -MM 别名 --verbose -v 别名 --version --warn- -W 别名 --warn-= -W 别名 --write-dependencies -MD 别名 --write-user-dependencies -MMD 别名 选项 选项 说明 -A -B -F -G -H -I 头文件搜索路径 -I- -L 库文件搜索路径 -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mach -ObjC Treat source input files as Objective-C inputs -ObjC++ Treat source input files as Objective-C++ inputs -Q -Qn -Qunused-arguments Don't emit warning for unused driver arguments -R -S Only run preprocess and compilation steps -T -Tbss -Tdata -Ttext -V -Wa, Pass the comma separated arguments in to the assembler 另参见-Xassembler -Wl, Pass the comma separated arguments in to the linker -Wp, Pass the comma separated arguments in to the preprocessor 另参见-Xpreprocessor -X -Xanalyzer Pass to the static analyzer -Xarch_ -Xassembler Pass to the assembler 另参见-Wa, -Xclang Pass to the clang compiler -Xlinker Pass to the linker -Xpreprocessor Pass to the preprocessor 另参见-Wp, -Z -Z-Xlinker-no-demangle -Z-reserved-lib-cckext -Z-reserved-lib-stdc++ -Zlinker-input -a -all_load -allowable_client -ansi 等价于-std=c++98 或者-std=c89 -arch -arch_errors_fatal -arch_only -arcmt-migrate-emit-errors Emit ARC errors even if the migrator can fix them -arcmt-migrate-report-output Output path for the plist report -b -bind_at_load -bundle -bundle_loader -c Only run preprocess, compile, and assemble steps -ccc- -ccc-arcmt-check Check for ARC migration issues that need manual handling -ccc-arcmt-migrate Apply modifications and produces temporary files that conform to ARC -ccc-arcmt-modify Apply modifications to files to conform to ARC -ccc-arrmt-check -ccc-arcmt-check 别名 -ccc-arrmt-modify -ccc-arcmt-modify 别名 -ccc-clang-archs Comma separate list of architectures to use the clang compiler for -ccc-clang-cxx Enable the clang compiler for C++ -ccc-cxx Act as a C++ driver -ccc-echo Echo commands before running them -ccc-gcc-name Name for native GCC compiler -ccc-host-triple -target 别名 -ccc-install-dir Simulate installation in the given directory -ccc-no-clang Disable the clang compiler -ccc-no-clang-cpp Disable the clang preprocessor -ccc-no-clang-cxx Disable the clang compiler for C++ -ccc-objcmt-migrate Apply modifications and produces temporary files to migrate to modern ObjC syntax -ccc-pch-is-pch Use lazy PCH for precompiled headers -ccc-pch-is-pth Use pretokenized headers for precompiled headers -ccc-print-bindings Show bindings of tools to actions -ccc-print-options Dump parsed command line arguments -ccc-print-phases Dump list of actions to perform -client-name -combine -compatibility-version -coverage -cpp-precomp -current-version -cxx-isystem -d -dA -dead-strip -dependency-file -dumpmachine -dumpspecs -dumpversion -dylib-file -dylinker -dylinker-install-name -dynamic -dynamiclib -e -emit-ast Emit Clang AST files for source inputs -emit-llvm Use the LLVM representation for assembler and object files -exported_symbols_list -gcc-toolchain Use the gcc toolchain at the given directory -headerpad-max-install-names -i -idirafter -iframework -imacros -image-base -include -include-pch -index-header-map -init -install-name -integrated-as -iprefix -iquote -isysroot -isystem -iwithprefix -iwithprefixbefore -iwithsysroot -keep-private-externs -l -lazy-framework -lazy-library -m -m32 -m3dnow -m3dnowa -m64 -mabi= -maes -march= -marm -mavx -mavx2 -mbmi -mbmi2 -mcmodel= -mconstant-cfstrings -mcpu= -mdynamic-no-pic -mfix-and-continue -mfloat-abi= -mfma4 -mfpmath= -mfpu= -mglobal-merge -mhard-float -mios-simulator-version-min= -mios-version-min= -miphoneos-version-min= -mkernel -mlinker-version= -mllvm -mlzcnt -mmacosx-version-min= -mmmx -mms-bitfields -mno-3dnow -mno-3dnowa -mno-aes -mno-avx -mno-avx2 -mno-bmi -mno-bmi2 -mno-constant-cfstrings -mno-fma4 -mno-global-merge -mno-lzcnt -mno-mmx -mno-omit-leaf-frame-pointer -mno-pascal-strings -mno-popcnt -mno-red-zone -mno-relax-all -mno-rtd -mno-soft-float -mno-sse -mno-sse2 -mno-sse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-sse4a -mno-ssse3 -mno-stackrealign -mno-thumb -mno-warn-nonportable-cfstrings -momit-leaf-frame-pointer -mpascal-strings -mpopcnt -mqdsp6-compat -mred-zone -mregparm= -mrelax-all -mrtd -msmall-data-threshold= -msoft-float -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -msse4a -mssse3 -mstack-alignment= -mstackrealign -mthumb -mtune= -multi-module -multiply-defined -multiply-defined-unused -mwarn-nonportable-cfstrings -no-canonical-prefixes Use relative instead of canonical paths -no-cpp-precomp -no-integrated-as -no-integrated-cpp -no-dead-strip-inits-and-terms -nobuiltininc -nodefaultlibs -nofixprebinding -nolibc -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdinc -nostdinc++ -nostdlib -nostdlibinc -o Write output to -objcmt-migrate-literals Enable migration to modern ObjC literals -objcmt-migrate-subscripting Enable migration to modern ObjC subscripting -object -p -pagezero-size -pass-exit-codes -pedantic -pedantic-errors -pg -pie -pipe Use pipes between commands, when possible -prebind -prebind-all-twolevel-modules -preload -print-file-name= Print the full library path of -print-ivar-layout -print-libgcc-file-name Print the library path for \libgcc.a\ -print-multi-directory -print-multi-lib -print-multi-os-directory -print-prog-name= Print the full program path of -print-search-dirs Print the paths used for finding libraries and programs -private-bundle -pthread -pthreads -r -rdynamic -read-only-relocs -remap -rewrite-legacy-objc Rewrite Legacy Objective-C source to C++ -rewrite-objc Rewrite Objective-C source to C++ -rpath -rtlib= -s -save-temps Save intermediate compilation results -sectalign -sectcreate -sectobjectsymbols -sectorder -seg1addr -seg-addr-table -seg-addr-table-filename -segaddr -segcreate -seglinkedit -segprot -segs_read_ -segs-read-only-addr -segs-read-write-addr -shared -shared-libgcc -single-module -specs -specs= -static -static-libgcc -static-libstdc++ -std-default= -std= 指定语言标准,clang 也有同名选项 -stdlib= -sub-library -sub-umbrella -t -target Generate code for the given target -time Time individual commands -traditional -traditional-cpp -trigraphs -twolevel-namespace -twolevel-namespace-hints -u -umbrella -undef -undefined -unexported-symbols-list -use-gold-plugin -v Show commands to run and use verbose output -verify Verify output using a verifier. -weak-l -weak-framework -weak-library -weak-reference-mismatches -whatsloaded -whyload -working-directory Resolve file paths relative to the specified directory -working-directory= -working-directory 别名 -x Treat subsequent input files as having type -y 诊断 选项 说明 -W -Wall 打开所有警告 -Wdeprecated -Wextra -Wframe-larger-than -Wframe-larger-than= -Wframe-larger-than 别名 -Wlarge-by-value-copy 参见 clang 选项.语言 -Wlarge-by-value-copy= 参见 clang 选项.语言 -Wlarger-than -Wlarger-than- -Wlarger-than 别名 -Wlarger-than= -Wlarger-than 别名 -Wno-deprecated -Wno-nonportable-cfstrings -Wno-write-strings -Wnonportable-cfstrings -Wwrite-strings -w Suppress all warnings -fcolor-diagnostics/-fno-color-diagnostics 开启/关闭诊断色彩 -fdiagnostics-fixit-info/-fno-diagnostics-fixit-info -fdiagnostics-format= clang/msvc/vi -fdiagnostics-parseable-fixits -fdiagnostics-print-source-range-info -fdiagnostics-show-category= none/id/name -fdiagnostics-show-note-include-stack -fno-diagnostics-show-note-include-stack -fdiagnostics-show-option/-fno-diagnostics-show-option 优化 选项 说明 -O 后面指定优化级别,例如,-O2 -O4 -OO 调试信息 选项 说明 -g 另参见--debug -g0 -g2 -g3 -gdwarf-2 -gfull -ggdb -gstabs -gstabs+ -gstabs1 -gstabs2 -gused 预处理 选项 说明 -D Predefine the specified macro -U Undefine the specified macro -E Run preprocessor, emit preprocessed file -C Enable comment output in -E mode -CC Enable comment output in -E mode, even from macro expansions -P Disable linemarker output in -E mode -dD Print macro definitions in -E mode in addition to normal output -dM Print macro definitions in -E mode instead of normal output 标志 所有标志类型的选项都以-f 开头,并且大都有正负两种形式,例如,-fPIC 和-fno-PIC,后 者是前者的负选项形式 选项 说明 -f -fPIC/-fno-PIC -fPIE/-fno-PIE -faccess-control/-fno-access-control -faddress-sanitizer/-fno-address-sanitizer -fallow-unsupported -faltivec -fapple-kext -fapple-pragma-pack/-fno-apple-pragma-pack -fasm/-fno-asm -fasm-blocks/-fno-asm-blocks -fassociative-math/-fno-associative-math -fassume-sane-operator-new/-fno-assume-sane-operator-new -fast -fastcp -fastf -fasynchronous-unwind-tables/-fno-asynchronous-unwind-tables -fblocks/-fno-blocks -fbootclasspath= -fborland-extensions/-fno-borland-extensions -fbuiltin/-fno-builtin -fbuiltin-strcat/-fno-builtin-strcat -fbuiltin-strcpy/-fno-builtin-strcpy -fcaret-diagnostics/-fno-caret-diagnostics -fcatch-undefined-behavior Generate runtime checks for undefined behavior. -fclasspath= -fcommon/-fno-common -fcompile-resource= -fconstant-cfstrings/-fno-constant-cfstrings -fconstant-string-class= -fconstexpr-backtrace-limit= -fconstexpr-depth= -fcreate-profile -fcxx-exceptions/-fno-cxx-exceptions -fcxx-modules/-fno-cxx-modules -fdata-sections -fdebug-pass-arguments -fdebug-pass-structure -fdelayed-template-parsing/-fno-delayed-template-parsing -fdollars-in-identifiers/-fno-dollars-in-identifiers -fdwarf-directory-asm/-fno-dwarf-directory-asm -fdwarf2-cfi-asm/-fno-dwarf2-cfi-asm -felide-constructors/-fno-elide-constructors -feliminate-unused-debug-symbols/ -fno-eliminate-unused-debug-symbols -femit-all-decls -fencoding= -ferror-limit= -fexceptions/-fno-exceptions -fextdirs= -ffast-math -ffinite-math-only/-fno-finite-math-only -ffor-scope/-fno-for-scope -ffreestanding -ffunction-sections -fgnu-keywords/-fno-gnu-keywords -fgnu-runtime -fgnu89-inline/-fno-gnu89-inline -fheinous-gnu-extensions -fhonor-infinites -fhonor-infinities 别名 -fhonor-infinities/-fno-honor-infinites -fhonor-nans/-fno-honor-nans -fhosted -filelist -findirect-virtual-calls -fapple-kext 别名 -finline/-fno-inline -finline-functions/-fno-inline-functions -finstrument-functions -fkeep-inline-functions/-fno-keep-inline-functions -flat_namespace -flax-vector-conversions/-fno-lax-vector-conversions -flimit-debug-info/-fno-limit-debug-info Limit debug information produced to reduce size of debug binary -flimited-precision= -flto/-fno-lto -fmacro-backtrace-limit= -fmath-errno/-fno-math-errno -fmerge-all-constants/-fno-merge-all-constants -fmessage-length= -fmodule-cache-path -fmodules/-fno-modules -fms-compatibility/-fno-ms-compatibility -fms-extensions/-fno-ms-extensions -fmsc-version= -fmudflap -fmudflapth -fnested-functions -fnext-runtime -fobjc -fobjc-abi-version= -fobjc-arc/-fno-objc-arc -fobjc-arc-exceptions/-fno-objc-arc-exceptions -fobjc-atdefs -fobjc-call-cxx-cdtors -fobjc-exceptions/-fno-objc-exceptions -fobjc-gc -fobjc-gc-only -fobjc-infer-related-result-type/-fno-objc-infer-related-result-type -fobjc-legacy-dispatch/-fno-objc-legacy-dispatch -fobjc-link-runtime -fobjc-new-property -fobjc-nonfragile-abi/-fno-objc-nonfragile-abi -fobjc-nonfragile-abi-version= -fobjc-sender-dependent-dispatch -fomit-frame-pointer/-fno-omit-frame-pointer -fopenmp -foptimize-sibling-calls/-fno-optimize-sibling-calls -force-cpusubtype-ALL -force-flat-namespace -force-load -foutput-class-dir= -fpack-struct/-fno-pack-struct -fpack-struct= -fpascal-strings/-fno-pascal-strings -fpch-preprocess -fpic/-fno-pic -fpie/-fno-pie -fprofile-arcs -fprofile-generate -framework -frandom-seed= -freciprocal-math -fno-reciprocal-math -freorder-blocks -frtti/-fno-rtti -fsched-interblock -fshort-enums/-fno-short-enums -fshort-wchar -fshow-column/-fno-show-column -fshow-overloads= -fshow-source-location/-fno-show-source-location -fsignaling-math/-fno-signaling-math -fsigned-bitfields -fsigned-char -fsigned-zeros/-fno-signed-zeros -fspell-checking/-fno-spell-checking -fstack-protector/-fno-stack-protector -fstack-protector-all -fstrict-aliasing/-fno-strict-aliasing -fstrict-enums/-fno-strict-enums -fstrict-overflow/-fno-strict-overflow -fsyntax-only -ftabstop= -ftemplate-backtrace-limit= -ftemplate-depth- -ftemplate-depth= -fterminated-vtables -ftest-coverage -fthread-sanitizer/-fno-thread-sanitizer -fthreadsafe-statics/-fno-threadsafe-statics -ftime-report -ftrap-function= Issue call to specified function rather than a trap instruction -ftrapping-math/-fno-trapping-math -ftrapv -ftrapv-handler= -funit-at-a-time/-fno-unit-at-a-time -funroll-loops -funsafe-math-optimizations -fno-unsafe-math-optimizations -funsigned-bitfields -funsigned-char -funwind-tables/-fno-unwind-tables -fuse-cxa-atexit/-fno-use-cxa-atexit -fverbose-asm/-fno-verbose-asm -fvisibility-inlines-hidden -fvisibility= -fwrapv/-fno-wrapv -fwritable-strings -fzero-initialized-in-bss/-fno-zero-initialized-in-bss -fno-crash-diagnostics -fno-operator-names -fno-working-directory 编译阶段 driver 在创建编译管道时,根据下面这些参数(未包含其别名)确定最后的编译阶段 参数 最后阶段 E\M\MM 预处理 -fsyntax-only\-rewrite-objc\-rewrite-legacy-objc\--migrate \--analyze\--analyze-auto\-emit-ast\-S 编译 -c 汇编 链接 driver 定义了如下几个编译阶段: 预处理 预编译 编译 汇编 链接 Driver 中的每个阶段对应一个工作,例如,预处理阶段对应预处理工作,每个工作都有一 个输出,作为下一阶段的输入,一些选项决定了工作的输出类型,参见下表 阶段 选项 工作类型 输出类型 预处理 -M 预处理 TY_Dependencies -MM 预处理 TY_Dependencies 预处理 取决于输入类型 预编译 预编译 TY_PCH 编译 -fsyntax-only 编译 TY_Nothing -rewrite-objc 编译 TY_RewrittenObjC -rewrite-legacy-objc 编译 TY_RewrittenLegacyObjC --analyze 分析 TY_Plist --analyze-auto 分析 TY_Plist --migrate 迁移 TY_Remap -emit-ast 编译 TY_AST -emit-llvm -S 编译 TY_LTO_IR -emit-llvm 编译 TY_LTO_BC 汇编 汇编 TY_Object Driver 会将工作交给适当的工具处理,工具生成特定于该工具的命令行,例如,Clang 工 具会跟据工作类型、输出类型以及命令行参数生成 Clang(cc1,cc1as)命令行,当然, 一些选项也可以通过直传的方式传递给工具命令行,例如,通过-Xclang 可以直传 Clang 编译器参数,通过-Xlinker 可以直传链接器参数。从 Driver 到工具命令行一般具有如下流 程: clang 选项 分析器 选项 说明 -cfg-add-implicit-dtor Add C++ implicit destructors to CFGs for all analyses -cfg-add-initializers Add C++ initializers to CFGs for all analyses -unoptimized-cfg Generate unoptimized CFGs for all analyses -analyze-function Run analysis on specific function -analyzer-checker Choose analyzer checkers to enable -analyzer-checker-help Display the list of analyzer checkers that are available -analyzer-constraints Source Code Analysis - Symbolic Constraint Engines basic:Use basic constraint tracking range:Use constraint tracking of concrete value ranges -analyzer-disable-checker Choose analyzer checkers to disable Driver Cmdline Tool -analyzer-disable-retry-exhausted Do not re-analyze paths leading to exhausted nodes with a different strategy (may decrease code coverage) -analyzer-display-progress Emit verbose output about the analyzer's progress -analyzer-eagerly-assume Eagerly assume the truth/falseness of some symbolic constraints -analyzer-inline-max-function-size Bound on the number of basic blocks in an inlined function (200 by default) -analyzer-inline-max-stack-depth Bound on stack depth while inlining (4 by default) -analyzer-inlining-mode Specify the function selection heuristic used during inlining all:Analyze all functions in the order defined in the TU noredundancy:Do not analyze a function which has been previously inlined, use call graph to order -analyzer-ipa Specify the inter-procedural analysis mode none:Perform only intra-procedural analysis inlining:Experimental: Inline callees when their definitions are available -analyzer-max-loop The maximum number of times the analyzer will go through a loop -analyzer-max-nodes The maximum number of nodes the analyzer can generate (150000 default, 0 = no limit) -analyzer-no-eagerly-trim-egraph Don't eagerly remove uninteresting ExplodedNodes from the ExplodedGraph -analyzer-opt-analyze-headers Force the static analyzer to analyze functions defined in header files -analyzer-opt-analyze-nested-blocks Analyze the definitions of blocks in addition to functions -analyzer-output -analyzer-output= Source Code Analysis - Output Options html\plist\plist-multi-file\plist-html\text -analyzer-purge -analyzer-purge= Source Code Analysis - Dead Symbol Removal Frequency statement:Purge symbols, bindings, and constraints before every statement block:Purge symbols, bindings, and constraints before every basic block none:Do not purge symbols, bindings, or constraints -analyzer-stats Print internal analyzer statistics. -analyzer-store -analyzer-store= Source Code Analysis - Abstract Memory Store Models region:Use region-based analyzer store -analyzer-viz-egraph-graphviz Display exploded graph using GraphViz -analyzer-viz-egraph-ubigraph Display exploded graph using Ubigraph -trim-egraph Only show error-related paths in the analysis graph 迁移 选项 说明 -migrator-no-finalize-removal -migrator-no-nsalloc-error 依赖 选项 说明 -dependency-dot Filename to write DOT-formatted header dependencies to -dependency-file Filename (or -) to write dependency output to -H Show header includes and nesting depth -header-include-file Filename (or -) to write header include output to -MG Add missing headers to dependency list -MP Create phony target for each dependency (other than main file) -MT Specify target for dependency -sys-header-deps Include system headers in dependency output 文件系统 选项 说明 -working-directory -working-directory= Resolve file paths relative to the specified directory 诊断 选项 说明 -diagnostic-log-file Filename (or -) to log diagnostics to -serialize-diagnostic-file File for serializing diagnostics in a binary format -dump-build-information output a dump of some build information to a file -fcolor-diagnostics Use colors in diagnostics -fconstexpr-backtrace-limit -fdiagnostics-format clang/msvc/vi -fdiagnostics-parseable-fixits -fdiagnostics-print-source-range-info -fdiagnostics-show-category none/id/name -fdiagnostics-show-option Print option name with mappable diagnostics -fdiagnostics-show-note-include-stack -ferror-limit 错误限制(0 为不限制) -fmacro-backtrace-limit 宏展开回溯限制(0 为不限制) -fmessage-length -fno-caret-diagnostics -fno-diagnostics-fixit-info -fno-diagnostics-show-note-include-stack -fno-show-column -fno-show-source-location -fshow-column -fshow-overloads= -ftabstop -ftemplate-backtrace-limit -pedantic -pedantic-errors -verify -w -W -Wno-rewrite-macros Silence ObjC rewriting warnings 前端 选项 说明 -add-plugin Use the named plugin action in addition to the default action -analyze Run static analysis engine -arcmt-check Check for ARC migration issues that need manual handling -arcmt-migrate Apply modifications and produces temporary files that conform to ARC -arcmt-migrate-emit-errors Emit ARC errors even if the migrator can fix them -arcmt-migrate-report-output Output path for the plist report -arcmt-modify Apply modifications to files to conform to ARC -ast-dump Build ASTs and then debug dump them -ast-dump-xml Build ASTs and then debug dump them in a verbose XML format -ast-merge Merge the given AST file into the translation unit being compiled. -ast-print Build ASTs and then pretty-print them -ast-view Build ASTs and view them with GraphViz -code-completion-at Dump code-completion information at a location -code-completion-at= -code-completion-macros Include macros in code-completion results -code-completion-patterns Include code patterns in code-completion results -disable-free Disable freeing of memory on exit -dump-raw-tokens Lex file in raw mode and dump raw tokens -dump-tokens Run preprocessor, dump internal rep of tokens -E Run preprocessor, emit preprocessed file -emit-codegen-only Generate machine code, but discard output -emit-html Output input source as HTML -emit-llvm Build ASTs then convert to LLVM, emit .ll file -emit-llvm-bc Build ASTs then convert to LLVM, emit .bc file -emit-llvm-only Build ASTs and convert to LLVM, discarding output -emit-module Generate pre-compiled module file from a module map -emit-obj Emit native object files -emit-pch Generate pre-compiled header file -emit-pth Generate pre-tokenized header file -Eonly Just run preprocessor, no output (for timings) -fixit Apply fix-it advice to the input source -fixit= Apply fix-it advice creating a file with the given suffix -fixit-recompile Apply fix-it changes and recompile -fixit-to-temporary Apply fix-it changes to temporary files -fix-only-warnings Apply fix-it advice only for warnings, not errors -fix-what-you-can Apply fix-it advice even in the presence of unfixable errors -foverride-record-layout= Override record layouts with those in the given file -fsyntax-only Run parser and perform semantic analysis -ftime-report Print the amount of time each phase of compilation takes -help Print this help text -init-only Only execute frontend initialization -load Load the named plugin (dynamic shared object) -migrate Migrate source code -mllvm Additional arguments to forward to LLVM's option processing -mt-migrate-directory Directory for temporary files produced during ARC or ObjC migration -no-code-completion-globals Do not include global declarations in code-completion results. -o Specify output file -objcmt-migrate-literals Enable migration to modern ObjC literals -objcmt-migrate-subscripting Enable migration to modern ObjC subscripting -plugin Use the named plugin action instead of the default action (use \help\ to list available options) -plugin-arg- Pass to plugin -print-decl-contexts Print DeclContexts and their Decls -print-preamble Print the \preamble\ of a file, which is a candidate for implicit precompiled headers. -print-stats Print performance metrics and statistics -relocatable-pch Whether to build a relocatable precompiled header -rewrite-macros Expand macros without full preprocessing -rewrite-objc Rewrite ObjC into C (code rewriter example) -rewrite-test Rewriter playground -S Emit native assembly code -version Print the compiler version -x Input language type 代码生成 选项 说明 -backend-option Additional arguments to forward to LLVM backend (during code gen) -cl-fast-relaxed-math OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__ -cl-finite-math-only OpenCL only. Allow floating-point optimizations that assume arguments and results are not NaNs or +-Inf. -cl-mad-enable OpenCL only. Enable less precise MAD instructions to be generated. -cl-unsafe-math-optimizations OpenCL only. Allow unsafe floating-point optimizations. Also implies -cl-no-signed-zeros and -cl-mad-enable -coverage-file Emit coverage data to this filename. The extension will be replaced. -disable-llvm-optzns Don't run LLVM optimization passes -disable-llvm-verifier Don't run the LLVM IR verifier pass -disable-red-zone Do not emit code that uses the red zone. -dwarf-debug-flags The string to embed in the Dwarf debug flags record. -fcuda-is-device Generate code for CUDA device -fdata-sections Place each data in its own section (ELF Only) -fdebug-compilation-dir The compilation directory to embed in the debug info. -femit-coverage-data Instrument the program to emit gcov coverage data when run. -femit-coverage-notes Emit a gcov coverage notes file when compiling. -fforbid-guard-variables Emit an error if a C++ static local initializer would need a guard variable -ffreestanding Assert that the compilation takes place in a freestanding environment -ffunction-sections Place each function in its own section (ELF Only) -fhidden-weak-vtables Generate weak vtables and RTTI with hidden visibility -finstrument-functions Generate calls to instrument function entry and exit -flimit-debug-info Limit debug information produced to reduce size of debug binary -fno-builtin Disable implicit builtin knowledge of functions -fno-common Compile common globals like normal definitions -fno-dwarf2-cfi-asm Don't use the cfi directives -fno-dwarf-directory-asm Don't separate directory and filename in .file directives -fno-inline Disable use of the inline keyword -fno-inline-functions Disable automatic function inlining -fno-limit-debug-info Do not limit debug information produced to reduce size of debug binary -fno-merge-all-constants Disallow merging of constants. -fno-use-cxa-atexit Don't use __cxa_atexit for calling destructors -fobjc-arc-exceptions Use EH-safe code when synthesizing retains and releases in -fobjc-arc -fobjc-dispatch-method= Objective-C dispatch method to use -fobjc-runtime-has-arc The target Objective-C runtime provides ARC entrypoints -fobjc-runtime-has-terminate The target Objective-C runtime provides an objc_terminate entrypoint -fstrict-enums Enable optimizations based on the strict definition of an enum's value range. -ftrap-function= Issue call to specified function rather than a trap instruction -funroll-loops Turn on loop unroller -fuse-register-sized-bitfield-access Use register sized accesses to bit-fields, when possible. -g Generate source level debug information -main-file-name Main file name to use for debug info -masm-verbose Generate verbose assembly output -mcode-model The code model to use -mconstructor-aliases Emit complete constructors and destructors as aliases when possible -mdebug-pass Enable additional debug output -mdisable-fp-elim Disable frame pointer elimination optimization -mdisable-tail-calls Disable tail call optimization, keeping the call stack accurate -menable-no-infs Allow optimization to assume there are no infinities. -menable-no-nans Allow optimization to assume there are no NaNs. -menable-unsafe-fp-math Allow unsafe floating-point math optimizations which may decrease precision -mfloat-abi The float ABI to use -mlimit-float-precision Limit float precision to the given value -mlink-bitcode-file Link the given bitcode file before performing optimizations. -mnoexecstack Mark the file as not needing an executable stack -mno-global-merge Disable merging of globals -mno-zero-initialized-in-bss Do not put zero initialized data in the BSS -momit-leaf-frame-pointer Omit frame pointer setup for leaf functions. -mregparm Limit the number of registers available for integer arguments -mrelax-all (integrated-as) Relax all machine instructions -mrelocation-model The relocation model to use -msave-temp-labels (integrated-as) Save temporary labels -msoft-float Use software floating point -mstack-alignment= Set the stack alignment -mstackrealign Force realign the stack at entry to every function. -munwind-tables Generate unwinding tables for all functions -no-implicit-float Don't generate implicit floating point instructions (x86-only) -Os Optimize for size -Oz Optimize for size, regardless of performance -pg Enable mcount instrumentation -relaxed-aliasing Turn off Type Based Alias Analysis 头文件搜索 选项 说明 -c-isystem Add directory to the C SYSTEM include search path -cxx-isystem Add directory to the C++ SYSTEM include search path -F Add directory to framework include search path -fdisable-module-hash Disable the module hash -fmodule-cache-path Specify the module cache path -I Add directory to include search path -idirafter Add directory to AFTER include search path -iframework Add directory to SYSTEM framework search path -index-header-map Make the next included directory (-I or -F) an indexer header map -internal-externc-isystem Add directory to the internal system include search path with implicit extern \C\ semantics; these are assumed to not be user-provided and are used to model system and standard headers' paths. -internal-isystem Add directory to the internal system include search path; these are assumed to not be user-provided and are used to model system and standard headers' paths. -iprefix Set the -iwithprefix/-iwithprefixbefore prefix -iquote Add directory to QUOTE include search path -isysroot Set the system root directory (usually /) -isystem Add directory to SYSTEM include search path -iwithprefix Set directory to SYSTEM include search path with prefix -iwithprefixbefore Set directory to include search path with prefix -iwithsysroot Add directory to SYSTEM include search path, absolute paths are relative to -isysroot -nobuiltininc Disable builtin #include directories -nostdinc++ Disable standard #include directories for the C++ standard library -nostdsysteminc Disable standard system #include directories -objc-isystem Add directory to the ObjC SYSTEM include search path -objcxx-isystem Add directory to the ObjC++ SYSTEM include search path -resource-dir The directory which holds the compiler resource files -stdlib= C++ standard library to use -v Enable verbose output 语言 选项 说明 -cl-fast-relaxed-math OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__ -cl-single-precision-constant OpenCL only. Treat double precision floating-point constant as single precision constant. -cl-std= OpenCL language standard to compile for -faddress-sanitizer Enable AddressSanitizer instrumentation (memory error detection) -faltivec Enable AltiVec vector initializer syntax -fapple-kext Use Apple's kernel extensions ABI -fapple-pragma-pack Enable Apple gcc-compatible #pragma pack handling -fblocks Enable the 'blocks' language feature -fblocks-runtime-optional Weakly link in the blocks runtime -fborland-extensions Accept non-standard constructs supported by the Borland compiler -fcatch-undefined-behavior Generate runtime checks for undefined behavior. -fconstant-string-class Specify the class to use for constant Objective-C string objects. -fconstexpr-depth Maximum depth of recursive constexpr function calls -fconst-strings Use a const qualified type for string literals in C and ObjC -fcxx-exceptions Enable C++ exceptions -fdebugger-cast-result-to-id Enable casting unknown expression results to id -fdebugger-objc-literal Enable special debugger support for objective-C subscripting and literals -fdebugger-support Enable special debugger support behavior -fdelayed-template-parsing Parse templated function definitions at the end of the translation unit -fdeprecated-macro Defines the __DEPRECATED macro -fdollars-in-identifiers Allow '$' in identifiers -fdump-record-layouts Dump record layout information -fdump-record-layouts-simple Dump record layout information in a simple form used for testing -fdump-vtable-layouts Dump the layouts of all vtables that will be emitted in a translation unit -femit-all-decls Emit all declarations, even if unused -fexceptions Enable support for exception handling -ffake-address-space-map Use a fake address space map; OpenCL testing purposes only -ffast-math Enable the *frontend*'s 'fast-math' mode. This has no effect on optimizations, but provides a preprocessor macro __FAST_MATH__ the same as GCC's -ffast-math flag. -ffreestanding -fgnu89-inline Use the gnu89 inline semantics -fgnu-keywords Allow GNU-extension keywords regardless of language standard -fgnu-runtime Generate output compatible with the standard GNU Objective-C runtime -fheinous-gnu-extensions Assert that the compilation takes place in a freestanding environment -fmath-errno Require math functions to indicate errors by setting errno -fmodule-name Specify the name of the module to build -fmodules Enable the 'modules' language feature -fms-compatibility Enable Microsoft compatibility mode -fmsc-version Version of the Microsoft C/C++ compiler to report in _MSC_VER (0 = don't define it (default)) -fms-extensions Accept some non-standard constructs supported by the Microsoft compiler -fno-access-control Disable C++ access control -fno-assume-sane-operator-new Don't assume that C++'s global operator new can't alias any pointer -fno-bitfield-type-align Ignore bit-field types when aligning structures -fno-builtin Disable implicit builtin knowledge of functions -fno-constant-cfstrings Enable creation of CodeFoundation-type constant strings -fno-const-strings Don't use a const qualified type for string literals in C and ObjC -fno-deprecated-macro Undefines the __DEPRECATED macro -fno-dollars-in-identifiers Disallow '$' in identifiers -fno-elide-constructors Disable C++ copy constructor elision -fno-gnu-keywords Disallow GNU-extension keywords regardless of language standard -fno-inline Disable use of the inline keyword -fno-lax-vector-conversions Disallow implicit conversions between vectors with a different number of elements or different element types -fno-objc-infer-related-result-type do not infer Objective-C related result type based on method family -fno-operator-names Do not treat C++ operator name keywords as synonyms for operators -fno-rtti Disable generation of rtti information -fno-signed-char Char is unsigned -fno-spell-checking Disable spell-checking -fno-threadsafe-statics Do not emit code to make initialization of local statics thread safe -fobjc-arc -fobjc-default-synthesize-properties -fobjc-exceptions -fobjc-fragile-abi -fobjc-gc -fobjc-gc-only -fobjc-runtime-has-weak -fpack-struct Specify the default maximum struct packing alignment -fpascal-strings Recognize and construct Pascal-style string literals -fshort-enums Allocate to an enum type only as many bytes as it needs for the declared range of possible values -fshort-wchar Force wchar_t to be a short unsigned int -fsjlj-exceptions Use SjLj style exceptions -ftemplate-depth Maximum depth of recursive template instantiation -fthread-sanitizer Enable ThreadSanitizer instrumentation (race detection) -ftrapv Trap on integer overflow -ftrapv-handler Specify the function to be called on overflow. -funknown-anytype Enable parser support for the __unknown_anytype type; for testing purposes only -fvisibility Default symbol visibility default\ hidden\ protected -fvisibility-inlines-hidden Give inline C++ member functions default visibility by default -fwrapv Treat signed integer overflow as two's complement -fwritable-strings Store string literals as writable data -mms-bitfields Set the default structure layout to be compatible with the Microsoft compiler standard. -mqdsp6-compat Enable hexagon-qdsp6 backward compatibility -mrtd Make StdCall calling convention the default -Os Optimize for size -Oz Optimize for size, regardless of performance -pic-level Value for __PIC__ -pie-level Value for __PIE__ -print-ivar-layout Enable Objective-C Ivar layout bitmap print trace -pthread Support POSIX threads in generated code -stack-protector Enable stack protectors -static-define Should __STATIC__ be defined -std= Language standard to compile for c89\c90\iso9899:1990\iso9899:199409\gnu89\gnu90 c99\c9x\iso9899:1999\iso9899:199x\gnu99\gnu9x c11\c1x\iso9899:2011\gnu11\gnu1x c++98\c++03\gnu++98 c++0x\c++11\gnu++0x\gnu++11 cl\cuda 注意:driver 也有这个选项 -traditional-cpp Enable some traditional CPP emulation -trigraphs Process trigraph sequences -Wlarge-by-value-copy Warn if a function definition returns or accepts an object larger in bytes that a given value -Wlarge-by-value-copy= -Wlarge-by-value-copy 别名 预处理 选项 说明 -chain-include Include and chain a header file after turning it into PCH -D Predefine the specified macro -detailed-preprocessing-record include a detailed record of preprocessing actions -dump-deserialized-pch-decls -error-on-deserialized-pch-decl -faltivec Enable AltiVec vector initializer syntax -fno-validate-pch Disable validation of precompiled headers -fobjc-arc-cxxlib= Objective-C++ Automatic Reference Counting standard library kind -imacros Include macros from file before parsing -include Include file before parsing -include-pch Include precompiled header file -include-pth Include file before parsing -preamble-bytes= Assume that the precompiled header is a precompiled preamble covering the first N bytes of the main file -remap-file Replace the contents of the file with the contents of the file -token-cache Use specified token cache file -U Undefine the specified macro -undef undef all system defines 预处理输出 选项 说明 -dM Print macro definitions in -E mode instead of normal output -dD Print macro definitions in -E mode in addition to normal output -C Enable comment output in -E mode -P Disable linemarker output in -E mode -CC Enable comment output in -E mode, even from macro expansions 目标 选项 说明 -cxx-abi Target a particular C++ ABI type -target-abi Target a particular ABI type -target-cpu Target a specific cpu type -target-feature Target specific attributes -target-linker-version Target linker version -triple -triple= Specify target triple (e.g. i686-apple-darwin9)

相关文档