📄 fragments.texi
字号:
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,@c 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.@c This is part of the GCC manual.@c For copying conditions, see the file gcc.texi.@node Fragments@chapter Makefile Fragments@cindex makefile fragmentWhen you configure GCC using the @file{configure} script, it willconstruct the file @file{Makefile} from the template file@file{Makefile.in}. When it does this, it can incorporate makefilefragments from the @file{config} directory. These are used to setMakefile parameters that are not amenable to being calculated byautoconf. The list of fragments to incorporate is set by@file{config.gcc} (and occasionally @file{config.build}and @file{config.host}); @xref{System Config}.Fragments are named either @file{t-@var{target}} or @file{x-@var{host}},depending on whether they are relevant to configuring GCC to producecode for a particular target, or to configuring GCC to run on aparticular host. Here @var{target} and @var{host} are mnemonicswhich usually have some relationship to the canonical system name, butno formal connection.If these files do not exist, it means nothing needs to be added for agiven target or host. Most targets need a few @file{t-@var{target}}fragments, but needing @file{x-@var{host}} fragments is rare.@menu* Target Fragment:: Writing @file{t-@var{target}} files.* Host Fragment:: Writing @file{x-@var{host}} files.@end menu@node Target Fragment@section Target Makefile Fragments@cindex target makefile fragment@cindex @file{t-@var{target}}Target makefile fragments can set these Makefile variables.@table @code@findex LIBGCC2_CFLAGS@item LIBGCC2_CFLAGSCompiler flags to use when compiling @file{libgcc2.c}.@findex LIB2FUNCS_EXTRA@item LIB2FUNCS_EXTRAA list of source file names to be compiled or assembled and insertedinto @file{libgcc.a}.@findex Floating Point Emulation@item Floating Point EmulationTo have GCC include software floating point libraries in @file{libgcc.a}define @code{FPBIT} and @code{DPBIT} along with a few rules as follows:@smallexample# We want fine grained libraries, so use the new code# to build the floating point emulation libraries.FPBIT = fp-bit.cDPBIT = dp-bit.cfp-bit.c: $(srcdir)/config/fp-bit.c echo '#define FLOAT' > fp-bit.c cat $(srcdir)/config/fp-bit.c >> fp-bit.cdp-bit.c: $(srcdir)/config/fp-bit.c cat $(srcdir)/config/fp-bit.c > dp-bit.c@end smallexampleYou may need to provide additional #defines at the beginning of @file{fp-bit.c}and @file{dp-bit.c} to control target endianness and other options.@findex CRTSTUFF_T_CFLAGS@item CRTSTUFF_T_CFLAGSSpecial flags used when compiling @file{crtstuff.c}.@xref{Initialization}.@findex CRTSTUFF_T_CFLAGS_S@item CRTSTUFF_T_CFLAGS_SSpecial flags used when compiling @file{crtstuff.c} for sharedlinking. Used if you use @file{crtbeginS.o} and @file{crtendS.o}in @code{EXTRA-PARTS}.@xref{Initialization}.@findex MULTILIB_OPTIONS@item MULTILIB_OPTIONSFor some targets, invoking GCC in different ways produces objectsthat can not be linked together. For example, for some targets GCCproduces both big and little endian code. For these targets, you mustarrange for multiple versions of @file{libgcc.a} to be compiled, one foreach set of incompatible options. When GCC invokes the linker, itarranges to link in the right version of @file{libgcc.a}, based onthe command line options used.The @code{MULTILIB_OPTIONS} macro lists the set of options for whichspecial versions of @file{libgcc.a} must be built. Write options thatare mutually incompatible side by side, separated by a slash. Writeoptions that may be used together separated by a space. The buildprocedure will build all combinations of compatible options.For example, if you set @code{MULTILIB_OPTIONS} to @samp{m68000/m68020msoft-float}, @file{Makefile} will build special versions of@file{libgcc.a} using the following sets of options: @option{-m68000},@option{-m68020}, @option{-msoft-float}, @samp{-m68000 -msoft-float}, and@samp{-m68020 -msoft-float}.@findex MULTILIB_DIRNAMES@item MULTILIB_DIRNAMESIf @code{MULTILIB_OPTIONS} is used, this variable specifies thedirectory names that should be used to hold the various libraries.Write one element in @code{MULTILIB_DIRNAMES} for each element in@code{MULTILIB_OPTIONS}. If @code{MULTILIB_DIRNAMES} is not used, thedefault value will be @code{MULTILIB_OPTIONS}, with all slashes treatedas spaces.For example, if @code{MULTILIB_OPTIONS} is set to @samp{m68000/m68020msoft-float}, then the default value of @code{MULTILIB_DIRNAMES} is@samp{m68000 m68020 msoft-float}. You may specify a different value ifyou desire a different set of directory names.@findex MULTILIB_MATCHES@item MULTILIB_MATCHESSometimes the same option may be written in two different ways. If anoption is listed in @code{MULTILIB_OPTIONS}, GCC needs to know aboutany synonyms. In that case, set @code{MULTILIB_MATCHES} to a list ofitems of the form @samp{option=option} to describe all relevantsynonyms. For example, @samp{m68000=mc68000 m68020=mc68020}.@findex MULTILIB_EXCEPTIONS@item MULTILIB_EXCEPTIONSSometimes when there are multiple sets of @code{MULTILIB_OPTIONS} beingspecified, there are combinations that should not be built. In thatcase, set @code{MULTILIB_EXCEPTIONS} to be all of the switch exceptionsin shell case syntax that should not be built.For example the ARM processor cannot execute both hardware floatingpoint instructions and the reduced size THUMB instructions at the sametime, so there is no need to build libraries with both of theseoptions enabled. Therefore @code{MULTILIB_EXCEPTIONS} is set to:@smallexample*mthumb/*mhard-float*@end smallexample@findex MULTILIB_EXTRA_OPTS@item MULTILIB_EXTRA_OPTSSometimes it is desirable that when building multiple versions of@file{libgcc.a} certain options should always be passed on to thecompiler. In that case, set @code{MULTILIB_EXTRA_OPTS} to be the listof options to be used for all builds. If you set this, you shouldprobably set @code{CRTSTUFF_T_CFLAGS} to a dash followed by it.@findex NATIVE_SYSTEM_HEADER_DIR@item NATIVE_SYSTEM_HEADER_DIRIf the default location for system headers is not @file{/usr/include},you must set this to the directory containing the headers. This valueshould match the value of the @code{SYSTEM_INCLUDE_DIR} macro.@findex SPECS@item SPECSUnfortunately, setting @code{MULTILIB_EXTRA_OPTS} is not enough, sinceit does not affect the build of target libraries, at least not thebuild of the default multilib. One possible work-around is to use@code{DRIVER_SELF_SPECS} to bring options from the @file{specs} fileas if they had been passed in the compiler driver command line.However, you don't want to be adding these options after the toolchainis installed, so you can instead tweak the @file{specs} file that willbe used during the toolchain build, while you still install theoriginal, built-in @file{specs}. The trick is to set @code{SPECS} tosome other filename (say @file{specs.install}), that will then becreated out of the built-in specs, and introduce a @file{Makefile}rule to generate the @file{specs} file that's going to be used atbuild time out of your @file{specs.install}.@end table@node Host Fragment@section Host Makefile Fragments@cindex host makefile fragment@cindex @file{x-@var{host}}The use of @file{x-@var{host}} fragments is discouraged. You should doso only if there is no other mechanism to get the behavior desired.Host fragments should never forcibly override variables set by theconfigure script, as they may have been adjusted by the user.Variables provided for host fragments to set include:@table @code@item X_CFLAGS@itemx X_CPPFLAGSThese are extra flags to pass to the C compiler and preprocessor,respectively. They are used both when building GCC, and when compilingthings with the just-built GCC@.@item XCFLAGSThese are extra flags to use when building the compiler. They are notused when compiling @file{libgcc.a}. However, they @emph{are} used whenrecompiling the compiler with itself in later stages of a bootstrap.@item BOOT_LDFLAGSFlags to be passed to the linker when recompiling the compiler withitself in later stages of a bootstrap. You might need to use this if,for instance, one of the front ends needs more text space than thelinker provides by default.@item EXTRA_PROGRAMSA list of additional programs required to use the compiler on this host,which should be compiled with GCC and installed alongside the frontends. If you set this variable, you must also provide rules to buildthe extra programs.@end table
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -