README 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. GCC MAINTAINER INFORMATION
  2. ==========================
  3. If you are having some problem with a system header that is either
  4. broken by the manufacturer, or is broken by the fixinclude process,
  5. then you will need to alter or add information to the include fix
  6. definitions file, ``inclhack.def''. Please also send relevant
  7. information to gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org and,
  8. please, to me: bkorb@gnu.org.
  9. To make your fix, you will need to do several things:
  10. 1. Obtain access to the AutoGen program on some platform. It does
  11. not have to be your build platform, but it is more convenient.
  12. 2. Edit "inclhack.def" to reflect the changes you need to make.
  13. See below for information on how to make those changes.
  14. 3. Run the "genfixes" shell script to produce a new copy of
  15. the "fixincl.x" file.
  16. 4. Rebuild the compiler and check the header causing the issue.
  17. Make sure it is now properly handled. Add tests to the
  18. "test_text" entry(ies) that validate your fix. This will
  19. help ensure that future fixes won't negate your work.
  20. Do *NOT* specify test text for "wrap" or "replacement" fixes.
  21. There is no real possibility that these fixes will fail.
  22. If they do, you will surely know straight away.
  23. NOTE: "test_text" is interpreted by the shell as it gets
  24. copied into the test header. THEREFORE you must quote
  25. dollar sign characters and back quotes -- unless you mean
  26. for them to be interpreted by the shell.
  27. e.g. the math_huge_val_from_dbl_max test_text needs to
  28. put text into both float.h and math.h, so it includes a
  29. back-quoted script to add text to float.h.
  30. 5. Go into the fixincludes build directory and type, "make check".
  31. You are guaranteed to have issues printed out as a result.
  32. Look at the diffs produced. Make sure you have not clobbered
  33. the proper functioning of a different fix. Make sure your
  34. fix is properly tested and it does what it is supposed to do.
  35. 6. Now that you have the right things happening, synchronize the
  36. $(srcdir)/tests/base directory with the $(builddir)/tests/res
  37. directory. The output of "make check" will be some diffs that
  38. should give you some hints about what to do.
  39. 7. Rerun "make check" and verify that there are no issues left.
  40. MAKING CHANGES TO INCLHACK.DEF
  41. ==============================
  42. 0. If you are not the fixincludes maintainer, please send that
  43. person email about any changes you may want to make. Thanks!
  44. 1. Every fix must have a "hackname" that is compatible with C syntax
  45. for variable names and is unique without regard to alphabetic case.
  46. Please keep them alphabetical by this name. :-)
  47. 2. If the problem is known to exist only in certain files, then
  48. identify the files with "files = " entries. If you use fnmatch(3C)
  49. wild card characters in a "files" entry, be certain that the first
  50. "files" entry has no such character. Otherwise, the "make check"
  51. machinery will attempt to create files with those characters in the
  52. name. That is inconvenient.
  53. 3. It is relatively expensive to fire off a process to fix a source
  54. file, therefore write apply tests to avoid unnecessary fix
  55. processes. The preferred apply tests are "select", "bypass", "mach"
  56. "sum", and "c-test" because they are performed internally:
  57. * select - Run a regex on the contents of the file being considered.
  58. All such regex-es must match. Matching is done with
  59. extended regular expressions.
  60. * bypass - Run a regex on the contents of the file being considered.
  61. No such regex may match.
  62. * sum - Select a specific version of a file that has a matching
  63. check sum. The BSD version of checksum ["sum(1BSD)"]
  64. is used. Each "sum" entry should contain exactly three
  65. space separated tokens: the sum, some number and the
  66. basename of the file. The "some number" is ignored.
  67. If there are multiple "sum" entries, only one needs to
  68. match in order to pass. For example:
  69. sum = '1234 3 foobar.h';
  70. specifies that the "foobar.h" header in any directory
  71. will match if it has the checksum 1234.
  72. * c_test - call a function in fixtests.c. See that file.
  73. * files - the "fnmatch" pattern of the file(s) to examine for
  74. the issue. There may be several copies of this attribute.
  75. If the header lives in a /usr/include subdirectory, be
  76. sure to include that subdirectory in the name. e.g. net/if.h
  77. * mach - Match the output of config.guess against a series of fnmatch
  78. patterns. It must match at least one of the patterns, unless
  79. "not-machine" has also been specified. In that case, the
  80. config.guess output must not match any of the patterns.
  81. The next test is relatively slow because it must be handled in a
  82. separate shell process. Some platforms do not support server shells,
  83. so the whole process is even slower and more cumbersome there.
  84. * test - These should be arguments to the program, "/bin/test".
  85. You may perform multiple commands, if you enclose them
  86. in backquotes and echo out valid test arguments. For
  87. example, you might echo out '0 -eq 1' if you want a false
  88. result, or '0 -eq 0' for a true result.
  89. These tests are required to:
  90. 1. Be positive for all header files that require the fix.
  91. It is desirable to:
  92. 2. Be negative as often as possible whenever the fix is not
  93. required, avoiding the process overhead.
  94. It is nice if:
  95. 3. The expression is as simple as possible to both
  96. process and understand by people. :-)
  97. Please take advantage of the fact AutoGen will glue
  98. together string fragments. It helps. Also take note
  99. that double quote strings and single quote strings have
  100. different formation rules. Double quote strings are a
  101. tiny superset of ANSI-C string syntax. Single quote
  102. strings follow shell single quote string formation
  103. rules, except that the backslash is processed before
  104. '\\', '\'' and '#' characters (using C character syntax).
  105. Each test must pass or the fix is not applied. For example,
  106. all "select" expressions must be found and not one "bypass"
  107. selection may be found.
  108. Examples of test specifications:
  109. hackname = broken_assert_stdio;
  110. files = assert.h;
  111. select = stderr;
  112. bypass = "include.*stdio.h";
  113. The ``broken_assert_stdio'' fix will be applied only to a file
  114. named "assert.h" if it contains the string "stderr" _and_ it
  115. does _not_ contain the expression "include.*stdio.h".
  116. hackname = no_double_slash;
  117. c_test = "double_slash";
  118. The ``no_double_slash'' fix will be applied if the
  119. ``double_slash_test()'' function says to. See ``fixtests.c''
  120. for documentation on how to include new functions into that
  121. module.
  122. 4. There are currently four methods of fixing a file:
  123. 1. a series of sed expressions. Each will be an individual
  124. "-e" argument to a single invocation of sed. Unless you
  125. need to use multiple or complex sed expressions, please
  126. use the "replacement text" method instead.
  127. 2. a shell script. These scripts are _required_ to read all
  128. of stdin in order to avoid pipe stalls. They may choose to
  129. discard the input.
  130. 3. Replacement text. If the replacement is empty, then no
  131. fix is applied. Otherwise, the replacement text is
  132. written to the output file and no further fixes are
  133. applied. If you really want a no-op file, replace the
  134. file with a comment.
  135. Replacement text "fixes" must be first in this file!!
  136. 4. A C language subroutine method for both tests and fixes.
  137. See ``fixtests.c'' for instructions on writing C-language
  138. applicability tests and ``fixfixes.c'' for C-language fixing.
  139. These files also contain tables that describe the currently
  140. implemented fixes and tests.
  141. If at all possible, you should try to use one of the C language
  142. fixes as it is far more efficient. There are currently five
  143. such fixes, three of which are very special purpose:
  144. i) char_macro_def - This function repairs the definition of an
  145. ioctl macro that presumes CPP macro substitution within
  146. pairs of single quote characters.
  147. ii) char_macro_use - This function repairs the usage of ioctl
  148. macros that no longer can wrap an argument with single quotes.
  149. iii) machine_name - This function will look at "#if", "#ifdef",
  150. "#ifndef" and "#elif" directive lines and replace the first
  151. occurrence of a non-reserved name that is traditionally
  152. pre-defined by the native compiler.
  153. The next two are for general use:
  154. iv) wrap - wraps the entire file with "#ifndef", "#define" and
  155. "#endif" self-exclusionary text. It also, optionally, inserts
  156. a prolog after the "#define" and an epilog just before the
  157. "#endif". You can use this for a fix as follows:
  158. c_fix = wrap;
  159. c_fix_arg = "/* prolog text */";
  160. c_fix_arg = "/* epilog text */";
  161. If you want an epilog without a prolog, set the first "c_fix_arg"
  162. to the empty string. Both or the second "c_fix_arg"s may be
  163. omitted and the file will still be wrapped.
  164. THERE IS A SPECIAL EXCEPTION TO THIS, HOWEVER:
  165. If the regular expression '#if.*__need' is found, then it is
  166. assumed that the file needs to be read and interpreted more
  167. than once. However, the prolog and epilog text (if any) will
  168. be inserted.
  169. v) format - Replaces text selected with a regular expression with
  170. a specialized formating string. The formatting works as follows:
  171. The format text is copied to the output until a '%' character
  172. is found. If the character after the '%' is another '%', then
  173. one '%' is output and processing continues. If the following
  174. character is not a digit, then the '%' and that character are
  175. copied and processing continues. Finally, if the '%' *is*
  176. followed by a digit, that digit is used as an index into the
  177. regmatch_t array to replace the two characters with the matched
  178. text. i.e.: "%0" is replaced by the full matching text, "%1"
  179. is the first matching sub-expression, etc.
  180. This is used as follows:
  181. c_fix = format;
  182. c_fix_arg = "#ifndef %1\n%0\n#endif";
  183. c_fix_arg = "#define[ \t]+([A-Z][A-Z0-9a-z_]*).*";
  184. This would wrap a one line #define inside of a "#ifndef"/"#endif"
  185. pair. The second "c_fix_arg" may be omitted *IF* there is at least
  186. one select clause and the first one identifies the text you wish to
  187. reformat. It will then be used as the second "c_fix_arg". You may
  188. delete the selected text by supplying an empty string for the
  189. replacement format (the first "c_fix_arg").
  190. Note: In general, a format c_fix may be used in place of one
  191. sed expression. However, it will need to be rewritten by
  192. hand. For example:
  193. sed = 's@^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$'
  194. '@& || __GNUC__ >= 3@';
  195. may be rewritten using a format c_fix as:
  196. c_fix = format;
  197. c_fix_arg = '%0 || __GNUC__ >= 3';
  198. c_fix_arg = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
  199. Multiple sed substitution expressions probably ought to remain sed
  200. expressions in order to maintain clarity. Also note that if the
  201. second sed expression is the same as the first select expression,
  202. then you may omit the second c_fix_arg. The select expression will
  203. be picked up and used in its absence.
  204. EXAMPLES OF FIXES:
  205. ==================
  206. hackname = AAA_ki_iface;
  207. replace; /* empty replacement -> no fixing the file */
  208. When this ``fix'' is invoked, it will prevent any fixes
  209. from being applied.
  210. ------------------
  211. hackname = AAB_svr4_no_varargs;
  212. replace = "/* This file was generated by fixincludes. */\n"
  213. "#ifndef _SYS_VARARGS_H\n"
  214. "#define _SYS_VARARGS_H\n\n"
  215. "#ifdef __STDC__\n"
  216. "#include <stdarg.h>\n"
  217. "#else\n"
  218. "#include <varargs.h>\n"
  219. "#endif\n\n"
  220. "#endif /* _SYS_VARARGS_H */\n";
  221. When this ``fix'' is invoked, the replacement text will be
  222. emitted into the replacement include file. No further fixes
  223. will be applied.
  224. ------------------
  225. hackname = hpux11_fabsf;
  226. files = math.h;
  227. select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
  228. bypass = "__cplusplus";
  229. c_fix = format;
  230. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  231. test_text =
  232. "# define fabsf(x) ((float)fabs((double)(float)(x)))\n";
  233. This fix will ensure that the #define for fabs is wrapped
  234. with C++ protection, providing the header is not already
  235. C++ aware.
  236. ------------------
  237. 5. Testing fixes.
  238. The brute force method is, of course, to configure and build
  239. GCC. But you can also:
  240. cd ${top_builddir}/gcc
  241. rm -rf include-fixed/ stmp-fixinc
  242. make stmp-fixinc
  243. I would really recommend, however:
  244. cd ${top_builddir}/fixincludes
  245. make check
  246. To do this, you *must* have autogen installed on your system.
  247. The "check" step will proceed to construct a shell script that
  248. will exercise all the fixes, using the sample test_text
  249. provided with each fix. Once done, the changes made will
  250. be compared against the changes saved in the source directory.
  251. If you are changing the tests or fixes, the change will likely
  252. be highlighted.