URL
https://opencores.org/ocsvn/scarts/scarts/trunk
Subversion Repositories scarts
[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [fixincludes/] [README] - Rev 15
Go to most recent revision | Compare with Previous | Blame | View Log
FIXINCLUDES OPERATION=====================See also: http://autogen.SourceForge.net/fixinc.htmlThe set of fixes required was distilled down to just the data requiredto specify what needed to happen for each fix. Those data were editedinto a file named gcc/fixinc/inclhack.def. A program called AutoGen(http://autogen.SourceForge.net) uses these definitions to instantiateseveral different templates that then produces code for a fixincludeprogram (fixincl.x) and a shell script to test its functioning. Oncertain platforms (viz. those that do not have functional bidirectionalpipes), the fixincl program is split into two. This should only concernyou on DOS and BeOS.Regards,Bruce <bkorb@gnu.org>GCC MAINTAINER INFORMATION==========================If you are having some problem with a system header that is eitherbroken by the manufacturer, or is broken by the fixinclude process,then you will need to alter or add information to the include fixdefinitions file, ``inclhack.def''. Please also send relevantinformation to gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org and,please, to me: bkorb@gnu.org.To make your fix, you will need to do several things:1. Obtain access to the AutoGen program on some platform. It doesnot have to be your build platform, but it is more convenient.2. Edit "inclhack.def" to reflect the changes you need to make.See below for information on how to make those changes.3. Run the "genfixes" shell script to produce a new copy ofthe "fixincl.x" file.4. Rebuild the compiler and check the header causing the issue.Make sure it is now properly handled. Add tests to the"test_text" entry(ies) that validate your fix. This willhelp ensure that future fixes won't negate your work.5. Go into the fixinc build directory and type, "make check".You are guaranteed to have issues printed out as a result.Look at the diffs produced. Make sure you have not clobberedthe proper functioning of a different fix. Make sure yourfix is properly tested and it does what it is supposed to do.6. Now that you have the right things happening, syncronize the$(srcdir)/tests/base directory with the $(builddir)/tests/resdirectory. The output of "make check" will be some diffs thatshould give you some hints about what to do.7. Rerun "make check" and verify that there are no issues left.MAKING CHANGES TO INCLHACK.DEF==============================0. If you are not the fixincludes maintainer, please send thatperson email about any changes you may want to make. Thanks!1. Every fix must have a "hackname" that is compatible with C syntaxfor variable names and is unique without regard to alphabetic case.Please keep them alphabetical by this name. :-)2. If the problem is known to exist only in certain files,then name each such file with a "files = " entry.3. It is relatively expensive to fire off a process to fix a sourcefile, therefore write apply tests to avoid unnecessary fixprocesses. The preferred apply tests are "select", "bypass" and"c_test" because they are performed internally. "test" sendsa command to a server shell that actually fires off one or moreprocesses to do the testing. Avoid it, if you can, but it isstill more efficient than a fix process. Also available is"mach". If the target machine matches any of the namedglobbing-style patterns, then the machine name test will pass.It is desired, however, to limit the use of this test.These tests are required to:1. Be positive for all header files that require the fix.It is desireable to:2. Be negative as often as possible whenever the fix is notrequired, avoiding the process overhead.It is nice if:3. The expression is as simple as possible to bothprocess and understand by people. :-)Please take advantage of the fact AutoGen will gluetogether string fragments. It helps. Also take notethat double quote strings and single quote strings havedifferent formation rules. Double quote strings are atiny superset of ANSI-C string syntax. Single quotestrings follow shell single quote string formationrules, except that the backslash is processed before'\\', '\'' and '#' characters (using C character syntax).Examples of test specifications:hackname = broken_assert_stdio;files = assert.h;select = stderr;bypass = "include.*stdio.h";The ``broken_assert_stdio'' fix will be applied only to a filenamed "assert.h" if it contains the string "stderr" _and_ itdoes _not_ contain the expression "include.*stdio.h".hackname = no_double_slash;c_test = "double_slash";The ``no_double_slash'' fix will be applied if the``double_slash_test()'' function says to. See ``fixtests.c''for documentation on how to include new functions into thatmodule.4. There are currently four methods of fixing a file:1. a series of sed expressions. Each will be an individual"-e" argument to a single invocation of sed.2. a shell script. These scripts are _required_ to read allof stdin in order to avoid pipe stalls. They may choose todiscard the input.3. Replacement text. If the replacement is empty, then nofix is applied. Otherwise, the replacement text iswritten to the output file and no further fixes areapplied. If you really want a no-op file, replace thefile with a comment.Replacement text "fixes" must be first in this file!!4. A C language subroutine method for both tests and fixes.See ``fixtests.c'' for instructions on writing C-languageapplicability tests and ``fixfixes.c'' for C-language fixing.These files also contain tables that describe the currentlyimplemented fixes and tests.If at all possible, you should try to use one of the C languagefixes as it is far more efficient. There are currently fivesuch fixes, three of which are very special purpose:i) char_macro_def - This function repairs the definition of anioctl macro that presumes CPP macro substitution withinpairs of single quote characters.ii) char_macro_use - This function repairs the usage of ioctlmacros that no longer can wrap an argument with single quotes.iii) machine_name - This function will look at "#if", "#ifdef","#ifndef" and "#elif" directive lines and replace the firstoccurrence of a non-reserved name that is traditionallypre-defined by the native compiler.The next two are for general use:iv) wrap - wraps the entire file with "#ifndef", "#define" and"#endif" self-exclusionary text. It also, optionally, insertsa prolog after the "#define" and an epilog just before the"#endif". You can use this for a fix as follows:c_fix = wrap;c_fix_arg = "/* prolog text */";c_fix_arg = "/* epilog text */";If you want an epilog without a prolog, set the first "c_fix_arg"to the empty string. Both or the second "c_fix_arg"s may beomitted and the file will still be wrapped.THERE IS A SPECIAL EXCEPTION TO THIS, HOWEVER:If the regular expression '#if.*__need' is found, then it isassumed that the file needs to be read and interpreted morethan once. However, the prolog and epilog text (if any) willbe inserted.v) format - Replaces text selected with a regular expression witha specialized formating string. The formatting works as follows:The format text is copied to the output until a '%' characteris found. If the character after the '%' is another '%', thenone '%' is output and processing continues. If the followingcharacter is not a digit, then the '%' and that character arecopied and processing continues. Finally, if the '%' *is*followed by a digit, that digit is used as an index into theregmatch_t array to replace the two characters with the matchedtext. i.e.: "%0" is replaced by the full matching text, "%1"is the first matching sub-expression, etc.This is used as follows:c_fix = format;c_fix_arg = "#ifndef %1\n%0\n#endif";c_fix_arg = "#define[ \t]+([A-Z][A-Z0-9a-z_]*).*";This would wrap a traditional #define inside of a "#ifndef"/"#endif"pair. The second "c_fix_arg" may be omitted *IF* there isa select clause and the first one matches the text you wantreplaced. You may delete text by supplying an empty string forthe format (the first "c_fix_arg").Note: In general, a format c_fix may be used in place of onesed expression. However, it will need to be rewritten byhand. For example:sed = 's@^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$''@& || __GNUC__ >= 3@';may be rewritten using a format c_fix as:c_fix = format;c_fix_arg = '%0 || __GNUC__ >= 3';c_fix_arg = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';Multiple sed substitution expressions probably ought to remain sedexpressions in order to maintain clarity. Also note that if thesecond sed expression is the same as the first select expression,then you may omit the second c_fix_arg. The select expression willbe picked up and used in its absence.EXAMPLES OF FIXES:==================hackname = AAA_ki_iface;replace; /* empty replacement -> no fixing the file */When this ``fix'' is invoked, it will prevent any fixesfrom being applied.------------------hackname = AAB_svr4_no_varargs;replace = "/* This file was generated by fixincludes. */\n""#ifndef _SYS_VARARGS_H\n""#define _SYS_VARARGS_H\n\n""#ifdef __STDC__\n""#include <stdarg.h>\n""#else\n""#include <varargs.h>\n""#endif\n\n""#endif /* _SYS_VARARGS_H */\n";When this ``fix'' is invoked, the replacement text will beemitted into the replacement include file. No further fixeswill be applied.------------------hackname = hpux11_fabsf;files = math.h;select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";bypass = "__cplusplus";c_fix = format;c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";test_text ="# define fabsf(x) ((float)fabs((double)(float)(x)))\n";This fix will ensure that the #define for fabs is wrappedwith C++ protection, providing the header is not alreadyC++ aware.------------------5. Testing fixes.The brute force method is, of course, to configure and buildGCC. But you can also:cd ${top_builddir}/gccrm -rf fixinc.sh include/ stmp-fixincmake stmp-fixincI would really recommend, however:cd ${top_builddir}/gcc/fixincmake checkTo do this, you *must* have autogen installed on your system.The "check" step will proceed to construct a shell script thatwill exercize all the fixes, using the sample test_textprovided with each fix. Once done, the changes made willbe compared against the changes saved in the source directory.If you are changing the tests or fixes, the change will likelybe highlighted.
Go to most recent revision | Compare with Previous | Blame | View Log
