网站首页 > 博客文章 正文
GCC是每个从事Linux,以及嵌入式开发等必备的编译器,由于帮助手册较多,这里使用了分页的形式进行分享,如下为Ubuntu Server 22.04操作系统平台。
GCC帮助手册的第5小节,第747~947行。
747 This option is disregarded if it does not match the suffix of a specified dumpbase, except as an
748 alternative to the executable suffix when appending the linker output base name to dumppfx, as specified
749 below:
750 gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
751 creates main.out as the primary output, and avoids overwriting the auxiliary and dump outputs by using the
752 executable name minus auxdropsuf as a prefix, creating auxiliary outputs named main-foo.* and main-bar.*
753 and dump outputs named main-foo.c.* and main-bar.c.*.
754 -dumpdir dumppfx
755 When forming the name of an auxiliary or dump output file, use dumppfx as a prefix:
756 gcc -dumpdir pfx- -c foo.c ...
757 creates foo.o as the primary output, and auxiliary outputs named pfx-foo.*, combining the given dumppfx
758 with the default dumpbase derived from the default primary output, derived in turn from the input name.
759 Dump outputs also take the input name suffix: pfx-foo.c.*.
760 If dumppfx is to be used as a directory name, it must end with a directory separator:
761 gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
762 creates obj/bar.o as the primary output, and auxiliary outputs named dir/bar.*, combining the given dumppfx
763 with the default dumpbase derived from the primary output name. Dump outputs also take the input name
764 suffix: dir/bar.c.*.
765 It defaults to the location of the output file, unless the output file is a special file like "/dev/null".
766 Options -save-temps=cwd and -save-temps=obj override this default, just like an explicit -dumpdir option.
767 In case multiple such options are given, the last one prevails:
768 gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
769 outputs foo.o, with auxiliary outputs named foo.* because -save-temps=* overrides the dumppfx given by the
770 earlier -dumpdir option. It does not matter that =obj is the default for -save-temps, nor that the output
771 directory is implicitly the current directory. Dump outputs are named foo.c.*.
772 When compiling from multiple input files, if -dumpbase is specified, dumpbase, minus a auxdropsuf suffix,
773 and a dash are appended to (or override, if containing any directory components) an explicit or defaulted
774 dumppfx, so that each of the multiple compilations gets differently-named aux and dump outputs.
775 gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
776 outputs auxiliary dumps to dir/pfx-main-foo.* and dir/pfx-main-bar.*, appending dumpbase- to dumppfx. Dump
777 outputs retain the input file suffix: dir/pfx-main-foo.c.* and dir/pfx-main-bar.c.*, respectively.
778 Contrast with the single-input compilation:
779 gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
780 that, applying -dumpbase to a single source, does not compute and append a separate dumpbase per input
781 file. Its auxiliary and dump outputs go in dir/pfx-main.*.
782 When compiling and then linking from multiple input files, a defaulted or explicitly specified dumppfx also
783 undergoes the dumpbase- transformation above (e.g. the compilation of foo.c and bar.c above, but without
784 -c). If neither -dumpdir nor -dumpbase are given, the linker output base name, minus auxdropsuf, if
785 specified, or the executable suffix otherwise, plus a dash is appended to the default dumppfx instead.
786 Note, however, that unlike earlier cases of linking:
787 gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
788 does not append the output name main to dumppfx, because -dumpdir is explicitly specified. The goal is
789 that the explicitly-specified dumppfx may contain the specified output name as part of the prefix, if
790 desired; only an explicitly-specified -dumpbase would be combined with it, in order to avoid simply
791 discarding a meaningful option.
792 When compiling and then linking from a single input file, the linker output base name will only be appended
793 to the default dumppfx as above if it does not share the base name with the single input file name. This
794 has been covered in single-input linking cases above, but not with an explicit -dumpdir that inhibits the
795 combination, even if overridden by -save-temps=*:
796 gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
797 Auxiliary outputs are named foo.*, and dump outputs foo.c.*, in the current working directory as ultimately
798 requested by -save-temps=cwd.
799 Summing it all up for an intuitive though slightly imprecise data flow: the primary output name is broken
800 into a directory part and a basename part; dumppfx is set to the former, unless overridden by -dumpdir or
801 -save-temps=*, and dumpbase is set to the latter, unless overriden by -dumpbase. If there are multiple
802 inputs or linking, this dumpbase may be combined with dumppfx and taken from each input file. Auxiliary
803 output names for each input are formed by combining dumppfx, dumpbase minus suffix, and the auxiliary
804 output suffix; dump output names are only different in that the suffix from dumpbase is retained.
805 When it comes to auxiliary and dump outputs created during LTO recompilation, a combination of dumppfx and
806 dumpbase, as given or as derived from the linker output name but not from inputs, even in cases in which
807 this combination would not otherwise be used as such, is passed down with a trailing period replacing the
808 compiler-added dash, if any, as a -dumpdir option to lto-wrapper; being involved in linking, this program
809 does not normally get any -dumpbase and -dumpbase-ext, and it ignores them.
810 When running sub-compilers, lto-wrapper appends LTO stage names to the received dumppfx, ensures it
811 contains a directory component so that it overrides any -dumpdir, and passes that as -dumpbase to sub-
812 compilers.
813 -v Print (on standard error output) the commands executed to run the stages of compilation. Also print the
814 version number of the compiler driver program and of the preprocessor and the compiler proper.
815 -###
816 Like -v except the commands are not executed and arguments are quoted unless they contain only alphanumeric
817 characters or "./-_". This is useful for shell scripts to capture the driver-generated command lines.
818 --help
819 Print (on the standard output) a description of the command-line options understood by gcc. If the -v
820 option is also specified then --help is also passed on to the various processes invoked by gcc, so that
821 they can display the command-line options they accept. If the -Wextra option has also been specified
822 (prior to the --help option), then command-line options that have no documentation associated with them are
823 also displayed.
824 --target-help
825 Print (on the standard output) a description of target-specific command-line options for each tool. For
826 some targets extra target-specific information may also be printed.
827 --help={class|[^]qualifier}[,...]
828 Print (on the standard output) a description of the command-line options understood by the compiler that
829 fit into all specified classes and qualifiers. These are the supported classes:
830 optimizers
831 Display all of the optimization options supported by the compiler.
832 warnings
833 Display all of the options controlling warning messages produced by the compiler.
834 target
835 Display target-specific options. Unlike the --target-help option however, target-specific options of
836 the linker and assembler are not displayed. This is because those tools do not currently support the
837 extended --help= syntax.
838 params
839 Display the values recognized by the --param option.
840 language
841 Display the options supported for language, where language is the name of one of the languages
842 supported in this version of GCC. If an option is supported by all languages, one needs to select
843 common class.
844 common
845 Display the options that are common to all languages.
846 These are the supported qualifiers:
847 undocumented
848 Display only those options that are undocumented.
849 joined
850 Display options taking an argument that appears after an equal sign in the same continuous piece of
851 text, such as: --help=target.
852 separate
853 Display options taking an argument that appears as a separate word following the original option, such
854 as: -o output-file.
855 Thus for example to display all the undocumented target-specific switches supported by the compiler, use:
856 --help=target,undocumented
857 The sense of a qualifier can be inverted by prefixing it with the ^ character, so for example to display
858 all binary warning options (i.e., ones that are either on or off and that do not take an argument) that
859 have a description, use:
860 --help=warnings,^joined,^undocumented
861 The argument to --help= should not consist solely of inverted qualifiers.
862 Combining several classes is possible, although this usually restricts the output so much that there is
863 nothing to display. One case where it does work, however, is when one of the classes is target. For
864 example, to display all the target-specific optimization options, use:
865 --help=target,optimizers
866 The --help= option can be repeated on the command line. Each successive use displays its requested class
867 of options, skipping those that have already been displayed. If --help is also specified anywhere on the
868 command line then this takes precedence over any --help= option.
869 If the -Q option appears on the command line before the --help= option, then the descriptive text displayed
870 by --help= is changed. Instead of describing the displayed options, an indication is given as to whether
871 the option is enabled, disabled or set to a specific value (assuming that the compiler knows this at the
872 point where the --help= option is used).
873 Here is a truncated example from the ARM port of gcc:
874 % gcc -Q -mabi=2 --help=target -c
875 The following options are target specific:
876 -mabi= 2
877 -mabort-on-noreturn [disabled]
878 -mapcs [disabled]
879 The output is sensitive to the effects of previous command-line options, so for example it is possible to
880 find out which optimizations are enabled at -O2 by using:
881 -Q -O2 --help=optimizers
882 Alternatively you can discover which binary optimizations are enabled by -O3 by using:
883 gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
884 gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
885 diff /tmp/O2-opts /tmp/O3-opts | grep enabled
886 --version
887 Display the version number and copyrights of the invoked GCC.
888 -pass-exit-codes
889 Normally the gcc program exits with the code of 1 if any phase of the compiler returns a non-success return
890 code. If you specify -pass-exit-codes, the gcc program instead returns with the numerically highest error
891 produced by any phase returning an error indication. The C, C++, and Fortran front ends return 4 if an
892 internal compiler error is encountered.
893 -pipe
894 Use pipes rather than temporary files for communication between the various stages of compilation. This
895 fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has
896 no trouble.
897 -specs=file
898 Process file after the compiler reads in the standard specs file, in order to override the defaults which
899 the gcc driver program uses when determining what switches to pass to cc1, cc1plus, as, ld, etc. More than
900 one -specs=file can be specified on the command line, and they are processed in order, from left to right.
901 -wrapper
902 Invoke all subcommands under a wrapper program. The name of the wrapper program and its parameters are
903 passed as a comma separated list.
904 gcc -c t.c -wrapper gdb,--args
905 This invokes all subprograms of gcc under gdb --args, thus the invocation of cc1 is gdb --args cc1 ....
906 -ffile-prefix-map=old=new
907 When compiling files residing in directory old, record any references to them in the result of the
908 compilation as if the files resided in directory new instead. Specifying this option is equivalent to
909 specifying all the individual -f*-prefix-map options. This can be used to make reproducible builds that
910 are location independent. See also -fmacro-prefix-map and -fdebug-prefix-map.
911 -fplugin=name.so
912 Load the plugin code in file name.so, assumed to be a shared object to be dlopen'd by the compiler. The
913 base name of the shared object file is used to identify the plugin for the purposes of argument parsing
914 (See -fplugin-arg-name-key=value below). Each plugin should define the callback functions specified in the
915 Plugins API.
916 -fplugin-arg-name-key=value
917 Define an argument called key with a value of value for the plugin called name.
918 -fdump-ada-spec[-slim]
919 For C and C++ source and include files, generate corresponding Ada specs.
920 -fada-spec-parent=unit
921 In conjunction with -fdump-ada-spec[-slim] above, generate Ada specs as child units of parent unit.
922 -fdump-go-spec=file
923 For input files in any language, generate corresponding Go declarations in file. This generates Go
924 "const", "type", "var", and "func" declarations which may be a useful way to start writing a Go interface
925 to code written in some other language.
926 @file
927 Read command-line options from file. The options read are inserted in place of the original @file option.
928 If file does not exist, or cannot be read, then the option will be treated literally, and not removed.
929 Options in file are separated by whitespace. A whitespace character may be included in an option by
930 surrounding the entire option in either single or double quotes. Any character (including a backslash) may
931 be included by prefixing the character to be included with a backslash. The file may itself contain
932 additional @file options; any such options will be processed recursively.
933 Compiling C++ Programs
934 C++ source files conventionally use one of the suffixes .C, .cc, .cpp, .CPP, .c++, .cp, or .cxx; C++ header
935 files often use .hh, .hpp, .H, or (for shared template code) .tcc; and preprocessed C++ files use the suffix
936 .ii. GCC recognizes files with these names and compiles them as C++ programs even if you call the compiler the
937 same way as for compiling C programs (usually with the name gcc).
938 However, the use of gcc does not add the C++ library. g++ is a program that calls GCC and automatically
939 specifies linking against the C++ library. It treats .c, .h and .i files as C++ source files instead of C
940 source files unless -x is used. This program is also useful when precompiling a C header file with a .h
941 extension for use in C++ compilations. On many systems, g++ is also installed with the name c++.
942 When you compile C++ programs, you may specify many of the same command-line options that you use for compiling
943 programs in any language; or command-line options meaningful for C and related languages; or options that are
944 meaningful only for C++ programs.
945 Options Controlling C Dialect
946 The following options control the dialect of C (or languages derived from C, such as C++, Objective-C and
947 Objective-C++) that the compiler accepts:
猜你喜欢
- 2024-09-12 亚马逊自研Graviton4芯片实测,比英特尔至强8488C快5%
- 2024-09-12 Linux Ubuntu系统部署C++环境的方法
- 2024-09-12 加上一个关键字,数组遍历耗时从7.8秒降到1.4秒,这是为什么呢?
- 2024-09-12 ubuntu下安装CUDA,cuDNN及pytorch-gpu版本的步骤教程
- 2024-09-12 Ubuntu 20.04 CUDA&cuDNN安装方法
- 2024-09-12 手把手教你在 Ubuntu16.04 安装 GPU 驱动 + CUDA9.0 + cuDNN7
- 2024-09-12 ubuntu 19.10有什么新特性?(ubuntu 20.10 新特性)
- 2024-09-12 Ubuntu 24.10 开发代号确定为 "Oracular Oriole"
- 2024-09-12 Ubuntu 20.10迎来最后一个Beta测试版本
- 2024-09-12 如何在Linux系统上安装最新版本的VMware
你 发表评论:
欢迎- 367℃用AI Agent治理微服务的复杂性问题|QCon
- 358℃初次使用IntelliJ IDEA新建Maven项目
- 358℃手把手教程「JavaWeb」优雅的SpringMvc+Mybatis整合之路
- 351℃Maven技术方案最全手册(mavena)
- 348℃安利Touch Bar 专属应用,让闲置的Touch Bar活跃起来!
- 346℃InfoQ 2024 年趋势报告:架构篇(infoq+2024+年趋势报告:架构篇分析)
- 345℃IntelliJ IDEA 2018版本和2022版本创建 Maven 项目对比
- 342℃从头搭建 IntelliJ IDEA 环境(intellij idea建包)
- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)