Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Target-Fragment.html 16KB

3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Target Fragment (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Target Fragment (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Target Fragment (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Fragments.html#Fragments" rel="up" title="Fragments">
  30. <link href="Host-Fragment.html#Host-Fragment" rel="next" title="Host Fragment">
  31. <link href="Fragments.html#Fragments" rel="prev" title="Fragments">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Target-Fragment"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Host-Fragment.html#Host-Fragment" accesskey="n" rel="next">Host Fragment</a>, Up: <a href="Fragments.html#Fragments" accesskey="u" rel="up">Fragments</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Target-Makefile-Fragments"></a>
  68. <h3 class="section">20.1 Target Makefile Fragments</h3>
  69. <a name="index-target-makefile-fragment"></a>
  70. <a name="index-t_002dtarget"></a>
  71. <p>Target makefile fragments can set these Makefile variables.
  72. </p>
  73. <dl compact="compact">
  74. <dd><a name="index-LIBGCC2_005fCFLAGS"></a>
  75. </dd>
  76. <dt><code>LIBGCC2_CFLAGS</code></dt>
  77. <dd><p>Compiler flags to use when compiling <samp>libgcc2.c</samp>.
  78. </p>
  79. <a name="index-LIB2FUNCS_005fEXTRA"></a>
  80. </dd>
  81. <dt><code>LIB2FUNCS_EXTRA</code></dt>
  82. <dd><p>A list of source file names to be compiled or assembled and inserted
  83. into <samp>libgcc.a</samp>.
  84. </p>
  85. <a name="index-CRTSTUFF_005fT_005fCFLAGS"></a>
  86. </dd>
  87. <dt><code>CRTSTUFF_T_CFLAGS</code></dt>
  88. <dd><p>Special flags used when compiling <samp>crtstuff.c</samp>.
  89. See <a href="Initialization.html#Initialization">Initialization</a>.
  90. </p>
  91. <a name="index-CRTSTUFF_005fT_005fCFLAGS_005fS"></a>
  92. </dd>
  93. <dt><code>CRTSTUFF_T_CFLAGS_S</code></dt>
  94. <dd><p>Special flags used when compiling <samp>crtstuff.c</samp> for shared
  95. linking. Used if you use <samp>crtbeginS.o</samp> and <samp>crtendS.o</samp>
  96. in <code>EXTRA-PARTS</code>.
  97. See <a href="Initialization.html#Initialization">Initialization</a>.
  98. </p>
  99. <a name="index-MULTILIB_005fOPTIONS"></a>
  100. </dd>
  101. <dt><code>MULTILIB_OPTIONS</code></dt>
  102. <dd><p>For some targets, invoking GCC in different ways produces objects
  103. that cannot be linked together. For example, for some targets GCC
  104. produces both big and little endian code. For these targets, you must
  105. arrange for multiple versions of <samp>libgcc.a</samp> to be compiled, one for
  106. each set of incompatible options. When GCC invokes the linker, it
  107. arranges to link in the right version of <samp>libgcc.a</samp>, based on
  108. the command line options used.
  109. </p>
  110. <p>The <code>MULTILIB_OPTIONS</code> macro lists the set of options for which
  111. special versions of <samp>libgcc.a</samp> must be built. Write options that
  112. are mutually incompatible side by side, separated by a slash. Write
  113. options that may be used together separated by a space. The build
  114. procedure will build all combinations of compatible options.
  115. </p>
  116. <p>For example, if you set <code>MULTILIB_OPTIONS</code> to &lsquo;<samp>m68000/m68020
  117. msoft-float</samp>&rsquo;, <samp>Makefile</samp> will build special versions of
  118. <samp>libgcc.a</samp> using the following sets of options: <samp>-m68000</samp>,
  119. <samp>-m68020</samp>, <samp>-msoft-float</samp>, &lsquo;<samp>-m68000 -msoft-float</samp>&rsquo;, and
  120. &lsquo;<samp>-m68020 -msoft-float</samp>&rsquo;.
  121. </p>
  122. <a name="index-MULTILIB_005fDIRNAMES"></a>
  123. </dd>
  124. <dt><code>MULTILIB_DIRNAMES</code></dt>
  125. <dd><p>If <code>MULTILIB_OPTIONS</code> is used, this variable specifies the
  126. directory names that should be used to hold the various libraries.
  127. Write one element in <code>MULTILIB_DIRNAMES</code> for each element in
  128. <code>MULTILIB_OPTIONS</code>. If <code>MULTILIB_DIRNAMES</code> is not used, the
  129. default value will be <code>MULTILIB_OPTIONS</code>, with all slashes treated
  130. as spaces.
  131. </p>
  132. <p><code>MULTILIB_DIRNAMES</code> describes the multilib directories using GCC
  133. conventions and is applied to directories that are part of the GCC
  134. installation. When multilib-enabled, the compiler will add a
  135. subdirectory of the form <var>prefix</var>/<var>multilib</var> before each
  136. directory in the search path for libraries and crt files.
  137. </p>
  138. <p>For example, if <code>MULTILIB_OPTIONS</code> is set to &lsquo;<samp>m68000/m68020
  139. msoft-float</samp>&rsquo;, then the default value of <code>MULTILIB_DIRNAMES</code> is
  140. &lsquo;<samp>m68000 m68020 msoft-float</samp>&rsquo;. You may specify a different value if
  141. you desire a different set of directory names.
  142. </p>
  143. <a name="index-MULTILIB_005fMATCHES"></a>
  144. </dd>
  145. <dt><code>MULTILIB_MATCHES</code></dt>
  146. <dd><p>Sometimes the same option may be written in two different ways. If an
  147. option is listed in <code>MULTILIB_OPTIONS</code>, GCC needs to know about
  148. any synonyms. In that case, set <code>MULTILIB_MATCHES</code> to a list of
  149. items of the form &lsquo;<samp>option=option</samp>&rsquo; to describe all relevant
  150. synonyms. For example, &lsquo;<samp>m68000=mc68000 m68020=mc68020</samp>&rsquo;.
  151. </p>
  152. <a name="index-MULTILIB_005fEXCEPTIONS"></a>
  153. </dd>
  154. <dt><code>MULTILIB_EXCEPTIONS</code></dt>
  155. <dd><p>Sometimes when there are multiple sets of <code>MULTILIB_OPTIONS</code> being
  156. specified, there are combinations that should not be built. In that
  157. case, set <code>MULTILIB_EXCEPTIONS</code> to be all of the switch exceptions
  158. in shell case syntax that should not be built.
  159. </p>
  160. <p>For example the ARM processor cannot execute both hardware floating
  161. point instructions and the reduced size THUMB instructions at the same
  162. time, so there is no need to build libraries with both of these
  163. options enabled. Therefore <code>MULTILIB_EXCEPTIONS</code> is set to:
  164. </p><div class="smallexample">
  165. <pre class="smallexample">*mthumb/*mhard-float*
  166. </pre></div>
  167. <a name="index-MULTILIB_005fREQUIRED"></a>
  168. </dd>
  169. <dt><code>MULTILIB_REQUIRED</code></dt>
  170. <dd><p>Sometimes when there are only a few combinations are required, it would
  171. be a big effort to come up with a <code>MULTILIB_EXCEPTIONS</code> list to
  172. cover all undesired ones. In such a case, just listing all the required
  173. combinations in <code>MULTILIB_REQUIRED</code> would be more straightforward.
  174. </p>
  175. <p>The way to specify the entries in <code>MULTILIB_REQUIRED</code> is same with
  176. the way used for <code>MULTILIB_EXCEPTIONS</code>, only this time what are
  177. required will be specified. Suppose there are multiple sets of
  178. <code>MULTILIB_OPTIONS</code> and only two combinations are required, one
  179. for ARMv7-M and one for ARMv7-R with hard floating-point ABI and FPU, the
  180. <code>MULTILIB_REQUIRED</code> can be set to:
  181. </p><div class="smallexample">
  182. <pre class="smallexample"><code>MULTILIB_REQUIRED</code> = mthumb/march=armv7-m
  183. <code>MULTILIB_REQUIRED</code> += march=armv7-r/mfloat-abi=hard/mfpu=vfpv3-d16
  184. </pre></div>
  185. <p>The <code>MULTILIB_REQUIRED</code> can be used together with
  186. <code>MULTILIB_EXCEPTIONS</code>. The option combinations generated from
  187. <code>MULTILIB_OPTIONS</code> will be filtered by <code>MULTILIB_EXCEPTIONS</code>
  188. and then by <code>MULTILIB_REQUIRED</code>.
  189. </p>
  190. <a name="index-MULTILIB_005fREUSE"></a>
  191. </dd>
  192. <dt><code>MULTILIB_REUSE</code></dt>
  193. <dd><p>Sometimes it is desirable to reuse one existing multilib for different
  194. sets of options. Such kind of reuse can minimize the number of multilib
  195. variants. And for some targets it is better to reuse an existing multilib
  196. than to fall back to default multilib when there is no corresponding multilib.
  197. This can be done by adding reuse rules to <code>MULTILIB_REUSE</code>.
  198. </p>
  199. <p>A reuse rule is comprised of two parts connected by equality sign. The left
  200. part is the option set used to build multilib and the right part is the option
  201. set that will reuse this multilib. Both parts should only use options
  202. specified in <code>MULTILIB_OPTIONS</code> and the equality signs found in options
  203. name should be replaced with periods. An explicit period in the rule can be
  204. escaped by preceding it with a backslash. The order of options in the left
  205. part matters and should be same with those specified in
  206. <code>MULTILIB_REQUIRED</code> or aligned with the order in <code>MULTILIB_OPTIONS</code>.
  207. There is no such limitation for options in the right part as we don&rsquo;t build
  208. multilib from them.
  209. </p>
  210. <p><code>MULTILIB_REUSE</code> is different from <code>MULTILIB_MATCHES</code> in that it
  211. sets up relations between two option sets rather than two options. Here is an
  212. example to demo how we reuse libraries built in Thumb mode for applications built
  213. in ARM mode:
  214. </p><div class="smallexample">
  215. <pre class="smallexample"><code>MULTILIB_REUSE</code> = mthumb/march.armv7-r=marm/march.armv7-r
  216. </pre></div>
  217. <p>Before the advent of <code>MULTILIB_REUSE</code>, GCC select multilib by comparing command
  218. line options with options used to build multilib. The <code>MULTILIB_REUSE</code> is
  219. complementary to that way. Only when the original comparison matches nothing it will
  220. work to see if it is OK to reuse some existing multilib.
  221. </p>
  222. <a name="index-MULTILIB_005fEXTRA_005fOPTS"></a>
  223. </dd>
  224. <dt><code>MULTILIB_EXTRA_OPTS</code></dt>
  225. <dd><p>Sometimes it is desirable that when building multiple versions of
  226. <samp>libgcc.a</samp> certain options should always be passed on to the
  227. compiler. In that case, set <code>MULTILIB_EXTRA_OPTS</code> to be the list
  228. of options to be used for all builds. If you set this, you should
  229. probably set <code>CRTSTUFF_T_CFLAGS</code> to a dash followed by it.
  230. </p>
  231. <a name="index-MULTILIB_005fOSDIRNAMES"></a>
  232. </dd>
  233. <dt><code>MULTILIB_OSDIRNAMES</code></dt>
  234. <dd><p>If <code>MULTILIB_OPTIONS</code> is used, this variable specifies
  235. a list of subdirectory names, that are used to modify the search
  236. path depending on the chosen multilib. Unlike <code>MULTILIB_DIRNAMES</code>,
  237. <code>MULTILIB_OSDIRNAMES</code> describes the multilib directories using
  238. operating systems conventions, and is applied to the directories such as
  239. <code>lib</code> or those in the <code>LIBRARY_PATH</code> environment variable.
  240. The format is either the same as of
  241. <code>MULTILIB_DIRNAMES</code>, or a set of mappings. When it is the same
  242. as <code>MULTILIB_DIRNAMES</code>, it describes the multilib directories
  243. using operating system conventions, rather than GCC conventions. When it is a set
  244. of mappings of the form <var>gccdir</var>=<var>osdir</var>, the left side gives
  245. the GCC convention and the right gives the equivalent OS defined
  246. location. If the <var>osdir</var> part begins with a &lsquo;<samp>!</samp>&rsquo;,
  247. GCC will not search in the non-multilib directory and use
  248. exclusively the multilib directory. Otherwise, the compiler will
  249. examine the search path for libraries and crt files twice; the first
  250. time it will add <var>multilib</var> to each directory in the search path,
  251. the second it will not.
  252. </p>
  253. <p>For configurations that support both multilib and multiarch,
  254. <code>MULTILIB_OSDIRNAMES</code> also encodes the multiarch name, thus
  255. subsuming <code>MULTIARCH_DIRNAME</code>. The multiarch name is appended to
  256. each directory name, separated by a colon (e.g.
  257. &lsquo;<samp>../lib32:i386-linux-gnu</samp>&rsquo;).
  258. </p>
  259. <p>Each multiarch subdirectory will be searched before the corresponding OS
  260. multilib directory, for example &lsquo;<samp>/lib/i386-linux-gnu</samp>&rsquo; before
  261. &lsquo;<samp>/lib/../lib32</samp>&rsquo;. The multiarch name will also be used to modify the
  262. system header search path, as explained for <code>MULTIARCH_DIRNAME</code>.
  263. </p>
  264. <a name="index-MULTIARCH_005fDIRNAME"></a>
  265. </dd>
  266. <dt><code>MULTIARCH_DIRNAME</code></dt>
  267. <dd><p>This variable specifies the multiarch name for configurations that are
  268. multiarch-enabled but not multilibbed configurations.
  269. </p>
  270. <p>The multiarch name is used to augment the search path for libraries, crt
  271. files and system header files with additional locations. The compiler
  272. will add a multiarch subdirectory of the form
  273. <var>prefix</var>/<var>multiarch</var> before each directory in the library and
  274. crt search path. It will also add two directories
  275. <code>LOCAL_INCLUDE_DIR</code>/<var>multiarch</var> and
  276. <code>NATIVE_SYSTEM_HEADER_DIR</code>/<var>multiarch</var>) to the system header
  277. search path, respectively before <code>LOCAL_INCLUDE_DIR</code> and
  278. <code>NATIVE_SYSTEM_HEADER_DIR</code>.
  279. </p>
  280. <p><code>MULTIARCH_DIRNAME</code> is not used for configurations that support
  281. both multilib and multiarch. In that case, multiarch names are encoded
  282. in <code>MULTILIB_OSDIRNAMES</code> instead.
  283. </p>
  284. <p>More documentation about multiarch can be found at
  285. <a href="https://wiki.debian.org/Multiarch">https://wiki.debian.org/Multiarch</a>.
  286. </p>
  287. <a name="index-SPECS"></a>
  288. </dd>
  289. <dt><code>SPECS</code></dt>
  290. <dd><p>Unfortunately, setting <code>MULTILIB_EXTRA_OPTS</code> is not enough, since
  291. it does not affect the build of target libraries, at least not the
  292. build of the default multilib. One possible work-around is to use
  293. <code>DRIVER_SELF_SPECS</code> to bring options from the <samp>specs</samp> file
  294. as if they had been passed in the compiler driver command line.
  295. However, you don&rsquo;t want to be adding these options after the toolchain
  296. is installed, so you can instead tweak the <samp>specs</samp> file that will
  297. be used during the toolchain build, while you still install the
  298. original, built-in <samp>specs</samp>. The trick is to set <code>SPECS</code> to
  299. some other filename (say <samp>specs.install</samp>), that will then be
  300. created out of the built-in specs, and introduce a <samp>Makefile</samp>
  301. rule to generate the <samp>specs</samp> file that&rsquo;s going to be used at
  302. build time out of your <samp>specs.install</samp>.
  303. </p>
  304. </dd>
  305. <dt><code>T_CFLAGS</code></dt>
  306. <dd><p>These are extra flags to pass to the C compiler. They are used both
  307. when building GCC, and when compiling things with the just-built GCC.
  308. This variable is deprecated and should not be used.
  309. </p></dd>
  310. </dl>
  311. <hr>
  312. <div class="header">
  313. <p>
  314. Next: <a href="Host-Fragment.html#Host-Fragment" accesskey="n" rel="next">Host Fragment</a>, Up: <a href="Fragments.html#Fragments" accesskey="u" rel="up">Fragments</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  315. </div>
  316. </body>
  317. </html>