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