This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch]: add dependency checking to fixincludes
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch]: add dependency checking to fixincludes
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 14 Jul 2000 16:29:21 +0100
- Organization: Codesourcery LLC
Hi,
the attached patch adds smarts to the fixinclude machinery which inserts
#pragma GCC dependency "<whereever>"
pragmas to the fixed files. Thus, if the original source file is ever
updated, the user gets a warning.
For those fixes which use include_next to include the original header
file, I've introduced the new flag `include_original' to the autogen
templates. If any fix applied to a file has that flag set, the pragma
is not issued.
I also added the makefile target `fixincludes', which unconditionally
runs fixincludes.
I've built and tested this on i686-pc-linux-gnu, and it seems good there.
ok?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-07-07 Nathan Sidwell <nathan@codesourcery.com>
* Makefile.in (fixincludes): New rule
* fixinc/fixincl.c (create_file): Add INCORIG parameter. Emit
pragma dependency, if needed.
(write_replacement): Adjust create_file call.
(test_for_changes): Add INCORIG parameter. Use it.
(process): Adjust test_for_changes call.
* fixinc/fixincl.tpl: Process include_original flag.
* fixinc/fixlib.h (FD_INCLUDE_ORIGINAL): New flag.
* fixinc/inclhack.def
(AAB_fd_zero_asm_posix_types_h): Add include_original flag.
(AAB_fd_zero_gnu_types_h): Likewise.
(AAB_fd_zero_selectbits_h): Likewise.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.474
diff -c -3 -p -r1.474 Makefile.in
*** Makefile.in 2000/07/05 05:33:55 1.474
--- Makefile.in 2000/07/07 08:28:21
*************** fixinc.sh: $(FIXINCSRCDIR)/mkfixinc.sh $
*** 1940,1945 ****
--- 1940,1950 ----
export MAKE srcdir ; \
cd ./fixinc; $(SHELL) $${srcdir}/mkfixinc.sh $(target)
+ fixincludes:
+ rm -f stmp-fixinc
+ $(MAKE) stmp-fixinc
+ $(MAKE) install-headers
+
# Build fixed copies of system files.
stmp-fixinc: fixinc.sh gsyslimits.h
rm -rf include; mkdir include
Index: fixinc/fixincl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.c,v
retrieving revision 1.33
diff -c -3 -p -r1.33 fixincl.c
*** fixincl.c 2000/05/17 14:56:13 1.33
--- fixincl.c 2000/07/07 08:28:41
*************** run_compiles ()
*** 541,547 ****
FILE *
! create_file ()
{
int fd;
FILE *pf;
--- 541,548 ----
FILE *
! create_file (incorig)
! int incorig;
{
int fd;
FILE *pf;
*************** create_file ()
*** 582,588 ****
fprintf (stderr, "Fixed: %s\n", pz_curr_file);
pf = fdopen (fd, "w");
- #ifdef LATER
{
static const char hdr[] =
"/* DO NOT EDIT THIS FILE.\n\n"
--- 583,588 ----
*************** create_file ()
*** 592,598 ****
fprintf (pf, hdr, pz_curr_file);
}
! #endif
return pf;
}
--- 592,605 ----
fprintf (pf, hdr, pz_curr_file);
}
!
! if (!incorig)
! {
! static const char hdr[] =
! "#pragma GCC dependency \"/usr/include/%s\" rerun `make fixincludes' in GCC source\n\n";
!
! fprintf (pf, hdr, pz_curr_file);
! }
return pf;
}
*************** write_replacement (p_fixd)
*** 1070,1076 ****
return;
{
! FILE* out_fp = create_file (pz_curr_file);
fputs (pz_text, out_fp);
fclose (out_fp);
}
--- 1077,1083 ----
return;
{
! FILE* out_fp = create_file (p_fixd->fd_flags & FD_INCLUDE_ORIGINAL);
fputs (pz_text, out_fp);
fclose (out_fp);
}
*************** write_replacement (p_fixd)
*** 1087,1094 ****
output of the filter chain.
*/
void
! test_for_changes (read_fd)
int read_fd;
{
FILE *in_fp = fdopen (read_fd, "r");
FILE *out_fp = (FILE *) NULL;
--- 1094,1102 ----
output of the filter chain.
*/
void
! test_for_changes (read_fd, incorig)
int read_fd;
+ int incorig;
{
FILE *in_fp = fdopen (read_fd, "r");
FILE *out_fp = (FILE *) NULL;
*************** test_for_changes (read_fd)
*** 1116,1122 ****
*/
else if (ch != *pz_cmp)
{
! out_fp = create_file (pz_curr_file);
#ifdef DO_STATS
altered_ct++;
--- 1124,1130 ----
*/
else if (ch != *pz_cmp)
{
! out_fp = create_file (incorig);
#ifdef DO_STATS
altered_ct++;
*************** process ()
*** 1164,1169 ****
--- 1172,1178 ----
int todo_ct = FIX_COUNT;
int read_fd = -1;
int num_children = 0;
+ int incorig = 0;
if (access (pz_curr_file, R_OK) != 0)
{
*************** process ()
*** 1226,1231 ****
--- 1235,1241 ----
read_fd = start_fixer (read_fd, p_fixd, pz_curr_file);
num_children++;
+ incorig |= p_fixd->fd_flags & FD_INCLUDE_ORIGINAL;
}
/* IF we have a read-back file descriptor,
*************** process ()
*** 1233,1239 ****
if (read_fd >= 0)
{
! test_for_changes (read_fd);
#ifdef DO_STATS
apply_ct += num_children;
#endif
--- 1243,1249 ----
if (read_fd >= 0)
{
! test_for_changes (read_fd, incorig);
#ifdef DO_STATS
apply_ct += num_children;
#endif
Index: fixinc/fixincl.tpl
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.tpl,v
retrieving revision 1.13
diff -c -3 -p -r1.13 fixincl.tpl
*** fixincl.tpl 2000/05/12 21:59:25 1.13
--- fixincl.tpl 2000/07/07 08:28:41
*************** _FOR fix ",\n" =]
*** 198,203 ****
--- 198,205 ----
_IF shell _exist =] | FD_SHELL_SCRIPT[=
_ELIF c_fix _exist =] | FD_SUBROUTINE[=
_ELIF replace _exist =] | FD_REPLACEMENT[=
+ _ENDIF =][=
+ _IF include_original _exist =] | FD_INCLUDE_ORIGINAL[=
_ENDIF =],
a[=hackname _cap=]Tests, apz[=hackname _cap=]Patch }[=
Index: fixinc/fixlib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.h,v
retrieving revision 1.11
diff -c -3 -p -r1.11 fixlib.h
*** fixlib.h 2000/05/14 19:29:02 1.11
--- fixlib.h 2000/07/07 08:28:43
*************** typedef struct patch_desc tPatchDesc;
*** 133,138 ****
--- 133,139 ----
#define FD_SHELL_SCRIPT 0x0002
#define FD_SUBROUTINE 0x0004
#define FD_REPLACEMENT 0x0008
+ #define FD_INCLUDE_ORIGINAL 0x0010
#define FD_SKIP_TEST 0x8000
typedef struct fix_desc tFixDesc;
Index: fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/inclhack.def,v
retrieving revision 1.80
diff -c -3 -p -r1.80 inclhack.def
*** inclhack.def 2000/06/17 19:42:47 1.80
--- inclhack.def 2000/07/07 08:28:44
*************** fix = {
*** 165,170 ****
--- 165,171 ----
files = asm/posix_types.h;
mach = 'i[34567]86-*-linux-gnu*';
bypass = '} while';
+ include_original = 1;
/*
* Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
*************** fix = {
*** 205,210 ****
--- 206,212 ----
hackname = AAB_fd_zero_gnu_types_h;
files = gnu/types.h;
mach = 'i[34567]86-*-linux-gnu*';
+ include_original = 1;
/*
* Define _TYPES_H_WRAPPER at the end of the wrapper, not
*************** fix = {
*** 244,249 ****
--- 246,252 ----
hackname = AAB_fd_zero_selectbits_h;
files = selectbits.h;
mach = 'i[34567]86-*-linux-gnu*';
+ include_original = 1;
/*
* Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not