Target Makefile Fragments#
Target makefile fragments can set these Makefile variables.
LIBGCC2_CFLAGSCompiler flags to use when compiling
libgcc2.c.LIB2FUNCS_EXTRAA list of source file names to be compiled or assembled and inserted into
libgcc.a.
- CRTSTUFF_T_CFLAGS#
Special flags used when compiling
crtstuff.c. See How Initialization Functions Are Handled.
- CRTSTUFF_T_CFLAGS_S#
Special flags used when compiling
crtstuff.cfor shared linking. Used if you usecrtbeginS.oandcrtendS.oinEXTRA-PARTS. See How Initialization Functions Are Handled.
- MULTILIB_OPTIONS#
For some targets, invoking GCC in different ways produces objects that cannot be linked together. For example, for some targets GCC produces both big and little endian code. For these targets, you must arrange for multiple versions of
libgcc.ato be compiled, one for each set of incompatible options. When GCC invokes the linker, it arranges to link in the right version oflibgcc.a, based on the command line options used.The
MULTILIB_OPTIONSmacro lists the set of options for which special versions oflibgcc.amust be built. Write options that are mutually incompatible side by side, separated by a slash. Write options that may be used together separated by a space. The build procedure will build all combinations of compatible options.For example, if you set
MULTILIB_OPTIONStom68000/m68020 msoft-float,Makefilewill build special versions oflibgcc.ausing the following sets of options:-m68000,-m68020,-msoft-float,-m68000 -msoft-float, and-m68020 -msoft-float.
- MULTILIB_DIRNAMES#
If
MULTILIB_OPTIONSis used, this variable specifies the directory names that should be used to hold the various libraries. Write one element inMULTILIB_DIRNAMESfor each element inMULTILIB_OPTIONS. IfMULTILIB_DIRNAMESis not used, the default value will beMULTILIB_OPTIONS, with all slashes treated as spaces.MULTILIB_DIRNAMESdescribes the multilib directories using GCC conventions and is applied to directories that are part of the GCC installation. When multilib-enabled, the compiler will add a subdirectory of the formprefix/multilibbefore each directory in the search path for libraries and crt files.For example, if
MULTILIB_OPTIONSis set tom68000/m68020 msoft-float, then the default value ofMULTILIB_DIRNAMESism68000 m68020 msoft-float. You may specify a different value if you desire a different set of directory names.
- MULTILIB_MATCHES#
Sometimes the same option may be written in two different ways. If an option is listed in
MULTILIB_OPTIONS, GCC needs to know about any synonyms. In that case, setMULTILIB_MATCHESto a list of items of the formoption=optionto describe all relevant synonyms. For example,m68000=mc68000 m68020=mc68020.
- MULTILIB_EXCEPTIONS#
Sometimes when there are multiple sets of
MULTILIB_OPTIONSbeing specified, there are combinations that should not be built. In that case, setMULTILIB_EXCEPTIONSto be all of the switch exceptions in shell case syntax that should not be built.For example the ARM processor cannot execute both hardware floating point instructions and the reduced size THUMB instructions at the same time, so there is no need to build libraries with both of these options enabled. Therefore
MULTILIB_EXCEPTIONSis set to:*mthumb/*mhard-float*
- MULTILIB_REQUIRED#
Sometimes when there are only a few combinations are required, it would be a big effort to come up with a
MULTILIB_EXCEPTIONSlist to cover all undesired ones. In such a case, just listing all the required combinations inMULTILIB_REQUIREDwould be more straightforward.The way to specify the entries in
MULTILIB_REQUIREDis same with the way used forMULTILIB_EXCEPTIONS, only this time what are required will be specified. Suppose there are multiple sets ofMULTILIB_OPTIONSand only two combinations are required, one for ARMv7-M and one for ARMv7-R with hard floating-point ABI and FPU, theMULTILIB_REQUIREDcan be set to:MULTILIB_REQUIRED = mthumb/march=armv7-m MULTILIB_REQUIRED += march=armv7-r/mfloat-abi=hard/mfpu=vfpv3-d16
The
MULTILIB_REQUIREDcan be used together withMULTILIB_EXCEPTIONS. The option combinations generated fromMULTILIB_OPTIONSwill be filtered byMULTILIB_EXCEPTIONSand then byMULTILIB_REQUIRED.
- MULTILIB_REUSE#
Sometimes it is desirable to reuse one existing multilib for different sets of options. Such kind of reuse can minimize the number of multilib variants. And for some targets it is better to reuse an existing multilib than to fall back to default multilib when there is no corresponding multilib. This can be done by adding reuse rules to
MULTILIB_REUSE.A reuse rule is comprised of two parts connected by equality sign. The left part is the option set used to build multilib and the right part is the option set that will reuse this multilib. Both parts should only use options specified in
MULTILIB_OPTIONSand the equality signs found in options name should be replaced with periods. An explicit period in the rule can be escaped by preceding it with a backslash. The order of options in the left part matters and should be same with those specified inMULTILIB_REQUIREDor aligned with the order inMULTILIB_OPTIONS. There is no such limitation for options in the right part as we don’t build multilib from them.MULTILIB_REUSEis different fromMULTILIB_MATCHESin that it sets up relations between two option sets rather than two options. Here is an example to demo how we reuse libraries built in Thumb mode for applications built in ARM mode:MULTILIB_REUSE = mthumb/march.armv7-r=marm/march.armv7-r
Before the advent of
MULTILIB_REUSE, GCC select multilib by comparing command line options with options used to build multilib. TheMULTILIB_REUSEis complementary to that way. Only when the original comparison matches nothing it will work to see if it is OK to reuse some existing multilib.
- MULTILIB_EXTRA_OPTS#
Sometimes it is desirable that when building multiple versions of
libgcc.acertain options should always be passed on to the compiler. In that case, setMULTILIB_EXTRA_OPTSto be the list of options to be used for all builds. If you set this, you should probably setCRTSTUFF_T_CFLAGSto a dash followed by it.
- MULTILIB_OSDIRNAMES#
If
MULTILIB_OPTIONSis used, this variable specifies a list of subdirectory names, that are used to modify the search path depending on the chosen multilib. UnlikeMULTILIB_DIRNAMES,MULTILIB_OSDIRNAMESdescribes the multilib directories using operating systems conventions, and is applied to the directories such aslibor those in theLIBRARY_PATHenvironment variable. The format is either the same as ofMULTILIB_DIRNAMES, or a set of mappings. When it is the same asMULTILIB_DIRNAMES, it describes the multilib directories using operating system conventions, rather than GCC conventions. When it is a set of mappings of the formgccdir=osdir, the left side gives the GCC convention and the right gives the equivalent OS defined location. If theosdirpart begins with a!, GCC will not search in the non-multilib directory and use exclusively the multilib directory. Otherwise, the compiler will examine the search path for libraries and crt files twice; the first time it will addmultilibto each directory in the search path, the second it will not.For configurations that support both multilib and multiarch,
MULTILIB_OSDIRNAMESalso encodes the multiarch name, thus subsumingMULTIARCH_DIRNAME. The multiarch name is appended to each directory name, separated by a colon (e.g.../lib32:i386-linux-gnu).Each multiarch subdirectory will be searched before the corresponding OS multilib directory, for example
/lib/i386-linux-gnubefore/lib/../lib32. The multiarch name will also be used to modify the system header search path, as explained forMULTIARCH_DIRNAME.
- MULTIARCH_DIRNAME#
This variable specifies the multiarch name for configurations that are multiarch-enabled but not multilibbed configurations.
The multiarch name is used to augment the search path for libraries, crt files and system header files with additional locations. The compiler will add a multiarch subdirectory of the form
prefix/multiarchbefore each directory in the library and crt search path. It will also add two directoriesLOCAL_INCLUDE_DIR/multiarchandNATIVE_SYSTEM_HEADER_DIR/multiarch) to the system header search path, respectively beforeLOCAL_INCLUDE_DIRandNATIVE_SYSTEM_HEADER_DIR.MULTIARCH_DIRNAMEis not used for configurations that support both multilib and multiarch. In that case, multiarch names are encoded inMULTILIB_OSDIRNAMESinstead.More documentation about multiarch can be found at https://wiki.debian.org/Multiarch.
- SPECS#
Unfortunately, setting
MULTILIB_EXTRA_OPTSis not enough, since it does not affect the build of target libraries, at least not the build of the default multilib. One possible work-around is to useDRIVER_SELF_SPECSto bring options from thespecsfile as if they had been passed in the compiler driver command line. However, you don’t want to be adding these options after the toolchain is installed, so you can instead tweak thespecsfile that will be used during the toolchain build, while you still install the original, built-inspecs. The trick is to setSPECSto some other filename (sayspecs.install), that will then be created out of the built-in specs, and introduce aMakefilerule to generate thespecsfile that’s going to be used at build time out of yourspecs.install.
- T_CFLAGS#
These are extra flags to pass to the C compiler. They are used both when building GCC, and when compiling things with the just-built GCC. This variable is deprecated and should not be used.